/* NeoWise Stories — shared styles
   One family (Fraunces, variable optical size) does both display and reading. */

:root {
  --ink: #121827;        /* night */
  --ink-2: #0d1220;
  --panel: #1b2336;      /* deep panel */
  --line: #2c3753;
  --cream: #efe6d3;      /* comet cream */
  --cream-dim: #c9c0ad;
  --dusk: #8a96ad;
  --ember: #e3a04a;      /* hearth ember */
  --ember-hi: #f2bd6e;
  --ember-lo: #a9701f;
  --danger: #e98a7a;
  --radius-s: 6px;
  --radius-l: 18px;
  --measure: 38rem;
  --page: 64rem;
  --font: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font);
  font-optical-sizing: auto;
  font-size: 1.125rem;
  line-height: 1.6;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--ember-hi); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--cream); }
:focus-visible { outline: 2px solid var(--ember-hi); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--ember); color: var(--ink); }

.wrap { width: 100%; max-width: var(--page); margin: 0 auto; padding: 0 1.25rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ header */
.site-header { position: relative; z-index: 5; }
.site-header .wrap { display: flex; align-items: center; gap: 1.5rem; padding-top: 1.1rem; padding-bottom: 1.1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--cream); text-decoration: none; margin-right: auto; }
.brand svg { width: 38px; height: 38px; color: var(--cream); }
.brand-name { font-size: 1.3rem; font-weight: 500; letter-spacing: .005em; font-variation-settings: "SOFT" 100, "WONK" 1; line-height: 1; }
.brand-name small { display: block; font-size: .72rem; color: var(--dusk); font-weight: 400; letter-spacing: .02em; margin-top: .25rem; font-variation-settings: "SOFT" 50, "WONK" 0; }
.nav { display: flex; gap: 1.25rem; align-items: center; font-size: 1rem; }
.nav a { color: var(--cream-dim); text-decoration: none; padding: .25rem 0; border-bottom: 1px solid transparent; }
.nav a:hover { color: var(--cream); }
.nav a[aria-current="page"] { color: var(--cream); border-bottom-color: var(--ember); }
@media (max-width: 720px) {
  .site-header .wrap { gap: .6rem 1rem; }
  .nav { width: 100%; overflow-x: auto; gap: 1.1rem; font-size: .95rem; padding-bottom: .2rem; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }
}

/* ------------------------------------------------------------------ hearth (hero backdrop) */
.hearth { position: relative; isolation: isolate; }
.hearth::before {
  content: ""; position: absolute; inset: -14rem 0 0 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(18,24,39,.55) 0%, rgba(18,24,39,.72) 45%, var(--ink) 100%),
    url("hearth.webp") center 60% / cover no-repeat;
}
/* Same fade, different firesides */
.hearth-library::before {
  background:
    linear-gradient(180deg, rgba(18,24,39,.5) 0%, rgba(18,24,39,.7) 50%, var(--ink) 100%),
    url("hearth-library.webp") center 70% / cover no-repeat;
}
.hearth-about::before {
  background:
    linear-gradient(180deg, rgba(18,24,39,.5) 0%, rgba(18,24,39,.7) 50%, var(--ink) 100%),
    url("hearth-about.webp") center 65% / cover no-repeat;
}
.hearth .page-head { padding-top: clamp(3rem, 10vh, 6.5rem); padding-bottom: clamp(2.5rem, 8vh, 5rem); }

main { flex: 1; }

/* ------------------------------------------------------------------ sentence form */
.teller { padding-top: clamp(2.5rem, 8vh, 6rem); padding-bottom: clamp(2.5rem, 7vh, 5rem); }
.teller-sentence {
  font-size: clamp(1.75rem, 4.6vw, 3.05rem);
  line-height: 1.36;
  font-weight: 340;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  max-width: 21em;
  margin: 0;
  text-wrap: pretty;
}
.pick {
  position: relative; display: inline-block; vertical-align: baseline;
}
.pick select {
  appearance: none; -webkit-appearance: none;
  font: inherit; color: var(--ember-hi); background: transparent;
  border: 0; border-bottom: 2px dashed rgba(227,160,74,.75);
  padding: 0 .05em .02em; margin: 0; border-radius: 0; cursor: pointer;
  line-height: 1.15; font-style: italic;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
.pick select:hover { color: var(--cream); border-bottom-color: var(--cream); }
.pick select:focus-visible { outline: 2px solid var(--ember-hi); outline-offset: 4px; }
.pick select option { font-style: normal; color: #111; background: #fff; }
.sizer { position: absolute; visibility: hidden; white-space: pre; font: inherit; font-style: italic; }

.teller-actions { display: flex; align-items: center; gap: 1.25rem; margin-top: 2.25rem; flex-wrap: wrap; }
.teller-note { color: var(--dusk); font-size: .95rem; margin: 1rem 0 0; max-width: 34rem; }

/* ------------------------------------------------------------------ buttons */
.btn {
  font: inherit; font-size: 1.05rem; line-height: 1;
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .9rem 1.35rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--cream);
  text-decoration: none; transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--cream-dim); color: var(--cream); }
