/* ==========================================================================
   Larisa Chalichuk — Classic Fine-Press Premium Sample Reader
   ========================================================================== */

:root {
  --bg: #F9F8F4;
  --surface: #EFEEE9;
  --ink: #1D2124;
  --ink-soft: #3D4246;
  --muted: #5D6057;
  --hairline: #DDD9D0;
  --accent: #202A30;
  --foil: #8C6616;
  --serif: 'Newsreader', Georgia, serif;
  --sans: 'Golos Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --reader-size: 19px;
}

[data-theme="sepia"] {
  --bg: #F3ECE0;
  --surface: #E9DFCE;
  --ink: #262018;
  --ink-soft: #43392D;
  --muted: #675A4C;
  --hairline: #D7CBB8;
  --accent: #362C22;
  --foil: #876015;
}

[data-theme="night"] {
  --bg: #1A2227;
  --surface: #222C32;
  --ink: #F2F0EA;
  --ink-soft: #D6D3CB;
  --muted: #A4ACB2;
  --hairline: rgba(242, 240, 234, 0.14);
  --accent: #F2F0EA;
  --foil: #E4C272;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background-color 0.25s ease, color 0.25s ease;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--foil); outline-offset: 2px; }

/* Progress hairline */
.reader-rail {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 120; pointer-events: none;
}
.reader-rail__fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--foil));
  transform-origin: left center; transform: scaleX(0);
}

