/*
  THE DAILY FLOW | Ancient Scroll Edition
  Presentation only. The reader's existing JavaScript, lesson JSON,
  reading progress and all lesson text remain unchanged.
*/

:root {
  --night: #21130f;
  --night-deep: #120b09;
  --mahogany: #402319;
  --wine: #6c3026;
  --gold: #b98b4d;
  --gold-bright: #e4c287;
  --gold-dark: #80592b;
  --paper: #efdbb3;
  --paper-light: #f8ebcb;
  --paper-edge: #b48c57;
  --ink: #382719;
  --ink-soft: #624c37;
  --ink-faint: #7b6044;
  --line: rgba(112, 75, 40, .35);
  --reading-font-size: 19px;
  --manuscript-font: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --text-font: Georgia, "Times New Roman", serif;
  --paper-image: url("parchment-texture.jpg");
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--text-font); }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible {
  outline: 3px solid #e1ac5a;
  outline-offset: 4px;
}

.brand-mark {
  display: block;
  color: var(--gold-bright);
  font-family: var(--manuscript-font);
  font-size: 27px;
  line-height: 1;
  text-shadow: 0 0 18px rgba(237, 174, 73, .35);
  text-align: center;
}

.welcome, .eyebrow, .cover-series, .cover-volume,
.volume-meta, .toolbar-name, .toc-heading, #lesson-number {
  font-family: var(--manuscript-font);
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: .18em;
}

/* ------------------------------------------------------------------
   THE DIGITAL LIBRARY: A SCROLL RESTING ON A DARK ARCHIVE DESK
   ------------------------------------------------------------------ */