.btn svg { width: 1.1em; height: 1.1em; flex: none; }
.btn-primary { background: var(--ember); border-color: var(--ember); color: #1a1206; font-weight: 600; }
.btn-primary:hover { background: var(--ember-hi); border-color: var(--ember-hi); color: #1a1206; }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn-quiet { border-color: transparent; padding-left: .2rem; padding-right: .2rem; color: var(--cream-dim); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line); }
.btn-quiet:hover { border-color: transparent; text-decoration-color: var(--ember); }

/* ------------------------------------------------------------------ story page */
.story { padding-top: 1rem; padding-bottom: 4rem; }
.story-inner { max-width: var(--measure); }
.story-title {
  font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.12; font-weight: 420;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  margin: 0 0 .9rem; text-wrap: balance;
}
.ingredients { color: var(--dusk); font-size: .98rem; margin: 0 0 2.2rem; max-width: var(--measure); }
.ingredients b { color: var(--cream-dim); font-weight: 500; }
.story-text { font-size: 1.2rem; line-height: 1.78; font-weight: 360; }
.story-text p { margin: 0 0 1.15em; }
.story-text p:first-child::first-letter {
  float: left; font-size: 3.6em; line-height: .86; padding: .06em .12em 0 0;
  color: var(--ember-hi); font-weight: 500; font-variation-settings: "SOFT" 100, "WONK" 1;
}
.story-text.is-streaming p:last-child::after {
  content: ""; display: inline-block; width: .5em; height: .5em; margin-left: .3em; border-radius: 50%;
  background: var(--ember); box-shadow: 0 0 12px 3px var(--ember); animation: ember 1.1s ease-in-out infinite;
}
@keyframes ember { 50% { opacity: .35; transform: scale(.75); } }
.status-line { color: var(--dusk); font-style: italic; margin: 0 0 1.5rem; }
.error-line { color: var(--danger); margin: 0 0 1.5rem; }

.story-tools { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 2.4rem 0 0; padding-top: 1.6rem; border-top: 1px solid var(--line); }
.feedback { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.feedback p { margin: 0 .75rem 0 0; color: var(--cream-dim); }
.chip { font: inherit; font-size: .95rem; padding: .5rem .95rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--cream-dim); cursor: pointer; }
.chip:hover { color: var(--cream); border-color: var(--cream-dim); }
.chip[aria-pressed="true"] { background: var(--panel); color: var(--cream); border-color: var(--ember); }

/* ------------------------------------------------------------------ player */
.player {
  position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 10;
  margin: 2rem 0 0; padding: .75rem 1.1rem .75rem .75rem;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "play title amb" "play seek amb";
  gap: .1rem 1rem; align-items: center;
  background: rgba(27,35,54,.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius-l);
  box-shadow: 0 18px 40px -18px rgba(0,0,0,.7);
}
.play-btn {
  grid-area: play; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ember); color: #1a1206; display: grid; place-items: center;
}
.play-btn:hover { background: var(--ember-hi); }
.play-btn svg { width: 22px; height: 22px; }
.play-btn .i-pause { display: none; }
.player.is-playing .play-btn .i-play { display: none; }
.player.is-playing .play-btn .i-pause { display: block; }
.player.is-loading .play-btn { opacity: .7; }
.player-title { grid-area: title; font-size: .95rem; color: var(--cream-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: end; }
.seek-row { grid-area: seek; display: flex; align-items: center; gap: .6rem; min-width: 0; }
.time { font-size: .85rem; color: var(--dusk); font-variant-numeric: tabular-nums; min-width: 2.6em; }
.ambience { grid-area: amb; display: flex; align-items: center; gap: .4rem; color: var(--dusk); font-size: .85rem; }
.ambience button { background: none; border: 0; color: inherit; cursor: pointer; padding: .3rem; display: grid; place-items: center; border-radius: 6px; }
.ambience button svg { width: 20px; height: 20px; }
.ambience.is-off { opacity: .5; }
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; width: 100%; height: 24px; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--ember) var(--fill, 0%), var(--line) var(--fill, 0%)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--ember); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--cream); margin-top: -5px; border: 0; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--cream); border: 0; }
.ambience input { width: 84px; }
@media (max-width: 560px) {
  .player { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "play title" "play seek" "amb amb"; padding-right: .9rem; }
  .ambience { padding-top: .35rem; margin-top: .35rem; border-top: 1px solid var(--line); }
  .ambience input { flex: 1; width: auto; }
}

