/* ==========================================================================
   Octavio Gregorio — portfolio
   Tokens → base → layout → components → pages → motion
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --paper: #f4f1ea;
  --paper-2: #ebe6db;
  --paper-3: #e1dbcd;
  --ink: #19161f;
  --ink-2: #4a4553;
  --ink-3: #6d6776;
  --line: rgba(25, 22, 31, 0.14);
  --line-strong: rgba(25, 22, 31, 0.28);
  --accent: #5a33c9;
  --accent-hover: #4a26b0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(90, 51, 201, 0.1);
  --gold: #f2c94c;
  --gold-ink: #19161f;
  --ok: #1f7a4d;
  --err: #b42318;
  --err-soft: rgba(180, 35, 24, 0.08);
  --shadow: 0 1px 2px rgba(25, 22, 31, 0.06), 0 8px 24px rgba(25, 22, 31, 0.08);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Motion — curves from Emil Kowalski's animation guide */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-press: 160ms;
  --dur-fast: 200ms;
  --dur-ui: 250ms;

  --wrap: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
  --header-h: 64px;
  --radius: 10px;
  --radius-sm: 6px;

  color-scheme: light;
  interpolate-size: allow-keywords;
}

:root[data-theme="dark"] {
  --paper: #121019;
  --paper-2: #1b1824;
  --paper-3: #252131;
  --ink: #eeeaf5;
  --ink-2: #b3adc0;
  --ink-3: #8c8699;
  --line: rgba(238, 234, 245, 0.12);
  --line-strong: rgba(238, 234, 245, 0.26);
  --accent: #a68bff;
  --accent-hover: #bba6ff;
  --accent-ink: #121019;
  --accent-soft: rgba(166, 139, 255, 0.12);
  --ok: #5fd39a;
  --err: #ff8a80;
  --err-soft: rgba(255, 138, 128, 0.1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* ---------- Language visibility ---------- */
html[lang="es"] [lang="en"], html[lang="es"] [lang="zh-Hans"],
html[lang="en"] [lang="es"], html[lang="en"] [lang="zh-Hans"],
html[lang="zh-Hans"] [lang="es"], html[lang="zh-Hans"] [lang="en"] { display: none !important; }
/* The switch buttons always show, whatever their own lang attribute */
html .lang-switch button[lang] { display: inline-grid !important; }

:root[lang="zh-Hans"] {
  --font-display: "Fraunces", "Noto Serif SC", serif;
  --font-sans: "IBM Plex Sans", "Noto Sans SC", system-ui, sans-serif;
}
:root[lang="zh-Hans"] .display,
:root[lang="zh-Hans"] .section-head h2 { letter-spacing: 0; line-height: 1.15; }
:root[lang="zh-Hans"] body { line-height: 1.8; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  transition: background-color var(--dur-ui) ease, color var(--dur-ui) ease;
}

img, video, svg, iframe { display: block; max-width: 100%; }
img, video { height: auto; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
p, li { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }

::selection { background: var(--gold); color: var(--gold-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
}
.skip-link:focus { top: 12px; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- Type helpers ---------- */
.display {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.02;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.muted { color: var(--ink-2); }

.link {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: text-decoration-color var(--dur-fast) ease, color var(--dur-fast) ease;
}
@media (hover: hover) and (pointer: fine) {
  .link:hover { text-decoration-color: var(--accent); color: var(--accent); }
}

mark, .mark {
  background: linear-gradient(transparent 55%, var(--gold) 55%, var(--gold) 92%, transparent 92%);
  color: inherit;
  padding: 0 0.08em;
}
:root[data-theme="dark"] mark,
:root[data-theme="dark"] .mark {
  background: linear-gradient(transparent 55%, rgba(242, 201, 76, 0.35) 55%, rgba(242, 201, 76, 0.35) 92%, transparent 92%);
}

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: clamp(72px, 10vw, 128px); }
.section + .section { border-top: 1px solid var(--line); }

.section-head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 8px 20px;
  margin-bottom: clamp(32px, 5vw, 56px);
}
.section-head .num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 4.6vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.section-head p {
  grid-column: 2;
  max-width: 60ch;
  color: var(--ink-2);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-ui) ease, background-color var(--dur-ui) ease;
  view-transition-name: site-header;
}
.site-header[data-scrolled] { border-bottom-color: var(--line); }

.site-header .wrap {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-right: auto;
}
.brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  image-rendering: pixelated;
}
.brand small {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--ink-3);
}

.site-nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  gap: 4px;
}
.site-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--ink-2);
  transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}
.site-nav a[aria-current="page"],
.site-nav a.is-active { color: var(--ink); background: var(--paper-2); }
@media (hover: hover) and (pointer: fine) {
  .site-nav a:hover { color: var(--ink); background: var(--paper-2); }
}

.tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: var(--paper-2); border-color: var(--line-strong); }
}

.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

