/* ====================================================================
   Reader Stylesheet (Full)
   - Fixed background color (no scrolling gradient)
   - 10 switchable themes (5 dark, 5 light)
   - 5 font-size presets (Small → XX-Large)
   - Mobile friendly, rounded corners, subtle shadows
   - Unicode cog icon (no SVG)
   ==================================================================== */

/* -------- Root tokens (fallbacks) -------- */
:root{
  /* Typography & layout */
  --base-font-size: 16px;        /* overridden by [data-font] */
  --radius-lg: 18px;
  --radius-sm: 12px;
  --gap: 16px;
  --maxw: 980px;

  /* Palette tokens (overridden by themes) */
  --bg: #0f1720;           /* page background */
  --bg-elev: #14212c;      /* card/modal background */
  --ink: #eaf5ff;          /* primary text */
  --muted: #b8d2e8;        /* secondary text */
  --accent: #66b3ff;       /* buttons, links */
  --accent-2: #8cc7ff;     /* button gradient top */
  --line: #1e3a52;         /* borders */
  --summary-bg: #163047;   /* summary bar background */
  --shadow: rgba(0,0,0,.55);

  /* Focus ring */
  --focus: 0 0 0 3px rgba(102,179,255,.5);
}

/* =======================
   FONT SIZE PRESETS
   ======================= */
body[data-font="small"]   { --base-font-size: 14px; }
body[data-font="normal"]  { --base-font-size: 16px; }
body[data-font="large"]   { --base-font-size: 18px; }
body[data-font="xlarge"]  { --base-font-size: 20px; }
body[data-font="xxlarge"] { --base-font-size: 22px; }

/* =======================
   THEME PRESETS (5 dark + 5 light)
   ======================= */

/* DARK THEMES */
body[data-theme="dark1"]{
  --bg:#0f1720; --bg-elev:#14212c; --ink:#eaf5ff; --muted:#b8d2e8;
  --accent:#66b3ff; --accent-2:#8cc7ff; --line:#1e3a52; --summary-bg:#163047; --shadow:rgba(0,0,0,.55);
}
body[data-theme="dark2"]{
  --bg:#0b0f14; --bg-elev:#131b24; --ink:#e8f0fa; --muted:#b7c5d8;
  --accent:#7aa2ff; --accent-2:#a8c0ff; --line:#233142; --summary-bg:#172232; --shadow:rgba(0,0,0,.55);
}
body[data-theme="dark3"]{
  --bg:#121212; --bg-elev:#1e1e1e; --ink:#f1f1f1; --muted:#cfcfcf;
  --accent:#5ec8e5; --accent-2:#92dced; --line:#2a2a2a; --summary-bg:#1a1a1a; --shadow:rgba(0,0,0,.6);
}
body[data-theme="dark4"]{
  --bg:#0d1416; --bg-elev:#152127; --ink:#eaf8f8; --muted:#bfe2e2;
  --accent:#6ad3d3; --accent-2:#9ce6e6; --line:#1a3035; --summary-bg:#193039; --shadow:rgba(0,0,0,.55);
}
body[data-theme="dark5"]{
  --bg:#150f1f; --bg-elev:#221833; --ink:#f4ecff; --muted:#d8c8f0;
  --accent:#b08cff; --accent-2:#c9aaff; --line:#2f2550; --summary-bg:#281e3b; --shadow:rgba(0,0,0,.55);
}

/* LIGHT THEMES */
body[data-theme="light1"]{
  --bg:#e9f3ff; --bg-elev:#ffffff; --ink:#0f2438; --muted:#345a78;
  --accent:#2f7de8; --accent-2:#5aa2ff; --line:#cfe3ff; --summary-bg:#e2eeff; --shadow:rgba(0,0,0,.08);
}
body[data-theme="light2"]{
  --bg:#f7fafc; --bg-elev:#ffffff; --ink:#0d1b2a; --muted:#3d5a80;
  --accent:#457b9d; --accent-2:#5fa8d3; --line:#e6edf5; --summary-bg:#eef3f8; --shadow:rgba(0,0,0,.08);
}
body[data-theme="light3"]{
  --bg:#fff7f0; --bg-elev:#ffffff; --ink:#332515; --muted:#7d6247;
  --accent:#f2994a; --accent-2:#f6b27a; --line:#ffe7cf; --summary-bg:#fff0e3; --shadow:rgba(0,0,0,.08);
}
body[data-theme="light4"]{
  --bg:#f6fff9; --bg-elev:#ffffff; --ink:#0e2a1a; --muted:#36624c;
  --accent:#2cb67d; --accent-2:#71d4a9; --line:#e0f2e9; --summary-bg:#eafaf2; --shadow:rgba(0,0,0,.08);
}
body[data-theme="light5"]{
  --bg:#fff4fb; --bg-elev:#ffffff; --ink:#2a0e22; --muted:#6b3f5d;
  --accent:#e66fb1; --accent-2:#f19fcd; --line:#ffe0f2; --summary-bg:#ffeaf6; --shadow:rgba(0,0,0,.08);
}

