/* ============================================================
   THE BRIEF — design system for jhernandezportfolio.com
   Direction B: agency case-study deck, structured around the
   problem → insight → execution → result arc that's already
   how Javi writes about his own work.
   ============================================================ */

:root {
  /* Color */
  --paper: #F0F1ED;      /* page background — cool sage-grey, not cream */
  --paper-alt: #E6E7E0;  /* card / section background */
  --ink: #1C2321;        /* primary text */
  --ink-soft: #565F5B;   /* secondary text */
  --line: #D2D4CB;       /* hairline rules */
  --amber: #C97C1F;      /* flag accent — case numbers, active nav, key labels */
  --redline: #B3392B;    /* "before" state — problem, low score */
  --result: #2F6F4E;     /* "after" state — result, improved score */
  --white: #FAFAF8;

  /* Type */
  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-body: "IBM Plex Sans", -apple-system, sans-serif;

  /* Scale */
  --step-1: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --step-2: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --step-3: clamp(1.75rem, 1.5rem + 1.25vw, 2.5rem);
  --step-4: clamp(2.5rem, 2rem + 2.5vw, 4rem);
  --step-5: clamp(3.5rem, 2.5rem + 5vw, 6.5rem);

  --gap: clamp(1.25rem, 1rem + 1vw, 2.5rem);
  --max: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16191A;
    --paper-alt: #1E2222;
    --ink: #ECEAE3;
    --ink-soft: #A5ABA6;
    --line: #333733;
    --white: #1E2222;
  }
}
:root[data-theme="dark"] {
  --paper: #16191A;
  --paper-alt: #1E2222;
  --ink: #ECEAE3;
  --ink-soft: #A5ABA6;
  --line: #333733;
  --white: #1E2222;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-1);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img, video, iframe { max-width: 100%; }

a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav-name { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; text-decoration: none; }
.nav-links { display: flex; gap: clamp(1rem, 2vw, 2rem); list-style: none; margin: 0; padding: 0; }
.nav-links a { text-decoration: none; font-size: 0.95rem; color: var(--ink-soft); transition: color 0.15s; }
.nav-links a:hover { color: var(--ink); }
.nav-status {
  display: inline-flex; align-items: center; gap: 0.5em;
  font-size: 0.85rem; color: var(--ink-soft);
}
.nav-status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--result);
}

/* ---------- Hero ---------- */
.hero { padding: clamp(3rem, 6vw, 6rem) 0 clamp(2rem, 4vw, 3rem); border-bottom: 1px solid var(--line); }
.hero-role { color: var(--amber); font-weight: 600; font-size: 0.95rem; margin: 0 0 1rem; }
.hero h1 {
  font-family: var(--font-display);
  font-size: var(--step-5);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 1.25rem;
  max-width: 16ch;
}
.hero-sub { max-width: 62ch; color: var(--ink-soft); font-size: var(--step-2); line-height: 1.5; margin: 0 0 2rem; }
.hero-stats { display: flex; flex-wrap: wrap; gap: clamp(1.5rem, 4vw, 3rem); margin: 0 0 2.25rem; }
.hero-stat b { display: block; font-family: var(--font-display); font-size: var(--step-3); font-weight: 500; }
.hero-stat span { color: var(--ink-soft); font-size: 0.9rem; }
.hero-ctas { display: flex; gap: 1rem; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 0.85em 1.5em; border-radius: 2px;
  font-size: 0.95rem; font-weight: 600; text-decoration: none;
  border: 1px solid var(--ink); transition: background 0.15s, color 0.15s;
}
.btn-primary { background: var(--ink); color: var(--white); }
.btn-primary:hover { background: var(--amber); border-color: var(--amber); color: var(--white); }
.btn-ghost { color: var(--ink); }
.btn-ghost:hover { background: var(--paper-alt); }

/* ---------- Section headers ---------- */
.section-head { padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(1.5rem, 3vw, 2rem); }
.section-head h2 { font-family: var(--font-display); font-size: var(--step-4); font-weight: 500; margin: 0 0 0.5rem; }
.section-head p { color: var(--ink-soft); margin: 0; max-width: 55ch; }

/* ---------- Case studies ---------- */
.case {
  border-top: 1px solid var(--line);
  padding: clamp(2.5rem, 5vw, 4rem) 0;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(2rem, 4vw, 4rem);
}
@media (max-width: 860px) { .case { grid-template-columns: 1fr; } }

.case-media { border-radius: 3px; overflow: hidden; background: var(--paper-alt); aspect-ratio: 16/9; }
.case-media iframe, .case-media img { width: 100%; height: 100%; object-fit: cover; border: 0; display: block; }
.case-media picture { display: contents; }
.case-caption { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.75rem; }

.case-num { color: var(--amber); font-weight: 600; font-size: 0.9rem; margin: 0 0 0.5rem; }
.case-awards { font-size: 0.85rem; color: var(--ink-soft); margin: 0 0 0.5rem; }
.case h3 { font-family: var(--font-display); font-size: var(--step-3); font-weight: 500; margin: 0 0 1.25rem; line-height: 1.15; }

.case-arc { border-top: 1px solid var(--line); }
.case-row { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: 0.9rem 0; border-bottom: 1px solid var(--line); }
.case-row dt { color: var(--amber); font-weight: 600; font-size: 0.85rem; }
.case-row dd { margin: 0; color: var(--ink); }

