/* =============================================================
   Layerwright — Colors & Type foundations
   Load this first. Consume tokens via var(--lw-*).
   ============================================================= */

/* --- Fonts (Google Fonts — substitutions flagged in README) --- */
@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..700;1,9..144,300..700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  /* ---------- Color — raw palette ------------------------------- */
  /* Paper / warm neutrals */
  --lw-paper:        #f5efe4;   /* primary background — warm cream */
  --lw-paper-2:      #ece4d3;   /* surface / hover fill */
  --lw-paper-3:      #ded3bc;   /* subtle divider / inset */
  --lw-ink:          #1a1613;   /* near-black, warm */
  --lw-ink-2:        #3a332c;   /* body text */
  --lw-ink-3:        #6b6257;   /* secondary text */
  --lw-ink-4:        #948b7d;   /* tertiary / placeholder */

  /* Terracotta — signature accent */
  --lw-terra:        #c65d3a;
  --lw-terra-deep:   #9c4425;
  --lw-terra-soft:   #e8a88f;
  --lw-terra-tint:   #f6ddd0;

  /* Supporting — deep forest (used sparingly, for tags/case-study chrome) */
  --lw-forest:       #2f4a3a;
  --lw-forest-soft:  #b9c5b3;

  /* Semantic — kept muted to match editorial vibe */
  --lw-success:      #4a6b3a;
  --lw-warning:      #b8860b;
  --lw-error:        #9c3a2a;
  --lw-info:         #3a5a78;

  /* ---------- Color — semantic aliases -------------------------- */
  --lw-bg:           var(--lw-paper);
  --lw-bg-elev:      #fbf7ee;       /* card / elevated surface */
  --lw-bg-sunk:      var(--lw-paper-2);
  --lw-fg:           var(--lw-ink);
  --lw-fg-muted:     var(--lw-ink-3);
  --lw-fg-subtle:    var(--lw-ink-4);
  --lw-border:       #d8ccb4;
  --lw-border-strong:#b5a58a;
  --lw-accent:       var(--lw-terra);
  --lw-accent-hover: var(--lw-terra-deep);
  --lw-link:         var(--lw-ink);         /* links lean on underline, not color */
  --lw-selection:    #f3c7b5;

  /* ---------- Type — families ----------------------------------- */
  --lw-font-serif:   "Fraunces", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --lw-font-sans:    "Inter", "Helvetica Neue", Arial, sans-serif;
  --lw-font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* ---------- Type — scale (modular, ratio 1.25 anchored at 16) - */
  --lw-text-2xs: 11px;
  --lw-text-xs:  12px;
  --lw-text-sm:  14px;
  --lw-text-md:  16px;   /* body */
  --lw-text-lg:  19px;
  --lw-text-xl:  24px;
  --lw-text-2xl: 32px;
  --lw-text-3xl: 44px;
  --lw-text-4xl: 60px;
  --lw-text-5xl: 84px;
  --lw-text-6xl: 120px;  /* editorial hero */

  /* ---------- Weights ------------------------------------------- */
  --lw-w-light:    300;
  --lw-w-regular:  400;
  --lw-w-medium:   500;
  --lw-w-semibold: 600;
  --lw-w-bold:     700;

  /* ---------- Line heights & tracking --------------------------- */
  --lw-lh-tight:   1.05;
  --lw-lh-snug:    1.18;
  --lw-lh-normal:  1.5;
  --lw-lh-loose:   1.7;

  --lw-tr-tight:  -0.02em;
  --lw-tr-display:-0.03em;  /* hero italic serif pulls in more */
  --lw-tr-normal:  0;
  --lw-tr-wide:    0.08em;
  --lw-tr-eyebrow: 0.22em;

  /* ---------- Spacing (4pt grid) -------------------------------- */
  --lw-space-1:  4px;
  --lw-space-2:  8px;
  --lw-space-3:  12px;
  --lw-space-4:  16px;
  --lw-space-5:  24px;
  --lw-space-6:  32px;
  --lw-space-7:  48px;
  --lw-space-8:  64px;
  --lw-space-9:  96px;
  --lw-space-10: 144px;
  --lw-space-11: 192px;

  /* ---------- Radii (restrained — premium = less rounding) ------ */
  --lw-radius-xs: 2px;
  --lw-radius-sm: 4px;
  --lw-radius-md: 8px;
  --lw-radius-lg: 14px;
  --lw-radius-pill: 999px;

  /* ---------- Shadows (warm, soft) ------------------------------ */
  --lw-shadow-1: 0 1px 2px rgba(60, 40, 20, 0.06);
  --lw-shadow-2: 0 4px 12px rgba(60, 40, 20, 0.08), 0 1px 2px rgba(60, 40, 20, 0.05);
  --lw-shadow-3: 0 12px 32px rgba(60, 40, 20, 0.10), 0 2px 6px rgba(60, 40, 20, 0.06);
  --lw-shadow-4: 0 24px 60px rgba(60, 40, 20, 0.14), 0 4px 12px rgba(60, 40, 20, 0.08);
  --lw-shadow-inset: inset 0 1px 0 rgba(255, 253, 246, 0.6), inset 0 -1px 0 rgba(60, 40, 20, 0.05);

  /* ---------- Motion -------------------------------------------- */
  --lw-ease: cubic-bezier(0.2, 0.7, 0.2, 1);     /* smooth, gentle */
  --lw-ease-out: cubic-bezier(0.16, 1, 0.3, 1);  /* editorial swoop */
  --lw-dur-fast: 140ms;
  --lw-dur-mid:  260ms;
  --lw-dur-slow: 520ms;

  /* ---------- Max measures -------------------------------------- */
  --lw-measure-prose: 62ch;
  --lw-measure-narrow: 42ch;
  --lw-container: 1240px;
}

