/* ============================================================
   THE DARK ROOM — card stock from the phone (build 47).
   Loaded last on purpose. Older rules across desk.css, youtube-polaroid.css,
   scripture.css and the desk-view stylesheet pinned cream paper on every
   card in the dark room ("paper stays paper"). The approved phone design
   keeps paper objects paper in BOTH rooms by giving them the room's own
   stock: DeskTheme.cardPaper #6E5F55 with cardInk #FFF9EF at night (the
   same opaque colour as the Library's dividing rule), mediaPaper and
   youtubePaper the same stock, and stickies their one daylight colour.
   Every value here is a --yd-* token, so this sheet cannot drift from the
   phone. Nothing in it applies in the light room.
   ============================================================ */

/* Card families on the Desk. Specificity (0,4,1)+ beats the older
   [data-theme="dark"] .note-card.family.state pins without !important. */
[data-theme="dark"] body .dv-item .note-card:is(
  .capture-photo, .capture-video, .uploaded-video-card,
  .youtube-polaroid-card, .photo-polaroid, .article-sheet, .website-specimen,
  .media-podcast-card, .media-audio-memo-card,
  .dv-newsletter, .dv-generic, .dv-podcast, .dv-article
),
[data-theme="dark"] body .dv-item .note-card:is(
  .capture-photo, .capture-video, .youtube-polaroid-card
):is(.state-alive, .state-active, .state-warm, .state-dormant),
[data-theme="dark"] body .dv-item .scripture-sheet,
[data-theme="dark"] body .dv-item .dv-chapter,
[data-theme="dark"] body .dv-item .dv-chapter.is-active,
[data-theme="dark"] body .dv-spot .dv-chapter,
[data-theme="dark"] body .dv-spot .dv-chapter.is-active {
  color-scheme: dark;
  background: var(--yd-card-paper);
  color: var(--yd-card-ink);
  border-color: rgba(255, 249, 239, 0.10);
  /* Descendants that read the generic ink/paper roles resolve on card stock. */
  --paper: var(--yd-card-paper);
  --paper-tint: var(--yd-card-paper);
  --surface: var(--yd-card-paper);
  --ink: var(--yd-card-ink);
  --ink-primary: var(--yd-card-ink);
  --ink-light: var(--yd-card-muted);
  --ink-faint: var(--yd-card-muted);
  --ink-secondary: var(--yd-card-muted);
  --ink-dim: var(--yd-card-muted);
  --object-paper: var(--yd-card-paper);
  --object-ink: var(--yd-card-ink);
  --object-muted: var(--yd-card-muted);
  --media-paper: var(--yd-card-paper);
  --media-ink: var(--yd-card-ink);
  --media-muted-ink: var(--yd-card-muted);
  --accent: var(--yd-card-writing-accent);
  --accent-warm: var(--yd-card-writing-accent);
  --gold: var(--yd-card-writing-accent);
  --gold-warm: var(--yd-card-writing-accent);
  --border: rgba(255, 249, 239, 0.12);
  --border-strong: rgba(255, 249, 239, 0.22);
}

/* Captions and titles those families paint with literal daylight ink.
   (A chapter sheet sits directly in its spot, not inside a .dv-item.) */
[data-theme="dark"] body :is(.dv-item, .dv-spot .dv-chapter) :is(
  .capture-photo-caption, .capture-video-caption, .photo-polaroid-caption,
  .photo-polaroid-fallback-title,
  .youtube-polaroid-title, .article-sheet-masthead, .article-sheet h3,
  .website-specimen-identity strong, .dv-chapter-title, .dv-nl-sender,
  .scripture-sheet h3, .scripture-sheet p
) {
  color: var(--yd-card-ink);
}
/* The handwritten photo caption has its own ink on the phone (photoInk). */
[data-theme="dark"] body .dv-item .photo-polaroid-handwriting {
  color: var(--yd-photo-ink);
}
/* Small labels the media families paint in daylight clay or amber. */
[data-theme="dark"] body .dv-item .media-object-label,
[data-theme="dark"] body .dv-item .media-object-label i {
  color: var(--yd-media-card-accent);
  background-color: var(--yd-media-card-accent);
}
[data-theme="dark"] body .dv-item .media-object-label { background-color: transparent; }
[data-theme="dark"] body .dv-item .media-audio-playing {
  color: var(--yd-media-amber);
}
[data-theme="dark"] body .dv-item .youtube-polaroid-duration {
  color: var(--yd-youtube-detail-ink);
}
[data-theme="dark"] body .dv-item .dv-nl-subject {
  color: var(--yd-card-ink);
}
[data-theme="dark"] body :is(.dv-item, .dv-spot .dv-chapter) :is(
  .youtube-polaroid-channel, .article-sheet-byline, .article-sheet-section,
  .website-specimen-identity small, .website-specimen-label,
  .dv-chapter-kicker, .dv-chapter-last, .media-podcast-byline,
  .photo-polaroid-meta, .photo-polaroid-fallback-note, .photo-polaroid-caption-affordance,
  .scripture-sheet header, .scripture-sheet footer
) {
  color: var(--yd-card-muted);
}
[data-theme="dark"] body :is(.dv-item, .dv-spot .dv-chapter) .dv-chapter-kicker {
  color: var(--yd-card-writing-accent);
}

