/* FlowerMoon appearance-v1: palette-only cascade for internal review.
 * Load after the actual page stylesheets, especially system-reading.css.
 * Three states: no data-theme = system, data-theme="day", data-theme="night".
 * The explicit day branch is repeated inside the dark media query so a saved
 * day choice cannot be recoloured by prefers-color-scheme: dark.
 */

/* Day is the fallback/system-light palette. */
:root,
html[data-theme="day"] {
  color-scheme: light !important;
  --fm-canvas: #ffffff;
  --fm-surface: #f5f5f7;
  --fm-surface-strong: #e8e8ed;
  --fm-ink: #1d1d1f;
  --fm-muted: #6e6e73;
  --fm-line: #d2d2d7;
  --fm-line-soft: #e8e8ed;
  --fm-action: #0071e3;
  --fm-action-hover: #005bb5;
  --fm-action-soft: #eef5ff;
  --fm-media: #222222;
  --fm-shadow: 0 16px 40px rgb(0 0 0 / .10);

  /* Existing variable names, including !important consumers. */
  --canvas: var(--fm-canvas) !important;
  --primary: var(--fm-ink) !important;
  --secondary: var(--fm-muted) !important;
  --edge: var(--fm-line) !important;
  --wash: var(--fm-surface) !important;
  --action: var(--fm-action) !important;
  --paper: var(--fm-canvas) !important;
  --ink: var(--fm-ink) !important;
  --muted: var(--fm-muted) !important;
  --line: var(--fm-line) !important;
  --line-soft: var(--fm-line-soft) !important;
  --card: var(--fm-surface) !important;
  --berry: var(--fm-action) !important;
  --berry-soft: var(--fm-action-soft) !important;
  --shadow: var(--fm-shadow) !important;
  --reader-paper: var(--fm-canvas) !important;
  --reader-paper-deep: var(--fm-surface) !important;
  --reader-ink: var(--fm-ink) !important;
  --reader-muted: var(--fm-muted) !important;
  --reader-rule: var(--fm-line) !important;
  --reader-berry: var(--fm-action) !important;
  --reader-berry-deep: var(--fm-action-hover) !important;
  --reader-berry-wash: var(--fm-action-soft) !important;
  --emil-paper: var(--fm-canvas) !important;
  --emil-ink: var(--fm-ink) !important;
  --emil-muted: var(--fm-muted) !important;
  --emil-line: var(--fm-line) !important;
  --emil-berry: var(--fm-action) !important;
  --emil-berry-soft: var(--fm-action-soft) !important;
  --discovery-paper: var(--fm-canvas) !important;
  --discovery-ink: var(--fm-ink) !important;
  --discovery-muted: var(--fm-muted) !important;
  --discovery-line: var(--fm-line) !important;
  --discovery-berry: var(--fm-action) !important;
}

/* Explicit night mode. */
html[data-theme="night"] {
  color-scheme: dark !important;
  --fm-canvas: #1d1d1f;
  --fm-surface: #2c2c2e;
  --fm-surface-strong: #3a3a3c;
  --fm-ink: #f5f5f7;
  --fm-muted: #b5b5ba;
  --fm-line: #48484a;
  --fm-line-soft: #3a3a3c;
  --fm-action: #64b5ff;
  --fm-action-hover: #9bcfff;
  --fm-action-soft: #1f3a52;
  --fm-media: #111111;
  --fm-shadow: 0 16px 40px rgb(0 0 0 / .28);
}

/* System-dark is the third mode only when the user has not chosen day/night. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="day"]):not([data-theme="night"]) {
    color-scheme: dark !important;
    --fm-canvas: #1d1d1f;
    --fm-surface: #2c2c2e;
    --fm-surface-strong: #3a3a3c;
    --fm-ink: #f5f5f7;
    --fm-muted: #b5b5ba;
    --fm-line: #48484a;
    --fm-line-soft: #3a3a3c;
    --fm-action: #64b5ff;
    --fm-action-hover: #9bcfff;
    --fm-action-soft: #1f3a52;
    --fm-media: #111111;
    --fm-shadow: 0 16px 40px rgb(0 0 0 / .28);
  }

  /* Manual day must beat discovery-edition's system dark block. */
  html[data-theme="day"] {
    color-scheme: light !important;
    --fm-canvas: #ffffff;
    --fm-surface: #f5f5f7;
    --fm-surface-strong: #e8e8ed;
    --fm-ink: #1d1d1f;
    --fm-muted: #6e6e73;
    --fm-line: #d2d2d7;
    --fm-line-soft: #e8e8ed;
    --fm-action: #0071e3;
    --fm-action-hover: #005bb5;
    --fm-action-soft: #eef5ff;
    --fm-media: #222222;
    --fm-shadow: 0 16px 40px rgb(0 0 0 / .10);
  }
}