.library-page {
  min-height: 100vh;
  color: var(--paper-light);
  background:
    radial-gradient(ellipse at 50% -15%, rgba(142, 84, 36, .35), transparent 65%),
    radial-gradient(circle at 0 100%, rgba(110, 48, 21, .18), transparent 40%),
    repeating-linear-gradient(90deg, rgba(255, 236, 185, .012) 0 1px, transparent 1px 7px),
    linear-gradient(130deg, #302018, #1a100d 55%, #291811);
}

.library-header {
  padding: 32px 20px 29px;
  color: #f0d7a7;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% -30%, #704325, transparent 65%),
    linear-gradient(#321b13, #1e120e);
  border-bottom: 4px double #916c3c;
  box-shadow: 0 10px 25px rgba(0, 0, 0, .25);
}

.library-header h1 {
  margin: 11px 0 9px;
  font-family: var(--manuscript-font);
  font-size: clamp(27px, 4vw, 40px);
  font-variant: small-caps;
  font-weight: normal;
  letter-spacing: .1em;
  text-shadow: 0 2px 12px #100806;
}

.library-header p, .sidebar-brand p {
  margin: 0;
  font-size: 11px;
  letter-spacing: .37em;
  font-weight: bold;
  font-family: var(--manuscript-font);
}

.library-main {
  position: relative;
  width: min(calc(100% - 52px), 940px);
  margin: 55px auto 70px;
  padding: 70px clamp(25px, 6vw, 78px) 45px;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 35%, rgba(255, 249, 218, .44), transparent 70%),
    linear-gradient(90deg, rgba(96, 50, 20, .17), transparent 5%, transparent 95%, rgba(96, 50, 20, .17)),
    var(--paper-image) repeat,
    var(--paper);
  background-size: auto, auto, 768px 768px, auto;
  border: 1px solid #c7a06b;
  outline: 1px solid rgba(227, 188, 116, .7);
  outline-offset: 6px;
  box-shadow:
    0 25px 65px rgba(0, 0, 0, .57),
    inset 0 0 40px rgba(104, 66, 31, .18),
    inset 0 0 0 9px rgba(239, 211, 154, .24),
    inset 0 0 0 11px rgba(132, 91, 47, .30);
}

/* Narrow bands at top and bottom suggest an unfurled scroll. */
.library-main::before, .library-main::after {
  content: "";
  position: absolute;
  left: -11px;
  width: calc(100% + 22px);
  height: 20px;
  border: 1px solid #9b6e37;
  border-radius: 16px;
  background: linear-gradient(180deg, #997040 0%, #d6b37a 22%, #e9cc95 48%, #ad8046 78%, #684422 100%);
  box-shadow: 0 5px 10px rgba(27, 14, 8, .3);
  pointer-events: none;
}
.library-main::before { top: -11px; }
.library-main::after { bottom: -11px; }

.library-heading { text-align: center; }
.welcome { margin: 0; color: var(--wine); font-size: 12px; }
.ornament {
  display: block;
  color: #956638;
  font-size: 36px;
  line-height: 1;
  margin: 20px auto 5px;
}
.library-heading h2 {
  margin: 8px 0 4px;
  font-family: var(--manuscript-font);
  font-weight: normal;
  font-variant: small-caps;
  font-size: clamp(37px, 5vw, 59px);
  line-height: 1.15;
  color: #4b2b1a;
}
.library-intro {
  margin: 12px 0 42px;
  font-size: 21px;
  font-style: italic;
  color: var(--ink-soft);
}

.volume-card {
  display: grid;
  grid-template-columns: 42% minmax(0, 1fr);
  position: relative;
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid #a07946;
  outline: 3px double rgba(130, 88, 45, .55);
  outline-offset: -9px;
  background:
    linear-gradient(135deg, rgba(255, 251, 229, .88), rgba(217, 182, 123, .4)),
    var(--paper-image);
  background-size: auto, 768px 768px;
  box-shadow: 0 14px 32px rgba(66, 37, 20, .24);
  transition: transform .2s ease, box-shadow .2s ease;
}
.volume-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 35px rgba(66, 37, 20, .32);
}
.volume-card-image { min-height: 385px; background: #150804; overflow: hidden; }
.volume-card-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.volume-card-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 46px clamp(22px, 4vw, 45px);
}
.eyebrow { color: var(--wine); font-size: 11px; }
.volume-rule { margin: 15px 0 2px; color: #926232; font-size: 29px; }
.volume-card-content h3 {
  margin: 9px 0 17px;
  color: #51271c;
  font-family: var(--manuscript-font);
  font-variant: small-caps;
  font-size: clamp(29px, 3.25vw, 42px);
  line-height: 1.1;
  font-weight: normal;
}
.volume-card-content > p {
  margin: 0;
  max-width: 390px;
  font-size: clamp(17px, 1.7vw, 20px);
  font-style: italic;
  line-height: 1.5;
  color: #644a32;
}
.volume-meta {
  display: block;
  margin-top: 25px;
  font-size: 11px;
  color: #795333;
}
.open-book {
  display: inline-block;
  margin-top: 24px;
  padding: 12px 20px;
  color: #f5e5be;
  background: linear-gradient(180deg, #643522, #3c2017);
  border: 1px solid #956736;
  box-shadow: inset 0 0 0 1px rgba(239, 195, 112, .18);
  font-family: var(--manuscript-font);
  font-size: 15px;
  letter-spacing: .03em;
}
.volume-card:hover .open-book { background: linear-gradient(180deg, #7e4430, #4c271a); }
.library-closing { margin-top: 42px; color: #9a713c; font-size: 19px; text-align: center; }
.library-footer {
  padding: 10px 20px 35px;
  color: #dfbd89;
  text-align: center;
  font-size: 11px;
  letter-spacing: .23em;
}

/* ------------------------------------------------------------------
   READER: THE CONTENT IS THE MANUSCRIPT; THE SIDEBAR IS THE INDEX
   ------------------------------------------------------------------ */

.reader-page {
  color: var(--ink);
  background: var(--night);
}
.reader-layout { display: grid; grid-template-columns: 303px minmax(0, 1fr); min-height: 100vh; }
.reader-sidebar {
  min-width: 0;
  background:
    linear-gradient(90deg, rgba(120, 76, 39, .15), transparent 12%),
    var(--paper-image) repeat,
    var(--paper);
  background-size: auto, 768px 768px, auto;
  border-right: 3px double #96663c;
}
.sidebar-brand {
  color: #edcf96;
  text-align: center;
  padding: 28px 14px 24px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(158, 94, 41, .34), transparent 75%),
    linear-gradient(#3b2118, #21130e);
  border-bottom: 3px double #a57947;
}
.sidebar-brand h2 {
  margin: 12px 0 7px;
  font-family: var(--manuscript-font);
  font-weight: normal;
  font-variant: small-caps;
  letter-spacing: .07em;
  font-size: 24px;
}
.sidebar-inner { padding: 28px 19px 48px; }
.sidebar-book-title { text-align: center; }
.sidebar-book-title .eyebrow { margin: 0 0 8px; }
.sidebar-book-title h2 {
  margin: 10px 0 13px;
  color: #592c1e;
  font-family: var(--manuscript-font);
  font-weight: normal;
  font-variant: small-caps;
  font-size: 28px;
  line-height: 1.15;
}
.sidebar-book-title > p:last-child { margin: 0; font-size: 15px; font-style: italic; line-height: 1.5; color: var(--ink-soft); }
.sidebar-divider {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 25px 0 20px;
  color: #8d6033;
  font-size: 24px;
}
.sidebar-divider::before, .sidebar-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.toc-heading { margin: 0 0 14px; text-align: center; color: #643d27; font-size: 13px; }
#table-of-contents { display: flex; flex-direction: column; gap: 4px; }
.toc-link {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-bottom-color: rgba(133, 93, 50, .22);
  background: transparent;
  text-align: left;
  color: #4b3322;
  font-family: var(--manuscript-font);
  font-size: 14px;
  line-height: 1.4;
  transition: background .16s ease;
}
.toc-link:hover { background: rgba(146, 92, 39, .13); }
.toc-link.active {
  color: #492014;
  background: rgba(177, 120, 56, .20);
  border-color: rgba(125, 74, 30, .45);
  font-weight: bold;
  box-shadow: inset 3px 0 0 #8d4b2c;
}
.toc-index { min-width: 23px; color: #945d31; font-weight: bold; }
.back-to-library {
  display: block;
  margin-top: 30px;
  padding-top: 19px;
  border-top: 1px solid var(--line);
  color: #66381f;
  text-decoration: none;
  font-family: var(--manuscript-font);
  font-size: 14px;
}
.back-to-library:hover { text-decoration: underline; }

.reader-main {
  min-width: 0;
  background:
    linear-gradient(90deg, rgba(131, 88, 45, .20), transparent 5%, transparent 95%, rgba(131, 88, 45, .16)),
    radial-gradient(ellipse at 50% 35%, rgba(255, 250, 229, .48), transparent 82%),
    var(--paper-image) repeat,
    var(--paper);
  background-size: auto, auto, 768px 768px, auto;
}
.reader-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 13px clamp(15px, 4vw, 38px);
  color: var(--gold-bright);
  background: linear-gradient(135deg, #372017, #24140f);
  border-bottom: 3px double #af8651;
}
.toolbar-name { color: #efd5a6; font-size: 12px; }
.reader-controls { display: flex; flex-wrap: wrap; gap: 9px; }
.reader-controls button {
  min-height: 38px;
  padding: 8px 13px;
  color: #f0d8ad;
  background: #4b2b1d;
  border: 1px solid #a77b4d;
  border-radius: 3px;
  font-family: var(--manuscript-font);
  font-size: 14px;
  font-weight: bold;
}
.reader-controls button:hover { background: #66412a; }

/* The original fiery-tongue artwork stays intact. */
.book-cover {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 445px;
  margin: 24px clamp(17px, 3.5vw, 52px) 0;
  padding: 61px clamp(20px, 5vw, 60px);
  color: #f7e2b9;
  border: 1px solid #9c703d;
  background-image:
    linear-gradient(90deg, rgba(13, 5, 4, .82) 0%, rgba(20, 7, 4, .70) 50%, rgba(16, 6, 4, .28) 100%),
    url("flow-cover.jpg");
  background-position: center, 67% center;
  background-size: cover;
  box-shadow: 0 13px 30px rgba(66, 37, 19, .30);
}
.book-cover::before {
  content: "";
  position: absolute;
  inset: 11px;
  border: 2px solid rgba(224, 180, 102, .68);
  box-shadow: inset 0 0 0 4px rgba(25, 10, 6, .28), 0 0 0 4px rgba(38, 17, 10, .3);
  pointer-events: none;
}
.book-cover::after {
  content: "✧";
  position: absolute;
  bottom: 18px;
  right: 22px;
  color: #d7a95b;
  font-size: 18px;
  pointer-events: none;
}
.cover-content { position: relative; z-index: 1; max-width: 720px; text-align: center; }
.cover-series { margin: 0; font-size: 12px; color: #f0d09d; }
.cover-ornament { display: block; margin: 13px auto 7px; font-size: 24px; color: #e1b265; }
.cover-volume { margin: 0 0 15px; font-size: 15px; color: #e7b76c; }
.cover-content h1 {
  margin: 12px 0 18px;
  font-family: var(--manuscript-font);
  font-weight: normal;
  font-variant: small-caps;
  font-size: clamp(40px, 5.3vw, 76px);
  line-height: 1.04;
  text-shadow: 0 3px 17px #000;
}
.cover-subtitle {
  margin: 0;
  font-size: clamp(18px, 2.1vw, 27px);
  font-style: italic;
  line-height: 1.42;
  color: #f2dec2;
  text-shadow: 0 2px 7px #000;
}
.cover-wave { margin-top: 22px; color: #dfac63; font-size: 35px; }

/* The lesson itself is written on the parchment. */
.lesson-reading-area {
  width: min(calc(100% - 64px), 820px);
  margin: 0 auto;
  padding: 42px 0 72px;
}
.lesson-heading { text-align: center; margin-bottom: 24px; }
.lesson-heading::after { content: "❦"; display: block; margin: 13px auto 0; color: #956c3b; font-size: 28px; }
#lesson-number {
  display: inline-block;
  padding: 9px 27px;
  font-size: 12px;
  color: #6b3421;
  background: rgba(218, 180, 113, .25);
  border-top: 1px solid #9a6b3c;
  border-bottom: 1px solid #9a6b3c;
}
#lesson-content {
  color: var(--ink);
  font-family: var(--text-font);
  font-size: var(--reading-font-size);
  line-height: 1.82;
  overflow-wrap: break-word;
}
#lesson-content article { max-width: 100%; }
#lesson-content h1, #lesson-content h2, #lesson-content h3 { font-family: var(--manuscript-font); }
#lesson-content h1 {
  max-width: 760px;
  margin: 10px auto 36px;
  padding-bottom: 25px;
  color: #592c1b;
  text-align: center;
  font-size: 1.9em;
  line-height: 1.21;
  font-variant: small-caps;
  border-bottom: 3px double #a77a46;
}
#lesson-content h2 {
  margin: 36px 0 16px;
  color: #693a22;
  font-size: 1.25em;
  line-height: 1.35;
  font-variant: small-caps;
}
#lesson-content h3 { margin: 26px 0 12px; color: #693a22; font-size: 1.07em; }
#lesson-content p { margin: 0 0 20px; }
#lesson-content ul, #lesson-content ol { margin: 0 0 24px; padding-left: 1.6em; }
#lesson-content li { margin-bottom: 12px; }
#lesson-content li::marker { color: #8a5631; }
#lesson-content blockquote {
  margin: 22px 0 30px;
  padding: 19px 25px;
  color: #4e3424;
  background: rgba(219, 179, 106, .19);
  border-left: 4px solid #986232;
  border-top: 1px solid rgba(127, 86, 40, .22);
  border-bottom: 1px solid rgba(127, 86, 40, .22);
}
#lesson-content blockquote p:last-child { margin-bottom: 0; }
#lesson-content hr { margin: 30px 0; border: 0; border-top: 1px solid var(--line); }
#lesson-content section:first-of-type > p:first-child:has(strong) {
  padding: 18px 22px;
  background: rgba(221, 181, 111, .20);
  border: 1px solid rgba(145, 91, 45, .48);
}

.reader-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 24px clamp(13px, 4vw, 38px) 30px;
  border-top: 4px double rgba(134, 91, 42, .53);
}
.reader-navigation button {
  padding: 12px 19px;
  color: #f6e4ba;
  background: linear-gradient(180deg, #633c26, #3f2318);
  border: 1px solid #93673d;
  font-family: var(--manuscript-font);
  font-weight: bold;
  font-size: 14px;
}
.reader-navigation button:hover:not(:disabled) { background: #70442c; }
.reader-navigation button:disabled {
  color: #87725b;
  background: rgba(130, 97, 63, .12);
  border-color: rgba(123, 83, 45, .32);
  cursor: not-allowed;
}
#lesson-progress { font-family: var(--manuscript-font); color: #65442c; text-align: center; font-size: 14px; }

/* ------------------------------------------------------------------
   DARK MODE: AN INK-AND-CHARCOAL MANUSCRIPT IN WARM LAMP LIGHT
   ------------------------------------------------------------------ */

.dark-mode.reader-page { --ink: #f0dfbd; --ink-soft: #d5bd98; --ink-faint: #b9a281; --line: rgba(222, 168, 94, .31); }
.dark-mode .reader-sidebar {
  background:
    linear-gradient(rgba(29, 21, 17, .94), rgba(29, 21, 17, .94)),
    var(--paper-image) repeat;
  background-size: auto, 768px 768px;
  border-color: #815b38;
}
.dark-mode .reader-main {
  background:
    linear-gradient(90deg, rgba(8, 5, 4, .4), transparent 7%, transparent 93%, rgba(8, 5, 4, .4)),
    linear-gradient(rgba(36, 27, 21, .94), rgba(36, 27, 21, .94)),
    var(--paper-image) repeat;
  background-size: auto, auto, 768px 768px;
}
.dark-mode .sidebar-book-title h2,
.dark-mode #lesson-content h1,
.dark-mode #lesson-content h2,
.dark-mode #lesson-content h3 { color: #e8c28a; }
.dark-mode .sidebar-book-title > p:last-child,
.dark-mode .toc-heading, .dark-mode .toc-link,
.dark-mode #lesson-content, .dark-mode #lesson-progress { color: #f0dfbd; }
.dark-mode .eyebrow, .dark-mode .toc-index { color: #d4a363; }
.dark-mode .sidebar-divider { color: #c89a5d; }
.dark-mode .toc-link { border-bottom-color: rgba(197, 150, 90, .15); }
.dark-mode .toc-link:hover { background: rgba(174, 121, 69, .15); }
.dark-mode .toc-link.active {
  color: #ffe0ae;
  background: rgba(181, 114, 52, .27);
  border-color: rgba(201, 143, 76, .6);
  box-shadow: inset 3px 0 0 #d7a66b;
}
.dark-mode .back-to-library { color: #e5bf86; }
.dark-mode #lesson-number {
  color: #f5d29e;
  background: rgba(174, 115, 54, .18);
  border-color: #a37b48;
}
.dark-mode .lesson-heading::after { color: #cda46a; }
.dark-mode #lesson-content h1 { border-color: #a97d48; }
.dark-mode #lesson-content li::marker { color: #c59863; }
.dark-mode #lesson-content blockquote,
.dark-mode #lesson-content section:first-of-type > p:first-child:has(strong) {
  color: #f0dfbd;
  background: rgba(177, 118, 58, .13);
  border-color: rgba(202, 150, 81, .65);
}
.dark-mode .reader-navigation { border-color: rgba(202, 150, 81, .44); }
.dark-mode .reader-navigation button:disabled {
  color: #97866f;
  background: #30271f;
  border-color: #5b4531;
}

/* ------------------------------------------------------------------
   COMPACT SCREENS
   ------------------------------------------------------------------ */

@media (max-width: 1000px) {
  .reader-layout { grid-template-columns: 255px minmax(0, 1fr); }
  .sidebar-inner { padding: 23px 13px 35px; }
  .book-cover { min-height: 370px; }
}

@media (max-width: 680px) {
  .library-header { padding: 25px 14px 23px; }
  .library-header h1 { letter-spacing: .05em; }
  .library-main {
    width: calc(100% - 38px);
    margin: 39px auto 50px;
    padding: 50px 18px 36px;
    outline-offset: 3px;
  }
  .library-heading h2 { font-size: clamp(33px, 8vw, 45px); }
  .library-intro { margin-bottom: 28px; }
  .volume-card { grid-template-columns: 1fr; }
  .volume-card-image { min-height: 0; height: 225px; }
  .volume-card-image img { object-position: center 43%; }
  .volume-card-content { padding: 32px 22px 37px; }
  .volume-card-content h3 { font-size: clamp(29px, 7vw, 39px); }
  .reader-layout { display: flex; flex-direction: column; }
  .reader-sidebar { border-right: 0; border-bottom: 3px double #96663c; }
  .sidebar-brand { padding: 18px; }
  .sidebar-inner { padding: 19px 17px 25px; }
  .sidebar-book-title h2 { font-size: 26px; }
  .sidebar-divider { margin: 15px 0 14px; }
  #table-of-contents { max-height: 235px; overflow-y: auto; }
  .reader-toolbar { padding: 11px 13px; }
  .toolbar-name { font-size: 10px; letter-spacing: .11em; }
  .reader-controls { gap: 5px; }
  .reader-controls button { padding: 7px 9px; font-size: 13px; }
  .book-cover {
    min-height: 355px;
    margin: 15px 12px 0;
    padding: 43px 23px;
    background-position: center, 63% center;
  }
  .book-cover::before { inset: 7px; }
  .cover-content h1 { font-size: clamp(37px, 8vw, 53px); }
  .cover-subtitle { font-size: 17px; }
  .cover-series { font-size: 10px; }
  .lesson-reading-area { width: calc(100% - 36px); padding: 30px 0 45px; }
  #lesson-content h1 { font-size: 1.6em; }
  .reader-navigation { padding: 19px 10px 26px; gap: 6px; }
  .reader-navigation button { padding: 10px 8px; font-size: 12px; }
  #lesson-progress { font-size: 12px; }
}

@media (max-width: 370px) {
  .reader-toolbar { flex-wrap: wrap; justify-content: center; }
  .reader-navigation button { font-size: 11px; }
  .reader-navigation { gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .volume-card, .toc-link { transition: none; }
}