/* =======================
   GLOBAL / RESET
   ======================= */
*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-size: var(--base-font-size);        /* font size driven by data-font */
  font-family: Aptos, "Segoe UI", -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background: var(--bg);                    /* fixed background color */
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.modal-open{ overflow:hidden; }         /* prevent scroll when modal open }

/* Visually-hidden helper (for screen-reader only text, if needed) */
.sr-only{
  position:absolute !important;
  width:1px; height:1px; padding:0; margin:-1px; overflow:hidden;
  clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

/* =======================
   HEADER
   ======================= */
.site-header{
  display:flex; justify-content:center; padding:24px 16px 8px;
}
.hero{
  width:100%; max-width:var(--maxw); text-align:center;
}
.site-title{
  margin:18px 0 6px;
  font-family: "Gabriela", serif;
  font-size: clamp(28px, 4.5vw, 46px);
  letter-spacing:.3px;
  color: var(--ink);
  text-shadow: 0 2px 8px rgba(0,0,0,.35);
  display:flex; gap:10px; align-items:center; justify-content:center;
}
.title-trigger{
  appearance:none; background:none; border:none; cursor:pointer;
  color:inherit; font: inherit; padding:0; text-align:center;
}
.title-trigger:hover{ text-decoration: underline; text-underline-offset: 4px; }

/* Cog trigger (Unicode icon) */
.cog-trigger{
  appearance:none; border:none; background: transparent; cursor:pointer;
  border-radius: 999px; padding:6px;
  min-width: 36px; min-height: 36px;           /* touch target */
  display:inline-grid; place-items:center;
  transition: transform .15s ease, background .2s ease, filter .2s ease, box-shadow .2s ease;
}
.cog-trigger:hover{ background: var(--bg-elev); }
.cog-trigger:active{ transform: translateY(10px); }  /* click anim */
.cog-trigger:focus-visible{ outline:none; box-shadow: var(--focus); }

.cog-symbol{
  display:block; line-height:1; font-size: 22px;
  color: var(--accent);
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.4));
}

.site-subtitle{
  margin:0 0 16px;
  color: var(--muted);
}

/* =======================
   BUTTONS
   ======================= */
.btn{
  appearance: none; border:none; cursor:pointer;
  padding: 10px 16px; border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color:#041d2f; font-weight:700;
  box-shadow: 0 6px 18px rgba(0,0,0,.2), inset 0 1px 0 #ffffff66;
  transition: transform .15s ease, filter .2s ease, box-shadow .2s ease;
  will-change: transform;
}
.btn:hover{ filter: brightness(1.08); }
.btn:active{ transform: translateY(10px); } /* click animation */
.btn:focus-visible{ outline: none; box-shadow: var(--focus); }

.btn-secondary{
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-elev));
  color: var(--ink);
  border: 1px solid var(--line);
}

/* =======================
   CONTENT
   ======================= */
.content{
  margin: 16px auto 40px; padding: 0 16px; max-width: var(--maxw);
}
.card{
  margin-bottom: var(--gap);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px var(--shadow);
  overflow:hidden;
}
details > summary{
  list-style:none;
  padding: 16px 18px;
  background: var(--summary-bg);
  color: var(--ink);
  font-family: "Gabriela", serif;
  font-size: clamp(18px, 3.5vw, 24px);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  position: relative;
  user-select: none;
}
details > summary::-webkit-details-marker{ display:none; }
details > summary::after{
  content: "▸";
  position:absolute; right:16px; top:50%; transform: translateY(-50%) rotate(0deg);
  transition: transform .25s ease;
  color: var(--accent);
  font-size: 18px;
}
details[open] > summary::after{ transform: translateY(-50%) rotate(90deg); }