/* The common canvas and chrome. !important is intentional: the source has
 * literal colours and system-reading.css has an !important token layer. */
html,
body,
body > main,
body > #app,
.site-header,
.edition-header,
header.edition-header,
.footer {
  background: var(--fm-canvas) !important;
  color: var(--fm-ink) !important;
  border-color: var(--fm-line) !important;
}
body,
html {
  transition: none !important;
}

/* Navigation, masthead, Logo, and language controls. */
.edition-nav-inner,
.masthead,
.section-nav,
.nav,
.nav-links,
.mast-meta,
.edition-links,
.edition-languages {
  color: var(--fm-ink) !important;
  border-color: var(--fm-line) !important;
  background: transparent !important;
}
.edition-nav-inner :is(a, .language-switch, .topic-current),
.nav-links a,
.section-nav a,
.language-switch,
.theme-toggle,
.brand,
.brand span {
  color: var(--fm-ink) !important;
  border-color: var(--fm-line) !important;
}
.edition-nav-inner .edition-languages,
.brand-tagline,
.mast-meta,
.language-switch.is-disabled {
  color: var(--fm-muted) !important;
}
.edition-nav-inner a[aria-current="page"],
.section-nav a[aria-current="page"],
.nav-links a[aria-current="page"],
.edition-links a:hover,
.edition-languages a:hover,
.language-switch:hover,
.theme-toggle:hover {
  color: var(--fm-action) !important;
  border-color: var(--fm-action) !important;
}
.edition-symbol img {
  background: transparent !important;
}
html[data-theme] .edition-nav-inner .edition-symbol img { background:transparent !important;filter:none !important; }
html[data-theme="night"] .edition-nav-inner .edition-symbol img { content:url('https://1850540354.cdn.123clouddisk.com/1850540354/60715222'); }
@media (prefers-color-scheme:dark){html:not([data-theme]) .edition-nav-inner .edition-symbol img{background:transparent!important;filter:none!important;content:url('https://1850540354.cdn.123clouddisk.com/1850540354/60715222')}}
/* Reading artwork is never inverted. The preceding logo rule is the only
 * intentional inversion and is limited to the navigation mark. */
main img,
main article img,
main figure img,
.reader img,
.reader-body img,
.archive-media img,
.fmc-video-thumb,
.illustration img {
  filter: none !important;
}

/* Typography roles: reading images/media remain untouched; text is ink. */
main,
main :where(p, li, dt, dd, blockquote, figcaption, label, time, cite),
.reader,
.reader-body,
.archive-directory,
.translation-page,
.about-copy,
.about-hero,
.film-index,
.discovery-main,
.discovery-tv,
main.wrap > section,
main.wrap > article {
  color: var(--fm-ink) !important;
}
main :where(h1, h2, h3, h4, h5, h6),
.reader :where(h1, h2, h3, h4, h5, h6),
.about-hero h1,
.about-copy h2,
.film-index .event-card h2,
.discovery-tv .day-head h2 {
  color: var(--fm-ink) !important;
}

/* Directories and archive metadata: titles/metadata are neutral, not blue. */
.archive-directory li,
.event-card,
.event-facts,
.event-facts :is(.issue-label, .event-day),
.event-index,
.event-index :is(.event-seq, .event-when),
.event-date,
.event-date :is(strong, span),
.event-meta,
.source-note,
.count,
.status,
.reader-credit,
.archive-functions,
.activity-ledger,
.activity-ledger p,
.fmc-podcast-status,
.fmc-video-meta,
.row-zh,
.ep {
  color: var(--fm-muted) !important;
  border-color: var(--fm-line) !important;
}
.archive-directory li a,
.archive-directory li a:visited,
.archive-detail .reader-body a,
.archive-detail .reader-body a:visited,
.film-index .event-card h2 a,
.film-index .event-card h2 a:visited,
.row-title,
.row-title:visited,
.fmc-video-title,
.fmc-video-title:visited {
  color: var(--fm-ink) !important;
}
.archive-directory li a:hover,
.archive-detail .reader-body a:hover,
.film-index .event-card h2 a:hover,
.film-index .event-card h2 a:active,
.row-title:hover,
.ep:hover,
.fmc-video-title:hover,
.fmc-video-play:hover {
  color: var(--fm-action) !important;
}