/* Picture mats inside cards take the phone's image mat (mediaImageMat). */
[data-theme="dark"] body .dv-item :is(
  .website-specimen-capture, .product-specimen .website-specimen-capture,
  .product-specimen .website-specimen-screenshot, .website-specimen-favicon,
  .photo-polaroid-aperture, .photo-polaroid-fallback,
  .capture-photo-img, .capture-video-frame, .youtube-polaroid-aperture
) {
  background: var(--yd-media-image-mat);
}
[data-theme="dark"] body .dv-item :is(.capture-video-caption, .youtube-polaroid-caption) {
  background: var(--yd-card-paper);
  color: var(--yd-card-ink);
}

/* The chapter sheet loses its daylight gradient; the pile count and the
   Add control take the approved dark-wood treatment. */
[data-theme="dark"] body .dv-item .dv-chapter,
[data-theme="dark"] body .dv-spot .dv-chapter {
  background: var(--yd-card-paper);
}
[data-theme="dark"] body .dv-stack-count {
  background: var(--yd-pile-count-fill);
  color: var(--yd-pile-count-ink);
  border-color: transparent;
}
[data-theme="dark"] body .dv-add-source {
  background: var(--yd-desk-add-fill);
  color: var(--yd-desk-add-ink);
  border-color: var(--yd-desk-control-border);
}
[data-theme="dark"] body .dv-add-source .dv-add-source-plus {
  color: var(--yd-desk-add-plus);
}

/* Desk chooser cards on the landing and the share sheet are room furniture,
   not lit cream paper. */
[data-theme="dark"] body .desk-card,
[data-theme="dark"] body .desk-card:hover {
  color-scheme: dark;
  background: var(--yd-card-paper);
  color: var(--yd-card-ink);
  --ink: var(--yd-card-ink);
  --ink-light: var(--yd-card-muted);
  --ink-faint: var(--yd-card-muted);
}
[data-theme="dark"] body .desk-card-name { color: var(--yd-card-ink); }
[data-theme="dark"] body .desk-card-meta,
[data-theme="dark"] body .desk-card-desc { color: var(--yd-card-muted); }
[data-theme="dark"] body .share-modal,
[data-theme="dark"] body .share-modal-card,
[data-theme="dark"] body .share-sheet {
  color-scheme: dark;
  background: var(--yd-reference-panel);
  color: var(--yd-ink);
  --paper: var(--yd-reference-panel);
  --surface: var(--yd-reference-panel);
  --ink: var(--yd-ink);
  --ink-light: var(--yd-light-ink);
  --ink-faint: var(--yd-muted-ink);
  --ink-secondary: var(--yd-room-muted);
}

/* The manuscript and the reading pane are the room's own paper at night
   (DeskTheme.paper #35251D with ink #F0EBE1, coral chapter kicker), as on
   the phone's Writing screen — not a lit cream sheet. Media queries in
   desk.css pin cream at wide widths; this reads the same token everywhere. */
