/* ============================================================
   JP Gomez-Badia — Portfolio
   Design tokens, base type, layout primitives, motion.
   Everything one place. Edit a token, the whole site moves.
   ============================================================ */

:root {
  /* Palette — pulled from the Luma-Isla logo and warmed up */
  --paper:        #F2E4CB;  /* warm sand background */
  --paper-2:      #EAD9B8;  /* card / subtle surface */
  --paper-edge:   #D9C39A;  /* hairline rules in light areas */
  --ink:          #0E1726;  /* midnight navy — primary text */
  --ink-2:        #3A3530;  /* deep warm brown — secondary text */
  --ink-3:        #6B6258;  /* tertiary / labels */
  --ink-4:        #8A7E6E;  /* faintest text on paper */

  --accent:       #8C3A1F;  /* burgundy/brick — primary accent */
  --accent-2:     #A6531C;  /* lighter accent for hover/active */
  --aqua:         #2E5C70;  /* secondary accent — calm */
  --gold:         #C9842D;  /* sparing — live indicator only */

  /* Inverse: when we drop into the dark band */
  --dark-bg:      #0E1726;
  --dark-paper:   #F0E8DA;  /* text on dark */
  --dark-muted:   #C9B98E;  /* secondary on dark */
  --dark-accent:  #E89B2F;  /* gold reads better than burgundy on dark */
  --dark-rule:    rgba(240,232,218,0.18);

  /* Type */
  --serif:  "Newsreader", "Iowan Old Style", "Hoefler Text", Georgia, serif;
  --sans:   "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono:   "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Scale — bigger than typical to give the hero room */
  --fs-display: clamp(48px, 7.2vw, 104px);
  --fs-h1:      clamp(40px, 5.6vw, 76px);
  --fs-h2:      clamp(28px, 3.4vw, 44px);
  --fs-h3:      clamp(20px, 2vw, 26px);
  --fs-body:    17px;
  --fs-small:   14px;
  --fs-micro:   11px;

  /* Rhythm */
  --gutter:     clamp(20px, 4vw, 56px);
  --maxw:       1240px;
  --col-prose:  62ch;

  /* Motion */
  --ease:       cubic-bezier(.2,.7,.2,1);
  --ease-out:   cubic-bezier(.4,.2,.2,1);
}

/* Variable font axis tuning for Newsreader headlines */
.serif-wonk { font-variation-settings: "opsz" 72; }

/* ============================================================
   Reset / base
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "ss02", "cv11";
  text-rendering: optimizeLegibility;
}

/* Custom selection */
::selection { background: var(--accent); color: var(--paper); }

/* ============================================================
   Headings
   ============================================================ */

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 400;
  font-variation-settings: "opsz" 72;
  color: var(--ink);
  letter-spacing: -0.025em;
  line-height: 1.02;
  margin: 0 0 0.4em;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); letter-spacing: -0.02em; line-height: 1.05; }
h3 { font-size: var(--fs-h3); letter-spacing: -0.01em; line-height: 1.2; }

em, .emph {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  font-variation-settings: "opsz" 72;
}

/* ============================================================
   Links
   ============================================================ */

a {
  color: var(--ink);
  text-decoration: none;
  position: relative;
  transition: color 0.2s var(--ease);
}
a:hover { color: var(--accent); }

/* Inline link with subtle underline that thickens on hover */
.prose a,
a.link {
  background-image: linear-gradient(to right, var(--accent), var(--accent));
  background-position: 0 92%;
  background-repeat: no-repeat;
  background-size: 100% 1px;
  transition: background-size 0.3s var(--ease), color 0.2s var(--ease);
  color: var(--ink);
}
.prose a:hover,
a.link:hover {
  background-size: 100% 3px;
  color: var(--accent);
}

/* ============================================================
   Layout primitives
   ============================================================ */

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

.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(20px, 3vw, 40px);
}
@media (min-width: 880px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
  .row-2-3 { grid-template-columns: minmax(180px, 1fr) 2fr; }
  .row-3-2 { grid-template-columns: 3fr 2fr; }
  .row-3 { grid-template-columns: repeat(3, 1fr); }
}

