/* =============================================================================
   GLOBAL: loaded on every page.
   1. Tokens   2. Reset & base   3. Section shell   4. Shared components
   5. Backgrounds   6. Utilities   7. Motion
   Component CSS → css/components/   ·   Page CSS → css/pages/
   Documentation → /designsystem.md
   ============================================================================= */

/* ==========================================================================
   1. TOKENS
   ========================================================================== */
:root {
  /* Ink & paper */
  --c-ink:       #16130f;
  --c-ink-soft:  #4a4036;
  --c-cream:     #faf1dc;   /* newsprint */
  --c-paper:     #fffaf0;   /* cards, letters, receipts */

  /* Neubrutal pastels: one leads each section */
  --c-mustard:   #efc663;   /* hero */
  --c-butter:    #ffe5a6;
  --c-mint:      #a8d9c2;   /* nav, work */
  --c-salmon:    #ffa189;   /* CTAs, footer */
  --c-sky:       #9fd3f5;   /* skills */
  --c-lilac:     #c9b6ff;   /* kind words */
  --c-red:       #b43528;   /* red-pen marks, strikes, stamps */
  --c-green:     #2f6b4e;
  --c-wall:      #1d1813;   /* the doors hallway */

  /* Pale washes of the pastels, for portals and lit doorways */
  --c-mint-tint:   #d9f2e6;
  --c-salmon-tint: #ffe1d6;
  --c-lilac-tint:  #ece4ff;
  --c-butter-tint: #fff3d6;
  --c-sky-tint:    #dcf0fc;

  /* Type: every font on the site comes from these tokens. Change one here
     and it changes everywhere. Families are loaded once, in each page <head>. */
  --f-display:   "Anton", Impact, "Arial Narrow", sans-serif;   /* hero headline, card titles, stamps */
  --f-heading:   "Bangers", "Anton", Impact, sans-serif;        /* section headings */
  --f-body:      "DM Sans", system-ui, -apple-system, sans-serif;/* reading */
  --f-label:     var(--f-body);                                 /* kickers, meta lines, badges */
  --f-meme:      "Luckiest Guy", "Bangers", Impact, sans-serif;  /* meme captions, comic */
  --f-poster:    "Teko", "Anton", Impact, sans-serif;            /* meme captions, film-poster (Latin + Devanagari) */
  --f-accent:    "Kalam", cursive;                              /* handwritten rhymes, remarks (Latin + Devanagari) */
  --f-serif:     var(--f-accent);                               /* same handwritten voice as .sec-head__sub */
  --f-hero-body: "Crimson Pro", Georgia, serif;                 /* hero reading text only */
  --f-nameplate: "UnifrakturCook", Georgia, serif;              /* masthead only */

  --t-xs:   clamp(0.74rem, 0.70rem + 0.15vw, 0.82rem);
  --t-sm:   clamp(0.86rem, 0.82rem + 0.18vw, 0.95rem);
  --t-base: clamp(0.98rem, 0.94rem + 0.20vw, 1.08rem);
  --t-md:   clamp(1.10rem, 1.02rem + 0.40vw, 1.32rem);
  --t-lg:   clamp(1.35rem, 1.15rem + 0.90vw, 1.90rem);
  --t-xl:   clamp(2.10rem, 1.50rem + 2.80vw, 3.80rem);
  --t-2xl:  clamp(2.60rem, 1.60rem + 4.60vw, 5.60rem);

  /* Lines, radii, hard shadows (never blurred) */
  --b:      3px;
  --b-thin: 2px;
  --r:      12px;
  --r-sm:   6px;
  --sh-sm:  3px 3px 0 var(--c-ink);
  --sh:     5px 5px 0 var(--c-ink);
  --sh-lg:  8px 8px 0 var(--c-ink);

  /* Motion */
  --e-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --e-back:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --e-swing:  cubic-bezier(0.25, 1.45, 0.45, 1);  /* doors, springy stuff */
  --d-fast:   160ms;
  --d-mid:    320ms;
  --d-slow:   700ms;

  /* Layout */
  --wrap:     1240px;
  --gutter:   clamp(16px, 4vw, 44px);
  --sec-pad:  clamp(52px, 6.5vw, 96px);
  --header-h: 100px;   /* nav.js measures the real value */
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
  min-height: 100svh;
  background: var(--c-mustard);
  color: var(--c-ink);
  font: 400 var(--t-base)/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
ul[class], ol[class] { list-style: none; padding: 0; }
h1, h2, h3, h4 { font-weight: 400; line-height: 1.05; }

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

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

/* ==========================================================================
   3. SECTION SHELL: every page section uses this
   ========================================================================== */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  isolation: isolate;
  overflow: clip;
  padding-block: var(--sec-pad);
  border-top: var(--b) solid var(--c-ink);
}

