/* Sun/moon morph button + warm letterpress midnight dark theme. */
.theme-picker {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #c6c8bf;
  border-radius: 50%;
  background: transparent;
  color: #42483d;
}

.theme-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-icon > * { transform-origin: 50% 50%; }
.theme-dark { opacity: 0; transform: rotate(-50deg) scale(.92); }
html[data-theme="dark"] .theme-dark { opacity: 1; transform: none; }
html[data-theme="dark"] .theme-light { opacity: 0; transform: rotate(50deg) scale(.92); }

.theme-picker:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .theme-picker:hover { color: var(--blue); border-color: #a0aed7; background-color: #e8ecfa; }
}

@media (prefers-reduced-motion: no-preference) {
  .theme-picker { transition: background-color 150ms, border-color 150ms, color 150ms; }
  .theme-icon { transition: transform 140ms var(--ease-out); }
  .theme-picker:active .theme-icon { transform: scale(.94); }
  html[data-theme-switching] .theme-icon > * {
    transition: transform 260ms var(--ease-out), opacity 200ms ease;
  }
}

/* Midnight background layer fade behind artwork. */
:root { --night-print: linear-gradient(112deg, #293143 1%, #263248 48%, #34435a); }
.ticket-top, #pinned-bar { isolation: isolate; }
.ticket-top::after,
.about-sheet::after,
.pass-stage::after,
#pinned-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0;
}
.ticket-top::after {
  background: radial-gradient(ellipse 46% 87% at 73% 43%, #60749393, transparent 95%), var(--night-print);
}
.about-sheet::after { background: var(--night-print); }
.pass-stage::after { background: radial-gradient(ellipse at 49% 57%, #52637b, #354357 67%, #2d394c); }
#pinned-bar::after { background: linear-gradient(105deg, #28354b, #1f2939); }

html[data-theme="dark"] .ticket-top::after,
html[data-theme="dark"] .about-sheet::after,
html[data-theme="dark"] .pass-stage::after,
html[data-theme="dark"] #pinned-bar::after {
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  html[data-theme-switching] .ticket-top::after,
  html[data-theme-switching] .about-sheet::after,
  html[data-theme-switching] .pass-stage::after,
  html[data-theme-switching] #pinned-bar::after {
    transition: opacity 260ms ease;
  }

  html[data-theme-switching] body,
  html[data-theme-switching] .masthead,
  html[data-theme-switching] .ticket,
  html[data-theme-switching] .ticket-top,
  html[data-theme-switching] .ticket-stub,
  html[data-theme-switching] .about-sheet,
  html[data-theme-switching] .pass-stage,
  html[data-theme-switching] .blue-title,
  html[data-theme-switching] .hero-intro,
  html[data-theme-switching] .ticket-rule,
  html[data-theme-switching] .ticket-rule p,
  html[data-theme-switching] .brand-name,
  html[data-theme-switching] .brand-pass,
  html[data-theme-switching] .annotation,
  html[data-theme-switching] .about-intro,
  html[data-theme-switching] .about-wordmark,
  html[data-theme-switching] .input-shell,
  html[data-theme-switching] .input-shell input,
  html[data-theme-switching] .paste,
  html[data-theme-switching] .submit,
  html[data-theme-switching] .help-link,
  html[data-theme-switching] .announcement-bell,
  html[data-theme-switching] .account-link,
  html[data-theme-switching] #pinned-bar,
  html[data-theme-switching] .post-card,
  html[data-theme-switching] .motion-bar,
  html[data-theme-switching] .message {
    transition: background-color 260ms ease, color 85ms step-end, border-color 260ms ease,
      box-shadow 260ms ease, transform 150ms var(--ease-out);
  }

  html[data-theme-switching] .submit::before,
  html[data-theme-switching] .perforation::before,
  html[data-theme-switching] .perforation::after {
    transition: background-color 260ms ease, border-color 260ms ease;
  }
}

/* Warm Letterpress Ink on Midnight Stock */
html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #10151e;
  --paper: #293346;
  --ink: #f1ede4;
  --muted: #b9c2d1;
  --blue: #acc0ff;
  --orange: #ff9361;
  --stroke: #354052;
  --rule: #53627a;
  --panel: #1c2533;
  --well: #141c28;
  --rim: #4a5970;
  --control: #293546;
  --control-hover: #36455b;
  --action: #455fc6;
  --action-hover: #506acb;
  --action-edge: #637bda;
  --good: #a4dab7;
  --good-stock: #243b34;
  --error: #ffad96;
  --error-stock: #452c2e;
  --flight-stock: #2e3c54;
  --sheet-shadow: 0 3px 0 #263041, 0 16px 29px -18px #03060dbf;
  --ink-stock: var(--night-print);
  --note-paper: linear-gradient(111deg, #303b4e, #293548 65%, #2c394c);
}

html[data-theme="dark"] ::selection { background: #aebeea; color: #182034; }
html[data-theme="dark"] .brand .brand-name,
html[data-theme="dark"] .about-brand .brand-name { color: var(--ink); }
html[data-theme="dark"] .brand-pass,
html[data-theme="dark"] .pin-glyph { color: var(--blue); }
html[data-theme="dark"] .theme-picker,
html[data-theme="dark"] .help-link { color: var(--ink); border-color: var(--rim); }
html[data-theme="dark"] .announcement-bell,
html[data-theme="dark"] .pinned-arrow { color: var(--muted); }

html[data-theme="dark"] .ticket,
html[data-theme="dark"] .about-sheet { border-color: var(--rim); box-shadow: var(--sheet-shadow); }
html[data-theme="dark"] .ticket { background: var(--panel); }
html[data-theme="dark"] .ticket-face::before,
html[data-theme="dark"] .about-sheet::before { mix-blend-mode: soft-light; opacity: .24; }
html[data-theme="dark"] .paper-light { background: radial-gradient(ellipse, #9fb5f32b, transparent 68%); }
html[data-theme="dark"] .halftone { background-image: radial-gradient(circle, #a9bad5 1px, transparent 1.25px); opacity: .44; }
html[data-theme="dark"] .spark-b { background: #b6c4ff; }
html[data-theme="dark"] .orbit::before { border-color: #b9c8ea88; }
html[data-theme="dark"] .hero-kicker { color: var(--muted); }
html[data-theme="dark"] .annotation { color: #c4d2ff; }

html[data-theme="dark"] .ticket-stub { background: #273245; border-color: #78839a; color: #d3d8ee; }
html[data-theme="dark"] .ticket-stub::before { background: var(--action); }
html[data-theme="dark"] .barcode {
  background: repeating-linear-gradient(
    to bottom,
    currentColor 0 2px, transparent 2px 4px,
    currentColor 4px 5px, transparent 5px 8px,
    currentColor 8px 12px, transparent 12px 14px,
    currentColor 14px 16px, transparent 16px 20px,
    currentColor 20px 23px, transparent 23px 25px
  );
}
html[data-theme="dark"] .desk[data-link-state="ready"] .barcode { filter: none; mix-blend-mode: normal; color: #f4ecd8; }

html[data-theme="dark"] .perforation { background: repeating-linear-gradient(to right, #758099 0 6px, transparent 6px 12px); }
html[data-theme="dark"] .perforation::before,
html[data-theme="dark"] .perforation::after { border-color: var(--rim); }
html[data-theme="dark"] .ticket-rule,
html[data-theme="dark"] .pass-guide-foot { border-color: var(--rule); }

html[data-theme="dark"] .hero-intro,
html[data-theme="dark"] .ticket-rule p,
html[data-theme="dark"] .message,
html[data-theme="dark"] .about-intro,
html[data-theme="dark"] .about-hint,
html[data-theme="dark"] .guide-instruction p,
html[data-theme="dark"] #announcement-date,
html[data-theme="dark"] #announcement-body { color: var(--muted); }

html[data-theme="dark"] .input-shell { background: var(--well); border-color: #636f83; }
html[data-theme="dark"] .input-shell:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px #8ca7ff26; }
html[data-theme="dark"] .input-shell input { color: var(--ink); }
html[data-theme="dark"] .input-shell input::placeholder,
html[data-theme="dark"] .input-icon { color: #aab5c7; }
html[data-theme="dark"] .desk[data-link-state="ready"] .input-shell { --ink-line: var(--good); }
html[data-theme="dark"] .desk[data-link-state="error"] .input-shell { --ink-line: var(--error); }
html[data-theme="dark"] .ready-stamp,
html[data-theme="dark"] .paste[data-paste-state="done"] { color: var(--good); background: var(--good-stock); }
html[data-theme="dark"] .paste[data-paste-state="done"] { border-color: #668a74; }
html[data-theme="dark"] .desk[data-link-state="ready"] .input-icon,
html[data-theme="dark"] .message[data-tone="ready"] { color: var(--good); }
html[data-theme="dark"] .message[data-tone="error"] { color: var(--error); }

html[data-theme="dark"] .paste,
html[data-theme="dark"] #announcement-snooze,
html[data-theme="dark"] .cat-tab,
html[data-theme="dark"] .motion-chip,
html[data-theme="dark"] .stamp-btn,
html[data-theme="dark"] .reader-back,
html[data-theme="dark"] .about-secondary-btn {
  color: #e2dfd7;
  background-color: var(--control);
  border-color: var(--rim);
}
html[data-theme="dark"] .cat-tab[aria-pressed="true"],
html[data-theme="dark"] .motion-chip[aria-pressed="true"] {
  border-color: var(--blue);
  background: #273862;
  color: #d6e2ff;
}
html[data-theme="dark"] .stamp-btn[aria-pressed="true"] {
  border-color: #548367;
  background: var(--good-stock);
  color: var(--good);
}

html[data-theme="dark"] .submit { background: #273975; border-color: var(--action-edge); box-shadow: 0 2px 0 #0b1223; }
html[data-theme="dark"] .submit::before,
html[data-theme="dark"] .account-link,
html[data-theme="dark"] .about-primary-btn,
html[data-theme="dark"] .guide-start,
html[data-theme="dark"] .guide-book { background-color: var(--action); border-color: var(--action-edge); }
html[data-theme="dark"] .submit::after { background-image: linear-gradient(112deg, #364caa 42%, #4b63c4 74%, #7388d9 92%, transparent 93%); }
html[data-theme="dark"] .account-link,
html[data-theme="dark"] .about-primary-btn,
html[data-theme="dark"] .guide-start { box-shadow: 0 2px 0 #141e40; }

html[data-theme="dark"] .post-card {
  border-color: #3f4d64;
  background: linear-gradient(155deg, #212c3d 0%, #1c2534 100%);
  box-shadow: 0 2px 0 #121823;
}
html[data-theme="dark"] .post-issue,
html[data-theme="dark"] .post-card-foot,
html[data-theme="dark"] .post-card-excerpt { color: var(--muted); }
html[data-theme="dark"] .post-card-foot { border-color: #3d4b61; }
html[data-theme="dark"] .post-cat-badge {
  border-color: #495974;
  background: #283549;
  color: #cbd8ff;
}
html[data-theme="dark"] .post-empty {
  border-color: var(--rim);
  background: var(--well);
}
html[data-theme="dark"] .post-empty p { color: var(--muted); }
html[data-theme="dark"] .post-empty button {
  border-color: var(--rim);
  background: var(--control);
  color: var(--ink);
}

html[data-theme="dark"] .reader-toolbar,
html[data-theme="dark"] .reader-nav-footer { border-color: var(--rule); }
html[data-theme="dark"] .reader-badges,
html[data-theme="dark"] .reader-subtitle,
html[data-theme="dark"] .reader-nav-label { color: var(--muted); }
html[data-theme="dark"] .reader-prose { color: #e2ddd3; }
html[data-theme="dark"] .reader-prose h2 { color: #b7c9ff; }
html[data-theme="dark"] .reader-prose blockquote {
  background: #232f42;
  color: #d7deeb;
}
html[data-theme="dark"] .reader-prose pre {
  border-color: #3a475d;
  background: #121925;
  color: #e4e9f5;
}
html[data-theme="dark"] .reader-prose code { background: #263144; color: #e8edf8; }
html[data-theme="dark"] .reader-callout {
  border-color: #4e638e;
  background: #212e44;
  color: #d4e0fa;
}
html[data-theme="dark"] .reader-toc,
html[data-theme="dark"] .reader-nav-btn {
  border-color: var(--rim);
  background: #212b3c;
}
html[data-theme="dark"] .reader-toc-link { color: var(--muted); }
html[data-theme="dark"] .reader-toc-link[aria-current="true"] {
  background: #2b3c5d;
  color: #d1deff;
}

html[data-theme="dark"] .motion-bar {
  border-color: var(--rim);
  background: #18202d;
  color: var(--muted);
}
html[data-theme="dark"] .motion-bar-label { color: var(--muted); }
html[data-theme="dark"] .press-mark { border-color: #b5c4ffa8; }
html[data-theme="dark"] .charm-stage::before { background-image: radial-gradient(circle, #9caac4 .8px, transparent 1px); }
html[data-theme="dark"] .charm-stage::after { background: radial-gradient(ellipse, #050a12aa, transparent 68%); }

html[data-theme="dark"] .pass-guide { border-color: var(--rim); background: var(--panel); box-shadow: var(--sheet-shadow); }
html[data-theme="dark"] .pass-guide-head { background: var(--ink-stock); border-color: var(--rule); }
html[data-theme="dark"] .guide-step + .guide-step { border-color: var(--stroke); }
html[data-theme="dark"] .guide-instruction strong { color: var(--ink); }
html[data-theme="dark"] .copy-tip[open] p { border-color: #738685; }
html[data-theme="dark"] .copy-tip kbd { background: var(--well); border-color: var(--rim); color: var(--ink); }
html[data-theme="dark"] .guide-art { border-color: #626879; background-color: #433e38; }
html[data-theme="dark"] .art-copy { background-color: #303e55; }
html[data-theme="dark"] .art-paste { background-color: #303f3b; }
html[data-theme="dark"] .guide-no { color: #d6d9d1; }

html[data-theme="dark"] #pinned-bar { color: #d9e0f0; border-color: var(--rim); }
html[data-theme="dark"] .announcement-scrim,
html[data-theme="dark"] .pass-guide::backdrop { background: #060910ab; }
html[data-theme="dark"] .announcement-paper-shell { --note-edge: #657187; --note-stock: var(--note-paper); }
html[data-theme="dark"] .announcement-meta::after { background-image: repeating-linear-gradient(90deg, #788397 0 3px, transparent 3px 7px); }
html[data-theme="dark"] .announcement-dismiss { color: var(--ink); }
html[data-theme="dark"] #announcement-title { color: #c1cefa; }
html[data-theme="dark"] .announcement-tab { border-color: #5b6982; background: #222d3f; color: #c5cfe2; }
html[data-theme="dark"] .announcement-tab[aria-pressed="true"] { border-color: var(--blue); background: #2c3e64; color: #eef2ff; }
html[data-theme="dark"] .announcement-content { scrollbar-color: #6c7a90 transparent; }

html[data-theme="dark"] .colophon-cell {
  border-color: #4b5a73;
  background: #202a3b;
}
html[data-theme="dark"] .colophon-cell dt { color: var(--muted); }
html[data-theme="dark"] .pass-stage { border-color: #768297; }
html[data-theme="dark"] .print-track,
html[data-theme="dark"] .print-track::before,
html[data-theme="dark"] .print-track::after { border-color: #a3b7d067; }

html[data-theme="dark"] .pass-coupon,
html[data-theme="dark"] html[data-pass-entry]::after,
html[data-theme="dark"] html[data-pass-return]::after {
  border-color: #76859c;
  color: #ccdaff;
  box-shadow: 1px 2px 0 #708099, 2px 4px 0 #485870, 4px 8px 0 -3px #344359, 5px 18px 30px -12px #04081199;
  background:
    radial-gradient(circle, var(--orange) 0 66%, transparent 70%) 10% 21% / 3.3% 6.3% no-repeat,
    repeating-linear-gradient(0deg, #c2cde2 0 2px, transparent 2px 4px, #c2cde2 4px 5px, transparent 5px 7px, #c2cde2 7px 10px, transparent 10px 13px) 93% 73% / 6% 31% no-repeat,
    repeating-linear-gradient(0deg, #9aa6bb 0 3px, transparent 3px 8px) 83% 0 / 1px 100% no-repeat,
    linear-gradient(90deg, transparent 0 82.9%, #303c50 83%),
    linear-gradient(90deg, #364259, #424f68 34%, #2d384d 42%, #4e5d77 42.5%, #3c4a63 55%, #344157 83%),
    var(--flight-stock);
}

@media (hover: hover) and (pointer: fine) {
  html[data-theme="dark"] .theme-picker:hover,
  html[data-theme="dark"] .help-link:hover,
  html[data-theme="dark"] .announcement-bell:hover,
  html[data-theme="dark"] .announcement-dismiss:hover,
  html[data-theme="dark"] .guide-dismiss:hover {
    background: var(--control-hover);
    color: var(--ink);
    border-color: #6c7e97;
    box-shadow: none;
  }
  html[data-theme="dark"] .paste:not([data-paste-state="done"]):hover,
  html[data-theme="dark"] #announcement-snooze:hover,
  html[data-theme="dark"] .cat-tab:hover,
  html[data-theme="dark"] .motion-chip:hover,
  html[data-theme="dark"] .stamp-btn:hover,
  html[data-theme="dark"] .reader-back:hover,
  html[data-theme="dark"] .about-secondary-btn:hover {
    background: var(--control-hover);
    color: var(--ink);
  }
  html[data-theme="dark"] .account-link:hover,
  html[data-theme="dark"] .about-primary-btn:hover,
  html[data-theme="dark"] .guide-start:hover {
    background: var(--action-hover);
  }
  html[data-theme="dark"] .post-card:hover {
    border-color: #6e85c4;
    box-shadow: 0 5px 0 #141b28, 0 12px 20px -14px rgba(0, 0, 0, .55);
  }
}

@media (max-width: 620px) {
  .theme-picker { width: 36px; height: 36px; }
}
