@layer reset, tokens, base, layout, components, utilities;

/* ============================================================ TOKENS */
@layer tokens {
  :root {
    /* surfaces */
    --bg:      #F2F2F2;   /* page + light modules */
    --panel:   #EAEBEC;   /* nav, hero, gallery cards */
    --ink:     #14151A;   /* hairlines + footer */

    /* text */
    --grey:    #6A6B6F;   /* mono labels */
    --prose:   #777A8A;   /* body copy */
    --faint:   #9A9B9F;   /* counts / muted */
    --faint-2: #898A90;

    /* accents */
    --accent:       #DB7A5F;  /* marks, A/B/C, in-progress */
    --accent-label: #C45239;  /* section right labels */
    --accent-red:   #EF6C6E;  /* year markers */

    /* ghost (card watermark) — barely-there panel tone on bg */
    --ghost: #EAEBEC;

    /* on dark */
    --on-dark:       #EAEBEC;
    --on-dark-faint: #9A9B9F;
    --footer-line:   #34353A;

    --line: 1px solid var(--ink);

    --mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --display: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    /* layout rhythm (desktop) */
    --gutter: 40px;       /* outer margin around the bordered stack */
    --pad:    56px;       /* inner module padding */
    --max:    1512px;
  }
}

/* ============================================================ RESET */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; }
  body { min-height: 100svh; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
  img, picture, svg { display: block; max-width: 100%; }
  img { height: auto; }
  a { color: inherit; text-decoration: none; }
  h1, h2, p { overflow-wrap: break-word; }
}

/* ============================================================ BASE */
@layer base {
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 16px;
    line-height: 1.5;
  }
  ::selection { background: var(--accent); color: var(--bg); }
  :where(a, [tabindex]):focus-visible { outline: 2px solid var(--accent-label); outline-offset: 3px; }

  .skip-link {
    position: fixed; inset-block-start: -200%; inset-inline-start: 1rem; z-index: 100;
    padding: .6rem 1rem; background: var(--ink); color: var(--bg);
    font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  }
  .skip-link:focus { inset-block-start: 1rem; }
}

/* ============================================================ LAYOUT */
@layer layout {
  /* page padding = 30px top / 40px sides / 24px bottom, capped + centred */
  .page {
    max-width: calc(var(--max) - 0px);
    margin-inline: auto;
    padding: 30px var(--gutter) 24px;
  }

  /* the bordered column: top hairline only — modules supply the rest */
  .stack { border-block-start: var(--line); }

  /* every module draws left + right + bottom hairlines → single grid lines */
  .module { border-inline: var(--line); border-block-end: var(--line); }

  .nav     { background: var(--panel); }
  .hero    { background: var(--panel); }
  .section { background: var(--bg); }
}

