/* Cava Reader — cavareader.app
   One page and a policy. Material 3, using the app's own token values read out
   of ui/theme/Palette.kt and Theme.kt, the app's own typefaces, and the app's
   own Lucide icon set. The gallery is progressively enhanced with JavaScript.
*/

/* --- 1. Typefaces: the app's own, subset by tools/build_site_fonts.py ------ */

@font-face {
  font-family: "YoungSerif";
  src: url("/fonts/youngserif.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Jakarta";
  src: url("/fonts/jakarta-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Jakarta";
  src: url("/fonts/jakarta-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Jakarta";
  src: url("/fonts/jakarta-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Jakarta";
  src: url("/fonts/jakarta-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --- 2. Tokens: verbatim from the app's Palette.kt and Theme.kt ------------ */

:root {
  /* Light: the mark's cream page, lifted to a paper. */
  --surface: #FBF7EE;
  --surface-container: #F5F0E4;
  --surface-container-high: #EFE9DC;
  --surface-container-highest: #E9E2D1;
  --surface-dim: #E9E2D1;
  --on-surface: #221A17;
  --on-surface-variant: #524640;
  --outline: #85776D;
  --outline-variant: #E0D8C8;

  /* Text that is quieter than --on-surface-variant but still has to be read. --outline is a
     3:1 hairline colour and measures 4.04:1 on the paper, so it draws rules and nothing else;
     this is the same brown at 6.06:1, for small print and the classics' fact labels. */
  --on-surface-quiet: #6B5B52;

  /* Ember, the brand accent. */
  --primary: #B4501E;
  --on-primary: #FFFFFF;
  --primary-container: #FFDCC2;
  --on-primary-container: #4A2000;
  --secondary: #7C3A5E;
  --secondary-container: #F5D9EA;
  --on-secondary-container: #33102A;

  /* Radii: the app's SOFT corner scale, from Tokens.kt. */
  --radius-sm: 9px;
  --radius-md: 15px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --radius-full: 999px;

  /* Type. YoungSerif for display and the lockup, Jakarta for everything else. */
  --display: "YoungSerif", Georgia, serif;
  --interface: "Jakarta", system-ui, sans-serif;
  --prose: "Jakarta", system-ui, sans-serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark: the logo plate itself, plum-black. */
    --surface: #180A12;
    --surface-container: #241421;
    --surface-container-high: #2E1D2B;
    --surface-container-highest: #392636;
    --surface-dim: #100608;
    --on-surface: #EDE3E6;
    --on-surface-variant: #CDBAC2;
    --outline: #947C89;
    --outline-variant: #4B3344;
    --on-surface-quiet: #A9919E;

    --primary: #FFB592;
    --on-primary: #552000;
    --primary-container: #773309;
    --on-primary-container: #FFDCC2;
    --secondary: #E5B4D3;
    --secondary-container: #5D2E50;
    --on-secondary-container: #F7DCEF;

    color-scheme: dark;
  }
}

/* --- 3. Base --------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--interface);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.12;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.4rem, 1.5rem + 4vw, 4rem);
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.4rem, 1.1rem + 1.5vw, 1.9rem);
  letter-spacing: -0.012em;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
}

svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.wrap {
  max-width: 960px;
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 32px);
}

/* The one icon class: currentColor stroke, sized by its parent. */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- 4. Header and footer -------------------------------------------------- */

.top {
  padding-block: 18px 20px;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--on-surface);
  font-family: var(--display);
  font-size: 1.45rem;
  line-height: 1;
}

.brand svg {
  width: 56px;
  height: 56px;
}

.top-link {
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--on-surface-variant);
  padding: 10px 16px;
  border-radius: var(--radius-full);
}

.top-link:hover {
  background: var(--surface-container);
  color: var(--on-surface);
}

.foot {
  margin-top: clamp(72px, 11vw, 128px);
  padding-block: 28px 40px;
  border-top: 1px solid var(--outline-variant);
}

.foot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--on-surface-variant);
  font-size: 0.9rem;
}

.foot-name {
  font-family: var(--interface);
  font-size: 0.9rem;
  color: var(--on-surface-variant);
}

.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.foot nav a {
  text-decoration: none;
  color: var(--on-surface-variant);
  padding: 8px 12px;
  border-radius: var(--radius-full);
}

.foot nav a:hover {
  background: var(--surface-container);
  color: var(--on-surface);
}

/* --- 5. Buttons: M3 filled and outlined ------------------------------------ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-family: var(--interface);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button .icon {
  width: 18px;
  height: 18px;
}

/* Filled: primary on primary. */
.button.filled {
  background: var(--primary);
  color: var(--on-primary);
}

/* Outlined: the second action on a filled container, so it uses the
   container's own on-colour for text and a rule of the accent for the border. */
.button.outlined {
  background: transparent;
  color: var(--on-primary-container);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
}

.button.outlined:hover {
  background: color-mix(in srgb, var(--on-primary-container) 6%, transparent);
  filter: none;
}

.button:hover {
  filter: brightness(0.96);
}

.button:active {
  transform: scale(0.98);
}

@media (max-width: 560px) {
  .button {
    flex: 1 1 100%;
  }
}

/* --- 6. The hero: an M3 container with the app's own large radius ---------- */

.hero {
  padding-top: clamp(8px, 2vw, 20px);
}

.hero-box {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--outline-variant));
  border-radius: var(--radius-xl);
  padding: clamp(32px, 5vw, 56px) clamp(24px, 4vw, 48px);
}