.lang-switch {
  display: inline-flex;
  height: 40px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.lang-switch button {
  place-items: center;
  min-width: 32px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-3);
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}
.lang-switch button:active { transform: scale(0.94); }
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.lang-switch button[lang="zh-Hans"] { font-family: "Noto Sans SC", var(--font-sans); font-size: 0.85rem; }
@media (hover: hover) and (pointer: fine) {
  .lang-switch button:not([aria-pressed="true"]):hover { background: var(--paper-2); color: var(--ink); }
}
@media (max-width: 380px) {
  .lang-switch button { min-width: 28px; }
}

.menu-btn { display: none; }
.menu-btn.icon-btn { padding: 0; }
.menu-btn .bar {
  display: block;
  width: 18px;
  height: 1.5px;
  background: currentColor;
  transition: transform var(--dur-ui) var(--ease-out);
}
.menu-btn .bars { display: grid; gap: 5px; }
.menu-btn[aria-expanded="true"] .bar:first-child { transform: translateY(3.25px) rotate(45deg); }
.menu-btn[aria-expanded="true"] .bar:last-child { transform: translateY(-3.25px) rotate(-45deg); }

.mobile-menu {
  position: fixed;
  inset: var(--header-h) 0 auto 0;
  z-index: 49;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 8px var(--gutter) 20px;
  transform-origin: top center;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), visibility 0s linear var(--dur-fast);
  opacity: 0;
  transform: translateY(-8px);
  visibility: hidden;
}
.mobile-menu[data-open] {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition-delay: 0s;
}
.mobile-menu ul { list-style: none; padding: 0; }
.mobile-menu li a {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  font-size: 1.15rem;
}
.mobile-menu .btn { margin-top: 16px; width: 100%; }

@media (max-width: 860px) {
  .site-nav, .tools .header-cv { display: none; }
  .brand small { display: none; }
  .menu-btn { display: inline-flex; }
}

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--paper);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 500;
  font-size: 1rem;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform var(--dur-press) var(--ease-out),
    background-color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; flex: none; }
.arrow, .go { width: 18px; height: 18px; flex: none; }
.btn .arrow { transition: transform var(--dur-fast) var(--ease-out); }

.btn--primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-ink);
  --btn-bd: var(--accent);
}
.btn--ink {
  --btn-bg: var(--ink);
  --btn-fg: var(--paper);
  --btn-bd: var(--ink);
}
.btn--sm { min-height: 40px; padding: 0 16px; font-size: 0.92rem; }

@media (hover: hover) and (pointer: fine) {
  .btn:hover { --btn-bg: var(--paper-2); }
  .btn--primary:hover { --btn-bg: var(--accent-hover); --btn-bd: var(--accent-hover); }
  .btn--ink:hover { --btn-bg: color-mix(in srgb, var(--ink) 85%, var(--paper)); }
  .btn:hover .arrow { transform: translateX(3px); }
  .btn:hover .arrow-down { transform: translateY(2px); }
}

.btn[disabled], .btn[aria-busy="true"] { opacity: 0.6; pointer-events: none; }

/* ---------- Hero ---------- */
.hero {
  padding-block: clamp(32px, 5vw, 64px) clamp(48px, 7vw, 88px);
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr);
  gap: clamp(32px, 6vw, 88px);
  align-items: end;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.88rem;
  color: var(--ink-2);
  margin-bottom: 28px;
}
.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 50%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .status .dot { animation: pulse 2.4s var(--ease-out) infinite; }
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); }
  70%, 100% { box-shadow: 0 0 0 8px transparent; }
}

.hero h1 {
  font-size: clamp(2.9rem, 7.4vw, 5.6rem);
  margin-bottom: 24px;
}
.hero h1 .light { font-weight: 300; font-style: italic; color: var(--ink-2); }

.lede {
  font-size: clamp(1.15rem, 1.8vw, 1.35rem);
  line-height: 1.55;
  max-width: 34ch;
  color: var(--ink);
  margin-bottom: 28px;
}
.lede em { font-style: normal; color: var(--accent); }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.hero-note {
  margin-top: 18px;
  font-size: 0.9rem;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hero-note svg { width: 16px; height: 16px; }

.portrait {
  position: relative;
  justify-self: end;
  width: 100%;
  max-width: 400px;
}
.portrait .photo { position: relative; }
.portrait .frame {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-2);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait .sticker {
  position: absolute;
  left: -22px;
  bottom: 44px;
  width: 84px;
  height: 84px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  rotate: -8deg;
  image-rendering: pixelated;
  transition: rotate var(--dur-ui) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .portrait:hover .sticker { rotate: 4deg; }
}
.portrait figcaption {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-3);
}

.proof {
  margin-top: clamp(48px, 7vw, 80px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  list-style: none;
  padding: 0;
}
.proof li {
  padding: 20px 20px 4px 0;
  display: grid;
  gap: 4px;
}
.proof li + li { padding-left: 20px; border-left: 1px solid var(--line); }
.proof strong {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.1;
}
.proof li > span { font-size: 0.9rem; color: var(--ink-2); line-height: 1.45; }

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; align-items: start; }
  .portrait { justify-self: start; max-width: 280px; }
  .portrait .sticker { left: auto; right: -14px; bottom: 16px; width: 64px; height: 64px; }
  .proof { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .proof li:nth-child(3) { padding-left: 0; border-left: 0; }
  .proof li:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

/* ---------- Work: case cards ---------- */
.cases {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(20px, 3vw, 32px);
}
.case-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}
.case-card--wide { grid-column: 1 / -1; }
.case-card--wide { display: grid; grid-template-columns: 1.3fr 1fr; gap: clamp(20px, 3vw, 40px); align-items: center; }

