/* baidu.fm — Lamplight Library theme + layout + identity.
 *
 * RULES (enforced by scripts/check_ui.sh):
 * - Controls are 100% daisyUI classes (btn/input/badge/join/menu/modal/
 *   range/progress/dock/tabs/toast/alert/loading). Nothing in this file may
 *   style a control.
 * - This file contains ONLY: (a) the lamplight theme variables, (b) layout,
 *   (c) the identity layer (covers, ribbon, lamplight, ticks, dropzone, log).
 * - COLOR SEMANTICS: --color-secondary (ribbon red) marks progress /
 *   "your place" / live states — never a button fill. --color-primary
 *   (lamplight) is the sole interactive accent.
 */

[data-theme="paperday"] {
  color-scheme: light;
  /* paper & ink */
  --color-base-100: #f5efe4;   /* paper ground */
  --color-base-200: #fdfaf2;   /* raised paper (cards) */
  --color-base-300: #ede5d4;   /* pressed */
  --color-base-content: #221d16; /* ink */
  /* roles — ONE accent does all the talking */
  --color-primary: #bc4123;    /* vermillion */
  --color-primary-content: #fdfaf2;
  --color-secondary: #a03a20;  /* deep vermillion: progress, "your place" */
  --color-secondary-content: #fdfaf2;
  --color-accent: #33635a;
  --color-accent-content: #f0f5f3;
  --color-neutral: #221d16;
  --color-neutral-content: #f5efe4;
  --color-info: #47597a;   --color-info-content: #eef1f6;
  --color-success: #33635a; --color-success-content: #eef4f2;
  --color-warning: #8a6420; --color-warning-content: #faf4e6;
  --color-error: #8f3b24;  --color-error-content: #faeee9;
  /* geometry — the consistency engine (unchanged scale) */
  --radius-field: 1.375rem;
  --radius-selector: 2rem;
  --radius-box: 0.875rem;
  --size-field: 0.275rem;
  --size-selector: 0.25rem;
  --border: 1px;
  --depth: 0;
  --noise: 0;
}
/* papernight: same geometry, inverted paper. Applied ONLY by explicit
 * user choice (Settings -> Appearance) or "match device" mode — never
 * automatically, so phone and desktop look identical by default. */
[data-theme="papernight"] {
  --color-accent: #b8a184;
  --color-accent-content: #221a10;
  --color-neutral: #ede4d3;
  --color-neutral-content: #171310;
  --color-info: #8fa6c9;   --color-info-content: #10151d;
  --color-success: #8fae7c; --color-success-content: #131a0e;
  --color-warning: #cf9c3f; --color-warning-content: #221703;
  --color-error: #d96a5a;  --color-error-content: #2a0f0a;
  --radius-field: 1.375rem;
  --radius-selector: 2rem;
  --radius-box: 0.875rem;
  --size-field: 0.275rem;
  --size-selector: 0.25rem;
  --border: 1px;
  --depth: 0;
  --noise: 0;
  color-scheme: dark;
  --color-base-100: #171310;
  --color-base-200: #211b14;
  --color-base-300: #2a2219;
  --color-base-content: #ede4d3;
  --color-primary: #d96a3b;
  --color-primary-content: #201007;
  --color-secondary: #d96a3b;
  --color-secondary-content: #201007;
}
[data-theme="papernight"] .topbar,
[data-theme="papernight"] main, [data-theme="papernight"] .playerbar {
  /* inherit the paperday component/theme rules below via same variables */
}

/* ---------- enforcement guard (grafted from Bookcloth UI spec) ----------
 * Any tappable control that reaches production without a daisyUI class
 * announces itself in magenta. */
button:not([class]),
input:not([class]):not([type="file"]):not(.input input):not(.label input),
select:not([class]) {
  outline: 3px solid magenta !important;
}