.lede {
  margin-top: 20px;
  font-family: var(--prose);
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.2rem);
  line-height: 1.65;
  max-width: 46ch;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.fine {
  margin-top: 20px;
  font-size: 0.85rem;
  line-height: 1.55;
  max-width: 52ch;
  color: var(--on-surface-variant);
}

/* --- 7. Free / Full: M3 outlined cards, side by side ----------------------- */

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: clamp(56px, 8vw, 96px);
}

@media (max-width: 720px) {
  .split {
    grid-template-columns: 1fr;
  }
}

.card {
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 3.5vw, 36px);
  background: var(--surface);
}

.card.paid {
  background: var(--primary-container);
  border-color: color-mix(in srgb, var(--primary) 24%, var(--outline-variant));
  color: var(--on-primary-container);
}

.card h2 {
  font-family: var(--interface);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}

.card.paid h2 {
  /* 80%, not 70%: at 70 this label measured 4.38:1 on the card's own dark tint, just under
     AA for small text, and it is a small uppercase label, which is exactly the case AA
     protects. 80% clears it at 5.22:1 without the label going loud. */
  color: color-mix(in srgb, var(--on-primary-container) 80%, var(--primary-container));
}

.card ul {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.card li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 0.98rem;
  line-height: 1.5;
}

.card li .icon {
  width: 17px;
  height: 17px;
  flex: none;
  align-self: center;
  color: var(--primary);
}

.card .button {
  margin-top: 28px;
}

/* Two ways to buy, side by side: the shipped .button, in exactly the split
   rocker the media controls next door use. Big radius on the outside, 8px on
   the facing corners, 4px between them, second half mirrored. Same shape
   language as the arrow keys, so it reads as one control rather than two. */
.pay-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 28px;
}

.pay-split .button {
  margin-top: 0;
  padding-inline: 12px;
  text-align: center;
  border-radius: var(--radius-lg) 8px 8px var(--radius-lg);
}

/* The right half mirrors the left, exactly as the second arrow does. */
.pay-split .button + .button {
  border-radius: 8px var(--radius-lg) var(--radius-lg) 8px;
}

/* The outlined half sits on the card's own tint, so its rule is the accent. */
.pay-split .button.outlined {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
}

/* 420px rather than 380px: "Pay with Monero" is longer than "Buy with card" and wraps to
   two lines in a half-width button on a 390px phone, which reads as a mistake. Below this
   width the pair stacks, where there is no facing corner to crop and both go back to full
   pills. */
@media (max-width: 420px) {
  .pay-split {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .pay-split .button,
  .pay-split .button + .button {
    border-radius: var(--radius-full);
  }
}

.card .fine {
  margin-top: 16px;
}

/* Small print on a primary-container says itself in the container's own ink,
   wherever that container is: the hero and the Full card are the same tint. */
.card.paid .fine,
.hero-box .fine {
  color: color-mix(in srgb, var(--on-primary-container) 75%, var(--primary-container));
}

/* --- 8. Privacy note -------------------------------------------------------- */

.privacy {
  margin-top: clamp(56px, 8vw, 96px);
  max-width: 62ch;
}

.privacy p {
  font-family: var(--prose);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--on-surface-variant);
}

