/* ============================================================
   Prasad Jayasiri — Economics
   main.css — design tokens, typography, buttons, layout,
               header, hero, achievement + class components.
   Load order matters: main -> sections -> responsive
   ============================================================ */


    :root{
      --teal:#7d6a39; --teal-d:#5f5029; --teal-2:#a5965f; --teal-t:#f6f2e7; --teal-t2:#e8dfc8;
      --gold:#a5965f; --gold-d:#83743f; --gold-t:#f5f2e7;
      --ink:#201a10; --body:#47433b; --muted:#8b877f; --line:#edeae6;
      --bg:#fbfaf8; --card:#ffffff;
      --serif:"Fraunces", "Noto Sans Sinhala", Georgia, "Times New Roman", serif;
      --sans:"Inter", "Noto Sans Sinhala", system-ui, -apple-system, sans-serif;
      --dt:#023d38; --dt-d:#012b27; --dt-2:#0d6b60; --dt-t:#edf4f3; --dt-t2:#ccdedb;
    }
    *{ box-sizing:border-box; }
    body{ margin:0; background:var(--bg); color:var(--body); font-family:var(--sans); font-size:16px; line-height:1.6; -webkit-font-smoothing:antialiased; }
    h1,h2,h3,h4{ font-family:var(--serif); color:var(--ink); margin:0; font-weight:500; letter-spacing:-0.01em; font-optical-sizing:auto; font-variation-settings:"SOFT" 0, "WONK" 0; }
    p{ margin:0; }
    a{ color:var(--dt); text-decoration:none; }
    a:hover{ color:var(--dt-2); }
    .wrap{ max-width:1200px; margin:0 auto; padding:0 60px; }
    .eyebrow{ font-family:var(--sans); font-size:12px; font-weight:700; letter-spacing:0.16em; text-transform:uppercase; color:var(--teal); }
    .btn{ display:inline-flex; align-items:center; gap:9px; font-family:var(--sans); font-weight:600; font-size:15px; padding:13px 24px; border-radius:999px; border:1px solid transparent; cursor:pointer; }
    .btn-primary{ background:var(--dt); color:#fff; }
    .btn-primary:hover{ background:var(--dt-d); color:#fff; }
    .btn-ghost{ background:#fff; color:var(--ink); border-color:var(--line); }
    .btn-ghost:hover{ border-color:var(--teal); color:var(--teal); }
    .chip{ display:inline-flex; align-items:center; gap:7px; font-size:13px; font-weight:600; color:var(--teal-d); background:var(--teal-t); border:1px solid var(--teal-t2); padding:6px 13px; border-radius:999px; }
    .card{ background:var(--card); border:1px solid var(--line); border-radius:18px; }
    .ph{ font-size:11px; font-weight:700; letter-spacing:0.06em; text-transform:uppercase; color:var(--gold-d); background:var(--gold-t); border:1px dashed #d9cba0; padding:3px 9px; border-radius:6px; display:inline-block; }
    svg{ display:block; }
    @keyframes letterIn{0%{opacity:0;transform:translateY(.32em) scale(.98);filter:blur(6px);text-shadow:0 0 22px rgba(42,34,21,.5);}55%{opacity:1;filter:blur(0);}100%{opacity:1;transform:translateY(0) scale(1);filter:blur(0);text-shadow:0 0 0 rgba(42,34,21,0);}}
    /* Resting state is VISIBLE. Hiding applies only while <html> carries .anim
       (added by the inline script in index.html, and removed by its safety timer),
       so the heading can never be left invisible if animations are throttled. */
    .ht span{display:inline-block;}
    html.anim .ht span{opacity:0;animation:letterIn .72s cubic-bezier(.2,.75,.25,1) forwards;will-change:transform,opacity,filter;}
    /* Hero name: a "written by hand" video clip in place of the old signature.
       The source is a 9:16 clip with the name in the middle on a light-grey
       ground, so the wrapper crops to the name band (object-fit:cover) and the
       filter + mix-blend-mode:multiply lift the grey to white and drop it,
       leaving only the ink strokes over the hero. */
    /* The crop is measured, not guessed. In the 720x1280 source the ink of the
       name runs y 476->747 and x 34->657, so its centre sits at 47.8% of the
       frame height, not 50%. A 40/16 box centred at 50% showed y 496->784 and
       sliced ~20px off the TOP of the letters. 40/18 widens the band to
       y 450->774 and `center 47%` re-centres it on the ink, leaving an even
       ~26px of clearance above and below. Both numbers are ratios, so the same
       crop holds at every width the 84% max-width produces. */
    .name-media{
      display:block; width:380px; max-width:84%; aspect-ratio:40 / 18;
      overflow:hidden; margin-top:16px; pointer-events:none;
    }
    /* No z-index inside #top, so the hero paints by DOM order and this clip's
       mix-blend-mode:multiply blends straight into the hero: the filter lifts the
       grey ground to white and multiply drops it, leaving only the ink strokes. */
    .name-video{
      width:100%; height:100%; object-fit:cover; object-position:center 47%; display:block;
      mix-blend-mode:multiply; filter:contrast(1.22) brightness(1.1);
    }
    @keyframes fadeUp{from{opacity:0;transform:translateY(16px);}to{opacity:1;transform:translateY(0);}}
    html.anim .featrow > div{opacity:0;animation:fadeUp .55s ease-out forwards;}
    .featrow > div:nth-child(1){animation-delay:.28s;}
    .featrow > div:nth-child(2){animation-delay:.42s;}
    .featrow > div:nth-child(3){animation-delay:.56s;}
    .featrow > div:nth-child(4){animation-delay:.70s;}
    .stack-fg{position:relative;z-index:2;background:var(--bg);border-radius:28px 28px 0 0;box-shadow:0 -24px 55px -20px rgba(30,26,20,.32);}
    @media (prefers-reduced-motion: reduce){.ht span,.featrow > div{animation:none!important;opacity:1;transform:none;}}

    /* Statistics reveal for the results panel. */
    @keyframes fadeUp2{from{opacity:0;transform:translateY(18px);}to{opacity:1;transform:translateY(0);}}
    .stat{position:relative;animation:fadeUp2 .7s ease-out both;animation-delay:calc(3.6s + var(--i)*.14s);}
    @media (prefers-reduced-motion: reduce){
      .stat{animation:none!important;opacity:1!important;transform:none!important;}
    }




    /* ---- deep teal #023d38: second primary (gold stays the accent) ---- */
    .btn-ghost:hover{ border-color:var(--dt); color:var(--dt); }
    a:hover{ color:var(--dt-2); }
    .chip{ color:var(--dt); background:var(--dt-t); border-color:var(--dt-t2); }
    /* flex:none is load-bearing. The svg carries width/height attributes but a
       flex item still defaults to `0 1 auto`, so as soon as the label needed
       more room than the cell had, the icon was shrunk horizontally while its
       height stayed at 22px — measured at 17.9 / 21.4 / 20.3 / 19.6px across
       the four cells, i.e. four different widths, each one a squashed 24x24
       viewBox with its artwork clipped. */
    .featrow > div{ display:flex; align-items:center; gap:11px; padding:20px 18px; }
    .featrow > div:not(:last-child){ border-right:1px solid var(--line); }
    .featrow > div svg{ stroke:var(--dt); flex:none; }
    /* Below ~1240px the cells are too narrow for the longest label, so it wraps.
       Balanced wrapping splits it into two even lines instead of one long line
       and an orphan, which is what made the row read as ragged. */
    .featrow > div span{ font-size:13.5px; line-height:1.35; text-wrap:balance; }

    /* ============================================================
       Header / navigation (with pure-CSS mobile menu)
       ============================================================ */
    /* The header lives inside #top (sticky, so it is the containing block and
       top:0 is still the page top). No z-index: it stacks by DOM order so the
       .hero-stamp video, the last child of #top, can paint over the nav. */
    .site-header{ position:absolute; top:0; left:0; right:0; background:transparent; }
    /* ...except while the phone menu is open: lift the header above the stamp
       so the headline ink doesn't print through the white menu panel. Safe —
       the header holds no blended content (HANDOVER §6.15). */
    #top:has(.nav-toggle:checked) .site-header{ z-index:2; }
    /* The portrait is the one thing in the hero above the stamp video: the stamp
       passes behind him. z-index is safe here — the portrait holds no blended
       content (the name clip's multiply lives in the text column, §6.15). No
       pointer events: there is nothing to click in it, and its box must not
       block the nav. */
    #top .hero-portrait{ z-index:1; pointer-events:none; }
    .nav-wrap{ display:flex; align-items:center; justify-content:space-between; gap:28px; padding-top:22px; padding-bottom:16px; }
    .brand{ display:flex; align-items:center; gap:13px; }
    .brand:hover{ color:inherit; }
    .brand-text{ line-height:1.15; }
    .brand-name{ display:block; font-family:var(--serif); font-size:20px; color:#24211c; }
    .brand-role{ display:block; font-size:11.5px; font-weight:700; letter-spacing:.13em; text-transform:uppercase; color:var(--teal); }
    .site-nav{ display:flex; align-items:center; gap:26px; font-size:14.5px; font-weight:600; }
    .site-nav a{ color:#24211c; }
    .site-nav a:hover{ color:var(--dt); }
    .site-nav a.nav-cta,
    .site-nav a.nav-cta:hover{ color:#fff; }
    .nav-cta{ box-shadow:0 8px 20px rgba(2,61,56,.28); }
    .nav-burger{ display:none; }

    /* ============================================================
       Hero video backdrop
       The <video> sits behind a warm semi-transparent veil so the
       existing light palette and dark hero text stay legible.
       ============================================================ */
    /* Stamp headline video: geometry (size/left/top/rotation) is owned by the
       positioner in main.js, which maps the clip's text block onto the
       .hero-si-test spacer. No z-index, no mask-image (HANDOVER §6.15/§6.18) —
       it is the LAST child of #top, so by DOM order it sits at the top of the
       hero's stack, over the nav too (HANDOVER §6.21). */
    #top .hero-stamp{
      position:absolute; left:0; top:0; pointer-events:none; will-change:transform;
      /* Blend the printed headline into the hero like ink. The clip's background
         is already pure white (flattened offline by design/tools/clean-stamp.py),
         and multiply over white is a no-op, so only the ink, the stamp and its
         shadow show and the hero's backdrop runs on uninterrupted. No CSS
         filter needed — re-run the script rather than filtering here. */
      mix-blend-mode:multiply;
    }
    #top .hero-video{
      position:absolute; inset:0; width:100%; height:100%;
      object-fit:cover; pointer-events:none;
      /* A subtle backdrop, right side only (client, 2026-10-24): nothing at all
         behind the text column, then the graphs fade in gradually toward the
         right edge, where they peak at the opacity below — never strong. Where
         the mask thins the video, #top's matching #e7e3d7 shows through, so the
         fade has no visible edge. (A mask is fine HERE — §6.18's phantom
         rectangle came from masking the portrait.) */
      opacity:.32;
      -webkit-mask-image:linear-gradient(to right, transparent 0%, transparent 52%, rgba(0,0,0,.35) 68%, #000 92%);
              mask-image:linear-gradient(to right, transparent 0%, transparent 52%, rgba(0,0,0,.35) 68%, #000 92%);
    }
    /* Reduced motion: main.js freezes the graphs on their finished last frame
       rather than hiding them — the board is the backdrop, not decoration. */

    /* ============================================================
       Current Classes — faded portrait, anchored right
       ============================================================ */

    /* ---- contact section: hand-lettered heading image (dark ink art,
       recoloured to cream so it reads on the deep-teal band) ---- */
    .contact-heading{
      display:block; width:100%; max-width:540px; height:auto; margin-top:16px;
      filter:brightness(0) invert(1);
    }
    /* write-in reveal, triggered when the contact band scrolls into view
       (.reveal is added by main.js so no-JS keeps it visible; .in-view fires it) */
    .contact-heading.reveal{ opacity:0; -webkit-clip-path:inset(0 100% 0 0); clip-path:inset(0 100% 0 0); }
    .contact-heading.reveal.in-view{ animation:headingWrite 1.5s cubic-bezier(.4,0,.2,1) forwards; }
    @keyframes headingWrite{
      0%{ opacity:0; -webkit-clip-path:inset(0 100% 0 0); clip-path:inset(0 100% 0 0); }
      14%{ opacity:1; }
      100%{ opacity:1; -webkit-clip-path:inset(0 0 0 0); clip-path:inset(0 0 0 0); }
    }
    @media (prefers-reduced-motion: reduce){
      .contact-heading.reveal, .contact-heading.reveal.in-view{
        opacity:1; -webkit-clip-path:none; clip-path:none; animation:none;
      }
    }

    /* screen-reader-only text (keeps the real heading in the document) */
    .visually-hidden{
      position:absolute !important; width:1px; height:1px; padding:0; margin:-1px;
      overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
    }


/* Sinhala headline spacer (index.html .hero-si-test): an empty, transparent box
   that only reserves the headline's space. Its aspect matches the stamp video's
   TEXT BLOCK (1278x396); the .hero-stamp video is sized/placed onto this box by
   main.js (TB there must match). Width rules are the headline's old ones so
   left + width are unchanged. */
.hero-si-test{ margin:0; line-height:0; width:100%; max-width:640px; aspect-ratio:1278 / 396; }
@media (min-width: 1025px){
  .hero-si-test{ width:780px; max-width:none; }
  /* 1fr alone is minmax(auto,1fr): the 780px headline would widen column 1 and
     shrink the portrait. minmax(0,...) lets it overflow instead. */
  .hero-wrap{ grid-template-columns:minmax(0,1fr) minmax(0,1fr) !important; }
  /* Nudge the portrait right so it doesn't cover the end of the headline. */
  .hero-portrait{ transform:translateX(clamp(60px, 9vw, 130px)); }
  /* Larger portrait on desktop only (the inline width:100% caps it to the grid
     column, so override both here to let it grow past the column). */
  .hero-portrait img{ width:600px !important; max-width:none !important; flex:none; }
}

/* The headline is now the .hero-stamp video (printed on paper); it carries its
   own write-on animation, so no CSS entrance is applied here. */
