/* ═══ Modernist design system — tokens, retuned to the portfolio's green ═══ */
:root {
  --color-bg: #f4f2ec;
  --color-surface: #eae9e9;
  --color-text: #17201c;
  --color-accent: #0e5c43;
  --color-accent-600: #0c4f3a;
  --color-accent-700: #0a4030;
  --color-accent-800: #0a4030;
  --color-accent-100: #e3ece8;
  --color-divider: #d6d1c6;
  --color-neutral-200: #e6e1d7;
  --color-neutral-900: #2d2b2b;

  --font-heading: "Archivo", system-ui, sans-serif;
  --font-heading-weight: 800;
  --font-body: "Archivo", system-ui, sans-serif;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --radius-md: 0px; --radius-lg: 0px;

  --shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--color-bg); color: var(--color-text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55; font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
p { margin: 0 0 var(--space-3); }
img { display: block; max-width: 100%; }
figure { margin: 0; }
html { scroll-behavior: smooth; }
a { color: var(--color-text); text-decoration: none; }
a:hover { color: var(--color-accent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

.grayscale { filter: grayscale(1) contrast(1.08); }

/* — rules — */
.hr { height: 2px; border: 0; margin: var(--space-4) 0; background: var(--color-divider); }

/* — buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.btn svg { display: block; }
.btn-primary { background: var(--color-accent); color: var(--color-bg); }
.btn-primary:hover { background: var(--color-accent-600); color: var(--color-bg); }
.btn-primary:active { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }

/* — tags — */
.tag {
  display: inline-flex; align-items: center; font-size: 11px;
  letter-spacing: 0.02em; padding: 3px 10px; border-radius: 0;
}
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }

/* — navigation — */
.nav {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--color-divider);
}
.nav-brand {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 18px; margin-right: auto; white-space: nowrap;
}
.nav a { color: inherit; text-decoration: none; font-size: 14px; }
/* The wrapper must not become a flex item itself — its links are the items,
   so they pick up the nav's gap. The <940px rule below overrides this. */
.nav-links { display: contents; }

/* ═══ Bilingual switching — driven by [data-lang] on the page root ═══ */
[data-l] { display: block; }
[data-li] { display: inline; }
[data-l="en"], [data-li="en"] { display: none; }
[data-lang="en"] [data-l="es"], [data-lang="en"] [data-li="es"] { display: none; }
[data-lang="en"] [data-l="en"] { display: block; }
[data-lang="en"] [data-li="en"] { display: inline; }

/* ═══ Page shell ═══ */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 64px); position: relative; z-index: 1; }
.kicker {
  display: block; font: 600 12px/1 var(--font-body); letter-spacing: .14em;
  text-transform: uppercase; color: var(--color-accent-700); margin: 0 0 18px;
}
.h2 { font: 800 clamp(30px, 4.4vw, 56px)/1 var(--font-heading); letter-spacing: -.025em; margin: 0; }
.lede { margin: 0; font: 400 15px/1.6 var(--font-body); color: color-mix(in srgb, var(--color-text) 72%, transparent); }
.section { padding: clamp(56px, 8vw, 104px) 0; }
/* Full-bleed tinted band that still respects the 1180px measure */
.band {
  padding: clamp(56px, 8vw, 104px) max(clamp(20px, 5vw, 64px), calc(50vw - 590px));
  margin-inline: calc(50% - 50vw);
  background: color-mix(in srgb, var(--color-text) 4%, var(--color-bg));
}
.sec-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; }