/* ------------------------------------------------------------------ library */
.page-head { padding-top: 2.5rem; padding-bottom: 1.5rem; }
.page-title { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.12; font-weight: 400; margin: 0 0 .6rem; font-variation-settings: "SOFT" 100, "WONK" 1; }
.page-lede { color: var(--cream-dim); margin: 0; max-width: 36rem; }
.sorter { display: flex; gap: .5rem; margin: 1.6rem 0 .5rem; flex-wrap: wrap; }
.sorter a { text-decoration: none; }
.library { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.library li { border-bottom: 1px solid var(--line); }
.library a.entry { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1.5rem; padding: 1.35rem 0; text-decoration: none; color: inherit; }
.library a.entry:hover .entry-title { color: var(--ember-hi); }
.entry-title { font-size: 1.4rem; line-height: 1.25; font-weight: 450; margin: 0; font-variation-settings: "SOFT" 100, "WONK" 1; }
.entry-excerpt { grid-column: 1; color: var(--cream-dim); margin: 0; font-size: 1.02rem; max-width: 44rem; }
.entry-meta { grid-column: 2; grid-row: 1 / span 2; text-align: right; color: var(--dusk); font-size: .9rem; white-space: nowrap; line-height: 1.5; }
.entry-meta .heard { color: var(--ember); }
@media (max-width: 560px) {
  .library a.entry { grid-template-columns: 1fr; }
  .entry-meta { grid-column: 1; grid-row: auto; text-align: left; }
}
.pager { display: flex; justify-content: space-between; gap: 1rem; padding-top: 2rem; padding-bottom: 4rem; }

/* ------------------------------------------------------------------ forms / auth */
.auth-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: clamp(2rem, 6vw, 5rem); align-items: start; padding-top: clamp(2rem, 7vh, 5rem); padding-bottom: 4rem; }
@media (max-width: 860px) { .auth-grid { grid-template-columns: 1fr; } }
.lead-title { font-size: clamp(2.3rem, 6vw, 3.8rem); line-height: 1.08; font-weight: 360; margin: 0 0 1.2rem; font-variation-settings: "SOFT" 100, "WONK" 1; text-wrap: balance; }
.lead-text { font-size: 1.2rem; color: var(--cream-dim); max-width: 32rem; margin: 0 0 1.5rem; }
.panel { background: rgba(27,35,54,.92); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 1.75rem; }
.panel h2 { font-size: 1.5rem; font-weight: 450; margin: 0 0 1.25rem; }
.tabs { display: flex; gap: .25rem; margin: 0 0 1.4rem; border-bottom: 1px solid var(--line); }
.tabs button { font: inherit; font-size: 1.05rem; background: none; border: 0; color: var(--dusk); padding: .4rem .2rem .7rem; margin-right: 1rem; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--cream); border-bottom-color: var(--ember); }
.field { display: block; margin: 0 0 1rem; }
.field span { display: block; font-size: .95rem; color: var(--cream-dim); margin-bottom: .35rem; }
.field input {
  width: 100%; font: inherit; font-size: 1.05rem; color: var(--cream); background: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: .75rem .85rem;
}
.field input:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(227,160,74,.2); }
.panel .btn-primary { width: 100%; justify-content: center; margin-top: .4rem; }
.form-foot { font-size: .95rem; color: var(--dusk); margin: 1.1rem 0 0; }
.notice { padding: .8rem 1rem; border-radius: var(--radius-s); margin: 0 0 1.2rem; font-size: 1rem; }
.notice-error { background: rgba(233,138,122,.12); color: #f3b3a7; border: 1px solid rgba(233,138,122,.35); }
.notice-ok { background: rgba(227,160,74,.1); color: var(--ember-hi); border: 1px solid rgba(227,160,74,.35); }
.narrow { max-width: 28rem; padding-top: clamp(2rem, 8vh, 5rem); padding-bottom: 4rem; }

/* ------------------------------------------------------------------ prose pages */
.prose { max-width: var(--measure); padding-top: 1rem; padding-bottom: 4rem; font-size: 1.15rem; line-height: 1.75; }
.prose h2 { font-size: 1.45rem; font-weight: 460; margin: 2.2rem 0 .6rem; }
.prose p, .prose li { color: var(--cream-dim); }
.prose strong { color: var(--cream); font-weight: 560; }

/* ------------------------------------------------------------------ footer */
.site-footer { border-top: 1px solid var(--line); color: var(--dusk); font-size: .95rem; }
.site-footer .wrap { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center; padding-top: 1.6rem; padding-bottom: 2rem; }
.site-footer a { color: var(--cream-dim); text-decoration: none; }
.site-footer a:hover { color: var(--cream); }
.site-footer .support { margin-left: auto; color: var(--ember-hi); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------------ after a story / story of the day */
.after-note { margin: 1.4rem 0 0; color: var(--cream-dim); font-size: 1.02rem; }
.status-line .btn, .error-line .btn { margin-top: .9rem; }
.sotd { padding-bottom: 4.5rem; }
.sotd-inner { max-width: var(--measure); border-top: 1px solid var(--line); padding-top: 2.4rem; }
.sotd-label { font-size: 1rem; font-weight: 500; color: var(--ember-hi); margin: 0 0 .7rem; font-variation-settings: "SOFT" 100, "WONK" 1; font-style: italic; }
.sotd-title { font-size: clamp(1.6rem, 3.6vw, 2.2rem); line-height: 1.15; font-weight: 420; margin: 0 0 .5rem; font-variation-settings: "SOFT" 100, "WONK" 1; text-wrap: balance; }
.sotd-title a { color: var(--cream); text-decoration: none; }
.sotd-title a:hover { color: var(--ember-hi); }
.sotd-meta { margin: 0 0 1rem; color: var(--dusk); font-size: .98rem; }
.sotd-meta a { color: var(--cream-dim); }
.sotd-excerpt { color: var(--cream-dim); margin: 0 0 1.4rem; }

/* tradition filter on the library */
.traditions { display: flex; flex-wrap: wrap; gap: .45rem; margin: 1rem 0 0; }
.traditions a { text-decoration: none; font-size: .9rem; padding: .38rem .8rem; }
.traditions .count { color: var(--dusk); margin-left: .3rem; font-size: .85em; }
.entry-tradition { color: var(--ember-hi); }
.story-tradition { display: inline-block; margin: 0 0 .8rem; font-size: .98rem; }

/* ------------------------------------------------------------------ admin */
.admin-stats { color: var(--cream-dim); margin: 0 0 1rem; }
.admin-stats b { color: var(--cream); font-weight: 560; }
.inline-form { display: inline-flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.hint { color: var(--dusk); font-size: .9rem; }
.admin-select { font: inherit; font-size: .95rem; color: var(--cream); background: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: .45rem .9rem; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .98rem; }
.admin-table th { text-align: left; font-weight: 500; color: var(--dusk); border-bottom: 1px solid var(--line); padding: .5rem .6rem; }
.admin-table td { border-bottom: 1px solid var(--line); padding: .8rem .6rem; vertical-align: top; }
.admin-table td a { color: var(--cream); }
.admin-table tr.is-featured td:first-child { box-shadow: inset 3px 0 0 var(--ember); }
.admin-sub { color: var(--dusk); font-size: .85rem; margin-top: .2rem; }
.tag { font-size: .78rem; color: var(--ember-hi); margin-left: .4rem; }
@media (max-width: 720px) { .admin-table th:nth-child(4), .admin-table td:nth-child(4) { display: none; } }
.tag-form input { font: inherit; font-size: .9rem; color: var(--cream); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: .3rem .45rem; width: 100%; min-width: 13rem; }
.tag-form input:hover, .tag-form input:focus { border-color: var(--line); background: var(--ink-2); outline: none; }