.prose { max-width: var(--col-prose); }
.prose-wide { max-width: 78ch; }
.prose-full { max-width: none; }
.prose p, .prose-wide p, .prose-full p { margin: 0 0 1.1em; font-size: var(--fs-body); line-height: 1.62; }

/* Full-width block — for hero quotes and statement bands.
   Headline can stretch to ~30ch instead of being squeezed in a side column. */
.fullwidth-block { max-width: none; }
.fullwidth-block h2 { max-width: 22ch; }
.fullwidth-block .lead { max-width: 60ch; }
.prose p:last-child, .prose-wide p:last-child { margin-bottom: 0; }
.prose strong, .prose-wide strong { font-weight: 600; color: var(--ink); }

/* Case study page: dedicated styling for long-form anonymised case notes */
.case-study {
  max-width: 78ch;
  margin: 0;
}
.case-study .case-meta {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 24px;
  padding: 0;
}
.case-study .case-meta span { display: inline-block; }
.case-study .case-meta span + span::before {
  content: " · ";
  margin: 0 6px;
  color: var(--ink-4);
}
.case-study h1.case-title {
  font-family: var(--serif);
  font-variation-settings: "opsz" 72;
  font-weight: 400;
  font-size: clamp(32px, 4.4vw, 56px);
  line-height: 1.04;
  letter-spacing: -0.025em;
  margin: 0 0 18px;
  color: var(--ink);
}
.case-study h1.case-title em {
  font-style: italic;
  color: var(--accent);
}
.case-study .case-lead {
  font-family: var(--sans);
  font-size: clamp(17px, 1.6vw, 19px);
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0 0 36px;
}
.case-study h2.case-beat {
  font-family: var(--serif);
  font-variation-settings: "opsz" 72;
  font-weight: 500;
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 36px 0 14px;
  color: var(--ink);
}
.case-study p { font-size: var(--fs-body); line-height: 1.65; margin: 0 0 1.1em; }
.case-study p:last-child { margin-bottom: 0; }

.case-nav-back {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: inline-block;
  margin: 0;
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
.case-nav-back:hover { color: var(--accent); }

.prose blockquote {
  font-family: var(--serif);
  font-variation-settings: "opsz" 72;
  font-style: italic;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.25;
  margin: 1.6em 0;
  padding-left: 1.2em;
  border-left: 1px solid var(--accent);
  color: var(--ink);
}

/* Section rhythm */
.section {
  padding: clamp(48px, 6vw, 88px) 0;
  position: relative;
}
.section + .section { border-top: 0.5px solid var(--paper-edge); }
.section-dark {
  background: var(--dark-bg);
  color: var(--dark-paper);
}
.section-dark h1, .section-dark h2, .section-dark h3 { color: var(--dark-paper); }
.section-dark em { color: var(--dark-accent); }
.section-dark a { color: var(--dark-paper); }
.section-dark a:hover { color: var(--dark-accent); }

/* ============================================================
   Mono labels (eyebrow, captions)
   ============================================================ */

.eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.4em;
  display: inline-block;
}
.eyebrow::before { content: "// "; opacity: 0.6; }

.label {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ============================================================
   Masthead (top bar)
   ============================================================ */

.mast {
  position: sticky; top: 0; z-index: 60;
  background: rgba(242, 228, 203, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 0.5px solid var(--paper-edge);
}
.mast-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding: 16px var(--gutter);
  max-width: var(--maxw);
  margin: 0 auto;
  gap: 24px;
}
.mast-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-decoration: none;
  line-height: 1;
}
.mast-brand:hover { text-decoration: none; }
.mast-brand .brand-name {
  font-family: var(--serif);
  font-variation-settings: "opsz" 36;
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--ink);
  transition: color 0.2s var(--ease);
}
.mast-brand:hover .brand-name { color: var(--accent); }
.mast-brand .brand-tagline {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-top: 4px;
  text-transform: lowercase;
}
@media (max-width: 640px) {
  .mast-brand .brand-name { font-size: 18px; }
  .mast-brand .brand-tagline { font-size: 9.5px; letter-spacing: 0.1em; }
}

.mast-nav {
  display: flex;
  gap: clamp(14px, 2vw, 28px);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}