.case-media {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-2);
}
.case-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms var(--ease-out);
}
.case-body { padding-top: 18px; }
.case-card--wide .case-body { padding-top: 0; }

.case-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.case-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin-bottom: 10px;
}
.case-card--wide .case-title { font-size: clamp(1.8rem, 3.4vw, 2.6rem); }
.case-desc { color: var(--ink-2); max-width: 52ch; }
.case-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-weight: 500;
  color: var(--accent);
}
.case-more .arrow { transition: transform var(--dur-fast) var(--ease-out); }
.case-card:active .case-media { transform: scale(0.99); }
.case-media { transition: transform var(--dur-press) var(--ease-out); }

@media (hover: hover) and (pointer: fine) {
  .case-card:hover .case-media img { transform: scale(1.03); }
  .case-card:hover .case-more .arrow { transform: translateX(4px); }
  .case-card:hover .case-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.15em; text-decoration-color: var(--line-strong); }
}

/* Typographic cover for projects without screenshots yet */
.cover-type {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: end;
  padding: clamp(18px, 3vw, 32px);
  color: #f4f1ea;
  background:
    radial-gradient(120% 90% at 85% 10%, rgba(166, 139, 255, 0.55), transparent 60%),
    radial-gradient(90% 80% at 10% 100%, rgba(242, 201, 76, 0.25), transparent 60%),
    #17131f;
}
.cover-type::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(to top, #000, transparent 85%);
}
.cover-type > span {
  position: relative;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  opacity: 0.8;
}
.cover-type b {
  position: relative;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.02em;
}
.cover-type--tfg {
  background:
    radial-gradient(100% 90% at 90% 0%, rgba(95, 211, 154, 0.35), transparent 60%),
    radial-gradient(90% 80% at 0% 100%, rgba(166, 139, 255, 0.35), transparent 60%),
    #101418;
}

@media (max-width: 760px) {
  .cases { grid-template-columns: 1fr; }
  .case-card--wide { display: flex; }
  .case-card--wide .case-body { padding-top: 18px; }
}

/* ---------- Work: compact list ---------- */
.more-head {
  margin: clamp(56px, 8vw, 88px) 0 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-2);
}
.more-list { list-style: none; padding: 0; border-top: 1px solid var(--line); }
.more-list li { border-bottom: 1px solid var(--line); }
.more-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) minmax(0, 0.8fr) 28px;
  gap: 20px;
  align-items: baseline;
  padding: 20px 8px;
  margin-inline: -8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: background-color var(--dur-fast) ease;
}
.more-row .year { font-family: var(--font-mono); font-size: 0.85rem; color: var(--ink-3); }
.more-row h3 { font-size: 1.1rem; font-weight: 600; line-height: 1.3; }
.more-row p { color: var(--ink-2); font-size: 0.95rem; margin-top: 2px; }
.more-row .stack { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-3); }
.more-row .go { color: var(--ink-3); transition: transform var(--dur-fast) var(--ease-out), color var(--dur-fast) ease; }
@media (hover: hover) and (pointer: fine) {
  a.more-row:hover { background: var(--paper-2); }
  a.more-row:hover .go { color: var(--accent); transform: translateX(3px); }
}
@media (max-width: 760px) {
  .more-row { grid-template-columns: 1fr 24px; gap: 4px 12px; }
  .more-row .year { grid-row: 1; grid-column: 1; }
  .more-row > div { grid-column: 1; }
  .more-row .stack { grid-column: 1; }
  .more-row .go { grid-row: 1 / span 3; grid-column: 2; align-self: center; }
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--gold-ink);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  vertical-align: 2px;
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(32px, 6vw, 80px);
}
.about-text p { font-size: 1.12rem; margin-bottom: 1.1em; max-width: 60ch; }
.about-text p:first-child {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.3vw, 1.7rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.ways { list-style: none; padding: 0; margin-top: 28px; display: grid; gap: 16px; }
.ways li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; }
.ways .n { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent); padding-top: 2px; }
.ways b { display: block; font-weight: 600; }
.ways li div > span { color: var(--ink-2); font-size: 0.98rem; }

.stack-list { display: grid; gap: 0; border-top: 1px solid var(--line); }
.stack-list div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.stack-list dt { font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink-3); padding-top: 2px; }
.stack-list dd { font-size: 0.98rem; }

.timeline { list-style: none; padding: 0; margin-top: 40px; }
.timeline li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.timeline .when { font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink-3); padding-top: 3px; }
.timeline b { display: block; font-weight: 600; }
.timeline li div > span { color: var(--ink-2); font-size: 0.95rem; }

.sub-h {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  margin: 0 0 12px;
}