.policy-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.policy-link:hover {
  text-decoration: underline;
}

.policy-link .icon {
  width: 15px;
  height: 15px;
}

/* --- 9. The privacy policy page --------------------------------------------- */

.article {
  padding-top: clamp(24px, 4vw, 40px);
  max-width: 760px;
}

.article h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.5vw, 1.9rem);
}

.article h2 {
  margin-top: 48px;
  font-family: var(--interface);
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  color: var(--on-surface);
}

.article h3 {
  margin: 28px 0 0;
  font-family: var(--interface);
  font-size: 1.02rem;
  font-weight: 650;
}

.article p,
.article ul {
  margin-top: 14px;
}

.article ul {
  padding-left: 22px;
}

.article li {
  margin-top: 6px;
}

.article p,
.article li {
  font-family: var(--prose);
  font-size: 1rem;
  line-height: 1.65;
}

.article a {
  color: var(--primary);
}

.table-scroll {
  overflow-x: auto;
  margin-top: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--outline-variant);
}

.article table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
  text-align: left;
  font-family: var(--interface);
}

.article th,
.article td {
  padding: 10px 12px;
  border: 1px solid var(--outline-variant);
  vertical-align: top;
}

.article th {
  background: var(--surface-container);
  font-weight: 650;
}

/* --- 10. The /get redirect -------------------------------------------------- */

.redirect {
  padding-top: 20vh;
  text-align: center;
}

.redirect a {
  color: var(--primary);
  font-weight: 600;
}

/* --- 11. Media: an unframed M3 browse strip, not a single-slide panel ------ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.gallery {
  --media-height: min(320px, calc((100vw - 2 * clamp(20px, 5vw, 32px)) * 9 / 16));
  container-type: inline-size;
  margin-top: 16px;
}

.media-strip {
  display: flex;
  gap: 16px;
  align-items: center;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 4px;
  scrollbar-width: none;
  padding: 0 4px;
  margin-inline: -4px;
  border-radius: var(--radius-xl);
  -webkit-overflow-scrolling: touch;
}

.media-strip::-webkit-scrollbar { display: none; }

.media-card {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: calc(var(--media-height) * 412 / 732);
  height: var(--media-height);
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface-container-high);
  scroll-snap-align: start;
  -webkit-user-drag: none;
  user-select: none;
  cursor: zoom-in;
  /* Insets move with scrolling, so the exposed edge is always rounded instead
     of slicing a card through its square middle. Content is masked, not scaled. */
  clip-path: inset(0 var(--mask-end, 0px) 0 var(--mask-start, 0px)
    round var(--mask-radius, var(--radius-lg)));
}

.media-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
  transition: filter 160ms ease;
}

.media-card:hover img { filter: brightness(1.06); }
.media-card:focus-visible { outline: none; }
.media-card:focus-visible::after {
  content: "";
  position: absolute;
  inset: 0 var(--mask-end, 0px) 0 var(--mask-start, 0px);
  border: 3px solid var(--primary);
  border-radius: var(--mask-radius, var(--radius-lg));
  pointer-events: none;
}
.media-strip:focus-visible { outline-offset: 2px; border-radius: var(--radius-xl); }

.media-trailer {
  width: calc(var(--media-height) * 16 / 9);
  height: var(--media-height);
  background: #552330;
  cursor: pointer;
}

.media-trailer img { object-fit: contain; }

.media-play {
  position: absolute;
  inset: 0;
  margin: auto;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: var(--primary-container);
  color: var(--on-primary-container);
  box-shadow: 0 2px 12px #0003;
  transform: translateX(var(--play-offset, 0px));
  transition: background 160ms ease;
}

.media-play .icon { width: 26px; height: 26px; margin-left: 3px; }
.media-trailer:hover .media-play { background: color-mix(in srgb, var(--on-primary-container) 5%, var(--primary-container)); }

.strip-controls {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 16px;
}

.media-control {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface-container-high);
  color: var(--on-surface);
  cursor: pointer;
  transition: background 160ms ease, border-radius 160ms ease;
}

.media-control .icon { width: 22px; height: 22px; }
.media-control:hover { background: var(--surface-container-highest); }
.media-control:active { border-radius: var(--radius-md); }
.media-control:focus-visible { border-radius: var(--radius-full); }
.media-control[aria-disabled="true"] { opacity: .38; cursor: default; }
.media-control[aria-disabled="true"]:hover { background: var(--surface-container-high); }