.mast-nav a {
  color: var(--ink-2);
  position: relative;
  padding: 4px 0;
}
.mast-nav a::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 1px; background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.35s var(--ease);
}
.mast-nav a:hover { color: var(--ink); }
.mast-nav a:hover::after { transform: scaleX(1); }
.mast-nav a[aria-current="page"] { color: var(--accent); }
.mast-nav a[aria-current="page"]::after { transform: scaleX(1); }

/* Reading progress */
.mast-progress {
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 1.5px;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s linear;
  transform-origin: left;
}

@media (max-width: 640px) {
  .mast-nav { font-size: 12.5px; gap: 14px; }
  .mast-brand { font-size: 16px; }
}

/* ============================================================
   Running head (per-page, under nav)
   ============================================================ */

.runner {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 14px var(--gutter) 0;
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex; justify-content: space-between;
  gap: 16px;
}
.runner .of { color: var(--accent); }

/* ============================================================
   Hero
   ============================================================ */

.hero {
  padding: clamp(40px, 8vw, 100px) 0 clamp(60px, 10vw, 140px);
}
.hero-display {
  font-family: var(--serif);
  font-variation-settings: "opsz" 72;
  font-weight: 400;
  font-size: var(--fs-display);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 0.5em;
  color: var(--ink);
  max-width: 22ch;
}
.hero-display em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  position: relative;
}
.hero-display em::after {
  content: ""; position: absolute;
  left: 2%; right: 2%; bottom: 0.08em;
  height: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform 1.1s var(--ease-out);
}
.is-in .hero-display em::after { transform: scaleX(1); transition-delay: 0.9s; }

.hero-dek {
  font-family: var(--sans);
  font-size: clamp(17px, 1.8vw, 21px);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 48ch;
  margin: 0 0 1.6em;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  border-radius: 0;
  border: 0.5px solid transparent;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover {
  background: var(--accent);
  color: var(--paper);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: rgba(14,23,38,0.4);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn .arr { transition: transform 0.25s var(--ease); display: inline-block; }
.btn:hover .arr { transform: translateX(4px); }

/* Inverted variants for dark sections */
.section-dark .btn-primary { background: var(--dark-accent); color: var(--dark-bg); }
.section-dark .btn-primary:hover { background: var(--paper); color: var(--dark-bg); }
.section-dark .btn-ghost { color: var(--dark-paper); border-color: rgba(240,232,218,0.5); }
.section-dark .btn-ghost:hover { color: var(--dark-accent); border-color: var(--dark-accent); }

/* ============================================================
   Reveal-on-scroll (used everywhere)
   ============================================================ */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease-out);
}
.reveal.is-in { opacity: 1; transform: none; }

/* word-stagger headlines (JS adds .word spans + delays) */
.headline-stagger .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s var(--ease), transform 0.55s var(--ease-out);
}
.is-in.headline-stagger .word,
.is-in .headline-stagger .word {
  opacity: 1; transform: none;
}

/* ============================================================
   Stats / numbers
   ============================================================ */

.stats {
  display: flex; gap: clamp(28px, 5vw, 60px); flex-wrap: wrap;
  padding-top: clamp(20px, 3vw, 30px);
  border-top: 0.5px solid var(--paper-edge);
}
.stat { min-width: 130px; }
.stat-label {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.stat-num {
  font-family: var(--serif);
  font-variation-settings: "opsz" 72;
  font-weight: 400;
  font-size: clamp(36px, 4.5vw, 56px);
  letter-spacing: -0.025em;
  line-height: 0.95;
  color: var(--ink);
}
.stat-aux {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--aqua);
  margin-top: 8px;
}

/* ============================================================
   Practice list / index entries
   ============================================================ */

.index-list {
  list-style: none; margin: 0; padding: 0;
  border-top: 0.5px solid var(--paper-edge);
}
.index-row {
  border-bottom: 0.5px solid var(--paper-edge);
  padding: clamp(24px, 3vw, 36px) 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: clamp(16px, 3vw, 36px);
  align-items: baseline;
  transition: padding-left 0.35s var(--ease);
}
.index-row:hover { padding-left: 12px; }
.index-row .num {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.18em;
  color: var(--accent);
  min-width: 3em;
}
.index-row h3 {
  font-family: var(--serif);
  font-variation-settings: "opsz" 72;
  font-size: clamp(22px, 2.6vw, 32px);
  line-height: 1.1;
  margin: 0 0 8px;
  color: var(--ink);
  transition: color 0.25s var(--ease);
}
.index-row:hover h3 { color: var(--accent); }
.index-row .index-dek {
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0;
  max-width: 60ch;
}
.index-row .index-meta {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.14em;
  color: var(--ink-3);
  text-align: right;
  white-space: nowrap;
  align-self: start;
  padding-top: 8px;
}