/* =============================================================
   Semantic element styles — opt in with `.lw` ancestor
   ============================================================= */

.lw {
  color: var(--lw-fg);
  background: var(--lw-bg);
  font-family: var(--lw-font-sans);
  font-size: var(--lw-text-md);
  line-height: var(--lw-lh-normal);
  font-feature-settings: "ss01", "ss02", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.lw ::selection { background: var(--lw-selection); color: var(--lw-ink); }
.lw img, .lw svg { image-rendering: -webkit-optimize-contrast; }

/* =============================================================
   Editorial CSS details — paper, rules, numerals, motion
   ============================================================= */

/* Paper grain — subtle, reads as print when zoomed close */
.lw-paper-grain { position: relative; isolation: isolate; }
.lw-paper-grain::before {
  content: "";
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(60,40,20,0.03) 0, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(60,40,20,0.025) 0, transparent 40%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7'/><feColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.05 0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: auto, auto, 180px 180px;
  mix-blend-mode: multiply;
  opacity: 0.55;
}
.lw-paper-grain > * { position: relative; z-index: 1; }

/* Editorial horizontal rule with ticker dot */
.lw-rule {
  position: relative; height: 1px; background: var(--lw-ink);
}
.lw-rule::after {
  content: ""; position: absolute; left: 0; top: -2.5px;
  width: 6px; height: 6px; background: var(--lw-terra); border-radius: 50%;
}
.lw-rule--double { height: 3px; background: none;
  border-top: 1px solid var(--lw-ink); border-bottom: 1px solid var(--lw-ink);
}

/* Tabular numerals + oldstyle figure helpers */
.lw-nums-tabular { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.lw-nums-oldstyle { font-feature-settings: "onum" 1, "ss01" 1; }

/* Drop cap — for lede paragraphs */
.lw-dropcap::first-letter {
  font-family: var(--lw-font-serif);
  font-style: italic; font-weight: 300;
  font-size: 5.2em; line-height: 0.82;
  float: left; padding: 6px 14px 0 0;
  color: var(--lw-terra);
  font-variation-settings: "opsz" 144;
}

/* Swash italic — press into for display italics with flourish */
.lw-swash { font-feature-settings: "swsh" 1, "salt" 1, "liga" 1, "dlig" 1; }

/* Small caps labels */
.lw-smallcaps {
  font-family: var(--lw-font-serif);
  font-feature-settings: "smcp" 1, "c2sc" 1;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  font-weight: 400;
}

/* Link — editorial underline that lifts */
.lw-link {
  color: var(--lw-ink); text-decoration: none;
  background-image: linear-gradient(to right, var(--lw-terra), var(--lw-terra));
  background-position: 0 100%; background-size: 100% 1px;
  background-repeat: no-repeat; padding-bottom: 2px;
  transition: background-size var(--lw-dur-mid) var(--lw-ease-out),
              color var(--lw-dur-fast) var(--lw-ease);
}
.lw-link:hover { background-size: 100% 2px; color: var(--lw-terra); }

/* Marquee ticker */
@keyframes lw-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.lw-marquee { display: flex; width: max-content; animation: lw-marquee 48s linear infinite; }
.lw-marquee:hover { animation-play-state: paused; }
.lw-marquee-mask { mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent); -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent); }