/* A compact split rocker: two cropped-soft shapes, like the media masks.
   Hover carries the arrow forward without changing the button's silhouette. */
.gallery + .split { margin-top: 16px; }
.strip-controls .media-control,
.viewer-controls .media-control {
  width: 72px;
  border-radius: var(--radius-lg) 8px 8px var(--radius-lg);
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}
.strip-controls .media-control + .media-control,
.viewer-controls .media-control + .media-control {
  border-radius: 8px var(--radius-lg) var(--radius-lg) 8px;
}
.strip-controls .media-control:hover,
.viewer-controls .media-control:hover {
  background: color-mix(in srgb, var(--on-secondary-container) 8%, var(--secondary-container));
}
.strip-controls .media-control[aria-disabled="true"] {
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
}
.strip-controls .icon,
.viewer-controls .icon { width: 28px; transition: transform 160ms cubic-bezier(.2, 0, 0, 1); }
.strip-controls .media-control:first-child:hover:not([aria-disabled="true"]) .icon,
.viewer-controls .media-control:first-child:hover .icon { transform: translateX(-3px); }
.strip-controls .media-control:last-child:hover:not([aria-disabled="true"]) .icon,
.viewer-controls .media-control:last-child:hover .icon { transform: translateX(3px); }
#viewer-close { border-radius: var(--radius-md); }

/* No mouse drag behavior: touch scrolling and horizontal wheel remain native. */

@media (max-width: 560px) {
  .gallery { --media-height: min(264px, calc((100vw - 2 * clamp(20px, 5vw, 32px)) * 9 / 16)); }
  .media-trailer { width: calc(var(--media-height) * 16 / 9); }
  .media-play { width: 56px; height: 56px; }
}

/* Container width, not assumed phone dimensions: the entire trailer fits,
   and portrait cards shrink with it while retaining the shared row height. */
@supports (width: 1cqw) {
  .gallery { --media-height: min(320px, 56.25cqw); }
  @media (max-width: 560px) {
    .gallery { --media-height: min(264px, 56.25cqw); }
  }
}
@media (hover: none) {
  .media-card:hover img { filter: none; }
}

/* --- 12. Large view: only the media and three essential controls ---------- */

html:has(.media-viewer[open]) { overflow: hidden; }

.media-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0 clamp(16px, 4vw, 56px);
  border: 0;
  background: var(--surface);
  color: var(--on-surface);
  overflow: hidden;
}

.media-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.media-viewer::backdrop { background: transparent; }

.viewer-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding-top: env(safe-area-inset-top, 0px);
}

#viewer-title { font-size: .875rem; color: var(--on-surface-variant); }

/* Native touch scrolling: slides follow the finger and snap without wrapping.
   Programmatic arrows use the same rail, so incoming media arrives sideways. */
.viewer-stage {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x pinch-zoom;
}
.viewer-stage::-webkit-scrollbar { display: none; }
.viewer-page {
  flex: 0 0 100%;
  display: grid;
  place-items: center;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  container-type: size;
}
/* aria-hidden is semantic only; it must not interfere with a reversing swipe. */
.viewer-stage.is-zoomed { overflow-x: hidden; touch-action: pan-x pan-y pinch-zoom; }
.viewer-page.is-zoomed { display: block; overflow: auto; overscroll-behavior: contain; }

.viewer-image {
  position: relative;
  display: block;
  width: auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  height: min(100%, calc((100vw - 2 * clamp(16px, 4vw, 56px)) * 732 / 412));
  aspect-ratio: 412 / 732;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: zoom-in;
  touch-action: pan-x pinch-zoom;
}

.viewer-image img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-width: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
}

/* The decoded detail image overlays the preview; no blank frame on upgrade. */
.viewer-detail { position: absolute; inset: 0; pointer-events: none; }

.viewer-page.is-zoomed .viewer-image { touch-action: pan-x pan-y pinch-zoom; }
.viewer-page.is-zoomed .viewer-image { width: 824px; max-width: none; height: auto; margin: auto; cursor: zoom-out; }
.viewer-page.is-zoomed img { width: 824px; max-width: none; height: auto; border-radius: 0; }