@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stack-list div, .timeline li { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- FAQ ---------- */
.faq { max-width: 820px; border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 22px 0;
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
}
.faq summary::-webkit-details-marker { display: none; }
.faq .plus {
  position: relative;
  flex: none;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  transition: transform var(--dur-ui) var(--ease-out), background-color var(--dur-fast) ease;
}
.faq .plus::before, .faq .plus::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 1.5px;
  background: currentColor;
  translate: -50% -50%;
}
.faq .plus::after { rotate: 90deg; transition: opacity var(--dur-fast) ease; }
.faq details[open] .plus { transform: rotate(180deg); background: var(--paper-2); }
.faq details[open] .plus::after { opacity: 0; }
@media (hover: hover) and (pointer: fine) {
  .faq summary:hover .plus { background: var(--paper-2); }
}
.faq .answer { padding: 0 48px 24px 0; color: var(--ink-2); max-width: 68ch; }
.faq .answer p + p { margin-top: 0.8em; }

.faq details::details-content {
  block-size: 0;
  overflow-y: clip;
  opacity: 0;
  transition:
    block-size var(--dur-ui) var(--ease-out),
    opacity var(--dur-ui) var(--ease-out),
    content-visibility var(--dur-ui) allow-discrete;
}
.faq details[open]::details-content { block-size: auto; opacity: 1; }

/* ---------- Contact ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}

.direct { display: grid; gap: 28px; }
.quick {
  padding: 22px;
  border-radius: var(--radius);
  background: var(--paper-2);
}
.quick h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.quick p { color: var(--ink-2); font-size: 0.95rem; margin-bottom: 14px; }
.quick .row { display: flex; flex-wrap: wrap; gap: 8px; }

.copy-email {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  text-align: left;
  transition: border-color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}
.copy-email:active { transform: scale(0.98); }
.copy-email .addr { font-family: var(--font-mono); font-size: 0.9rem; overflow-wrap: anywhere; }
.copy-email .state {
  position: relative;
  display: grid;
  font-size: 0.82rem;
  color: var(--ink-3);
  flex: none;
}
.copy-email .state > * {
  grid-area: 1 / 1;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.copy-email .done { opacity: 0; transform: translateY(4px); color: var(--ok); }
.copy-email[data-copied] .idle { opacity: 0; transform: translateY(-4px); }
.copy-email[data-copied] .done { opacity: 1; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .copy-email:hover { border-color: var(--accent); }
}

.socials { list-style: none; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.socials a {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: color var(--dur-fast) ease;
}
.socials svg { width: 20px; height: 20px; }
.socials small { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-3); }
.socials .go { transition: transform var(--dur-fast) var(--ease-out); color: var(--ink-3); }
@media (hover: hover) and (pointer: fine) {
  .socials a:hover { color: var(--accent); }
  .socials a:hover .go { transform: translate(2px, -2px); color: var(--accent); }
}

@media (max-width: 860px) {
  .contact-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 48px 40px;
  font-size: 0.95rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
  gap: 32px;
}
.footer-grid h2 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  font-weight: 400;
  margin-bottom: 12px;
}
.footer-grid ul { list-style: none; padding: 0; display: grid; gap: 6px; }
.footer-grid a { text-decoration: none; color: var(--ink-2); transition: color var(--dur-fast) ease; }
@media (hover: hover) and (pointer: fine) {
  .footer-grid a:hover { color: var(--accent); }
}
.footer-grid .linkish { color: var(--ink-2); font-size: inherit; transition: color var(--dur-fast) ease; }
.footer-brand p { color: var(--ink-2); max-width: 32ch; margin-top: 10px; }
.footer-bottom {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--ink-3);
}
@media (max-width: 760px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

/* ---------- Floating: back to top, mobile CTA ---------- */
.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), bottom var(--dur-ui) var(--ease-out);
}
.to-top svg { width: 20px; height: 20px; }
.to-top[data-show] { opacity: 1; transform: none; pointer-events: auto; }
.to-top:active { transform: scale(0.94); }

.mobile-cta {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: none;
  gap: 10px;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  transform: translateY(100%);
  transition: transform 400ms var(--ease-drawer);
}
.mobile-cta .btn { flex: 1; min-height: 46px; padding: 0 12px; }
.mobile-cta[data-show] { transform: none; }

@media (max-width: 760px) {
  .mobile-cta { display: flex; }
  body.has-mobile-cta .to-top[data-lift] { bottom: calc(84px + env(safe-area-inset-bottom)); }
  body.has-mobile-cta .site-footer { padding-bottom: 110px; }
}

/* ---------- Breadcrumbs ---------- */
.crumbs { padding-top: 28px; }
.crumbs ol {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--ink-3);
}
.crumbs li { display: inline-flex; gap: 6px; align-items: center; }
.crumbs li + li::before { content: "/"; color: var(--line-strong); }
.crumbs a { color: var(--ink-2); text-decoration: none; transition: color var(--dur-fast) ease; }
.crumbs [aria-current] { color: var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .crumbs a:hover { color: var(--accent); }
}