/* Reading-specific rails, notices, quotations, and detail surfaces. */
.reader-toc,
.reader .badges,
.reader-body > :is(h2, h3),
main.wrap section > :is(h2, h3),
main.wrap article > :is(h2, h3),
main.reader article > :is(h2, h3),
.translation-page hr,
.photo-caption,
.fmc-podcast-transcript,
.fmc-video-section,
.event-sort,
.day,
.row {
  border-color: var(--fm-line) !important;
}
.reader-toc-label,
.topic-languages,
.topic-languages .topic-missing,
.reader .badge,
.photo-caption,
.lang-copy,
.archive-detail .reader-credit,
.source-links,
.discovery-archive .event-facts,
.discovery-archive .event-index,
.discovery-archive .event-body p,
.discovery-archive .event-copy p {
  color: var(--fm-muted) !important;
}
.reader a.badge,
.topic-languages a,
.topic-languages .topic-current,
.back-link,
.archive-functions a,
.source-links a,
.reader-toc a,
.field-note a,
.event-link,
.home-links a,
.discovery-home .home-links a,
.discovery-archive .event-body h2 a:hover,
.discovery-tv .row-title:hover {
  color: var(--fm-action) !important;
}
.quote-block,
.reader article blockquote,
.field-note,
.translation-notice,
#app :where(.notice, .error, .loading),
main :where(details),
.poster-card,
.reading-card,
.event-card,
.category,
.fmc-podcast-card,
.fmc-video-card,
.fmc-podcast-dock,
.fmc-podcast-dock button,
.fmc-podcast-reopen,
.tools input,
.discovery-tv .tool input,
.event-sort select,
.search-wrap input {
  background: var(--fm-surface) !important;
  color: var(--fm-ink) !important;
  border-color: var(--fm-line) !important;
  box-shadow: none !important;
}
.quote-block,
.reader article blockquote {
  border-left-color: var(--fm-action) !important;
}

/* TV and podcast controls: blue is reserved for actual operations. */
button,
.button,
.today,
.fmc-podcast-actions :is(button, a),
.fmc-podcast-dock button,
.fmc-podcast-reopen,
.fmc-video-load,
.theme-toggle {
  border-color: var(--fm-action) !important;
  color: var(--fm-action) !important;
  background: transparent !important;
}
.today,
.discovery-tv .today {
  background: var(--fm-action) !important;
  color: var(--fm-canvas) !important;
}
.today:hover,
.fmc-podcast-actions :is(button, a):hover,
.fmc-podcast-actions :is(button, a):focus-visible,
.fmc-podcast-dock button:hover,
.fmc-podcast-dock button:focus-visible,
.fmc-podcast-reopen:hover,
.fmc-podcast-reopen:focus-visible {
  color: var(--fm-action-hover) !important;
  border-color: var(--fm-action-hover) !important;
}
.fmc-podcast-actions .fmc-podcast-play,
.fmc-podcast-transcript summary,
.fmc-video-fallback,
.fmc-video-play {
  color: var(--fm-action) !important;
}

/* Keep video/audio playback surfaces dark, regardless of reading theme. */
.fmc-video-stage,
.fmc-video-frame,
.fmc-video-window,
.fmc-video-window-stage,
.fmc-video-stage-placeholder,
main :where(video, iframe),
.poster-art {
  background: var(--fm-media) !important;
}
.fmc-video-thumb,
.fmc-video-frame,
main :where(video, iframe) {
  filter: none !important;
}

/* Hardcoded source system-dark overrides must not recolour explicit day. */
html[data-theme="day"] :where(.discovery-main, .discovery-tv, .reader, .archive-detail, .about-copy, .about-hero),
html[data-theme="day"] :where(.discovery-main, .discovery-tv, .reader, .archive-detail, .about-copy, .about-hero) * {
  border-color: var(--fm-line) !important;
}

:where(a, button, summary, input, select, textarea):focus-visible {
  outline-color: var(--fm-action) !important;
}