/* Only compositor-friendly opacity/transform; no layout animation. */
.media-viewer.is-opening { animation: viewer-enter 180ms cubic-bezier(.2, 0, 0, 1) both; }
.media-viewer.is-closing { animation: viewer-leave 140ms cubic-bezier(.4, 0, 1, 1) both; pointer-events: none; }
.media-viewer.is-opening .viewer-stage { animation: media-enter 180ms cubic-bezier(.2, 0, 0, 1) both; }
.media-viewer.is-closing .viewer-stage { animation: media-leave 140ms cubic-bezier(.4, 0, 1, 1) both; }
@keyframes viewer-enter { from { opacity: 0; } to { opacity: 1; } }
@keyframes viewer-leave { from { opacity: 1; } to { opacity: 0; } }
@keyframes media-enter { from { transform: scale(.975); } to { transform: scale(1); } }
@keyframes media-leave { from { transform: scale(1); } to { transform: scale(.975); } }

.viewer-video {
  width: min(100%, 1120px, calc((100dvh - 192px) * 16 / 9));
  width: min(100%, 1120px, calc(100cqh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-lg);
  position: relative;
  background: #552330;
}

.viewer-video .video-placeholder { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewer-video iframe { position: relative; display: block; width: 100%; height: 100%; border: 0; opacity: 0; }
.viewer-video.is-ready iframe { opacity: 1; }

.viewer-controls {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding-block: 12px max(16px, env(safe-area-inset-bottom, 0px));
}

/* Stationary touch targets; the marks themselves morph with fractional scroll
   position, not a delayed selected-state transition. */
.viewer-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 8px;
}
.viewer-dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  cursor: pointer;
}
.viewer-dot-mark {
  position: relative;
  display: block;
  width: 24px;
  height: 6px;
  background: var(--outline);
  clip-path: inset(0 var(--dot-inset, 9px) round 3px);
  pointer-events: none;
}
.viewer-dot-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--primary);
  opacity: var(--dot-weight, 0);
}
.viewer-dot:focus-visible { border-radius: var(--radius-full); }
.viewer-controls { padding-top: 4px; }

/* An HTML hidden attribute must always beat component display declarations. */
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .media-control, .media-play { border: 1px solid ButtonText; }
  .media-card { border: 1px solid CanvasText; }
  .viewer-dot-mark, .viewer-dot-mark::after { background: ButtonText; }
  .media-control[aria-disabled="true"] { color: GrayText; opacity: 1; }
}

/* --- 12. The Full card's price line ---------------------------------------- */

/* The Play star rating, inside the Google Play button, after the label: "★ 4.7".

   Hidden until known. The number is read from the Play listing at runtime and the app has no
   ratings yet, so today the button reads exactly as it always has; the chip appears the day
   the first review lands. No zero state, no placeholder five.

   Inside the button rather than under it or floating in the hero's corner: it is the Play
   Store's own figure, the button is the Play Store, and putting it anywhere else made it read
   as a separate claim about the app. No rule, no second colour, no smaller type: it inherits
   the button's own font so the whole label reads as one line. */
/* One text row: use the same line-height for the label and digits.
   The outer button gap separates the download icon from this row only. */
.button .play-label {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.button .rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 7px;
  font: inherit;
  line-height: inherit;
}

.button .rating[hidden] { display: none; }
.button .rating .score { font: inherit; line-height: inherit; }
.button .rating .star {
  width: 1.05em;
  height: 1.05em;
  margin: 0;
  flex: none;
}

/* One price, in one place. The card says what the edition costs and what that covers; the
   fine print underneath carries the two caveats (tax, and Play's own local pricing) so the
   loud line stays one line. Reading as a unit: the number, then what it buys. */
.price {
  margin-top: 18px;
  font-family: var(--interface);
  font-size: 1.05rem;
  font-weight: 600;
  color: inherit;
}

.price .price-note {
  font-weight: 500;
  font-size: 0.9rem;
  color: color-mix(in srgb, var(--on-primary-container) 75%, var(--primary-container));
}

/* --- 13. The homepage's own answers ---------------------------------------- */

/* Native <details>, so the page is one line per question until someone opens one, and the
   content is real text in the document either way. Nothing here hides content that the
   page wants a search engine to read: a closed <details> holds its children in the DOM and
   in the accessibility tree, and the summary is what a reader (and a crawler) sees first. */
.answers {
  margin-top: clamp(56px, 8vw, 96px);
  max-width: 68ch;
}

