/* Magic Memory — components and long-form stylesheet, loaded after tokens.css.
   Token values (colour, type scale, spacing, radius, shadow, keylines, measures)
   live in tokens.json. This file keeps what tokens.json cannot hold: the Newsreader
   webfont, a colour-mix tint, the composite borders, motion, base element defaults,
   the type roles and the long-form (.mm-article) rules. */

@import url("https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400;1,6..72,500&display=swap");
@import url("../typography.css");

/* ============================================================
   MAGIC MEMORY — COLOR
   A duotone-plus brand: fluorescent PINK is the world,
   BLACK is the ink (engravings + text on white), WHITE is
   the voice (type on pink, reading surfaces). Nothing else.
   The pink is loud on purpose. Use it at full bleed.
   ============================================================ */

:root {
  /* ---- Functional tint (derived in oklab, on-brand) ------- */
  --mm-pink-line:   color-mix(in oklab, var(--mm-black) 78%, var(--mm-pink));
}

/* ============================================================
   MAGIC MEMORY — SPACING, RADIUS, BORDER, SHADOW, MOTION
   The system is flat and printed: hairline rules, hard
   corners, almost no shadow. Cards behave like physical
   playing cards — a fixed ratio, a thin keyline, a crisp lift.
   ============================================================ */

:root {
  /* ---- Border / keyline ----------------------------------- */
  --border:        var(--bd-rule) solid var(--mm-white);
  --border-ink:    var(--bd-rule) solid var(--mm-black);
  --border-hair:   var(--bd-hair) solid var(--mm-hairline);

  /* ---- Motion --------------------------------------------- */
  --ease-out:  cubic-bezier(0.22, 1, 0.36, 1);     /* @kind other */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);   /* @kind other */
  --dur-fast:  120ms;   /* @kind other */
  --dur-base:  220ms;   /* @kind other */
  --dur-slow:  420ms;   /* @kind other */
}

/* ============================================================
   MAGIC MEMORY — TYPOGRAPHY
   KraftMono is the DISPLAY face (headlines, subheads, labels,
   buttons). Newsreader is the BODY face (running text).
   Signature moves: (1) loud tracked-out display, (2) JUSTIFIED
   running text on wide columns, (3) italic-underline for the
   emphasis words Learn / Apply. Display is mostly UPPERCASE.
   ============================================================ */