/* Reveal on scroll (no JS fallback — visible by default, CSS scroll-driven where supported) */
@supports (animation-timeline: view()) {
  .lw-reveal {
    animation: lw-reveal linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 60%;
  }
  @keyframes lw-reveal {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* Card lift + frame on hover */
.lw-card { transition: transform var(--lw-dur-mid) var(--lw-ease-out), box-shadow var(--lw-dur-mid) var(--lw-ease-out), border-color var(--lw-dur-fast) var(--lw-ease); }
.lw-card:hover { transform: translateY(-4px); box-shadow: var(--lw-shadow-3); border-color: var(--lw-ink); }

/* Image tile — terracotta corner tabs */
.lw-tile { position: relative; overflow: hidden; }
.lw-tile::before, .lw-tile::after {
  content: ""; position: absolute; width: 18px; height: 18px; pointer-events: none;
  border: 1px solid var(--lw-terra); opacity: 0; transition: opacity var(--lw-dur-mid) var(--lw-ease);
}
.lw-tile::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.lw-tile::after  { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }
.lw-tile:hover::before, .lw-tile:hover::after { opacity: 1; }

/* Button refinements */
.lw-btn-primary { position: relative; overflow: hidden; }
.lw-btn-primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255,255,255,0.18) 50%, transparent 80%);
  transform: translateX(-100%); transition: transform var(--lw-dur-slow) var(--lw-ease-out);
}
.lw-btn-primary:hover::after { transform: translateX(100%); }

/* Number monogram */
.lw-numeral {
  font-family: var(--lw-font-serif); font-style: italic; font-weight: 300;
  font-feature-settings: "lnum" 1; letter-spacing: -0.04em;
}

/* Marginal aside — editorial sidebar */
.lw-marginalia {
  font-family: var(--lw-font-serif); font-style: italic; font-weight: 300;
  font-size: 13px; line-height: 1.55; color: var(--lw-ink-3);
  border-left: 1px solid var(--lw-border-strong); padding-left: 14px;
}

/* Focus ring — warm, not system-blue */
.lw *:focus-visible { outline: 2px solid var(--lw-terra); outline-offset: 3px; border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  .lw-marquee { animation: none; }
  .lw-card { transition: none; }
  .lw-btn-primary::after { display: none; }
}

/* =============================================================
   Responsive overrides — the inline-style grids collapse on
   narrow viewports. Attribute substring selectors target the
   existing `style="grid-template-columns: ..."` declarations.
   ============================================================= */
@media (max-width: 900px) {
  main section [style*="grid-template-columns"],
  footer [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }
  main section > div > div[style*="display: grid"][style*="120px"] {
    grid-template-columns: 1fr !important;
  }
  header nav { gap: 18px !important; flex-wrap: wrap; justify-content: flex-end; }
  header nav > a:not(:last-child):not(:nth-last-child(2)):not(:nth-last-child(3)) { display: none; }
  header > div { padding: 16px 20px !important; }
  main section { padding-left: 20px !important; padding-right: 20px !important; padding-top: 72px !important; padding-bottom: 72px !important; }
  footer { padding-left: 20px !important; padding-right: 20px !important; }
  .lw-marquee { animation-duration: 28s; }
}

/* Focus-visible for <a onClick> nav items (they lack tabIndex by default, but buttons get it) */
.lw a:focus-visible, .lw button:focus-visible {
  outline: 2px solid var(--lw-terra);
  outline-offset: 3px;
}

/* FAQ: uses CSS Grid rows trick for animated expand without max-height clipping */
.lw-faq-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .32s var(--lw-ease);
}
.lw-faq-panel > div { overflow: hidden; }
.lw-faq-panel[data-open="true"] { grid-template-rows: 1fr; }

/* Process deliverable chip row */
.lw-deliverable {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--lw-border);
  font-family: var(--lw-font-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--lw-ink-3);
}
.lw-deliverable strong { color: var(--lw-terra); font-weight: 500; margin-right: 6px; }

/* Hero concrete-proof chip — shows latest shipped work, tiny heartbeat */
.lw-proof-chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: 1px solid var(--lw-border);
  border-radius: 999px; background: var(--lw-bg-elev);
  font-family: var(--lw-font-mono); font-size: 11px;
  letter-spacing: 0.06em; color: var(--lw-ink-2);
}
.lw-proof-chip::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--lw-terra); box-shadow: 0 0 0 0 rgba(198,93,58,0.6);
  animation: lw-heartbeat 2.8s ease-out infinite;
}
@keyframes lw-heartbeat {
  0%   { box-shadow: 0 0 0 0 rgba(198,93,58,0.55); }
  60%  { box-shadow: 0 0 0 10px rgba(198,93,58,0); }
  100% { box-shadow: 0 0 0 0 rgba(198,93,58,0); }
}
@media (prefers-reduced-motion: reduce) {
  .lw-proof-chip::before { animation: none; }
}