.card-body{
  padding: 14px 18px 18px;
  animation: fadeIn .25s ease both;
}
.card-body p, .card-body li{ color: #e8f3ff; }
body[data-theme^="light"] .card-body p,
body[data-theme^="light"] .card-body li{ color: #1b2a3a; }
.card-body strong{ color: var(--ink); }
.card-body ol, .card-body ul{ margin:8px 0 8px 22px; }
.card-body li{ margin: 4px 0; }

/* =======================
   FOOTER
   ======================= */
.site-footer{
  text-align:center; color: var(--muted); padding: 32px 16px;
}

/* =======================
   MODAL (Settings)
   ======================= */
.modal{
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}
.modal[aria-hidden="false"]{
  pointer-events: auto; opacity: 1;
}
.modal-backdrop{
  position:absolute; inset:0; background: rgba(0,0,0,.55);
}
.modal-card{
  position: relative;
  width: min(720px, calc(100% - 32px));
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 48px var(--shadow);
  padding: 18px;
}
.modal-title{
  margin: 4px 4px 12px;
  font-family: "Gabriela", serif;
  font-size: clamp(20px, 4vw, 28px);
  color: var(--ink);
  text-align: center;
}
.settings-group{ margin: 12px 0 16px; }
.settings-label{
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing:.4px;
  color: var(--muted);
}

/* Font size chips */
.chip-row{ display:flex; flex-wrap:wrap; gap:8px; }
.chip{
  appearance:none; border:1px solid var(--line); background: var(--bg);
  color: var(--ink); border-radius: 999px; padding:8px 12px; cursor:pointer;
  transition: transform .15s ease, background .2s ease, filter .2s ease;
}
.chip:hover{ filter: brightness(1.06); }
.chip:active{ transform: translateY(10px); }

/* Theme swatches: grid of 10 (pronounced previews) */
.theme-grid{
  display:grid;
  grid-template-columns: repeat(5, 1fr);
  gap:10px;
}

.theme-swatch{
  position: relative;
  width:100%;
  aspect-ratio: 16/10;
  border-radius: var(--radius-sm);
  border:2px solid var(--line);
  cursor:pointer;
  transition: transform .15s ease, filter .2s ease, box-shadow .2s ease, outline-color .2s ease;
  box-shadow: 0 4px 14px var(--shadow);
  background: var(--sw-bg, #111); /* base color per swatch (set below) */
  outline: 0 solid transparent;
}

/* Inner “card” + split BG for strong contrast */
.theme-swatch::before{
  content:"";
  position:absolute; inset:6px;
  border-radius: calc(var(--radius-sm) - 6px);
  border: 1px solid #00000022;
  /* diagonal split: top-left is elevated card, bottom-right is page bg */
  background:
    linear-gradient(155deg, var(--sw-elev, #222) 0 62%, var(--sw-bg, #111) 62% 100%);
  /* faint “text lines” preview for legibility cue */
  box-shadow:
    inset 0 18px 0 0 rgba(255,255,255,.06),
    inset 0 -18px 0 0 rgba(255,255,255,.08);
}

/* Accent dot */
.theme-swatch::after{
  content:"";
  position:absolute; right:10px; bottom:10px;
  width:18px; height:18px; border-radius:50%;
  background: var(--sw-accent, #4aa3ff);
  box-shadow: 0 0 0 2px #00000055, 0 6px 10px #0006;
}

/* Hover/focus/selected states */
.theme-swatch:hover,
.theme-swatch:focus-visible{
  filter: brightness(1.05);
  outline: 3px solid var(--sw-accent, #4aa3ff);
  outline-offset: 2px;
}
.theme-swatch.is-selected{
  outline: 3px solid var(--sw-accent, #4aa3ff);
  outline-offset: 2px;
  box-shadow: 0 6px 16px #0009;
}

/* Per-swatch preview variables (make each box clearly different) */
.theme-swatch[data-theme="dark1"] { --sw-bg:#0f1720; --sw-elev:#14212c; --sw-accent:#66b3ff; }
.theme-swatch[data-theme="dark2"] { --sw-bg:#0b0f14; --sw-elev:#131b24; --sw-accent:#7aa2ff; }
.theme-swatch[data-theme="dark3"] { --sw-bg:#121212; --sw-elev:#1e1e1e; --sw-accent:#5ec8e5; }
.theme-swatch[data-theme="dark4"] { --sw-bg:#0d1416; --sw-elev:#152127; --sw-accent:#6ad3d3; }
.theme-swatch[data-theme="dark5"] { --sw-bg:#150f1f; --sw-elev:#221833; --sw-accent:#b08cff; }

.theme-swatch[data-theme="light1"]{ --sw-bg:#e9f3ff; --sw-elev:#ffffff; --sw-accent:#2f7de8; }
.theme-swatch[data-theme="light2"]{ --sw-bg:#f7fafc; --sw-elev:#ffffff; --sw-accent:#457b9d; }
.theme-swatch[data-theme="light3"]{ --sw-bg:#fff7f0; --sw-elev:#ffffff; --sw-accent:#f2994a; }
.theme-swatch[data-theme="light4"]{ --sw-bg:#f6fff9; --sw-elev:#ffffff; --sw-accent:#2cb67d; }
.theme-swatch[data-theme="light5"]{ --sw-bg:#fff4fb; --sw-elev:#ffffff; --sw-accent:#e66fb1; }

.modal-actions{
  display:flex; justify-content:center; gap:10px; margin-top: 12px;
}

/* =======================
   ANIMATIONS
   ======================= */
@keyframes fadeIn{
  from{ opacity:0; transform: translateY(-4px); }
  to{ opacity:1; transform: translateY(0); }
}

/* =======================
   RESPONSIVE
   ======================= */
@media (min-width: 700px){
  .card-body{ padding: 18px 22px 22px; }
}
@media (max-width: 480px){
  .btn{ padding: 12px 18px; }
}
