/* Phase 2 case system. Folder material on the homepage is untouched.
   This file is the shared gate, ending, ink, and dark-surface layer. */

/* While the password is on, the page is the title, a short public brief,
   then the gate. The article body stays in the DOM for unlock. */
.case-fade { display: none; }

body.is-paywalled .case-content {
  max-height: none !important;
  overflow: visible;
  -webkit-mask-image: none !important;
  mask-image: none !important;
}
body.is-paywalled .case-content > :not(.case-header) {
  display: none !important;
}
body.is-paywalled .case-header { margin-bottom: 32px; }
body.is-paywalled .case-cover-video { display: none; }

.case-gate {
  position: relative;
  z-index: 6;
  width: 100%;
  max-width: none;
  margin: 0 0 48px;
}
body:not(.is-paywalled) .case-gate { display: none; }

.case-brief {
  margin: 0 0 28px;
  padding: 0;
  color: var(--text);
}
.case-brief p {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  letter-spacing: 0;
  color: var(--text);
}
.case-brief p.case-brief-kicker {
  margin: 0 0 8px;
  color: var(--text3, #84817c);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1.5;
  text-transform: uppercase;
}
.case-gate .pw-paywall {
  position: relative;
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 0;
  box-sizing: border-box;
}

.pw-lock { color: var(--text3, #8a8680); }
.pw-input:focus { border-color: var(--text); outline: none; }
.pw-input:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.case-end {
  margin: 8px 0 24px;
}
.case-next {
  display: block;
  color: var(--text);
  text-decoration: none;
  border-radius: 12px;
  outline: none;
}
.case-next-kicker {
  display: block;
  margin: 0 0 10px;
  color: var(--text3, #84817c);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1.5;
  text-transform: uppercase;
}
.case-next-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  border-radius: 12px;
  transition: background 180ms cubic-bezier(0.2, 0, 0, 1);
}
.case-next:hover .case-next-row,
.case-next:focus-visible .case-next-row {
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.case-next:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.case-next img {
  width: 72px;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
  flex: 0 0 auto;
  background: var(--bg2, #f4f1ea);
}
.case-next-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.case-next-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.4;
}
.case-next-meta {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text3, #84817c);
}
.case-end-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: baseline;
  margin: 18px 0 0;
  font-size: 13px;
  line-height: 1.6;
}
.case-end-links a {
  color: var(--text);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-underline-offset: 3px;
}
.case-end-links a:hover { text-decoration-color: currentColor; }
.case-end-links a:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.case-end-thanks { color: var(--text2, #55524e); }

/* Cover frames sit on paper, including night. */
.case-cover-video,
.spectrum-preview,
.annotated-phone-frame,
.showcase-video-frame {
  background: var(--bg2, #f3f0ea);
}
[data-theme="dark"] .case-cover-video,
[data-theme="dark"] .spectrum-preview,
[data-theme="dark"] .annotated-phone-frame,
[data-theme="dark"] .showcase-video-frame {
  background: #1c1c1c;
  border-color: rgba(255, 255, 255, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .case-cover-video,
  :root:not([data-theme="light"]) .spectrum-preview,
  :root:not([data-theme="light"]) .annotated-phone-frame,
  :root:not([data-theme="light"]) .showcase-video-frame {
    background: #1c1c1c;
    border-color: rgba(255, 255, 255, 0.08);
  }
}

.case-page picture { display: block; max-width: 100%; }
.annotated-phone-frame picture,
.spectrum-preview picture,
.choose-card-img-wrap picture,
.future-preview-frame picture,
.page-tab-frame picture {
  width: 100%;
  height: 100%;
}

.color-counter-code { overflow-x: auto; }
@media (max-width: 420px) {
  .color-counter-code { font-size: 10px; }
}
.color-primitives-row { grid-template-columns: 28px minmax(0, 1fr) auto; }
.token-flow-scale { overflow-x: auto; }

p.case-h2 { margin-top: 0.83em; }

.success-chip.is-selected {
  background: color-mix(in srgb, var(--text) 14%, transparent);
  color: var(--text);
}

/* Tokyo Transit — same night paper and toolbar as the other cases.
   Type sizes on the page stay as they were. */
.transit-page { background: var(--pg, #fff); color: #555; }
[data-theme="dark"] .transit-page { background: #111; color: #f1efeb; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .transit-page { background: #111; color: #f1efeb; }
}
.transit-page .back-link {
  top: 18px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #111;
  box-shadow: none;
  padding: 7px 8px;
  min-height: 0;
}
[data-theme="dark"] .transit-page .back-link,
:root:not([data-theme="light"]) .transit-page .back-link { color: #f1efeb; }
.transit-page .back-link:hover { background: color-mix(in srgb, currentColor 8%, transparent); box-shadow: none; }
.transit-page .back-link:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.transit-page::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: linear-gradient(180deg, var(--pg, #fff) 0%, transparent 100%);
  pointer-events: none;
  z-index: 9;
  opacity: 0;
  transition: opacity 320ms cubic-bezier(0.2, 0, 0, 1);
}
[data-theme="dark"] .transit-page::after,
:root:not([data-theme="light"]) .transit-page::after {
  background: linear-gradient(180deg, #111 0%, transparent 100%);
}
.transit-page.is-transit-scrolled::after { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .case-next-row,
  .transit-page::after { transition: none; }
}

/* The transit ending sits in a centred footer. Other case endings are left-aligned. */
.transit-page .case-end { text-align: left; }

/* Station editor: a white workshop in the light, the page's night paper after dark.
   Fills override the SVG and the markers the script paints. */
.transit-page {
  --d4-paper: #ffffff;
  --d4-line: #f0f0f0;
  --d4-dot: #e0e0e0;
  --d4-mark: #ffffff;
  --d4-label: #444444;
  --d4-title: #111111;
  --d4-copy: #555555;
  --d4-panel: #1f1f24;
  --d4-panel-line: #333333;
  --d4-panel-shadow: 0 4px 16px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.04);
  --d4-muted: #888888;
  --d4-quiet: #666666;
  --d4-hint: #ffffff;
  --d4-hint-opacity: 0.4;
}
[data-theme="dark"] .transit-page {
  --d4-paper: #1c1c1c;
  --d4-line: rgba(255, 255, 255, 0.08);
  --d4-dot: rgba(241, 239, 235, 0.2);
  --d4-mark: #111111;
  --d4-label: #f1efeb;
  --d4-title: #f1efeb;
  --d4-copy: #c8c4be;
  --d4-panel: #2a2a2e;
  --d4-panel-line: rgba(255, 255, 255, 0.16);
  --d4-panel-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --d4-muted: #c8c4be;
  --d4-quiet: #b7b3ac;
  --d4-hint: #b7b3ac;
  --d4-hint-opacity: 1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .transit-page {
    --d4-paper: #1c1c1c;
    --d4-line: rgba(255, 255, 255, 0.08);
    --d4-dot: rgba(241, 239, 235, 0.2);
    --d4-mark: #111111;
    --d4-label: #f1efeb;
    --d4-title: #f1efeb;
    --d4-copy: #c8c4be;
    --d4-panel: #2a2a2e;
    --d4-panel-line: rgba(255, 255, 255, 0.16);
    --d4-panel-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    --d4-muted: #c8c4be;
    --d4-quiet: #b7b3ac;
    --d4-hint: #b7b3ac;
    --d4-hint-opacity: 1;
  }
}
.transit-page .demo-4 .demo-h { color: var(--d4-title); }
.transit-page .demo-4 .demo-text { color: var(--d4-copy); }
.transit-page .demo-4 .demo-box { background: var(--d4-paper); border-color: var(--d4-line); }
.transit-page #d4-svg > rect:first-of-type { fill: var(--d4-paper); }
.transit-page #d4-grid circle { fill: var(--d4-dot); }
.transit-page .demo-4 .d4-station-halo,
.transit-page .demo-4 .d4-station-marker { fill: var(--d4-mark); }
.transit-page .demo-4 .d4-station-label { fill: var(--d4-label); }
.transit-page .demo-4 .d4-panel {
  background: var(--d4-panel);
  border-color: var(--d4-panel-line);
  box-shadow: var(--d4-panel-shadow);
}
.transit-page .demo-4 .d4p-title span { color: var(--d4-hint); opacity: var(--d4-hint-opacity); }
.transit-page .demo-4 .d4p-label,
.transit-page .demo-4 .d4p-coords,
.transit-page .demo-4 .d4p-step { color: var(--d4-muted); }
.transit-page .demo-4 .d4p-ja,
.transit-page .demo-4 .d4p-empty { color: var(--d4-quiet); }
.transit-page .demo-4 .d4p-toast {
  background: var(--d4-panel);
  border-color: var(--d4-panel-line);
}