/* ---------- Case study page ---------- */
.case-hero { padding-block: clamp(28px, 5vw, 56px) clamp(32px, 5vw, 56px); }
.case-hero h1 { font-size: clamp(2.6rem, 7vw, 5.2rem); margin: 14px 0 20px; }
.case-hero .lede { max-width: 46ch; margin-bottom: 0; }

.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: clamp(32px, 5vw, 48px);
  border-top: 1px solid var(--line);
}
.facts div { padding: 16px 16px 0 0; }
.facts div + div { padding-left: 16px; border-left: 1px solid var(--line); }
.facts dt { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-3); margin-bottom: 4px; }
.facts dd { font-size: 0.98rem; }
@media (max-width: 760px) {
  .facts { grid-template-columns: 1fr 1fr; }
  .facts div:nth-child(3) { padding-left: 0; border-left: 0; }
  .facts div:nth-child(n + 3) { border-top: 1px solid var(--line); margin-top: 16px; }
}

.case-cover {
  position: relative;
  aspect-ratio: 16 / 8;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-2);
}
.case-cover img { width: 100%; height: 100%; object-fit: cover; }
.case-cover--contain img { object-fit: contain; }
@media (max-width: 760px) {
  .case-cover { aspect-ratio: 4 / 3; }
}

.prose-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(24px, 5vw, 64px);
  padding-block: clamp(48px, 7vw, 88px);
}
.toc { position: sticky; top: calc(var(--header-h) + 24px); align-self: start; }
.toc ol { list-style: none; padding: 0; display: grid; gap: 4px; font-size: 0.92rem; }
.toc a {
  display: block;
  padding: 6px 10px;
  margin-left: -10px;
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  text-decoration: none;
  transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}
.toc a.is-active { color: var(--ink); background: var(--paper-2); }
@media (hover: hover) and (pointer: fine) {
  .toc a:hover { color: var(--ink); }
}
@media (max-width: 860px) {
  .prose-grid { grid-template-columns: 1fr; }
  .toc { display: none; }
}

.prose { max-width: 68ch; }
.prose > * + *,
.prose > section > * + *,
.prose > div > * + * { margin-top: 1.1em; }
.prose > section + section { margin-top: clamp(48px, 7vw, 72px); }
.prose h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-top: 2.2em;
}
.prose h2:first-child { margin-top: 0; }
.prose h2 + * { margin-top: 0.7em; }
.prose h3 { font-size: 1.15rem; font-weight: 600; margin-top: 1.8em; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--accent); }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--paper-2);
}
.prose blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 18px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  line-height: 1.4;
}
.prose figure { margin-block: 2em; }
.prose figcaption, .gallery figcaption { margin-top: 8px; font-size: 0.85rem; color: var(--ink-3); }

.callout {
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--paper-2);
  font-size: 0.98rem;
}
.callout b { display: block; margin-bottom: 4px; }

.pipeline {
  list-style: none;
  padding: 0 !important;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  counter-reset: step;
}
.pipeline li {
  margin: 0 !important;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  counter-increment: step;
}
.pipeline li::before {
  content: "0" counter(step);
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 6px;
}
.pipeline b { display: block; font-size: 0.95rem; }
@media (max-width: 640px) {
  .pipeline { grid-template-columns: 1fr 1fr; }
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 12px;
}
.gallery--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gallery .full { grid-column: 1 / -1; }
.gallery button {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: zoom-in;
  transition: transform var(--dur-press) var(--ease-out);
}
.gallery button:active { transform: scale(0.98); }
.gallery img { width: 100%; height: auto; transition: transform 500ms var(--ease-out), opacity 300ms ease; }
@media (hover: hover) and (pointer: fine) {
  .gallery button:hover img { transform: scale(1.03); }
}
.pixel img { image-rendering: pixelated; }

.next-case {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-bottom: clamp(56px, 8vw, 96px);
}
.next-case a {
  display: grid;
  gap: 4px;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  text-decoration: none;
  transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}
.next-case a:active { transform: scale(0.99); }
.next-case small { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-3); }
.next-case b { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; }
.next-case a:last-child { text-align: right; }
@media (hover: hover) and (pointer: fine) {
  .next-case a:hover { border-color: var(--line-strong); background: var(--paper-2); }
}
@media (max-width: 560px) {
  .next-case { grid-template-columns: 1fr; }
  .next-case a:last-child { text-align: left; }
}

.cta-band {
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  padding: clamp(28px, 5vw, 56px);
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(56px, 8vw, 96px);
}
.cta-band h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.6rem, 3.2vw, 2.4rem); line-height: 1.1; max-width: 20ch; }
.cta-band p { color: color-mix(in srgb, var(--paper) 70%, transparent); margin-top: 8px; }
.cta-band .btn { --btn-bg: var(--paper); --btn-fg: var(--ink); --btn-bd: var(--paper); }
@media (hover: hover) and (pointer: fine) {
  .cta-band .btn:hover { --btn-bg: var(--gold); --btn-bd: var(--gold); --btn-fg: var(--gold-ink); }
}