/* Scroll-driven reveal applied to section content */
@supports (animation-timeline: view()) {
  .lw-reveal-on-scroll {
    animation: lw-reveal-up linear both;
    animation-timeline: view();
    animation-range: entry 5% entry 40%;
  }
  @keyframes lw-reveal-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* Sticky mobile CTA — shows only on narrow viewports, after a bit of scroll */
.lw-sticky-cta {
  display: none;
}
@media (max-width: 900px) {
  .lw-sticky-cta {
    display: flex; position: fixed; left: 12px; right: 12px; bottom: 12px;
    z-index: 30; align-items: center; justify-content: space-between;
    background: var(--lw-ink); color: var(--lw-paper);
    padding: 12px 16px; border-radius: 8px;
    box-shadow: var(--lw-shadow-3);
    font-family: var(--lw-font-sans); font-size: 14px;
    opacity: 0; transform: translateY(8px); pointer-events: none;
    transition: opacity .24s var(--lw-ease), transform .24s var(--lw-ease);
  }
  .lw-sticky-cta[data-visible="true"] { opacity: 1; transform: translateY(0); pointer-events: auto; }
  .lw-sticky-cta strong { color: var(--lw-paper); font-weight: 500; margin-right: 10px; }
  .lw-sticky-cta em { font-style: italic; color: var(--lw-terra-soft); font-family: var(--lw-font-serif); font-size: 12px; margin-right: auto; }
  .lw-sticky-cta a {
    color: var(--lw-paper); background: var(--lw-terra);
    padding: 8px 12px; border-radius: 4px;
    text-decoration: none; font-size: 13px; font-weight: 500;
    display: inline-flex; align-items: center; gap: 6px;
  }
}

/* Display / heading treatments.
   The brand voice is italic serif at hero scale, upright serif at
   supporting scale, and sans for body + eyebrows. */

.lw h1, .lw .h1 {
  font-family: var(--lw-font-serif);
  font-weight: var(--lw-w-light);
  font-style: italic;
  font-size: clamp(var(--lw-text-4xl), 8vw, var(--lw-text-6xl));
  line-height: var(--lw-lh-tight);
  letter-spacing: var(--lw-tr-display);
  color: var(--lw-ink);
  font-variation-settings: "opsz" 144;
  text-wrap: balance;
}

.lw h2, .lw .h2 {
  font-family: var(--lw-font-serif);
  font-weight: var(--lw-w-regular);
  font-size: clamp(var(--lw-text-2xl), 4vw, var(--lw-text-4xl));
  line-height: var(--lw-lh-snug);
  letter-spacing: var(--lw-tr-tight);
  font-variation-settings: "opsz" 96;
  text-wrap: balance;
}

.lw h3, .lw .h3 {
  font-family: var(--lw-font-serif);
  font-weight: var(--lw-w-regular);
  font-size: var(--lw-text-xl);
  line-height: var(--lw-lh-snug);
  letter-spacing: var(--lw-tr-tight);
}

.lw h4, .lw .h4 {
  font-family: var(--lw-font-sans);
  font-weight: var(--lw-w-semibold);
  font-size: var(--lw-text-md);
  line-height: var(--lw-lh-snug);
  letter-spacing: 0;
}

.lw .eyebrow {
  font-family: var(--lw-font-sans);
  font-weight: var(--lw-w-medium);
  font-size: var(--lw-text-xs);
  text-transform: uppercase;
  letter-spacing: var(--lw-tr-eyebrow);
  color: var(--lw-fg-muted);
}

.lw p, .lw .body {
  font-size: var(--lw-text-md);
  line-height: var(--lw-lh-loose);
  color: var(--lw-ink-2);
  max-width: var(--lw-measure-prose);
}

.lw .lede {
  font-family: var(--lw-font-serif);
  font-weight: var(--lw-w-light);
  font-size: var(--lw-text-xl);
  line-height: var(--lw-lh-normal);
  color: var(--lw-ink);
  font-variation-settings: "opsz" 72;
}

.lw small, .lw .caption {
  font-size: var(--lw-text-sm);
  color: var(--lw-fg-muted);
  line-height: var(--lw-lh-normal);
}

.lw code, .lw .mono {
  font-family: var(--lw-font-mono);
  font-size: 0.92em;
  color: var(--lw-ink-2);
}

.lw a {
  color: var(--lw-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--lw-dur-fast) var(--lw-ease);
}
.lw a:hover { color: var(--lw-accent); }

.lw hr {
  border: 0;
  border-top: 1px solid var(--lw-border);
}
