/* Copied by scripts/build-portals.mjs from src/styles/_book.scss. Edit that file, never this one. */
/* ============================================================================
   THE BOOK: the brand book's patterns, shared by every page
   Ported from the Forge brand book (perception-workshop/tools/voice/book.html), with its class
   names. The law wins where they differ: design-systems/perception/system.md.
   - Tone: chapters walk from shadow to light. The holder (body.tone on an inner page, main.cv-after
     on the homepage, so the fixed cave stays covered) eases its surface and ink to the tone of the
     chapter in the middle of the screen (src/js/book.js). dark, dusk, dawn, light = black, charcoal,
     white, pure white.
   - .ov / .cov: a full-bleed photograph with type on its own dark area. .q4: a quote over a photo.
   - .fig + ratio classes, .bleed, .media, .gal--pair, .split--sticky: images on the law's ratios.
   - .mist: headlines and statements mist in once. .im2: black and white to color. Both hang on
     html.mo, which only exists when motion is welcome.
   - .vals / .nl: IX8c name lights, the index for every list of names.
   Plain CSS on purpose (no Sass): scripts/build-portals.mjs copies this file to /portal/book.css for
   the Labs page, which can't load the site's hashed CSS.
   ============================================================================ */

/* Registered, so the tone eases instead of snapping (law 10: 900 for a surface change) */
@property --bg    { syntax: '<color>'; inherits: true; initial-value: #0E0E0E; }
@property --ink   { syntax: '<color>'; inherits: true; initial-value: #F5F5F5; }
@property --ink-2 { syntax: '<color>'; inherits: true; initial-value: #888888; }
@property --line  { syntax: '<color>'; inherits: true; initial-value: #2A2A2A; }
@property --link  { syntax: '<color>'; inherits: true; initial-value: #E5223B; }

:root {
  --r3e: cubic-bezier(.16, 1, .3, 1);
  /* The statement face one step down, for the few long quotes (Overheard) */
  --t-statement-long: clamp(32px, 3.4vw, 56px);
}

/* ---------- Tone: shadow to light ---------- */
.tone {
  background-color: var(--bg);
  color: var(--ink);
  transition: --bg 900ms cubic-bezier(.4, 0, .2, 1), --ink 900ms cubic-bezier(.4, 0, .2, 1),
              --ink-2 900ms cubic-bezier(.4, 0, .2, 1), --line 900ms cubic-bezier(.4, 0, .2, 1),
              --link 900ms cubic-bezier(.4, 0, .2, 1);
}
.tone[data-tone="dark"], .tone[data-tone="dusk"], .ov {
  --ink: var(--p-white); --ink-2: var(--p-gray-light); --line: var(--p-gray);
  --link: var(--p-red); --link-from: var(--p-blue);
  --lnk-c: var(--p-red); --lnk-w: #FFFFFF;
}
.tone[data-tone="dark"] { --bg: var(--p-black); }
.tone[data-tone="dusk"] { --bg: var(--p-dark); }
.tone[data-tone="dawn"], .tone[data-tone="light"] {
  --ink: var(--p-black); --ink-2: rgb(14 14 14 / .64); --line: rgb(14 14 14 / .14);
  --link: var(--p-blue); --link-from: var(--p-red);
  --lnk-c: var(--p-blue); --lnk-w: #0E0E0E;
}
.tone[data-tone="dawn"]  { --bg: var(--p-white); }
.tone[data-tone="light"] { --bg: #FFFFFF; }

/* One Sections gap between two sections: the tone carries the change of subject, not a surface edge */
.tone .sec + .sec { padding-top: 0; }

/* Browser surfaces take the palette */
.tone ::selection { background: var(--p-red); color: #FFFFFF; }
.tone input, .tone textarea { caret-color: var(--p-red); }

/* ---------- Images (law 8): five ratios, square corners, cropped with intent ----------
   --op sets the crop; --op-wide overrides it from 744 up, where the frame changes shape. */
picture { display: contents; }
/* A picture is display: contents, so its img is the grid item: it spans the row like any other child.
   :where keeps this at the weight of a bare img, so a width or layout class on the img still wins. */
:where(.grid > picture) > img { grid-column: 1 / -1; min-width: 0; }
.fig { display: block; width: 100%; height: auto; object-fit: cover; object-position: var(--op, 50% 50%); }
.r-21x9 { aspect-ratio: 16 / 9; }
.r-16x9 { aspect-ratio: 16 / 9; }
.r-3x2  { aspect-ratio: 3 / 2; }
.r-4x5  { aspect-ratio: 4 / 5; }
.r-1x1  { aspect-ratio: 1 / 1; }
@media (min-width: 744px) {
  .r-21x9 { aspect-ratio: 21 / 9; }
  .fig, .ov .cov { object-position: var(--op-wide, var(--op, 50% 50%)); }
}
figure > figcaption {
  margin-top: var(--gap-bound);
  font-size: var(--t-small); line-height: 1.35; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* A full-bleed photograph joined to the hero above it: Blocks between them */
.bleed { display: block; }
.sec:has(+ .bleed) { padding-bottom: var(--gap-blocks); }

/* ---------- Full-bleed overlays (hero, Q4). Type sits on the photo's own dark area, no scrim. ---------- */
.ov { position: relative; overflow: hidden; isolation: isolate; color: var(--p-white); background: var(--p-black); }
.ov .cov { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: var(--op, 50% 50%); }
.ov > .grid { position: relative; }

/* Type over image (12.1): 4:5 on a phone, 21:9 from 744; the frame grows if the type needs more room */
.hero-ov {
  display: flex; flex-direction: column; justify-content: flex-end;
  aspect-ratio: 4 / 5;
  padding-top: calc(2 * var(--grid-margin) + 44px);
  padding-bottom: var(--gap-blocks);
}
.hero-ov > .grid { width: 100%; }
@media (min-width: 744px) { .hero-ov { aspect-ratio: 21 / 9; } }

/* Q4, a quote over a photograph: the photo rests at the foot of the frame, the quote on its clean dark top */
.q4 { display: grid; }
.q4 .cov { position: relative; inset: auto; grid-area: 1 / 1; align-self: end; height: auto; aspect-ratio: 3 / 2; mix-blend-mode: lighten; object-position: 50% 0; }
.q4 > .grid { grid-area: 1 / 1; align-self: start; padding-top: var(--gap-sections); padding-bottom: 48%; width: 100%; }

/* ---------- Layouts from the book ---------- */
.gap-blocks { margin-top: var(--gap-blocks); }

/* The one centered beat: a statement, a quote */
.ctr { text-align: center; }
.ctr .t-statement, .ctr .t-body, .ctr blockquote, .t-statement.ctr { margin-inline: auto; }

/* Media + text (12.5): image 6 cols, text 5 from col 8; mirrored puts the image right. Stacks image first.
   Sticky holds the image while the reading goes by. */
.grid.media { row-gap: var(--gap-blocks); align-items: center; }
@media (min-width: 744px) and (max-width: 1199px) {
  .media__img:has(.r-4x5), .media__text { grid-column: 1 / span 6; }
}
@media (min-width: 1200px) {
  .media__img  { grid-column: 1 / span 6; grid-row: 1; }
  .media__text { grid-column: 8 / span 5; grid-row: 1; }
  .media--mirror .media__img  { grid-column: 7 / span 6; }
  .media--mirror .media__text { grid-column: 1 / span 5; }
  .grid.media--sticky { align-items: start; }
  .media--sticky .media__img { position: sticky; top: calc(2 * var(--grid-margin) + var(--mark, 34px)); }
  /* Law 2: a head beside its reading sits one step under display-2, so it stays inside its columns */
  .media__text .t-display-2 { font-size: clamp(32px, 3.4vw, 56px); }
}

/* Sticky split (L6): the head holds while the body scrolls past */
@media (min-width: 744px) and (max-width: 1199px) {
  .split--sticky > .split__head:has(.r-4x5) { grid-column: 1 / span 6; }
}
@media (min-width: 1200px) {
  .grid.split--sticky { align-items: start; }
  .split--sticky > .split__head { position: sticky; top: calc(2 * var(--grid-margin) + var(--mark, 34px)); }
}

/* Gallery, wide + narrow pair (12.10): 8 + 4 cols, 5 + 3 on a tablet, same height. The narrow photo
   fills the height the wide one sets. Stacks on a phone, where the narrow one stands at 4:5. */
.gals > * + * { margin-top: var(--gap-siblings); }
.gal { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap-siblings) var(--grid-gutter); }
.gal > figure { display: flex; flex-direction: column; min-width: 0; }
.gal__frame { position: relative; }
@media (min-width: 744px) {
  .gal--pair { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .gal__wide   { grid-column: span 5; }
  .gal__narrow { grid-column: span 3; }
  .gal__narrow .gal__frame { flex: 1; }
  .gal__narrow .fig { position: absolute; inset: 0; height: 100%; aspect-ratio: auto; }
}
@media (min-width: 1200px) {
  .gal--pair { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .gal__wide   { grid-column: span 8; }
  .gal__narrow { grid-column: span 4; }
}

/* The method: rows of marks (Lottie), each with its name and its line. Five rows, so a rule between them. */
.marks > li {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); column-gap: var(--space-lg); row-gap: var(--gap-bound);
  align-items: center; padding-block: calc(var(--gap-siblings) / 2); border-top: 1px solid var(--line);
}
.marks > li:first-child { border-top: 0; padding-top: 0; }
.marks > li:last-child { padding-bottom: 0; }
.marks .lot { display: block; width: 64px; height: 64px; grid-row: span 2; cursor: pointer; }
.marks .lot svg { width: 100% !important; height: 100% !important; }
.marks p { color: var(--ink-2); line-height: 1.35; }
@media (min-width: 744px) {
  .marks > li { grid-template-columns: 88px minmax(0, 4fr) minmax(0, 7fr); column-gap: var(--grid-gutter); }
  .marks .lot { width: 88px; height: 88px; grid-row: auto; }
}

/* Overheard: one line owns the screen at a time. Natural height on a phone, a band from 744. */
.t-statement.long { font-size: var(--t-statement-long); }
.oh > li + li { margin-top: var(--gap-sections); }
@media (min-width: 744px) {
  .sec.oh-sec { padding-top: 0; padding-bottom: 0; }
  .oh > li { min-height: 80vh; min-height: 80svh; display: flex; align-items: center; }
  .oh > li + li { margin-top: 0; }
}

/* ---------- Motion. Every start state hangs on html.mo. ---------- */
/* Headlines and statements mist in once */
.mist { transition: opacity 900ms var(--r3e), filter 900ms var(--r3e), transform 900ms var(--r3e); }
.mo .mist:not(.in) { opacity: 0; filter: blur(10px); transform: translateY(16px); }

/* IM2: black and white to color */
.im2 { transition: filter 900ms cubic-bezier(.4, 0, .2, 1); }
.mo .im2:not(.in) { filter: grayscale(1); }

/* ---------- IX8c Name lights: the names breathe red, a tap lights one and opens it ---------- */
.vals > li { border-top: 1px solid var(--line); }
.vals > li:last-child { border-bottom: 1px solid var(--line); }
.vals .v-t { font-weight: 900; letter-spacing: .04em; }
.vals .vbtn {
  display: block; width: 100%; padding: var(--gap-grouped) 0;
  background: none; border: 0; border-radius: 0; color: inherit;
  font: inherit; letter-spacing: inherit; text-transform: inherit; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nl {
  position: relative; display: block; isolation: isolate;
  color: transparent; -webkit-text-stroke: .8px var(--ink); letter-spacing: inherit;
}
@media (max-width: 743px) { .nl { -webkit-text-stroke-width: .5px; } }
.nlg { position: absolute; inset: 0; z-index: -1; pointer-events: none; -webkit-text-stroke: 0; transition: opacity 300ms cubic-bezier(.4, 0, .2, 1); }
.nlgi {
  display: block; color: var(--bg); opacity: .25;
  filter: drop-shadow(0 0 6px var(--nl-c, #E5223B)) drop-shadow(0 0 18px var(--nl-c, #E5223B));
  animation: nlb 3.6s ease-in-out infinite;
}
@keyframes nlb { 0%, 100% { opacity: .25; } 50% { opacity: .85; } }
.vals > li:nth-child(6n+2) .nlgi { animation-delay: -.7s; }
.vals > li:nth-child(6n+3) .nlgi { animation-delay: -1.5s; }
.vals > li:nth-child(6n+4) .nlgi { animation-delay: -2.2s; }
.vals > li:nth-child(6n+5) .nlgi { animation-delay: -2.9s; }
.vals > li:nth-child(6n+6) .nlgi { animation-delay: -3.3s; }
/* The fill: the name lit in ink, left to right. Its text is the name again, so it stays out of the
   accessible name where the browser takes alt text for generated content. */
.nl::after {
  content: attr(data-t);
  content: attr(data-t) / "";
  position: absolute; inset: 0; color: var(--ink); -webkit-text-stroke: 0;
  clip-path: inset(0 100% 0 0); transition: clip-path 700ms var(--r3e);
}
.open .nl::after { clip-path: inset(0 0 0 0); }
.open .nlg { opacity: 0; }
/* The panel drops open underneath. Closed only once book.js runs, so without it every panel shows. */
.vals.is-on .vp { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows 500ms var(--r3e), visibility 0s linear 500ms; }
.vals.is-on .open .vp { grid-template-rows: 1fr; visibility: visible; transition: grid-template-rows 500ms var(--r3e), visibility 0s linear 0s; }
.vpi { min-height: 0; overflow: hidden; }
.vals .vpi > * + * { margin-top: var(--gap-grouped); }
.vals .vpi > :last-child { padding-bottom: var(--gap-grouped); }
.vals .vpi p { max-width: 65ch; color: var(--ink-2); }
.vals .vpi p:has(> a:only-child) { color: inherit; }
/* A client's mark in the open panel, and the shot when there is one: the black knockout, in a fixed box
   so every mark sits at one weight. On dark it turns white. */
.vp-in { display: flex; flex-direction: column; align-items: flex-start; gap: var(--gap-grouped); }
.vp-mark { display: block; flex: none; width: 160px; height: 80px; }
.vp-mark img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: left center; transition: filter 900ms cubic-bezier(.4, 0, .2, 1); }
.tone:is([data-tone="dark"], [data-tone="dusk"]) .vp-mark img { filter: invert(1); }
.vp-shot { max-width: 100%; }
@media (min-width: 744px) { .vp-shot { width: calc(6 / 8 * 100%); } }
@media (min-width: 1200px) { .vp-mark { width: 200px; height: 96px; } .vp-shot { width: calc(8 / 12 * 100%); } }

@media (prefers-reduced-motion: reduce) {
  .nlgi { opacity: .55; }
}