/* ============================================================ COMPONENTS */
@layer components {

  /* ---------------- label type ---------------- */
  .label, .label-wide, .label-cap {
    font-family: var(--mono); font-weight: 400;
    font-size: 11px; line-height: 1.5; text-transform: uppercase; color: var(--grey);
  }
  .label      { letter-spacing: .073em; }
  .label-wide { letter-spacing: .118em; }
  .label-cap  { letter-spacing: .06em; }
  .label-12 {
    font-family: var(--mono); font-weight: 400;
    font-size: 12px; line-height: 1.9; letter-spacing: .03em;
    text-transform: uppercase; color: var(--grey);
  }
  .muted   { color: var(--faint); }
  .ink     { color: var(--ink); }
  .accent  { color: var(--accent); }
  .accent-label { color: var(--accent-label); }
  .ghost   { color: var(--ghost); }
  .prose-c { color: var(--prose); }

  .prose {
    font-family: var(--display); font-weight: 400;
    font-size: 14px; line-height: 1.715; color: var(--prose);
    text-align: justify; text-justify: inter-character; hyphens: auto;
  }

  /* big mono titles (cards + timeline rows) */
  .title-lg {
    font-family: var(--display); font-weight: 700;
    font-size: clamp(1.6rem, 2.1vw, 2rem);   /* 32px */
    line-height: 1.084; letter-spacing: .003em; text-transform: uppercase; color: var(--ink);
  }

  /* ---------------- nav ---------------- */
  .nav { display: flex; align-items: stretch; min-block-size: 48px; }
  .nav__menu {
    display: grid; place-items: center; inline-size: 56px;
    border-inline-end: var(--line); color: var(--accent);
  }
  .nav__ticker {
    display: flex; align-items: center; flex: 1 1 auto; min-inline-size: 0;
    padding-inline: 56px 20px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .nav__links { display: flex; align-items: stretch; }
  .nav__link {
    display: flex; align-items: center; gap: .45em;
    padding-inline: 16px; color: var(--ink);
    border-inline-start: var(--line);
    transition: background-color .25s ease, color .25s ease;
  }
  .nav__link:last-child { padding-inline: 40px; }
  .nav__link:hover { background: var(--ink); color: var(--panel); }
  .nav__link:hover .muted { color: var(--panel); }

  /* ---------------- hero ---------------- */
  .hero { padding: 52px var(--pad) 64px; display: flex; flex-direction: column; gap: 52px; }
  .hero__header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
  .hero__loc { display: inline-flex; align-items: center; gap: 30px; }
  .hero__blips { color: var(--accent); inline-size: 21px; height: 6px; }
  .hero__art { inline-size: 100%; height: auto; }

  .hero__columns { display: grid; grid-template-columns: 1fr 1fr; gap: var(--pad); }
  .hero__col { border-block-start: var(--line); padding-block-start: 16px; }
  .hero__identity span { display: block; }
  .hero__identity span:not(.ink) { color: var(--grey); }
  .hero__status { margin-block-start: 14px; }

  /* ---------------- section title bar ---------------- */
  .bar {
    display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
    padding: 14px var(--pad); background: var(--bg);
    border-block-end: var(--line);
  }
  .bar--dark { background: var(--ink); border-block-end: 0; }
  .bar--dark .bar__left { color: var(--faint); }

  /* ---------------- §01 cards ---------------- */
  .cards { display: grid; grid-template-columns: repeat(3, 1fr); }
  .card {
    display: flex; flex-direction: column; gap: 24px;
    padding: var(--pad);
    min-block-size: clamp(17rem, 24vw, 21.8rem);
  }
  .card + .card { border-inline-start: var(--line); }
  .card__top { display: flex; align-items: center; justify-content: space-between; }
  .card__top .ghost { letter-spacing: .12em; }

  /* ---------------- §02 timeline ---------------- */
  .trow {
    display: grid; grid-template-columns: 76px 1fr auto; align-items: center;
    column-gap: 0; padding: var(--pad);
  }
  .trow + .trow { border-block-start: var(--line); }
  .trow__num { font-size: 13px; color: var(--accent); align-self: center; }
  .trow__body { display: flex; flex-direction: column; gap: 20px; }
  .trow__head { display: flex; flex-direction: column; gap: 16px; }
  .trow__tag { color: var(--ink); }
  .trow__body .prose { max-inline-size: 30rem; }
  .trow__year {
    font-size: 12px; letter-spacing: .108em; text-transform: uppercase;
    color: var(--accent-red); align-self: center; white-space: nowrap;
  }

  /* ---------------- §03 gallery ---------------- */
  .gallery { display: grid; grid-template-columns: 1fr 1fr; }
  .gcard { background: var(--panel); padding: 34px; display: flex; flex-direction: column; gap: 14px; }
  .gcard:nth-child(odd)   { border-inline-end: var(--line); }
  .gcard:nth-child(-n+2)  { border-block-end: var(--line); }
  .gcard__media { position: relative; border: var(--line); aspect-ratio: 648 / 484; overflow: hidden; }
  .gcard__img {
    inline-size: 100%; block-size: 100%; object-fit: cover;
    transition: transform .9s cubic-bezier(.2,.7,.2,1);
  }
  .gcard:hover .gcard__img, .gcard:focus-within .gcard__img { transform: scale(1.05); }

  /* ---- worn-VHS roll-over (after the Scotch VHS pen): grain + tape clip ---- */
  /* constant film grain */
  .gcard__media::before,
  .gcard__media::after {
    content: ""; position: absolute; inset: 0; z-index: 2;
    pointer-events: none;
  }
  .gcard__media::before {
    background: url("img/vhs-grain.png");
    background-size: 256px 256px;
    mix-blend-mode: overlay;
    opacity: 0; transition: opacity .25s ease;
  }
  /* animated VHS-static tape clip — fades in on hover */
  .gcard__media::after {
    background: url("img/vhs-static.gif") center / cover no-repeat;
    background-position-y: -20px;
    mix-blend-mode: screen;
    opacity: 0; transition: opacity .25s ease;
  }
  .gcard:hover .gcard__media::before, .gcard:focus-within .gcard__media::before { opacity: .6; }
  .gcard:hover .gcard__media::after,  .gcard:focus-within .gcard__media::after  { opacity: .64; }

  /* reduced motion: keep the static grain, drop the animated tape clip */
  @media (prefers-reduced-motion: reduce) {
    .gcard:hover .gcard__media::after, .gcard:focus-within .gcard__media::after { display: none; }
    .gcard:hover .gcard__media::before, .gcard:focus-within .gcard__media::before { opacity: .8; }
  }
  .gcard__cap { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
  .gcard__cap .ink { color: var(--ink); }

  /* ---------------- §04 philosophy ---------------- */
  .philosophy {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 88px var(--pad);
  }
  .philosophy__head {
    font-family: var(--display); font-weight: 400;
    font-size: clamp(2.5rem, 4vw, 3.75rem);  /* 40 → 60 */
    line-height: 1.066; letter-spacing: -.013em; color: var(--ink);
  }
  .philosophy__sub {
    font-family: var(--mono); font-weight: 300;
    font-size: clamp(1.125rem, 1.5vw, 1.375rem);  /* 18 → 22 */
    line-height: 1.73; color: var(--ink);
    margin-block-start: 24px;
  }
  .philosophy__arrow { color: var(--ink); margin-block-start: clamp(1.6rem, 3vw, 2.5rem); }

  /* ---------------- §05 footer ---------------- */
  .footer { background: var(--ink); color: var(--on-dark); }
  .footer__body {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: clamp(2rem, 4vw, 3rem); align-items: end;
    padding: 72px var(--pad);
  }
  .footer__lede {
    font-family: var(--display); font-weight: 100;
    font-size: clamp(1.375rem, 3.1vw, 2.5rem);  /* 22 → 40 */
    line-height: 1.3; color: var(--on-dark); max-inline-size: 17ch;
  }
  .footer__contact { justify-self: end; text-align: end; display: flex; flex-direction: column; gap: 24px; }
  .footer__enq { color: var(--faint-2); letter-spacing: .108em; }
  .footer__email {
    display: inline-block; align-self: end; white-space: nowrap; max-inline-size: 100%;
    font-family: var(--display); font-weight: 400;
    font-size: clamp(1.375rem, 2.6vw, 2.25rem);  /* 22 → 36 */
    letter-spacing: .003em; text-transform: uppercase; color: var(--on-dark);
    border-block-end: 2px solid currentColor;
    transition: color .25s ease, border-color .25s ease;
  }
  .footer__email:hover { color: var(--accent); border-color: var(--accent); }

  .colophon {
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: 16px var(--pad);
    border-block-start: 1px solid var(--footer-line);
    color: var(--faint);
  }
  .colophon .label { color: var(--faint); letter-spacing: .08em; }
}

/* ============================================================ UTILITIES */
@layer utilities {
  .sr-only {
    position: absolute; inline-size: 1px; block-size: 1px;
    padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    [data-reveal] { opacity: 0; transform: translateY(18px); }
    [data-reveal].is-in { opacity: 1; transform: none; transition: opacity .8s ease, transform .8s cubic-bezier(.2,.7,.2,1); }
  }

  /* ---------------- responsive ---------------- */
  @media (max-width: 1024px) {
    :root { --pad: 40px; }
    .trow { grid-template-columns: 56px 1fr; row-gap: 1rem; }
    .trow__year { grid-column: 2; justify-self: start; }
  }

  @media (max-width: 860px) {
    .cards { grid-template-columns: 1fr; }
    .card + .card { border-inline-start: 0; border-block-start: var(--line); }
    .card { min-block-size: 0; }
  }

  @media (max-width: 760px) {
    :root { --gutter: 0px; --pad: 28px; }
    .page { padding: 0; }
    .nav__menu { inline-size: 44px; }
    .nav__ticker { padding-inline: 14px 20px; white-space: normal; }
    .nav__links { display: none; }
    .hero { padding: 52px 28px 24px; }
    .hero__columns { grid-template-columns: 1fr; gap: 1.75rem; }
    .footer__body { grid-template-columns: 1fr; gap: 2.5rem; padding: 34px 28px 56px; }
    .footer__contact { justify-self: start; text-align: start; }
    .footer__email { align-self: start; }
    .footer__lede { max-inline-size: none; }
    .colophon { flex-direction: column; gap: .5rem; padding-block: 24px; }
  }

  @media (max-width: 560px) {
    .gallery { grid-template-columns: 1fr; }
    .gcard:nth-child(odd) { border-inline-end: 0; }
    .gcard:nth-child(-n+3) { border-block-end: var(--line); }
    .gcard__cap { flex-direction: column; gap: .25rem; }
  }
}