.delta { display: flex; align-items: baseline; gap: 0.6rem; margin: 1.25rem 0; }
.delta-before, .delta-after { font-family: var(--font-display); font-size: var(--step-3); font-weight: 500; }
.delta-before { color: var(--redline); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--redline) 50%, transparent); }
.delta-after { color: var(--result); font-size: var(--step-4); }
.delta-rule { flex: 0 0 auto; width: 28px; height: 1px; background: var(--ink-soft); position: relative; top: -0.4em; }
.delta-label { color: var(--ink-soft); font-size: 0.85rem; align-self: flex-end; }

.case-stats { display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem; margin-top: 1.5rem; }
.case-stats .stat b { display: block; font-family: var(--font-display); font-size: var(--step-2); font-weight: 500; }
.case-stats .stat span { color: var(--ink-soft); font-size: 0.85rem; }

/* ---------- About ---------- */
.about { border-top: 1px solid var(--line); padding: clamp(2.5rem, 5vw, 4rem) 0; display: grid; grid-template-columns: 0.8fr 1.2fr; gap: clamp(2rem, 4vw, 4rem); }
@media (max-width: 860px) { .about { grid-template-columns: 1fr; } }
.about-photo {
  display: block; width: 100%; height: auto; aspect-ratio: 4/5;
  object-fit: cover; border-radius: 3px; background: var(--paper-alt);
}
.about-kicker { color: var(--amber); font-weight: 600; font-size: 0.9rem; margin: 0 0 0.5rem; }
.about h3 { font-family: var(--font-display); font-weight: 500; font-size: var(--step-2); margin: 1.5rem 0 0.5rem; }
.about-kicker + h3 { margin-top: 0; }
.about p { color: var(--ink-soft); max-width: 62ch; }

/* ---------- Contact / footer ---------- */
.contact { border-top: 1px solid var(--line); padding: clamp(3rem, 6vw, 5rem) 0; }
.contact h2 { font-family: var(--font-display); font-weight: 500; font-size: var(--step-4); max-width: 18ch; margin: 0 0 1.5rem; }
.contact-links { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; font-size: var(--step-1); }
.contact-links a { text-decoration: none; border-bottom: 1px solid var(--line); }
.contact-links a:hover { border-color: var(--ink); }
footer { border-top: 1px solid var(--line); padding: 1.5rem 0; font-size: 0.85rem; color: var(--ink-soft); }

/* ---------- Blog-specific (visually distinct, still on-brand) ---------- */
.blog-hero { padding: clamp(2.5rem, 5vw, 4.5rem) 0 clamp(1.5rem, 3vw, 2rem); border-bottom: 1px solid var(--line); }
.blog-hero h1 { font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: var(--step-4); margin: 0 0 0.75rem; }
.blog-hero p { color: var(--ink-soft); max-width: 55ch; }
.post-list { border-top: 1px solid var(--line); }
.post-row { display: block; padding: 1.75rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.post-row-top { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.post-date { color: var(--ink-soft); font-size: 0.85rem; }
.post-row h2 { font-family: var(--font-display); font-weight: 500; font-style: italic; font-size: var(--step-2); margin: 0.35rem 0 0.4rem; }
.post-row p { color: var(--ink-soft); margin: 0; max-width: 65ch; }

/* ---------- Article (full post) ---------- */
.article-header { padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(1.5rem, 3vw, 2rem); border-bottom: 1px solid var(--line); }
.article-back { display: inline-block; font-size: 0.85rem; color: var(--ink-soft); text-decoration: none; margin-bottom: 1.5rem; }
.article-back:hover { color: var(--ink); }
.article-header h1 { font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: var(--step-4); line-height: 1.15; margin: 0 0 0.75rem; max-width: 22ch; }
.article-meta { color: var(--ink-soft); font-size: 0.85rem; }

.article { padding: clamp(2rem, 4vw, 3rem) 0 clamp(3rem, 6vw, 5rem); max-width: 72ch; }
.article p { max-width: 68ch; }
.article > p:first-of-type { font-size: var(--step-2); color: var(--ink-soft); }
.article h2 {
  font-family: var(--font-display); font-weight: 500; font-size: var(--step-3);
  margin: 2.5rem 0 1rem; padding-top: 1.5rem; border-top: 1px solid var(--line);
}
.article h2:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.article h3 {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: var(--step-2); margin: 1.75rem 0 0.5rem;
}
.article h3 .lane-note { display: block; font-family: var(--font-body); font-style: normal; font-weight: 400; font-size: 0.9rem; color: var(--ink-soft); margin-top: 0.35rem; }
.article ul, .article ol { padding-left: 1.25rem; color: var(--ink); }
.article li { margin: 0.35rem 0; }
.article li p { margin: 0; }
.article strong { font-weight: 600; }
.article em { font-style: italic; }
.article hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
.article a { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; }
.article a:hover { text-decoration-color: var(--ink); }

.table-scroll { overflow-x: auto; margin: 1.25rem 0 2rem; border: 1px solid var(--line); border-radius: 3px; }
.article table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 560px; }
.article th, .article td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.article thead th { background: var(--paper-alt); font-family: var(--font-display); font-weight: 500; white-space: nowrap; }
.article tbody tr:last-child td { border-bottom: 0; }