@media (max-width: 760px) {
  .index-row { grid-template-columns: auto 1fr; }
  .index-row .index-meta { grid-column: 1 / -1; text-align: left; padding-top: 0; }
}

/* ============================================================
   Floor (the navy band at the bottom of any section)
   ============================================================ */

.floor {
  background: var(--dark-bg);
  color: var(--dark-muted);
  padding: 14px 0;
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.floor-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.floor .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); margin-right: 10px; vertical-align: 1px;
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,132,45,0.55); }
  50% { box-shadow: 0 0 0 7px rgba(201,132,45,0); }
}

/* ============================================================
   Footer
   ============================================================ */

.foot {
  background: var(--dark-bg);
  color: var(--dark-muted);
  padding: clamp(48px, 7vw, 96px) 0 36px;
}
.foot a { color: var(--dark-paper); }
.foot a:hover { color: var(--dark-accent); }
.foot h2 {
  font-family: var(--serif);
  font-variation-settings: "opsz" 72;
  color: var(--dark-paper);
  font-size: clamp(32px, 4.4vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
  max-width: 26ch;
}
.foot h2 em { color: var(--dark-accent); }
.foot-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  margin-top: 48px;
  padding-top: 28px;
  border-top: 0.5px solid var(--dark-rule);
}
@media (min-width: 720px) {
  .foot-grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
}
.foot-grid h4 {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dark-muted);
  margin: 0 0 14px;
  font-weight: 400;
}
.foot-grid ul { list-style: none; margin: 0; padding: 0; }
.foot-grid li { margin-bottom: 8px; }
.foot-grid li a { font-family: var(--sans); font-size: 14.5px; color: var(--dark-paper); }
.foot-meta {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 0.5px solid var(--dark-rule);
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dark-muted);
}

/* ============================================================
   Forms
   ============================================================ */

.form {
  display: grid; gap: 14px;
  max-width: 540px;
}
.form label {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: -8px;
}
.form input, .form textarea, .form select {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--paper-edge);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  padding: 12px 0 10px;
  transition: border-color 0.25s var(--ease);
}
.form input:focus, .form textarea:focus, .form select:focus {
  outline: none;
  border-color: var(--accent);
}
.form textarea { resize: vertical; min-height: 110px; }
.form button { justify-self: start; margin-top: 8px; }

/* ============================================================
   Custom cursor (subtle dot that picks up accent over links)
   ============================================================ */

@media (hover: hover) and (pointer: fine) {
  .cursor {
    position: fixed; top: 0; left: 0;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--ink);
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: width 0.18s var(--ease), height 0.18s var(--ease),
                background 0.18s var(--ease), opacity 0.18s var(--ease);
    mix-blend-mode: difference;
    opacity: 0;
  }
  .cursor.is-on { opacity: 0.85; }
  .cursor.is-link { width: 26px; height: 26px; background: var(--accent); }
}

/* ============================================================
   Page transitions (View Transitions API where supported)
   ============================================================ */

@supports (view-transition-name: root) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.35s;
    animation-timing-function: var(--ease);
  }
  ::view-transition-old(root) { animation-name: fadeOut; }
  ::view-transition-new(root) { animation-name: fadeIn; }
  @keyframes fadeOut { to { opacity: 0; } }
  @keyframes fadeIn  { from { opacity: 0; } }
}

/* ============================================================
   Utility helpers
   ============================================================ */

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.rule { height: 0.5px; background: var(--paper-edge); border: 0; margin: clamp(28px, 4vw, 56px) 0; }
.center { text-align: center; }
.muted { color: var(--ink-3); }
.accent { color: var(--accent); }
.aqua { color: var(--aqua); }