[data-theme="dark"] body .workspace,
[data-theme="dark"] body.two-pane .workspace,
[data-theme="dark"] body .reader-reading-pane,
[data-theme="dark"] body.two-pane .reader-reading-scroll,
[data-theme="dark"] body.two-pane .reader-reading-pane .reader-reading-bar {
  color-scheme: dark;
  background: var(--yd-paper);
  color: var(--yd-ink);
  --paper: var(--yd-paper);
  --paper-bg: var(--yd-paper);
  --paper-tint: var(--yd-paper-tint);
  --surface: var(--yd-paper);
  --ink: var(--yd-ink);
  --ink-primary: var(--yd-ink);
  --paper-ink: var(--yd-ink);
  --ink-light: var(--yd-light-ink);
  --paper-ink-light: var(--yd-light-ink);
  --ink-faint: var(--yd-muted-ink);
  --ink-secondary: var(--yd-room-muted);
  --ink-dim: var(--yd-muted-ink);
  --paper-muted: var(--yd-muted-ink);
  --border: rgba(240, 235, 225, 0.12);
  --border-strong: rgba(240, 235, 225, 0.22);
  --accent: var(--yd-action);
  --accent-warm: var(--yd-action-warm);
  --paper-action: var(--yd-action);
  --paper-action-hover: var(--yd-action-warm);
}
[data-theme="dark"] body .workspace .editor-body::selection,
[data-theme="dark"] body .workspace .editor-body *::selection {
  color: var(--yd-ink);
  background: var(--yd-selected-fill);
}
[data-theme="dark"] body .workspace .page-slab-chapter {
  color: var(--yd-coral);
}
[data-theme="dark"] body .workspace .doc-h1,
[data-theme="dark"] body .workspace .editor-title,
[data-theme="dark"] body .workspace input,
[data-theme="dark"] body .workspace textarea,
[data-theme="dark"] body .workspace .editor-body,
[data-theme="dark"] body .workspace [contenteditable="true"] {
  color: var(--yd-ink);
}
[data-theme="dark"] body .workspace input::placeholder,
[data-theme="dark"] body .workspace textarea::placeholder,
[data-theme="dark"] body .workspace .editor-body:empty::before,
[data-theme="dark"] body .workspace [data-placeholder]:empty::before {
  color: var(--yd-room-muted);
  opacity: 1;
}
[data-theme="dark"] body .workspace .editor-body :is(p, li, h1, h2, h3, h4, blockquote, span, em, strong, div, figcaption):not([style*="color"]) {
  color: inherit;
}
[data-theme="dark"] body .workspace .editor-body blockquote.cited-block {
  background: linear-gradient(135deg, rgba(222, 127, 83, .12), rgba(255, 255, 255, .04));
}

/* The legacy feedback toggle pins daylight blue after the base theme rules.
   Keep the same control and behavior, but use the phone's night-time ink. */
[data-theme="dark"] body .workspace .collab-feedback-toggle,
[data-theme="dark"] body .workspace .collab-feedback-toggle:is(:hover, .active) {
  color: var(--yd-tool-ink);
  border-color: var(--yd-tool-border);
  background: var(--yd-tool);
}
[data-theme="dark"] body .workspace .collab-feedback-toggle .collab-toggle-dot {
  background: currentColor;
}

/* Replies are written on the sticky paper itself, which keeps its daylight
   colours in the dark room like the phone's stickies; the reply field reads
   that paper's ink, not the room's. */
[data-theme="dark"] body .workspace .margin-reply-input {
  color: inherit;
}
/* The compact margin's popover and clusters are room furniture, not paper. */
[data-theme="dark"] body .margin-note-popover,
[data-theme="dark"] body .workspace .margin-note-cluster {
  background: var(--yd-chrome-raised);
  border-color: var(--yd-chrome-border);
  color: var(--yd-ink);
}
[data-theme="dark"] body .workspace .margin-rail-header {
  color: var(--yd-room-muted);
  border-bottom-color: var(--yd-chrome-border);
}

/* Library rules use the phone's DeskTheme.toolBorder, without another fade. */
[data-theme="dark"] body .lib-row2 + .lib-row2 {
  border-top: 1px solid var(--yd-tool-border);
}

/* The old brown waveform disappeared into the new dark card stock. */
[data-theme="dark"] body .media-object-waveform span,
[data-theme="dark"] body .reader-object-waveform span {
  background: var(--yd-media-waveform);
  opacity: 1;
}

/* Elapsed time and the active transport belong to the media card's ink,
   not the old brown ink intended for a light sheet. */
[data-theme="dark"] body .reader-audio-now,
[data-theme="dark"] body .is-playing .reader-object-play {
  color: var(--yd-media-card-accent);
}
[data-theme="dark"] body .reader-cite-btn {
  color: var(--yd-tool-ink);
  border-color: var(--yd-tool-border);
}