/* ---------- Video facade (YouTube loads only on click) ---------- */
.yt {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
.yt button {
  position: absolute;
  inset: 0;
  width: 100%;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.yt img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.85; transition: opacity var(--dur-fast) ease; }
.yt .play {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  border-radius: 999px;
  background: rgba(18, 16, 25, 0.8);
  color: #fff;
  font-weight: 500;
  backdrop-filter: blur(6px);
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-fast) ease;
}
.yt .play svg { width: 22px; height: 22px; }
.yt button:active .play { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .yt button:hover img { opacity: 1; }
  .yt button:hover .play { background: var(--accent); }
}
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.clip { border-radius: var(--radius); overflow: hidden; background: #000; }
.clip video { width: 100%; }

/* ---------- Lightbox ---------- */
.lightbox {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(1400px, 94vw);
  max-height: 92vh;
  margin: auto;
  overflow: visible;
  opacity: 1;
  transform: scale(1);
  transition:
    opacity var(--dur-ui) var(--ease-out),
    transform var(--dur-ui) var(--ease-out),
    overlay var(--dur-ui) allow-discrete,
    display var(--dur-ui) allow-discrete;
}
.lightbox:not([open]) { opacity: 0; transform: scale(0.96); }
@starting-style {
  .lightbox[open] { opacity: 0; transform: scale(0.96); }
}
.lightbox::backdrop {
  background: rgba(10, 8, 14, 0.82);
  opacity: 1;
  transition: opacity var(--dur-ui) var(--ease-out), overlay var(--dur-ui) allow-discrete, display var(--dur-ui) allow-discrete;
}
.lightbox:not([open])::backdrop { opacity: 0; }
@starting-style {
  .lightbox[open]::backdrop { opacity: 0; }
}
.lightbox img { max-height: 86vh; width: auto; margin-inline: auto; border-radius: var(--radius-sm); }
.lightbox p { color: #ddd; text-align: center; margin-top: 10px; font-size: 0.9rem; }
.lightbox .close {
  position: absolute;
  top: -48px;
  right: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}
.lightbox .close svg { width: 18px; height: 18px; }

/* ---------- Skeleton loading for media ---------- */
.skel { position: relative; background: var(--paper-2); isolation: isolate; }
.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--paper) 60%, transparent) 50%, transparent 80%);
  background-size: 200% 100%;
  transition: opacity 300ms ease;
}
@media (prefers-reduced-motion: no-preference) {
  .skel::after { animation: shimmer 1.4s linear infinite; }
}
.skel.is-loaded::after { opacity: 0; animation: none; }
.skel img { opacity: 0; transition: opacity 400ms var(--ease-out); }
.skel.is-loaded img { opacity: 1; }
html:not(.js) .skel img { opacity: 1; }
html:not(.js) .skel::after { display: none; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

/* ---------- Simple pages (404, privacidad) ---------- */
.simple { padding-block: clamp(56px, 10vw, 120px); }
.simple h1 { font-size: clamp(2.6rem, 7vw, 5rem); margin: 14px 0 20px; }
.simple .lede { max-width: 44ch; }
.simple .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

.big-code {
  font-family: var(--font-mono);
  font-size: clamp(5rem, 22vw, 14rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--paper-3);
  user-select: none;
}
.gb-screen {
  width: min(360px, 100%);
  aspect-ratio: 10 / 9;
  border-radius: 8px;
  background: #9bbc0f;
  color: #0f380f;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: var(--font-mono);
  padding: 20px;
  box-shadow: inset 0 0 0 10px #8bac0f, inset 0 0 0 12px #306230;
  image-rendering: pixelated;
}
.gb-screen b { display: block; font-size: 1.9rem; letter-spacing: 0.08em; }
.gb-screen .blink { display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .gb-screen .blink { animation: blink 1s steps(1) infinite; }
}
@keyframes blink { 50% { opacity: 0; } }

.legal h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.5rem; margin-top: 2em; }
.legal table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.legal th, .legal td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.legal th { font-weight: 600; }

/* ---------- Archive page ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}
.toolbar input[type="search"] {
  flex: 1 1 260px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
}
.toolbar input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--ink-2);
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease, border-color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .chip:hover { border-color: var(--line-strong); color: var(--ink); }
  .chip[aria-pressed="true"]:hover { color: var(--paper); }
}
.files { list-style: none; padding: 0; border-top: 1px solid var(--line); }
.files li { border-bottom: 1px solid var(--line); }
.files li[hidden] { display: none; }
.file {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 0;
}
.file .type {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
  text-align: center;
}
.file b { display: block; font-weight: 600; }
.file > div > span { color: var(--ink-2); font-size: 0.92rem; }
.file .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) {
  .file { grid-template-columns: 1fr; gap: 8px; }
  .file .type { justify-self: start; }
  .file .acts { justify-content: flex-start; }
}
.empty-state { padding: 32px 0; color: var(--ink-2); }

/* ==========================================================================
   Motion
   ========================================================================== */

