/* Rafael Euribe, portfolio. White ground, ink type, orange accent. */

:root {
  --bg: #ffffff;
  --ink: #151515;
  --muted: #62625f;
  --line: #e8e8e5;
  --wash: #f5f5f3;
  --tile: #f4f4f4;          /* soft backdrop behind every thumbnail; white renders blend into it */
  --about-bg: #f0f0f0;      /* About section background */
  --accent: #151515;        /* blocks and active states, with white text on top */
  --on-accent: #ffffff;
  --detail: #ff6a13;        /* the orange: small details only (underlines, text selection) */
  --accent-ink: #bf3f08;    /* orange text on white (5.4:1) */
  --max: 1320px;
  --gutter: clamp(16px, 2.4vw, 36px);
  --gap: clamp(16px, calc(0.8vw + 8px), 20px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h, 62px) + 8px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  scrollbar-color: #c8c8c4 transparent;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
::selection { background: var(--detail); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; border-radius: 2px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: var(--gutter); top: -60px; background: var(--ink); color: #fff; padding: 12px 16px; z-index: 50; text-decoration: none; }
.skip:focus { top: 12px; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  display: flex; align-items: baseline; justify-content: space-between; gap: 24px;
  padding: 24px var(--gutter);
}
.menu-toggle { display: none; }
.wordmark { font-weight: 700; font-size: 1.5rem; letter-spacing: -0.01em; text-decoration: none; }
.site-header nav { display: flex; gap: clamp(20px, 3vw, 36px); font-size: 1rem; font-weight: 700; }
.site-header nav a { text-decoration: none; color: var(--muted); transition: color 0.2s; }
.site-header nav a:hover { color: var(--ink); }

/* intro */
.intro { padding: clamp(36px, calc(3.5vw + 12px), 60px) var(--gutter) clamp(48px, calc(3vw + 20px), 60px); }
.intro h1 {
  margin: 0; max-width: 30ch;
  font-weight: 400; font-size: clamp(2rem, 3.6vw, 3rem); line-height: 1.08; letter-spacing: -0.03em;
  text-wrap: balance;
}
/* page-load entrance: headline eases in, the welcome line follows. Off for reduced-motion (see the media query at the end). */
@keyframes intro-in {
  from { opacity: 0; transform: translateY(14px); filter: blur(5px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}
.intro h1 { animation: intro-in 1.1s var(--ease) 0.1s backwards; }
.intro-sub { animation: intro-in 1.1s var(--ease) 0.4s backwards; }
.intro-sub { margin: 16px 0 0; color: var(--muted); font-size: 1rem; }
.about-actions { margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 20px 32px; }

.button {
  display: inline-block; background: var(--accent); color: var(--on-accent);
  padding: 16px 28px; border-radius: 999px; font-weight: 500; font-size: 1rem; text-decoration: none;
  transition: background 0.2s, transform 0.4s var(--ease);
}
.button:hover { background: #3a3a3a; transform: translateY(-1px); }
.text-link { color: var(--accent-ink); font-weight: 500; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 0.28em; }
.text-link:hover { color: var(--ink); }

/* filters */
.filter-bar { position: sticky; top: var(--header-h, 64px); z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.filters {
  padding: 16px var(--gutter);
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filters button {
  flex: none; font: 500 1rem/1 var(--font); color: var(--muted);
  background: transparent; border: 0; border-radius: 999px; padding: 12px 20px; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.filters button:hover { color: var(--ink); background: var(--wash); }
.filters button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* grid: stable masonry, columns built by main.js (plain CSS columns if scripting is off) */
.grid { padding: clamp(16px, 1.6vw, 24px) var(--gutter) 0; column-width: 240px; column-gap: var(--gap); }
.grid.is-built { display: flex; gap: var(--gap); align-items: flex-start; column-width: auto; }
.grid .col { flex: 1 1 0; min-width: 0; }

.work { margin: 0 0 var(--gap); break-inside: avoid; }
.work-open {
  position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 8px;
  background: var(--tile); cursor: zoom-in; overflow: hidden; isolation: isolate;
  transition: box-shadow 0.45s var(--ease);
}
/* multiply: white image backgrounds take the tile tint, dark artwork is unchanged in character */
.work-open img { width: 100%; height: auto; mix-blend-mode: multiply; }
.work-open:hover, .work-open:focus-visible {
  z-index: 2;
  box-shadow: 0 0 12px rgba(21, 21, 21, 0.2);
}
.work.tall .work-open { aspect-ratio: 2 / 3; }
.work.tall .work-open img { height: 100%; object-fit: cover; object-position: top; }
.work figcaption { display: none; }   /* captions live in the single-image view; the text stays in the page for it */

.grid-foot { padding: 24px var(--gutter) clamp(72px, 9vw, 128px); display: flex; flex-direction: column; align-items: center; gap: 24px; }
.grid-status { margin: 0; color: var(--muted); font-size: 1rem; font-variant-numeric: tabular-nums; }
.more {
  font: 500 1rem/1 var(--font); color: var(--ink); background: transparent; cursor: pointer;
  border: 1.5px solid var(--ink); border-radius: 999px; padding: 16px 32px;
  transition: background 0.2s, border-color 0.2s;
}
.more:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* about */
.about {
  /* full-bleed gray; the padding keeps the content on the same 1320px column as before */
  --side: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  background: var(--about-bg);
  padding: clamp(72px, 10vw, 144px) var(--side);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 32px clamp(32px, 6vw, 96px); }
.about h2, .contact h2 { margin: 0; font-weight: 500; font-size: 1.5rem; letter-spacing: -0.015em; line-height: 1.2; }
.about .lede { margin: 0 0 clamp(48px, 6vw, 80px); max-width: 40ch; font-size: clamp(1.25rem, 2.2vw, 1.75rem); line-height: 1.45; letter-spacing: -0.015em; text-wrap: pretty; }
.about h3 { margin: 0 0 16px; font-weight: 500; font-size: 1rem; color: var(--muted); }
.skills { margin-bottom: 48px; }
.skill-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(32px, 5vw, 72px); border-bottom: 1px solid rgba(21, 21, 21, 0.12); }
.skill-list li { padding: 24px 0 24px; border-top: 1px solid rgba(21, 21, 21, 0.12); }
.skill-list strong { display: block; font-weight: 500; }
.skill-list li:last-child:nth-child(odd) { grid-column: 1 / -1; }   /* an odd last skill gets the full width */
.skill-list li:last-child:nth-child(odd) p { max-width: 72ch; }
.skill-list p { margin: 8px 0 0; max-width: 40ch; color: var(--muted); font-size: 1rem; line-height: 1.55; text-wrap: pretty; }

/* contact: the orange block */
.contact {
  /* same two-column grid as About, so the details line up with the Skills block */
  --side: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  background: var(--accent); color: var(--on-accent);
  padding: clamp(72px, 10vw, 140px) var(--side);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 32px clamp(32px, 6vw, 96px); align-items: start;
}
.contact-inner { display: contents; }
.contact h2 { grid-column: 1; grid-row: 1 / span 2; }
.contact-inner > p { grid-column: 2; grid-row: 1; margin: 0; }
.contact-list { grid-column: 2; grid-row: 2; }
.contact-mail { display: inline-block; font-weight: 500; font-size: clamp(1.25rem, 3vw, 2rem); line-height: 1.1; letter-spacing: -0.03em; text-decoration: underline; text-decoration-color: var(--detail); text-decoration-thickness: 2px; text-underline-offset: 0.14em; overflow-wrap: anywhere; }
.contact-mail:hover { text-decoration-thickness: 4px; }
.contact-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 40px; font-size: 1rem; }
.contact-list a { text-decoration: underline; text-decoration-color: var(--detail); text-decoration-thickness: 1.5px; text-underline-offset: 0.25em; }
.contact :focus-visible { outline-color: var(--on-accent); }

.site-footer {
  --side: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  background: var(--accent); border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 28px var(--side) 40px;
}
.site-footer p { margin: 0; color: rgba(255, 255, 255, 0.68); font-size: 0.75rem; line-height: 1.6; }

/* lightbox */
.lightbox { border: 0; padding: 0; margin: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; background: var(--bg); color: var(--ink); }
.lightbox[open] { display: grid; grid-template-rows: auto 1fr auto; animation: lb-in 0.45s var(--ease); }
.lightbox::backdrop { background: var(--bg); }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.lb-top, .lb-bottom { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px var(--gutter); }
.lb-count { color: var(--muted); font-size: 1rem; font-variant-numeric: tabular-nums; }
.lb-stage { min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 var(--gutter); }
.lb-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; transition: opacity 0.3s; }
.lb-stage img.loading { opacity: 0; }
.lb-caption { margin: 0; flex: 1; text-align: center; max-width: 60ch; color: var(--ink); font-size: 1rem; line-height: 1.5; text-wrap: balance; }
.lb-btn {
  font: 500 1rem/1 var(--font); color: var(--ink); background: var(--tile);
  border: 0; border-radius: 999px; padding: 12px 20px; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.lb-btn:hover { background: var(--accent); color: var(--on-accent); }
#lb-prev, #lb-next { background: var(--accent); color: var(--on-accent); }
#lb-prev:hover, #lb-next:hover { background: #3a3a3a; }

/* small screens */
@media (max-width: 820px) {
  .about { grid-template-columns: 1fr; }
  .contact { grid-template-columns: 1fr; }
  .contact h2, .contact-inner > p, .contact-list { grid-column: 1; grid-row: auto; }
}
@media (max-width: 700px) {
  .skill-list { grid-template-columns: 1fr; }
  .filter-bar { position: static; }
  .filters { flex-wrap: wrap; overflow: visible; gap: 4px; }
  .filters button { padding: 12px 16px; }
}
@media (max-width: 560px) {
  /* phones: the three links live behind a menu button so the pinned header stays one slim row */
  .site-header { padding-block: 12px; align-items: center; }
  .menu-toggle { display: flex; flex-direction: column; justify-content: center; gap: 4px; width: 44px; height: 44px; margin-right: -12px; padding: 0 12px; background: none; border: 0; cursor: pointer; }
  .menu-toggle span { display: block; height: 2px; border-radius: 2px; background: var(--ink); transition: transform 0.3s var(--ease), opacity 0.2s; }
  .menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .site-header nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; gap: 0;
    padding: 4px var(--gutter) 12px; background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .site-header.menu-open nav { display: flex; }
  .site-header nav a { padding: 8px 0; }
  .lb-bottom { flex-wrap: wrap; justify-content: space-between; }
  .lb-caption { order: -1; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