/* Section header, always centred:
   newspaper kicker between rules → one-line rhyme → Hinglish aside */
.sec-head {
  position: relative;
  max-width: 860px;
  margin: 0 auto clamp(28px, 4vw, 44px);
  text-align: center;
}

/* "═══ PAGE 02 · NOW SHOWING ═══": a printed section rule, not a pill */
.sec-head__page {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
  font: 700 var(--t-xs)/1.2 var(--f-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sec-head__page::before,
.sec-head__page::after {
  content: "";
  flex: 0 1 64px;
  border-top: 4px double currentColor;
}

@media (max-width: 560px) {
  .sec-head__page { gap: 10px; letter-spacing: 0.08em; }
  .sec-head__page::before,
  .sec-head__page::after { flex-basis: 22px; }
}

.sec-head__title {
  font: 400 clamp(2.4rem, 1.7rem + 3.2vw, 4rem)/1.05 var(--f-heading);
  text-transform: uppercase;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.sec-head__sub {
  margin-top: 12px;
  font: 700 var(--t-base)/1.45 var(--f-accent);
  color: var(--c-ink-soft);
}

/* ==========================================================================
   4. SHARED COMPONENTS
   ========================================================================== */

/* ---- Button: flat fill, ink outline, hard shadow, presses in ---------- */
.btn {
  --btn-bg: var(--c-paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 20px;
  background: var(--btn-bg);
  border: var(--b) solid var(--c-ink);
  border-radius: var(--r-sm);
  box-shadow: var(--sh);
  font: 700 var(--t-sm)/1.1 var(--f-body);
  white-space: nowrap;
  transition: transform var(--d-fast) var(--e-out), box-shadow var(--d-fast) var(--e-out);
}

.btn:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--c-ink); }
.btn:active { transform: translate(5px, 5px); box-shadow: 0 0 0 var(--c-ink); }

.btn--salmon { --btn-bg: var(--c-salmon); }
.btn--mint   { --btn-bg: var(--c-mint); }
.btn--mustard{ --btn-bg: var(--c-mustard); }
.btn--ink    { --btn-bg: var(--c-ink); color: var(--c-paper); }

.btn[aria-disabled="true"] {
  cursor: not-allowed;
  background: repeating-linear-gradient(-45deg, var(--c-paper) 0 8px, var(--c-butter) 8px 16px);
}

.btn--sm { min-height: 40px; padding: 8px 14px; font-size: var(--t-xs); }

/* ---- Tone: one attribute picks a pastel + its pale wash ---------------- */
[data-tone="mint"]   { --tone: var(--c-mint);   --tone-tint: var(--c-mint-tint); }
[data-tone="salmon"] { --tone: var(--c-salmon); --tone-tint: var(--c-salmon-tint); }
[data-tone="lilac"]  { --tone: var(--c-lilac);  --tone-tint: var(--c-lilac-tint); }
[data-tone="butter"] { --tone: var(--c-butter); --tone-tint: var(--c-butter-tint); }
[data-tone="sky"]    { --tone: var(--c-sky);    --tone-tint: var(--c-sky-tint); }

/* ---- Meta line: "UX CASE STUDY / MOBILE APP": typeset, not chips ------- */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
  font: 700 var(--t-xs)/1.4 var(--f-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta > * + *::before {
  content: "/";
  margin-inline: 0.6em;
  color: var(--c-red);
}

/* ---- Rubber stamp ------------------------------------------------------ */
.stamp {
  display: inline-block;
  padding: 6px 12px;
  border: 3px double var(--stamp, var(--c-red));
  border-radius: 6px;
  color: var(--stamp, var(--c-red));
  font: 400 var(--t-sm)/1.1 var(--f-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  rotate: -8deg;
  mix-blend-mode: multiply;
}

/* ==========================================================================
   5. BACKGROUNDS (all CSS: zero image requests)
   ========================================================================== */
.bg-grid {
  background-image:
    linear-gradient(rgb(22 19 15 / 0.09) 1.5px, transparent 1.5px),
    linear-gradient(90deg, rgb(22 19 15 / 0.09) 1.5px, transparent 1.5px);
  background-size: 32px 32px;
}

.bg-dots {
  background-image: radial-gradient(rgb(22 19 15 / 0.16) 1.4px, transparent 1.6px);
  background-size: 14px 14px;
}

/* ==========================================================================
   6. UTILITIES
   ========================================================================== */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  padding: 8px 14px;
  background: var(--c-ink);
  color: var(--c-paper);
  transform: translateY(-200%);
}

.skip-link:focus-visible { transform: none; }

mark {
  padding-inline: 2px;
  background: linear-gradient(transparent 52%, var(--mark-c, var(--c-butter)) 52% 92%, transparent 92%);
  color: inherit;
}

/* ==========================================================================
   7. MOTION
   Hidden-until-revealed only applies once JS has booted (html.js),
   so the page is fully readable without JavaScript.
   ========================================================================== */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity var(--d-slow) var(--e-out), transform var(--d-slow) var(--e-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.js [data-reveal="pop"]   { transform: scale(0.88) rotate(-3deg); }
.js [data-reveal="left"]  { transform: translateX(-40px); }
.js [data-reveal="right"] { transform: translateX(40px); }

.js [data-reveal].is-revealed { opacity: 1; transform: none; }

/* Text that comes into focus word by word (js/utils/reveal.js splits it).
   The blur only lives on small inline words for under a second, then
   `filter: none` drops the layer, so it stays cheap on phones. */
.js [data-reveal-text] .rw {
  display: inline-block;
  opacity: 0;
  filter: blur(var(--rw-blur, 8px));
  translate: 0 0.32em;
  transition:
    opacity 650ms var(--e-out),
    filter 650ms var(--e-out),
    translate 750ms var(--e-out);
  transition-delay: calc(var(--reveal-delay, 0ms) + var(--w, 0) * 70ms);
}

.js [data-reveal-text].is-revealed .rw { opacity: 1; filter: none; translate: 0 0; }

@media (max-width: 640px) {
  :root { --rw-blur: 6px; }
}

/* Reading progress: a red rule across the very top. Pure CSS scroll
   timeline, so browsers without it simply don't show it. */
.scroll-progress { display: none; }

@supports (animation-timeline: scroll()) {
  .scroll-progress {
    display: block;
    position: fixed;
    inset: 0 0 auto;
    z-index: 60;
    height: 4px;
    background: var(--c-red);
    transform-origin: 0 50%;
    scale: 0 1;
    pointer-events: none;
    animation: scroll-grow linear both;
    animation-timeline: scroll(root);
  }

  @keyframes scroll-grow { to { scale: 1 1; } }
}

/* Parallax elements: JS writes --py; CSS owns the transform. */
[data-parallax] { translate: 0 var(--py, 0px); }

/* Shared loops. Each one animates only rotate / scale / opacity, so the
   compositor handles it without repainting. */
@keyframes rays-turn { to { rotate: 360deg; } }
@keyframes glow-pulse { 50% { opacity: 0.55; scale: 0.94; } }
@keyframes bob { 50% { translate: 0 -5px; rotate: var(--bob-rot, 4deg); } }
@keyframes shimmer { from { translate: -110% 0; } to { translate: 110% 0; } }

/* Looping animations stop painting while their section is off screen
   (js/utils/offscreen.js toggles the class). Big win on phones. */
.is-offscreen,
.is-offscreen::before,
.is-offscreen::after,
.is-offscreen *,
.is-offscreen *::before,
.is-offscreen *::after { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js [data-reveal] { opacity: 1; transform: none; }
  .js [data-reveal-text] .rw { opacity: 1; filter: none; translate: none; }
  [data-parallax] { translate: none; }
  .scroll-progress { display: none; }
}