/* Hero entrance — rare/first-visit tier, so it earns a stagger */
@media (prefers-reduced-motion: no-preference) {
  html.js [data-enter] {
    opacity: 0;
    transform: translateY(14px);
    animation: enter 700ms var(--ease-out) forwards;
    animation-delay: calc(var(--i, 0) * 70ms + 80ms);
  }
  html.js .portrait[data-enter] .frame {
    clip-path: inset(100% 0 0 0 round var(--radius));
    animation: unveil 900ms var(--ease-in-out) forwards;
    animation-delay: 160ms;
  }
  html.js .portrait[data-enter] { transform: none; }
  html.js .portrait[data-enter] .sticker {
    opacity: 0;
    scale: 0.9;
    animation: pop 450ms var(--ease-out) forwards;
    animation-delay: 900ms;
  }
}
@keyframes enter { to { opacity: 1; transform: none; } }
@keyframes unveil { to { clip-path: inset(0 0 0 0 round var(--radius)); } }
@keyframes pop { to { opacity: 1; scale: 1; } }

/* Scroll reveal — fires once */
@media (prefers-reduced-motion: no-preference) {
  html.js [data-reveal] {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 700ms var(--ease-out), transform 700ms var(--ease-out);
    transition-delay: calc(var(--i, 0) * 60ms);
  }
  html.js [data-reveal].is-in { opacity: 1; transform: none; }
}

/* Cross-document page transitions (Chrome/Edge 126+, Safari 18.2+) */
@view-transition { navigation: auto; }

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: vt-out 180ms var(--ease-out) both; }
  ::view-transition-new(root) { animation: vt-in 320ms var(--ease-out) both; }
}
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

/* Reduced motion: keep opacity/color feedback, drop movement */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root) { animation: vt-fade-out 150ms ease both; }
  ::view-transition-new(root) { animation: vt-fade-in 200ms ease both; }
  .btn:active, .icon-btn:active, .chip:active, .copy-email:active,
  .gallery button:active, .next-case a:active, .to-top:active { transform: none; }
  .to-top, .to-top[data-show] { transform: none; }
  .mobile-cta { transition: opacity 200ms ease; transform: none; opacity: 0; pointer-events: none; }
  .mobile-cta[data-show] { opacity: 1; pointer-events: auto; }
  .mobile-menu { transform: none; }
  .lightbox, .lightbox:not([open]) { transform: none; }
  .case-media img, .gallery img { transition: opacity 300ms ease; }
}
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }

/* Print: keep it readable */
@media print {
  .site-header, .mobile-cta, .to-top, .site-footer, .toc { display: none !important; }
  body { background: #fff; color: #000; }
}

/* Theme swap: skip per-element colour transitions for one frame */
.theme-swap, .theme-swap *, .theme-swap *::before, .theme-swap *::after { transition: none !important; }

/* ---------- Custom cursor (mouse only) ---------- */
/* Small precise pixel arrow; a pixel octopus (site.js) trails behind it. */
@media (hover: hover) and (pointer: fine) {
  html, body { cursor: url("../img/cursor.svg") 1 1, auto; }
  a, button, summary, label[for], .chip, [role="button"], select,
  .gallery button, .yt button, input[type="checkbox"] {
    cursor: url("../img/cursor-pointer.svg") 1 1, pointer;
  }
  input[type="text"], input[type="email"], input[type="search"], textarea { cursor: text; }
}

.pet {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 300;
  width: 26px;
  height: 22px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
  will-change: transform;
}
.pet[data-show] { opacity: 1; }
.pet img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  transition: opacity 200ms ease, transform 250ms var(--ease-out);
}
.pet .on { opacity: 0; }
.pet[data-hover] .off { opacity: 0; }
.pet[data-hover] .on { opacity: 1; }
.pet[data-hover] img { transform: scale(1.25); }
.pet[data-down] img { transform: scale(0.85); }

/* ---------- Small extras ---------- */
.btn .tiny {
  font-size: 0.6rem;
  font-weight: 400;
  opacity: 0.8;
  margin-left: -6px;
  align-self: flex-end;
  padding-bottom: 12px;
  letter-spacing: 0.02em;
}
.figbox { border-radius: var(--radius-sm); overflow: hidden; }

.case-cover-fig figcaption { margin-top: 10px; font-size: 0.85rem; color: var(--ink-3); }
.numbers {
  list-style: none;
  padding: 0 !important;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}