/* ============================ base & type ============================ */
:root {
  --serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --nav-h: 64px;
}
* { -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
/* Nothing should ever push the page sideways on a phone (defensive against a
   stray wide element/button overflowing the viewport). */
html, body { overflow-x: hidden; max-width: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
       sans-serif; background: var(--color-base-100);
       color: var(--color-base-content); min-height: 100vh; }
.txt-muted { color: color-mix(in oklab, var(--color-base-content) 72%, transparent); }
.txt-faint { color: color-mix(in oklab, var(--color-base-content) 66%, transparent); }
/* daisyUI's .label default ink (#767168) fails WCAG AA on paper — darken the
   account form labels to full ink so the blind-first sign-in stays readable. */
#acct-out .label, #acct-in .label { color: var(--color-base-content); }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* print masthead: a double rule under the header */
.topbar { border-bottom: 3px double
    color-mix(in oklab, var(--color-base-content) 45%, transparent); }

/* ============================ shell layout ============================ */
.topbar { position: relative; z-index: 1; }
.topbar .in { max-width: 1020px; margin: 0 auto;
    padding: 20px 20px 6px; display: flex; align-items: center; gap: 20px; }
.brand { font-family: var(--serif); font-size: 1.5em; line-height: 1; }
.brand span { color: var(--color-primary); }
.brand .tagline { font-family: -apple-system, sans-serif; font-size: .44em;
    letter-spacing: .14em; text-transform: uppercase; margin-top: 8px; }
.brand .tagline b { color: var(--color-primary); font-weight: 600; }
.desknav { margin-left: auto; }
@media (max-width: 767px) {
  .desknav { display: none; }
  #gearbtn { margin-left: auto; }
}

main { position: relative; z-index: 1; max-width: 1020px; margin: 0 auto;
    padding: 10px 20px calc(var(--nav-h) + 150px); }
.view { display: none; }
.view.on { display: block; }
h2.vh { font-family: var(--serif); font-size: 1.35em; font-weight: 400;
    margin: 30px 0 16px; }
h2.vh .cn { float: right; font-size: .7em; margin-top: .4em; }
.emptybox { text-align: center; padding: 20px 12px; line-height: 1.8; }
.emptybox .glyph { font-family: var(--serif); font-size: 2em;
    color: var(--color-neutral); display: block; margin-bottom: 8px; }

/* dock (phone) */
.dock { z-index: 30; }
@media (min-width: 768px) { .dock { display: none; } }
body.in-player .dock { display: none; }
body.in-player main { padding-bottom: 260px; }

/* ============================ convert layout ============================ */
.dropzone { display: block; border: 2px dashed color-mix(in oklab, var(--color-neutral) 80%, transparent);
    border-radius: var(--radius-box); padding: 32px 16px; text-align: center;
    cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone .dz1 { font-family: var(--serif); font-size: 1.1em; }
.dropzone .dz2 { display: block; margin-top: 8px; font-size: .78em;
    letter-spacing: .12em; }
.dropzone.dragover { border-color: var(--color-primary);
    background: rgba(226,166,91,.06); }
/* File input is CLIP-hidden (not display:none) so it stays focusable for
   screen readers AND its label reliably opens the picker + fires change on
   iOS. Show a focus ring on the label when the hidden input is focused. */
.vh-file { position: absolute; width: 1px; height: 1px; padding: 0;
    margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
    clip-path: inset(50%); border: 0; white-space: nowrap; }
.dropzone:has(.vh-file:focus-visible) { outline: 3px solid var(--color-primary);
    outline-offset: 2px; }
.formcol { display: flex; flex-direction: column; gap: 16px; }
/* daisyUI sets display on these, which overrides the [hidden] attribute — pin
   it back so .hidden = true actually hides them (preview bar, chapter filter). */
.formcol[hidden], .alert[hidden], label.input[hidden] { display: none; }
.joblog { font-family: var(--mono); font-size: .76em; line-height: 1.7;
    background: var(--color-base-300); border-radius: calc(var(--radius-box) - 6px);
    padding: 10px 13px; max-height: 200px; overflow: auto; margin-top: 10px; }
.joblog .t { margin-right: 8px; }

/* ============================ shelf & covers ============================ */
.shelf { display: grid; gap: 26px 18px;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (min-width: 768px) { .shelf { grid-template-columns:
    repeat(auto-fill, minmax(172px, 1fr)); gap: 30px 22px; } }
.vol { min-width: 0; }
.coverwrap { position: relative; cursor: pointer;
    filter: drop-shadow(0 10px 12px rgba(34,29,22,.28)); }
/* edition inks (fixed: identical in light and night) */
.ed-0 { background: #9c4a2e; } .ed-1 { background: #33635a; }
.ed-2 { background: #47597a; } .ed-3 { background: #6e6a32; }
.ed-4 { background: #6f5769; } .ed-5 { background: #2e4054; }
.cover { aspect-ratio: 2/3; border-radius: 4px 8px 8px 4px;
    position: relative; display: flex; flex-direction: column;
    align-items: center; padding: 9% 10%; overflow: hidden;
    color: #f3ead9; }
.cover::before { content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, rgba(0,0,0,.30) 0,
      rgba(0,0,0,.12) 6%, rgba(255,255,255,.08) 8%, transparent 11%); }
.cover::after { content: ""; position: absolute; inset: 6% 7%;
    border: 1px solid rgba(243,234,217,.5); border-radius: 2px;
    pointer-events: none; }
.cover .edno { position: relative; font-family: var(--mono);
    font-size: .52em; letter-spacing: .18em; opacity: .75;
    margin-top: 4%; text-align: center;
    /* the running-time stamp is one line, always — never wrap on small covers */
    white-space: nowrap; overflow: hidden; }
.cover .ct { position: relative; font-family: var(--serif);
    text-align: center; margin-top: 16%; font-size: .95em;
    line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 5;
    -webkit-box-orient: vertical; overflow: hidden; text-wrap: balance; }
.cover .orn { position: relative; text-align: center; opacity: .6;
    font-size: .8em; margin-top: 12%;
    /* Force the text (not emoji) glyph so iOS doesn't render ✳ as a green
       emoji; the U+FE0E variation selector in the markup is the main fix,
       this is the modern-browser backup. */
    font-variant-emoji: text; -webkit-font-variant-emoji: text; }
.cover .cm { position: relative; margin-top: auto; text-align: center;
    font-size: .5em; letter-spacing: .2em; text-transform: uppercase;
    opacity: .65; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 100%; }
/* bookmark ribbon = your place */
.ribbon { position: absolute; top: -4px; right: 12%; width: 12px;
    height: 32px; background: var(--color-primary);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
    box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.volmeta { margin-top: 11px; display: flex; align-items: flex-start;
    gap: 2px; }
.volmeta .vtxt { flex: 1; min-width: 0; }
.volmeta .vt { font-family: var(--serif); font-size: .9em;
    line-height: 1.35; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; }
.volmeta .vm { font-size: .74em; margin-top: 4px; display: flex;
    align-items: center; gap: 6px; flex-wrap: wrap; }

/* continue hero layout */
.continue { display: grid; grid-template-columns: 92px 1fr auto;
    gap: 18px; align-items: center; cursor: pointer; }
.continue .eyebrow { font-size: .7em; letter-spacing: .16em;
    text-transform: uppercase; color: var(--color-primary); }
.continue .t { font-family: var(--serif); font-size: 1.25em;
    margin: 6px 0 8px; line-height: 1.3; }
@media (max-width: 560px) { .continue { grid-template-columns: 80px 1fr; }
    .continue .resume { display: none; } }

/* ============================ player layout ============================ */
.phead { display: grid; grid-template-columns: 108px 1fr; gap: 20px;
    align-items: center; margin: 10px 0 6px; }
.phead .cover .ct { font-size: .62em; -webkit-line-clamp: 4; }
.phead .cover .orn, .phead .cover .cm { display: none; }
.phead h1 { font-family: var(--serif); font-weight: 400; font-size: 1.55em;
    margin: 0 0 8px; line-height: 1.28; text-wrap: balance; }
#pchapters { margin-top: 16px; }
#pchapters li { content-visibility: auto; contain-intrinsic-size: 48px; }
#pchapters .n { font-family: var(--mono); font-size: .78em; min-width: 24px;
    text-align: right; }
#pchapters .t { flex: 1; text-align: left; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; }
#pchapters .d { font-family: var(--mono); font-size: .78em; }
#pchapters .menu-active { position: relative; }
#pchapters .menu-active::before { content: ""; position: absolute;
    left: 0; top: 15%; bottom: 15%; width: 3px; border-radius: 2px;
    background: var(--color-secondary); }

/* ============================ player bar ============================ */
.playerbar { position: fixed; left: 0; right: 0; z-index: 29;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    background: color-mix(in oklab, var(--color-base-200) 97%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--color-neutral); display: none; }
@media (min-width: 768px) { .playerbar { bottom: 0; } }
body.in-player .playerbar { bottom: 0;
    padding-bottom: env(safe-area-inset-bottom); }
body.has-audio .playerbar { display: block; }
.playerbar .in { max-width: 1020px; margin: 0 auto;
    padding: 10px 20px 12px; position: relative; }
#miniprog { position: absolute; top: -1px; left: 0; right: 0; height: 2px;
    border-radius: 0; background: transparent; }
#mini { display: grid; grid-template-columns: 40px 1fr auto; gap: 13px;
    align-items: center; cursor: pointer; min-height: 54px; }
#mini .thumb { width: 40px; height: 56px; border-radius: 2px 5px 5px 2px;
    box-shadow: 0 3px 8px rgba(0,0,0,.5); }
#mini .t1 { font-family: var(--serif); font-size: .93em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mini .t2 { font-size: .76em; margin-top: 3px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
body.in-player #mini { display: none; }
#full { display: none; }
body.in-player #full { display: block; }
.seekwrap { position: relative; padding-top: 2px; }
.ticks { position: absolute; left: 0; right: 0; top: 50%; height: 6px;
    transform: translateY(-50%); pointer-events: none; }
.ticks i { position: absolute; top: 0; width: 1.5px; height: 6px;
    background: color-mix(in oklab, var(--color-base-content) 25%, transparent); }
.times { display: flex; justify-content: space-between;
    font-family: var(--mono); font-size: .76em; margin-top: 4px; }
.transport { display: flex; align-items: center; justify-content: center;
    gap: 14px; margin-top: 6px; }
.auxrow { display: flex; align-items: center; justify-content: center;
    gap: 12px; margin-top: 9px; }

/* ============================ modals (desktop centering) ============ */
@media (min-width: 768px) {
  .modal.modal-bottom { place-items: center; }
  .modal.modal-bottom .modal-box { border-radius: var(--radius-box);
      max-width: 30rem; }
}
.modal-box h3 { font-family: var(--serif); font-weight: 400;
    font-size: 1.15em; margin: 0 0 16px; }
.sheetgrid { display: flex; flex-wrap: wrap; gap: 9px; }
.flagbox { border: 1px solid var(--color-neutral);
    border-radius: calc(var(--radius-box) - 4px); padding: 12px 14px;
    margin-bottom: 10px; font-size: .9em; line-height: 1.55; }
.flagbox .why { font-size: .88em; margin-top: 5px; }
.codechip { font-family: var(--mono); background: var(--color-base-100);
    padding: 6px 10px; border-radius: 8px; user-select: all; }

/* toasts live at the TOP: the bottom edge already carries player bar + dock */
.toast { z-index: 60; }
.toast[hidden] { display: none; }


/* ===================== accessibility layer ===================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
:focus-visible { outline: 2.5px solid var(--color-primary);
    outline-offset: 2px; border-radius: 4px; }
.coverwrap:focus-visible { outline-offset: 4px; }
