/* ============================================================
   DramaFlash — shared design tokens
   Dark-first palette from the marketing spec, token discipline
   from the ZhiYa app (every colour goes through a variable).
   ============================================================ */

/* Self-hosted so the page never blocks on a font CDN (testers may be on
   networks where fonts.googleapis.com is unreachable). Variable 400-800. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
}

:root {
  /* surfaces */
  --bg: #0F0F11;
  --bg-2: #141417;
  --card: #1C1C21;
  --card-2: #232329;
  --elev: #2A2A32;
  --line: #2E2E37;
  --line-2: #3A3A45;

  /* ink */
  --ink: #FFFFFF;
  --ink-2: #E4E4EA;
  --muted: #B2B2B8;
  --muted-2: #8A8A93;
  --on-primary: #FFFFFF;
  --on-secondary: #FFFFFF;

  /* brand */
  --primary: #D92525;
  --primary-deep: #A81A1A;
  --primary-hi: #F03A3A;
  --primary-soft: rgba(217, 37, 37, .14);
  --primary-line: rgba(217, 37, 37, .42);

  /* text-coloured variants: the brand colours themselves are too dark to read
     on the dark ground, so ink uses these and fills use the brand ones */
  --link: #7FA6FF;
  --accent-text: #FF7070;
  --cover-plate: #141418;

  --secondary: #165DFF;
  --secondary-deep: #0E45C4;
  --secondary-soft: rgba(22, 93, 255, .14);
  --secondary-line: rgba(22, 93, 255, .40);

  /* status */
  --ok: #2FA36B;
  --ok-soft: rgba(47, 163, 107, .14);
  --warn: #E0A458;
  --warn-soft: rgba(224, 164, 88, .14);
  --bad: #D92525;
  --bad-soft: rgba(217, 37, 37, .14);
  --neutral-soft: rgba(178, 178, 184, .12);

  /* cover art (procedural, no external images) */
  --cover-1: #3A1220;
  --cover-2: #16233F;
  --cover-3: #1E3329;
  --cover-4: #3A2C12;

  /* radii — spec: card 12 / button 8 */
  --r-card: 12px;
  --r-btn: 8px;
  --r-pill: 999px;
  --r-sm: 8px;

  /* shadow — kept low, spec says "no shadows overdone" */
  --sh-card: 0 8px 22px -18px rgba(0, 0, 0, .9);
  --sh-pop: 0 20px 48px -22px rgba(0, 0, 0, .92), 0 0 0 1px var(--line);

  /* spacing */
  --pad-x: 16px;          /* spec: mobile safe margin */
  --gap: 12px;
  --tabbar-h: 60px;

  /* motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 130ms;
  --t: 220ms;

  /* type — Inter, US market. Readability floor: body 15, meta 13 */
  --font: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-h1: 22px;
  --fs-h2: 18px;
  --fs-h3: 16px;
  --fs-body: 15px;
  --fs-meta: 13px;
  --fs-chip: 13px;
  --lh: 1.55;
}

/* Light variant. Same variable names, so any screen can flip. */
html.light {
  --bg: #F6F6F8;
  --bg-2: #FFFFFF;
  --card: #FFFFFF;
  --card-2: #F1F1F4;
  --elev: #E7E7EC;
  --line: #DFDFE6;
  --line-2: #CBCBD5;

  --ink: #14141A;
  --ink-2: #33333C;
  --muted: #5C5C67;
  --muted-2: #6A6A76;
  --on-primary: #FFFFFF;
  --link: #165DFF;
  --accent-text: #B31515;
  --cover-plate: #141418;

  --primary-soft: rgba(217, 37, 37, .10);
  --secondary-soft: rgba(22, 93, 255, .10);

  --cover-1: #F3E3E8;
  --cover-2: #E2E8F5;
  --cover-3: #E1EFE6;
  --cover-4: #F3EBDA;

  --sh-card: 0 8px 22px -18px rgba(20, 20, 26, .5);
  --sh-pop: 0 20px 48px -22px rgba(20, 20, 26, .45), 0 0 0 1px var(--line);
}