/* The section label needs its own space above and below: it is a quiet heading over a list
   of rules, and without the bottom margin the first <summary>'s border-top sat right under
   the text as if it were underlining it. The margin is on the heading rather than on the
   first details so it survives the list being reordered. */
.answers h2 {
  margin: 0 0 clamp(16px, 2.5vw, 24px);
  font-family: var(--interface);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}

.answers details {
  border-top: 1px solid var(--outline-variant);
}

.answers details:last-of-type {
  border-bottom: 1px solid var(--outline-variant);
}

.answers summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 4px;
  cursor: pointer;
  list-style: none;
  font-family: var(--interface);
  font-size: 1.02rem;
  font-weight: 550;
  color: var(--on-surface);
  border-radius: var(--radius-sm);
}

/* The disclosure marker, drawn rather than inherited, so it matches the site's
   line weight and sits on the baseline of the question. */
.answers summary::-webkit-details-marker {
  display: none;
}

.answers summary::after {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 0.35em;
  border-right: 2px solid var(--outline);
  border-bottom: 2px solid var(--outline);
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.18s ease;
}

.answers details[open] summary::after {
  transform: rotate(-135deg) translateY(-1px);
}

.answers summary:hover {
  color: var(--primary);
}

.answers summary:hover::after {
  border-color: var(--primary);
}

/* Open: the answer comes down and fades in rather than appearing. `@starting-style` is the
   modern way to give a newly-rendered element an initial state to animate from, and
   `interpolate-size` lets the height be animated at all — without it `height: auto` is not
   animatable and the panel would just pop open. Browsers without either get the instant
   open, which is the same content, unanimated: this is the enhancement, not the mechanism. */
.answers .answer {
  padding: 0 4px 22px;
  color: var(--on-surface-variant);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.answers details[open] .answer {
  opacity: 1;
  transform: none;
}

/* A closed <details> does not render its content at all, so opening it produces a *newly
   rendered* element: it has no previous opacity to animate from, and without this block the
   panel appears at full opacity and only the height moves. `@starting-style` is exactly the
   rule for that case. */
@starting-style {
  .answers details[open] .answer {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@supports (interpolate-size: allow-keywords) {
  :root {
    interpolate-size: allow-keywords;
  }

  /* The height itself is animated, so the rows below slide down with the answer instead of
     jumping to it. 0fr -> 1fr would be the grid trick, but this element is already a plain
     block of prose and changing its display would change how its margins collapse. */
  .answers details::details-content {
    height: 0;
    overflow: hidden;
    transition: height 0.22s ease, content-visibility 0.22s ease allow-discrete;
  }

  .answers details[open]::details-content {
    height: auto;
  }

  @starting-style {
    .answers details[open]::details-content {
      height: 0;
    }
  }
}

.answers .answer p {
  font-family: var(--prose);
  font-size: 0.98rem;
  line-height: 1.65;
  margin-top: 10px;
}

.answers .answer p:first-child {
  margin-top: 0;
}

.answers .answer ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.answers .answer li {
  font-family: var(--prose);
  font-size: 0.98rem;
  line-height: 1.6;
  margin-top: 5px;
}

/* The 37 titles, as plain text in a two-column list on anything wide enough to hold two
   columns of whole titles. No links: the classics library has its own front door in the
   footer, and the homepage body does not compete with it. */
.answers .titles {
  columns: 2;
  column-gap: 28px;
  padding-left: 0;
  list-style: none;
}

.answers .titles li {
  break-inside: avoid;
  margin-top: 6px;
}

.answers .titles .by {
  color: var(--on-surface-quiet);
}

@media (max-width: 560px) {
  .answers .titles {
    columns: 1;
  }
}

/* --- 14. The classics library --------------------------------------------- */

/* One page per book, and an index. Both use the site's own header, footer and type: the
   only new vocabulary is the reading's facts, which are a small definition list, and the
   excerpt, which is set like the policy page's prose so it reads as the book rather than as
   the site talking about the book. */
.classic,
.classics-index {
  padding-top: clamp(16px, 3vw, 32px);
  max-width: 720px;
}

.crumbs {
  font-size: 0.86rem;
  margin-bottom: clamp(20px, 3vw, 28px);
}

.crumbs a {
  color: var(--on-surface-variant);
  text-decoration: none;
  font-weight: 500;
}

.crumbs a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.crumbs a::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 10px;
  border-left: 2px solid var(--outline);
  border-bottom: 2px solid var(--outline);
  transform: rotate(45deg) translateY(-1px);
}

.classic h1,
.classics-index h1 {
  font-size: clamp(2rem, 1.4rem + 2.6vw, 2.9rem);
}

.classic-by {
  margin-top: 10px;
  font-family: var(--interface);
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--on-surface-variant);
}

.classic-note {
  margin-top: 6px;
  font-family: var(--prose);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--on-surface-variant);
}