/* ---- Base element defaults --------------------------------- */
:where(body) {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Reusable type roles ----------------------------------- */
.mm-hero {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-display);
  text-transform: uppercase;
}
.mm-title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  line-height: var(--lh-tight);
  text-transform: uppercase;
}
/* tracked-out word: M A G I C */
.mm-spread {
  font-family: var(--font-display);
  letter-spacing: var(--tr-wide);
  text-transform: uppercase;
}
/* a header that justifies its words edge to edge: THE … HISTORY */
.mm-header-spread {
  font-family: var(--font-display);
  display: flex;
  justify-content: space-between;
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
}
.mm-label {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
}
/* signature justified running text */
.mm-prose {
  text-align: justify;
  text-justify: inter-word;
  line-height: var(--lh-body);
  hyphens: auto;
}
/* emphasis word, e.g. Learn / Apply */
.mm-emph {
  font-style: italic;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

/* ============================================================
   MAGIC MEMORY — LONG-FORM / EDITORIAL
   For websites, articles, newsletters. The deck's print rules
   (white on pink, justified mono) are tuned for screen reading:
   - running text is Newsreader; headings, quotes, captions,
     numerals and dividers are KraftMono;
   - running text is INK on WHITE (or ink on pink), never white
     on pink — white/pink is ~2.9:1, display sizes only;
   - justification switches on only when the column is wide
     enough to avoid rivers (container query);
   - links stay ink with a pink underline; hover fills pink.
   Scope: wrap any article body in .mm-article.
   ============================================================ */

/* ---- The article body ------------------------------------ */
.mm-article {
  container-type: inline-size;
  max-width: var(--measure-prose);
  font-family: var(--font-body);
  font-size: var(--fs-prose);
  line-height: var(--lh-prose);
  color: var(--read-text);
  hyphens: auto;
  -webkit-hyphens: auto;
  text-wrap: pretty;
  overflow-wrap: break-word;
}
.mm-article[data-surface="pink"] { --read-bg: var(--mm-pink); --read-text-soft: var(--mm-black); --read-hair: var(--mm-black); --read-mark: var(--mm-black); --read-highlight: var(--mm-pink-tint); }
.mm-article ::selection { background: var(--read-highlight); color: var(--read-text); }
.mm-article > * { margin: 0 0 var(--prose-gap); }
.mm-article > :last-child { margin-bottom: 0; }

@container (min-width: 30rem) {
  .mm-article p, .mm-article li { text-align: justify; text-justify: inter-word; }
}

/* headings */
.mm-article h1, .mm-article h2, .mm-article h3, .mm-article h4 { font-family: var(--font-display); font-weight: 400; text-wrap: balance; }
.mm-article h1 { font-size: var(--fs-h1-article); line-height: var(--lh-heading); text-transform: uppercase; letter-spacing: .04em; }
.mm-article h2 { font-size: var(--fs-h2-article); line-height: var(--lh-heading); text-transform: uppercase; letter-spacing: .1em; margin-top: var(--prose-section); padding-top: .55em; border-top: var(--bd-rule) solid var(--read-rule); }
.mm-article h3 { font-size: var(--fs-h3-article); line-height: 1.3; text-transform: uppercase; letter-spacing: var(--tr-label); margin-top: 2em; margin-bottom: .6em; }
.mm-article h4 { font-size: 1rem; font-style: italic; text-decoration: underline; text-underline-offset: .18em; margin-bottom: .4em; }
.mm-article h2 + *, .mm-article h3 + * { margin-top: 0; }

/* lede / standfirst */
.mm-article .mm-lede { font-size: var(--fs-lede); line-height: 1.4; text-align: left; }

/* emphasis — italic-underline is reserved for Learn / Apply */
.mm-article em { font-style: italic; }
.mm-article strong, .mm-article b { font-weight: 600; }
.mm-article .mm-emph { font-style: italic; text-decoration: underline; text-underline-offset: .18em; }

/* links: ink text, pink underline, pink fill on hover */
.mm-article a { color: inherit; text-decoration: underline; text-decoration-color: var(--read-mark); text-decoration-thickness: 2px; text-underline-offset: .2em; transition: background var(--dur-fast) var(--ease-out); }
.mm-article a:hover { background: var(--mm-pink); color: var(--mm-black); text-decoration-color: var(--mm-black); }
.mm-article[data-surface="pink"] a:hover { background: var(--mm-black); color: var(--mm-pink); }

/* lists: middot bullets, 01 numerals */
.mm-article ul, .mm-article ol { padding: 0; list-style: none; }
.mm-article li { position: relative; padding-left: 2.5ch; margin-bottom: .4em; }
.mm-article ul > li::before { content: "·"; position: absolute; left: .5ch; color: var(--read-mark); font-size: 1.4em; line-height: 1; top: .05em; }
.mm-article ol { counter-reset: mm; }
.mm-article ol > li { counter-increment: mm; padding-left: 4ch; }
.mm-article ol > li::before { content: counter(mm, decimal-leading-zero); position: absolute; left: 0; top: .2em; font-family: var(--font-display); font-size: .8em; color: var(--read-text-soft); }

/* quotes: keylines above + below, no side bar */
.mm-article blockquote { margin: 2em 0; padding: .9em 0; border-top: var(--bd-rule) solid var(--read-rule); border-bottom: var(--bd-rule) solid var(--read-rule); font-family: var(--font-display); font-size: var(--fs-quote); line-height: 1.3; text-transform: uppercase; letter-spacing: .02em; text-align: left; }
.mm-article blockquote p { text-align: left; margin: 0; }
.mm-article blockquote cite { display: block; margin-top: .9em; font-size: var(--fs-caption); font-style: normal; letter-spacing: var(--tr-label); }

/* dividers */
.mm-article hr { border: 0; height: auto; margin: 2.5em 0; text-align: center; color: var(--read-text); }
.mm-article hr::after { content: "·  ·  ·"; white-space: pre; letter-spacing: .4em; font-family: var(--font-display); }

/* figures */
.mm-article figure { margin: 2em 0; }
.mm-article figure img { display: block; width: 100%; height: auto; }
.mm-article figcaption { margin-top: .7em; font-family: var(--font-display); font-size: var(--fs-caption); letter-spacing: .08em; text-transform: uppercase; color: var(--read-text-soft); text-align: left; }
.mm-article .mm-wide { max-width: var(--measure-wide); width: min(var(--measure-wide), 100vw - 2rem); }

/* inline code / small marks */
.mm-article code, .mm-article kbd { font-family: var(--font-mono); font-size: .85em; }
.mm-article code, .mm-article kbd, .mm-article mark { background: var(--read-highlight); color: inherit; padding: 0 .3ch; }

/* footnotes */
.mm-article sup { font-size: .7em; line-height: 0; }
.mm-article sup a { text-decoration-thickness: 1px; }
.mm-article .mm-footnotes { margin-top: 3em; padding-top: 1em; border-top: var(--bd-hair) solid var(--read-rule); font-size: var(--fs-prose-sm); color: var(--read-text-soft); }

/* tables */
.mm-article table { width: 100%; border-collapse: collapse; font-size: var(--fs-prose-sm); }
.mm-article th { font-family: var(--font-display); font-size: var(--fs-caption); text-align: left; font-weight: 400; text-transform: uppercase; letter-spacing: var(--tr-label); border-bottom: var(--bd-rule) solid var(--read-rule); padding: .5em .8ch; }
.mm-article td { border-bottom: var(--bd-hair) solid var(--read-hair); padding: .55em .8ch; vertical-align: top; }

@media (prefers-reduced-motion: reduce) { .mm-article a { transition: none; } }

/* Allow the deck columns to shrink at tablet widths, without clipping content. */
@media (max-width: 1000px) {
  .d5-stage,
  .d5-copy {
    min-width: 0;
    max-width: 100%;
  }
}

/* Static-site mobile layout. These overrides intentionally beat the exported
   inline layout styles; desktop and the card artwork keep their original CSS. */
@media (max-width: 760px) {
  body > div > header,
  body > div > footer {
    padding-left: 24px !important;
    padding-right: 24px !important;
  }

  body > div > header > a {
    font-size: 14px !important;
    letter-spacing: .28em !important;
    overflow-wrap: anywhere;
  }

  body > div > section,
  body > div > div[style*="padding:"] {
    padding-left: 24px !important;
    padding-right: 24px !important;
  }

  /* Put the numbered station above its content instead of reserving a
     96px sidebar on a phone. The route continues vertically between stations. */
  section:has(> .t-station) {
    flex-direction: column !important;
    gap: 24px !important;
    margin-bottom: 72px !important;
  }

  section:has(> .t-station) > div:not(.t-station) {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  body > div > div > div[aria-hidden="true"][style*="border-left:"] {
    left: 51px !important;
  }

  #top > div > div,
  section > div,
  .s-col,
  .rx-grid > *,
  .rx-sheet > * {
    min-width: 0;
  }

  #top h1 {
    font-size: clamp(32px, 7.8vw, 52px) !important;
    overflow-wrap: anywhere;
  }

  .t-route {
    column-gap: 16px !important;
  }

  .t-route a {
    gap: 8px !important;
    font-size: 12px !important;
    letter-spacing: .08em !important;
  }

  .t-route a b {
    width: 24px !important;
    flex-shrink: 0;
  }

  nav[aria-label="The eight techniques"] {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)) !important;
  }

  #buy,
  #vi > div:not(.t-station) {
    padding: 32px 24px !important;
    min-width: 0;
  }

  #buy > div,
  #vi > div > div {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  #buy > .sh-ph {
    flex-basis: 100% !important;
  }

  .t-sub button {
    width: 100% !important;
    white-space: normal !important;
    line-height: 1.4 !important;
    padding: 14px 12px !important;
  }

  .s-arch,
  .tp-frame,
  .d4-arch {
    max-width: 100% !important;
    min-width: 0;
  }

  .tp-look {
    padding: 28px 24px !important;
  }

  .tp-pg > :not(.t-tech):not(.tp-mini-sprig) {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .s-p,
  .tp-src,
  .sh-lib,
  .r-box {
    overflow-wrap: anywhere;
  }

  div[style*="repeat(auto-fit, minmax(300px"],
  div[style*="repeat(auto-fit, minmax(280px"] {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)) !important;
  }

  .t-arch,
  .d5-stage,
  .d5-copy {
    min-width: 0;
    max-width: 100%;
  }

  #i .t-arch {
    padding-left: 24px !important;
    padding-right: 24px !important;
    overflow-wrap: anywhere;
  }
}