/* ═══ Rules-and-columns grids (the modernist signature) ═══ */
.colgrid { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 2px solid var(--color-divider); }
.colgrid > * { padding: 26px 24px; border-left: 2px solid var(--color-divider); }
.colgrid > *:first-child { padding-left: 0; border-left: 0; }
.colgrid > *:last-child { padding-right: 0; }
.colgrid.bounded { border-bottom: 2px solid var(--color-divider); }
.colgrid .num { display: block; font: 800 13px/1 var(--font-heading); color: var(--color-accent-700); margin: 0 0 16px; }
.colgrid .lbl { margin: 0 0 8px; font: 800 18px/1.15 var(--font-heading); letter-spacing: -.01em; }
.colgrid .txt { margin: 0; font: 400 13px/1.5 var(--font-body); color: color-mix(in srgb, var(--color-text) 66%, transparent); }
.colgrid.stat .lbl { font: 800 clamp(17px, 1.7vw, 21px)/1.15 var(--font-heading); margin-bottom: 10px; color: var(--color-accent-700); }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 2px solid var(--color-divider); }
.steps > * { padding: 30px 28px; border-left: 2px solid var(--color-divider); border-bottom: 2px solid var(--color-divider); }
.steps > *:first-child { padding-left: 0; border-left: 0; }
.steps > *:last-child { padding-right: 0; }
.steps .num { display: block; font: 800 14px/1 var(--font-heading); color: var(--color-accent-700); margin: 0 0 18px; }
.steps .lbl { margin: 0 0 10px; font: 800 20px/1.15 var(--font-heading); letter-spacing: -.01em; }
.steps .txt { margin: 0; font: 400 15px/1.55 var(--font-body); color: color-mix(in srgb, var(--color-text) 70%, transparent); }