/* Top bar */
.reader-bar {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.reader-bar__inner {
  max-width: 980px; margin: 0 auto; padding: 0 clamp(14px, 3.6vw, 32px);
  height: 62px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.reader-back {
  font-size: 11px; font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.reader-back:hover { color: var(--ink); }
.reader-back__short { display: none; }

.reader-bar__title {
  font-family: var(--serif); font-size: 17px; font-weight: 300;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

.reader-tools {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.tool-grp {
  display: inline-flex; align-items: center;
  border: 1px solid var(--hairline); border-radius: 2px; overflow: hidden;
  background: var(--surface);
}
.tool-grp button {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 9px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--muted); white-space: nowrap;
}
.tool-grp button.is-on {
  background: var(--accent); color: var(--bg);
}
.tool-grp button:disabled { opacity: 0.35; cursor: not-allowed; }

/* Main book sheet */
.reader-sheet {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(40px, 6.5vw, 84px) clamp(20px, 5vw, 44px) 96px;
}

/* Half-title frontispiece */
.reader-front {
  text-align: center;
  padding-bottom: 40px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--hairline);
  display: flex; flex-direction: column; align-items: center; gap: 13px;
}
.reader-front__emblem {
  width: 88px; height: auto; opacity: 0.92;
}
[data-theme="night"] .reader-front__emblem { filter: invert(0.92) hue-rotate(180deg); }

.reader-front__kicker {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.17em; text-transform: uppercase;
  color: var(--foil);
}
.reader-front__title {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(32px, 4.8vw, 50px); line-height: 1.08; letter-spacing: -0.02em;
  margin: 0;
}
.reader-front__author {
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
.reader-front__badge {
  display: inline-block; margin-top: 4px;
  padding: 6px 14px; border: 1px solid var(--hairline); border-radius: 2px;
  background: var(--surface); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
}

/* Prose body */
.reader-prose {
  font-family: var(--serif);
  font-size: var(--reader-size);
  line-height: 1.78;
  color: var(--ink-soft);
}
.reader-prose h2 {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(26px, 3.4vw, 35px); line-height: 1.16;
  color: var(--ink);
  margin: 2.2em 0 0.7em;
  padding-top: 1.2em;
  border-top: 1px solid var(--hairline);
}
.reader-prose h2:first-child {
  margin-top: 0; padding-top: 0; border-top: none;
}
.reader-prose h3 {
  font-family: var(--serif); font-weight: 400; font-style: italic;
  font-size: 1.24em; color: var(--ink);
  margin: 1.6em 0 0.55em;
}
.reader-prose p {
  margin: 0 0 1.08em;
}
.reader-prose p + p {
  clear: left;
}
.reader-prose p.is-dropcap::first-letter {
  font-family: var(--serif);
  float: left;
  font-size: 3.4em;
  line-height: 0.85;
  padding: 5px 10px 0 0;
  font-weight: 300;
  color: var(--foil);
}
.reader-prose blockquote {
  margin: 1.5em 0;
  padding: 15px 20px;
  border-left: 2px solid var(--foil);
  background: var(--surface);
  font-style: italic;
  color: var(--ink);
}
.reader-prose .reader-content-note {
  margin: 1.25em 0 1.05em;
  padding: 11px 16px;
  background: var(--surface);
  border-left: 2px solid var(--foil);
  border-radius: 2px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}
.reader-prose .quiz-block {
  margin: 0 0 1.15em;
  padding: 14px 18px;
  background: var(--surface);
  border-left: 2px solid var(--hairline);
  border-radius: 2px;
  white-space: pre-line;
  line-height: 1.68;
}
.reader-prose .reader-dialogue {
  margin: 0 0 1.0em;
  padding-left: 16px;
  border-left: 1.5px solid var(--hairline);
  color: var(--ink);
}

/* Living Plate (Frame A <-> Frame B) */
.living-plate {
  margin: 2.3em 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 2px;
}
.living-plate__frame {
  position: relative; overflow: hidden; border-radius: 2px; cursor: pointer;
  background: #F4F1EA;
}
.living-plate__frame img {
  display: block; width: 100%; height: auto;
  transition: opacity 0.9s ease;
}
.living-plate__frame img.frame-b {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0;
}
.living-plate.is-living .living-plate__frame img.frame-b { opacity: 1; }
.living-plate__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; font-family: var(--sans); font-size: 12.5px; color: var(--muted);
}
.living-plate__btn {
  appearance: none; background: transparent;
  border: 1px solid var(--hairline); border-radius: 2px;
  padding: 6px 12px; cursor: pointer;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink);
}
.living-plate__btn:hover { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* Infographic Plate (adapted cleanly for Day, Warm, and Evening modes) */
.infographic-plate {
  margin: 2.3em 0;
  padding: 18px;
  background: #FAF8F2;
  border: 1px solid var(--hairline);
  border-radius: 2px;
  color: #4A4E52;
}
[data-theme="night"] .infographic-plate {
  background: #273239;
  border-color: rgba(228, 194, 114, 0.24);
  color: var(--muted);
}
[data-theme="night"] .infographic-plate img {
  border-radius: 2px;
  filter: brightness(0.92) contrast(0.96);
}
.infographic-plate img {
  width: 100%; height: auto; display: block;
}
.infographic-plate figcaption {
  margin-top: 12px; font-family: var(--sans); font-size: 12px; text-align: center; color: inherit;
}

/* End-of-Sample Curtain + Honest Companion Access Box */
.sample-end {
  margin-top: 52px;
  padding: clamp(24px, 4vw, 40px);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-top: 2px solid var(--foil);
  border-radius: 2px;
}
.sample-end__grid {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 24px; align-items: center;
}
.sample-end h3 {
  font-family: var(--serif); font-weight: 300; font-size: clamp(24px, 3vw, 31px);
  line-height: 1.15; margin: 10px 0 12px;
}
.sample-end p {
  font-size: 15px; line-height: 1.65; color: var(--ink-soft); margin: 0 0 18px;
}

.companion-access-box {
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 2px;
  padding: 20px 18px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.companion-access-icon {
  width: 56px; height: 56px; border-radius: 50%;
  border: 1px solid var(--foil);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
}
.companion-access-caption {
  font-size: 12px; line-height: 1.5; color: var(--muted); max-width: 26ch;
}

.sample-btns {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.r-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 18px; border-radius: 2px; min-height: 42px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  border: 1px solid var(--accent); cursor: pointer;
}
.r-btn--primary { background: var(--accent); color: var(--bg); }
.r-btn--outline { background: transparent; color: var(--ink); border-color: var(--hairline); }

@media (max-width: 720px) {
  .reader-bar__title { display: none; }
  .sample-end__grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .reader-back__full { display: none; }
  .reader-back__short { display: inline; }
  .tool-grp button { padding: 6px 7px; font-size: 10px; letter-spacing: 0.04em; }
}