/* FlowerMoon appearance-v1: Apple-style Light/Dark/Auto footer control. */
.fmc-appearance-footer {
  width: min(calc(100% - 2rem), 60rem);
  margin:40px auto 0;
  padding:16px 0 calc(1rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line, #d2d2d7);
  color: var(--muted, #6e6e73);
  font-family:-apple-system, BlinkMacSystemFont, "SF Pro Text", "FMC Sans SC", "PingFang SC", system-ui, sans-serif;
  font-size:13px;
  line-height: 1.35;
}

.fmc-theme-fieldset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap:12px 16px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fmc-theme-legend {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  color: var(--ink, #1d1d1f);
  font-weight: 600;
}

.fmc-theme-options {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap:8px;
  min-width: 0;
}

.fmc-theme-option {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  gap:8px;
  padding:8px 12px;
  border: 1px solid var(--line, #d2d2d7);
  border-radius: 999px;
  color: var(--ink, #1d1d1f);
  background: var(--paper, Canvas);
  cursor: pointer;
  white-space: nowrap;
}

.fmc-theme-option:hover {
  border-color: var(--berry, #0071e3);
}

.fmc-theme-option:focus-within {
  outline: 2px solid var(--berry, #0071e3);
  outline-offset: 2px;
}

.fmc-theme-option input {
  inline-size: 1rem;
  block-size: 1rem;
  margin: 0;
  accent-color: var(--berry, #0071e3);
}

.fmc-theme-option-label {
  font-weight: 500;
}

.fmc-theme-option small {
  color: var(--muted, #6e6e73);
  font-size:12px;
}

@media (max-width: 560px) {
  .fmc-appearance-footer {
    width: min(calc(100% - 1.5rem), 60rem);
    margin-top: 2rem;
  }

  .fmc-theme-fieldset {
    align-items: flex-start;
    flex-direction: column;
  }

  .fmc-theme-options {
    width: 100%;
    justify-content: flex-start;
  }

  .fmc-theme-option {
    flex: 1 1 auto;
    justify-content: center;
  }
}

@media (max-width: 360px) {
  .fmc-theme-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .fmc-theme-option {
    gap:4px;
    padding-inline: .35rem;
    font-size:12px;
  }

  .fmc-theme-option small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fmc-appearance-footer *,
  .fmc-appearance-footer *::before,
  .fmc-appearance-footer *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* Ordinary editorial areas use the page canvas, not a card fill. Keep floating controls opaque. */
html[data-theme] :is(.quote-block,.reader article blockquote,.field-note,.translation-notice,main details,.poster-card,.reading-card,.event-card,.category,.fmc-podcast-card,.fmc-video-card,.event-sort select) { background-color:transparent !important; background-image:none !important; }
html[data-theme] :is(.quote-block,.reader article blockquote) { border-left-color:var(--fm-line) !important; }
@media all{
footer.fmc-appearance-footer{width:calc(100% - 32px);margin:8px auto 0;padding:0 0 env(safe-area-inset-bottom);border:0;display:flex;justify-content:flex-end}
.fmc-theme-fieldset{display:block;width:max-content;max-width:100%;position:relative}
.fmc-theme-legend,.fmc-theme-option small,.fmc-theme-option input{position:absolute;width:1px;height:1px;inline-size:1px;block-size:1px;clip-path:inset(50%);overflow:hidden;white-space:nowrap;display:block}
.fmc-theme-options{display:inline-flex;width:auto;gap:0;flex-wrap:nowrap;align-items:center;position:relative;padding-inline:2px;min-height:44px;isolation:isolate}
.fmc-theme-options:before{content:'';position:absolute;inset:50% 0 auto;transform:translateY(-50%);height:24px;box-sizing:border-box;border:1px solid var(--fm-line);border-radius:999px;pointer-events:none;z-index:-1}
.fmc-theme-options .fmc-theme-option{box-sizing:border-box;position:relative;display:flex;justify-content:center;align-items:center;flex:none;min-width:44px;height:44px;min-height:44px;padding:0;border:0;border-radius:0;background:transparent;outline:0;gap:0;font-size:12px;line-height:1;color:var(--fm-ink)}
.fmc-theme-option-label{box-sizing:border-box;display:block;min-width:100%;padding:0 4px;height:20px;line-height:20px;border-radius:999px;text-align:center;font-weight:400}
.fmc-theme-option input:checked+.fmc-theme-option-label{background:var(--fm-ink);color:var(--fm-canvas)}
.fmc-theme-option input:focus-visible+.fmc-theme-option-label{outline:2px solid var(--fm-action);outline-offset:2px}
}

/* One page-edge footer: reserve its space after content; fill short viewports. */
html:has(footer[data-fmc-appearance]) {position:relative; min-height:100%; min-height:100dvh; box-sizing:border-box;}
footer.fmc-appearance-footer[data-fmc-appearance]{position:static;width:100%;max-width:none;box-sizing:border-box;height:calc(68px + env(safe-area-inset-bottom));min-height:0;margin:0;padding:0;border:0;}
footer[data-fmc-appearance] .fmc-theme-options{box-sizing:border-box;height:44px;min-height:44px;padding-block:0;line-height:1;}
footer[data-fmc-appearance] .fmc-theme-fieldset{position:absolute; right:max(16px, env(safe-area-inset-right)); bottom:calc(12px + env(safe-area-inset-bottom)); margin:0;}
.fmc-theme-option input:focus-visible+.fmc-theme-option-label{outline:2px solid var(--fm-action);outline-offset:2px;}

@layer systemReading { html:root .edition-nav-inner .edition-symbol img { background-color:transparent!important;filter:none!important } }

/* Keep explicit day colors at paint time on Safari in system dark mode. */
html[data-theme="day"]{color-scheme:only light!important}