.numbers li { margin: 0 !important; padding: 16px 16px 16px 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; color: var(--ink-2); }
.numbers li:nth-child(odd) { padding-right: 20px; }
.numbers b { display: block; font-family: var(--font-display); font-size: 1.8rem; line-height: 1.1; color: var(--ink); margin-bottom: 4px; }
@media (max-width: 520px) { .numbers { grid-template-columns: 1fr; } }
.modes { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.modes th, .modes td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.modes th { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 400; color: var(--ink-3); }
.modes td:nth-child(n+3) { font-variant-numeric: tabular-nums; }
.prose figure .gallery { grid-template-columns: 1fr; }
.prose figure.narrow { max-width: 300px; }

/* ---------- Playable Game Boy (tower-hero.html) ---------- */
.gb {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
  margin-top: 1.4em;
}
.gb-body {
  --shell: #d9d5cc;
  --shell-dark: #b9b4a8;
  background: linear-gradient(180deg, var(--shell), #cfcac0);
  border-radius: 14px 14px 56px 14px;
  padding: 18px 18px 28px;
  box-shadow: inset 0 -4px 0 var(--shell-dark), 0 18px 40px rgba(25, 22, 31, 0.18);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.gb-bezel {
  position: relative;
  background: #5c5a68;
  border-radius: 10px 10px 32px 10px;
  padding: 18px 26px 12px;
}
.gb-led {
  position: absolute;
  left: 9px;
  top: 46%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3a1f24;
  transition: background-color 200ms ease, box-shadow 200ms ease;
}
.gb[data-on] .gb-led { background: #ff3b4e; box-shadow: 0 0 6px #ff3b4e; }
.gb-lcd {
  position: relative;
  aspect-ratio: 160 / 144;
  background: #9bbc0f;
  border-radius: 2px;
  overflow: hidden;
}
.gb-lcd canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.gb-power {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-family: var(--font-mono);
  font-weight: 500;
  color: #0f380f;
  background: #9bbc0f;
  transition: background-color var(--dur-fast) ease;
}
.gb-power svg { width: 20px; height: 20px; }
.gb-power:active { background: #8bac0f; }
@media (hover: hover) and (pointer: fine) {
  .gb-power:hover { background: #a7c81f; }
}
.gb[data-on] .gb-power { display: none; }
.gb-msg {
  position: absolute;
  inset: auto 8px 8px;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(15, 56, 15, 0.9);
  color: #e0f8d0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.4;
  text-align: center;
}
.gb-brand {
  margin-top: 6px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.8rem;
  color: #c9c6d6;
}
.gb-brand i { font-style: normal; font-family: var(--font-mono); font-size: 0.65rem; margin-left: 4px; color: #a19db3; }

.gb-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "dpad ab" "ss ss";
  align-items: center;
  gap: 22px 12px;
  margin-top: 24px;
}
.gb-dpad {
  grid-area: dpad;
  display: grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 34px);
  justify-self: start;
}
.gb-dpad button, .gb-dpad span { background: #2a2833; }
.gb-dpad [data-btn="up"] { grid-area: 1 / 2; border-radius: 4px 4px 0 0; }
.gb-dpad [data-btn="left"] { grid-area: 2 / 1; border-radius: 4px 0 0 4px; }
.gb-dpad span { grid-area: 2 / 2; }
.gb-dpad [data-btn="right"] { grid-area: 2 / 3; border-radius: 0 4px 4px 0; }
.gb-dpad [data-btn="down"] { grid-area: 3 / 2; border-radius: 0 0 4px 4px; }
.gb-ab {
  grid-area: ab;
  justify-self: end;
  display: flex;
  gap: 14px;
  rotate: -25deg;
  padding: 8px 10px;
  border-radius: 40px;
  background: rgba(0, 0, 0, 0.06);
}
.gb-ab button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #9a2257;
  color: #f6d9e5;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8rem;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}
.gb-ss {
  grid-area: ss;
  display: flex;
  justify-content: center;
  gap: 18px;
}
.gb-ss button {
  width: 58px;
  height: 14px;
  border-radius: 8px;
  background: #8c8896;
  rotate: -25deg;
  font-size: 0;
  position: relative;
}
.gb-ss button::after {
  content: attr(data-btn);
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5c5a68;
}
.gb-controls button {
  transition: transform 90ms var(--ease-out), filter 90ms ease;
  touch-action: none;
}
.gb-controls button[data-pressed] { transform: scale(0.92); filter: brightness(0.85); }
.gb-dpad button[data-pressed] { transform: none; filter: brightness(1.6); }

.gb-keys { display: grid; gap: 8px; margin-bottom: 16px; }
.gb-keys div { display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: 12px; }
.gb-keys dd { color: var(--ink-2); }
kbd {
  display: inline-block;
  min-width: 26px;
  margin-right: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-align: center;
  background: var(--paper);
}
.gb-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.gb:fullscreen { background: #121019; display: grid; place-items: center; grid-template-columns: 1fr; padding: 16px; }
.gb:fullscreen .gb-side { display: none; }
.gb:fullscreen .gb-body { width: min(440px, 100%); }

@media (max-width: 760px) {
  .gb { grid-template-columns: 1fr; }
  .gb-body { max-width: 380px; margin-inline: auto; width: 100%; }
  .gb-dpad { grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(3, 42px); }
  .gb-ab button { width: 54px; height: 54px; }
  .gb-keys { display: none; }
  .gb-side .sub-h { display: none; }
}
.gb-controls { touch-action: none; }
body.gb-in-view .to-top { opacity: 0; pointer-events: none; }
.gb-keys div { grid-template-columns: minmax(0, 1fr) auto; }
.gb-keys dt { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.gb-keys kbd { margin-right: 0; }
.kbd-or { color: var(--ink-3); font-size: 0.85rem; margin: 0 4px; }
.gb-keys div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.gb-keys dt { flex-wrap: nowrap; }
.gb-keys dd { color: var(--ink); font-weight: 500; }
.proof strong { overflow-wrap: break-word; }
@media (max-width: 520px) { .proof strong { font-size: clamp(1rem, 5.2vw, 1.25rem); } }