* { box-sizing: border-box; }

/* An author rule that sets display beats the UA sheet's [hidden]{display:none},
   so every .fatal / .err-line / .sheet with its own display was painting while the
   app believed it was closed. The attribute is the only hide switch this codebase
   uses, so it has to win. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body { overscroll-behavior-y: none; }

a { color: var(--secondary); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; }

/* ------------------------------------------------------------
   Atoms shared by H5 and admin
   ------------------------------------------------------------ */

.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 28px; height: 28px; }
.icon.fill { fill: currentColor; stroke: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;          /* tap target floor */
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  background: var(--card-2);
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 600;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hi); }
.btn.secondary { background: var(--secondary); color: var(--on-secondary); }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn.quiet { background: transparent; color: var(--muted); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: var(--fs-meta); }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--muted);
  font-size: var(--fs-chip);
  white-space: nowrap;
  cursor: pointer;
}
/* a red tint behind white text is unreadable on a white page, so the
   active chip takes the solid fill in the light theme instead */
html.light .chip.active { background: var(--primary); color: #fff; }

.chip.active {
  border-color: var(--primary-line);
  background: var(--primary-soft);
  color: var(--ink);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--neutral-soft);
  color: var(--muted);
  font-size: var(--fs-meta);
  font-weight: 500;
  line-height: 1.5;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.blue { background: var(--secondary-soft); color: var(--secondary); }

/* Red numeric badge — ZhiYa pattern: badge carries only the number,
   the words live in title/aria-label so it can never be clipped. */
.badge {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--primary);
  color: #FFF6F2;
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--card);
}

.field { display: block; margin-bottom: 14px; }
.field > label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: var(--fs-meta);
  font-weight: 500;
}
.field .ctl {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-btn);
  background: var(--bg-2);
  color: var(--ink);
  font-size: var(--fs-body);
}
.field .ctl:focus { outline: 2px solid var(--secondary); outline-offset: -1px; }
.field .hint { display: block; margin-top: 6px; color: var(--muted-2); font-size: var(--fs-meta); }
.field .err { display: block; margin-top: 6px; color: var(--bad); font-size: var(--fs-meta); }

.empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}
.empty .ico { opacity: .5; margin-bottom: 10px; }
.empty p { margin: 0; font-size: var(--fs-body); line-height: 1.6; }

/* Cover art: no external images in the prototype — each drama paints a
   procedural gradient from its own category, so nothing is ever a blank box. */
.cover {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(255, 255, 255, .16), transparent 60%),
    linear-gradient(140deg, var(--c1), var(--c2));
}
.cover::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, .55));
}
.cover .cover-mark {
  position: absolute;
  left: 10px;
  bottom: 8px;
  z-index: 2;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  background: var(--cover-plate);
  font-size: var(--fs-h2);
  font-weight: 700;
  letter-spacing: .2px;
  color: #fff;
}
.cover .cover-cat {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 2;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  background: var(--cover-plate);
  color: #fff;
  font-size: var(--fs-meta);
  font-weight: 600;
}

/* Sheet / modal */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 6, 8, .72);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease);
}
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay .sheet {
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
  box-shadow: var(--sh-pop);
  transform: translateY(14px) scale(.99);
  transition: transform var(--t) var(--ease);
}
.overlay.show .sheet { transform: none; }

/* Toast — ZhiYa rule: every successful action must be visibly acknowledged */
#toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  z-index: 90;
  max-width: 88vw;
  padding: 11px 18px;
  border-radius: var(--r-pill);
  background: var(--elev);
  color: var(--ink);
  border: 1px solid var(--line-2);
  box-shadow: var(--sh-pop);
  font-size: var(--fs-meta);
  text-align: center;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--primary-deep); border-color: var(--primary); color: #fff; }

.sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