/* ═══ Image slots — <image-slot> resolved to a plain element ═══ */
.slot { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
.slot img { width: 100%; height: 100%; object-fit: cover; }
.slot.contain { position: relative; }
.slot.contain img { object-fit: contain; }
/* Mid-grey, not currentColor: an empty slot sits on a light card or on the
   near-black of a video thumb, and the caption has to read on both. */
.slot-empty {
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 12px; font: 400 12px/1.4 var(--font-body); color: #8b8b86;
  border: 1px dashed color-mix(in srgb, #8b8b86 55%, transparent);
}

/* ═══ Card grids ═══ */
.cards { display: grid; gap: 24px; }
.cards.videos { grid-template-columns: repeat(auto-fill, minmax(288px, 1fr)); }
.cards.pdfs { grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 26px; }
.cards.projects { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.cards.logos { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px; }

/* Hairline-separated panels: the 2px gap IS the rule */
.panels { display: grid; gap: 2px; background: var(--color-divider); border: 2px solid var(--color-divider); }
.panels.posts { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.panels.threads { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.panel { background: var(--color-bg); display: flex; flex-direction: column; }
.panel:hover { background: var(--color-accent-100); }

.card {
  display: flex; flex-direction: column; border: 1px solid var(--color-divider);
  background: var(--color-bg); transition: border-color .18s ease, transform .18s ease;
}
.card:hover { border-color: var(--color-accent); transform: translateY(-3px); }
.card.doc:hover { border-color: var(--color-text); }
.card-media { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.badge {
  position: absolute; top: 12px; left: 12px; background: var(--color-bg); color: var(--color-text);
  font: 600 10px/1 var(--font-body); letter-spacing: .12em; text-transform: uppercase; padding: 6px 8px;
}
.crests { position: absolute; top: 11px; right: 12px; display: flex; gap: 5px; }
.crests img { width: 27px; height: 27px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0,0,0,.55)); }
.play {
  position: relative; width: 52px; height: 52px; background: var(--color-accent); color: var(--color-bg);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.dur { position: absolute; bottom: 12px; right: 12px; color: #fff; font: 600 12px/1 var(--font-body); letter-spacing: .04em; }
.card-title { font: 800 18px/1.18 var(--font-heading); letter-spacing: -.01em; color: var(--color-text); }
.card-meta { font: 400 13px/1.4 var(--font-body); color: color-mix(in srgb, var(--color-text) 58%, transparent); }

.chip {
  cursor: pointer; font: 600 12px/1 var(--font-body); letter-spacing: .06em; text-transform: uppercase;
  padding: 11px 16px; border: 1px solid var(--color-divider); background: transparent; color: var(--color-text);
}
.chip[aria-pressed="true"] { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-bg); }

/* ═══ Certifications ═══ */
.cert { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; align-items: baseline; padding: 22px 0; border-top: 2px solid var(--color-divider); }
.cert:last-of-type { border-bottom: 2px solid var(--color-divider); }
.cert h3 { margin: 0 0 5px; font: 800 19px/1.2 var(--font-heading); letter-spacing: -.01em; }
.cert .org { margin: 0; font: 400 14px/1.4 var(--font-body); color: color-mix(in srgb, var(--color-text) 60%, transparent); }
.cert .yr { font: 600 15px/1 var(--font-heading); color: var(--color-accent-700); }

/* ═══ Modal ═══ */
.backdrop { position: fixed; inset: 0; background: rgba(18,16,15,.74); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 60; }
.modal { background: var(--color-bg); width: 100%; max-width: 840px; max-height: 92vh; overflow: auto; border: 2px solid var(--color-text); }
[hidden] { display: none !important; }

/* ═══ Responsive — the .dc.html is a 1280px design; these are the fold-downs ═══ */
@media (max-width: 940px) {
  .nav-links { display: none !important; }
  .nav { gap: 10px; }
}
@media (max-width: 900px) {
  .colgrid, .steps { grid-template-columns: repeat(2, 1fr); }
  .colgrid > *, .steps > * { padding: 24px 20px; }
  .colgrid > *:nth-child(odd), .steps > *:nth-child(odd) { padding-left: 0; border-left: 0; }
  .colgrid > *:nth-child(even), .steps > *:nth-child(even) { padding-right: 0; }
  .colgrid > *, .steps > * { border-bottom: 2px solid var(--color-divider); }
  .about { grid-template-columns: 1fr !important; }
  .about figure { max-width: 340px; }
}
@media (max-width: 620px) {
  .colgrid, .steps { grid-template-columns: 1fr; }
  .colgrid > *, .steps > * { padding: 22px 0; border-left: 0; }
  .cards.videos, .cards.pdfs, .cards.projects { grid-template-columns: 1fr; }
  .nav { gap: 8px; padding: 10px clamp(16px, 5vw, 20px); }
  /* El nombre cede antes que el botón de contacto: si no cabe, se recorta. */
  .nav-brand { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 620px) {
  /* La ficha ampliada pasa a pantalla completa en el móvil. */
  .backdrop { padding: 0; align-items: stretch; }
  .modal { max-height: 100vh; border: 0; }
}
@media (max-width: 430px) {
  /* En pantallas muy estrechas cae el sobre: "Escríbeme" lleva al mismo sitio
     y es el que tiene que sobrevivir. Lleva !important porque el enlace trae
     su display en el atributo style, y eso gana a cualquier selector. */
  .nav a[href^="mailto:"] { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .card:hover { transition: none; transform: none; }
}
/* ═══════════════════════════════════════════════════════════════════════════
   Scroll reveals
   The hidden state is scoped to html.has-js, which main.js sets before paint.
   With JavaScript off the class never lands and every section stays visible —
   the page must read fully without scripts.
   Windows ships prefers-reduced-motion ON far more often than macOS, so the
   query below is a real production path, not an edge case.
   ═══════════════════════════════════════════════════════════════════════════ */
.has-js .reveal { opacity: 0; transform: translateY(18px); }
.has-js .revealed, .has-js .reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .has-js .reveal { opacity: 1 !important; transform: none !important; }
}

/* ═══ Filtering — a hidden card is removed from the grid, not just faded ═══ */
.card[hidden], .panel[hidden] { display: none !important; }

/* ═══ Cards carry their modal copy; the card itself never shows it ═══ */
.card-desc { display: none; }

/* Without JS the filter row does nothing, so it is not offered at all.
   The layout properties live here, not inline: without flex-wrap the five
   chips sit on one line and push the page wider than the phone. */
.filters { display: none; flex-wrap: wrap; gap: 10px; margin: 0 0 30px; }
.has-js .filters { display: flex; }

/* Skip link — the nav is sticky and the work starts well down the page */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--color-accent); color: var(--color-bg);
  padding: 12px 18px; font: 600 14px/1 var(--font-body);
}
.skip:focus { left: 12px; top: 12px; color: var(--color-bg); }

/* ═══ Formulario de suscripción ═══
   Sin esto el formulario no encoge por debajo de su base flex de 320px (los
   elementos flex tienen min-width:auto) y empuja la página en pantallas
   estrechas. */
.sub-form { min-width: 0; }