.classic-pitch {
  margin-top: 26px;
  font-family: var(--display);
  font-size: clamp(1.15rem, 1rem + 1vw, 1.45rem);
  line-height: 1.5;
  text-wrap: pretty;
}

/* The reading's facts: three pairs, on one line where there is room. */
.classic-facts {
  display: grid;
  gap: 14px 28px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 30px 0 0;
  padding: 20px 0;
  border-top: 1px solid var(--outline-variant);
  border-bottom: 1px solid var(--outline-variant);
}

.classic-facts dt {
  font-family: var(--interface);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--on-surface-quiet);
}

.classic-facts dd {
  margin: 5px 0 0;
  font-family: var(--interface);
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--on-surface);
}

.classic-facts a {
  color: var(--primary);
}

.classic-lede {
  margin-top: 28px;
  font-family: var(--prose);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--on-surface-variant);
  max-width: 58ch;
}

.opening {
  margin: 20px 0 0;
  padding-left: clamp(16px, 3vw, 22px);
  border-left: 2px solid var(--outline-variant);
}

.opening p {
  font-family: var(--display);
  font-size: 1.02rem;
  line-height: 1.72;
  text-wrap: pretty;
}

.opening p + p {
  margin-top: 16px;
}

.classic-source {
  margin-top: 14px;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--on-surface-quiet);
}

.classic-source a,
.classic-source a:visited {
  color: var(--on-surface-quiet);
  text-decoration: underline;
}

.classic h2,
.classics-index h2 {
  margin-top: clamp(44px, 6vw, 64px);
  font-family: var(--display);
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.6rem);
  font-weight: 400;
  letter-spacing: normal;
}

.classic-cta p {
  margin-top: 14px;
  font-family: var(--prose);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--on-surface-variant);
  max-width: 58ch;
}

.classic-cta .actions {
  margin-top: 24px;
}

/* The read-along screenshot, shown as one phone-sized card rather than a gallery: this page
   is about the book, and the picture is evidence of the one thing the book does here. */
.classic-shot {
  display: block;
  width: min(240px, 62vw);
  margin-top: 32px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--outline-variant);
  background: var(--surface-container);
}

.classic-shot img {
  display: block;
  width: 100%;
  height: auto;
}

.classic-more ul,
.classics-list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  border-top: 1px solid var(--outline-variant);
}

.classic-more li,
.classics-list li {
  border-bottom: 1px solid var(--outline-variant);
}

.classic-more a,
.classics-list a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 13px 0;
  text-decoration: none;
  color: var(--on-surface);
  font-family: var(--interface);
  font-size: 0.98rem;
  font-weight: 500;
}

.classic-more a span,
.classics-list a span {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--on-surface-variant);
}

.classic-more a:hover,
.classics-list a:hover {
  color: var(--primary);
}

.classic-more a:hover span,
.classics-list a:hover span {
  color: var(--primary);
}

.classics-index .actions {
  margin-top: clamp(36px, 5vw, 52px);
}

/* The one place the classics are shown side by side: the index, and only when the screen
   is wide enough for two columns of whole titles. */
@media (min-width: 720px) {
  .classics-list {
    columns: 2;
    column-gap: 32px;
  }

  .classics-list li {
    break-inside: avoid;
  }

  .classics-list a {
    justify-content: flex-start;
    gap: 6px;
  }

  .classics-list a span {
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .answers summary::after {
    transition: none;
  }

  /* The content transition too, not just the chevron: a reduce-motion reader asking for no
     animation means the panel as well. */
  .answers details::details-content,
  .answers .answer {
    transition: none;
  }

  .answers .answer {
    opacity: 1;
    transform: none;
  }
}

/* Forced colours: the disclosure marker is drawn with borders, so it survives, but the
   hover tint does not, and the summary needs to say what it is. */
@media (forced-colors: active) {
  .answers summary::after {
    border-color: ButtonText;
  }
  .answers details {
    border-color: CanvasText;
  }
}