/* Family stories (stories.js): interviews, a person's stories as chapters, story of the week.
   Uses the Family History look (--fh-*), with fallbacks so it also works on its own. */

.fst-root, .fst-screen {
  --fst-paper: var(--fh-paper, #f6efe2); --fst-card: var(--fh-card, #fffaf1); --fst-ink: var(--fh-ink, #2b2219);
  --fst-muted: var(--fh-muted, #7c6b57); --fst-line: var(--fh-line, #e5d8c3);
  --fst-accent: var(--fh-accent, #9a6a3a); --fst-accent-fg: var(--fh-accent-fg, #fffaf1);
  --fst-serif: var(--fh-serif, Georgia, "Iowan Old Style", "Noto Serif", "Times New Roman", serif);
  --fst-rec: #d6453d;
  /* accent-colored words: a touch nearer the ink, so small text keeps 4.5:1 on paper and cards (light and dark) */
  --fst-accent-text: color-mix(in srgb, var(--fst-accent) 70%, var(--fst-ink));
}
@media (prefers-color-scheme: dark) {
  .fst-root, .fst-screen {
    --fst-paper: var(--fh-paper, #17130e); --fst-card: var(--fh-card, #221c15); --fst-ink: var(--fh-ink, #f2e8d8);
    --fst-muted: var(--fh-muted, #b5a48d); --fst-line: var(--fh-line, #3a3025);
    --fst-accent: var(--fh-accent, #d9a86f); --fst-accent-fg: var(--fh-accent-fg, #17130e);
    --fst-rec: #ef5b52;
  }
}

/* ---------- full-screen views (interview, a person's stories) ---------- */
/* over sheets (85): a story can be played from a person page, which is a sheet */
.fst-screen { z-index: 87; background: var(--fst-paper); color: var(--fst-ink); display: flex; flex-direction: column; animation: rise .22s cubic-bezier(.2,.8,.2,1); }
.fst-top { display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-t, 0px) + 10px) 14px 10px; border-bottom: 1px solid var(--fst-line); background: var(--fst-paper); }
.fst-top .cbtn { background: var(--fst-card); color: var(--fst-ink); border: 1px solid var(--fst-line); }
.fst-top-t { flex: 1; min-width: 0; }
.fst-top-t b { display: block; font-family: var(--fst-serif); font-size: 20px; font-weight: 600; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fst-top-t span { display: block; font-size: 12.5px; color: var(--fst-muted); }
.fst-top-t span:empty { display: none; }
.fst-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 14px 16px calc(var(--safe-b, 0px) + 40px); }
.fst-body > .fst-root { max-width: 640px; margin: 0 auto; }

/* ---------- shared bits, so they look right inside or outside .fh ---------- */
.fst-root { color: var(--fst-ink); }
.fst-root h2 { font-family: var(--fst-serif); font-weight: 600; font-size: 24px; line-height: 1.2; margin: 4px 0 6px; }
.fst-root .hint, .fst-root .muted { color: var(--fst-muted); font-size: 14px; }
.fst-root .section-label { color: var(--fst-muted); }
.fst-root .btn:not(.secondary) { background: var(--fst-accent); color: var(--fst-accent-fg); }
.fst-root .btn.secondary { background: var(--fst-card); color: var(--fst-ink); border: 1px solid var(--fst-line); }
.fst-root .tab { background: var(--fst-card); color: var(--fst-ink); border: 1px solid var(--fst-line); }
.fst-root .tab[aria-pressed="true"] { background: var(--fst-ink); color: var(--fst-paper); border-color: var(--fst-ink); }
.fst-root .tab:disabled { opacity: .5; }
.fst-root .person-row { background: var(--fst-card); color: var(--fst-ink); border: 1px solid var(--fst-line); width: 100%; }
.fst-root .person-row span { color: var(--fst-muted); }
.fst-root .people-search { background: var(--fst-card); color: var(--fst-ink); border: 1px solid var(--fst-line); font-size: 16px; }   /* 16px: iPhone does not zoom in */
.fst-root .field input { background: var(--fst-card); color: var(--fst-ink); border-color: var(--fst-line); }
.fst-root .field span { color: var(--fst-muted); }
.fst-root .row-check { color: var(--fst-muted); margin: 0; }
.fst-root .row-check input { accent-color: var(--fst-accent); }
.fst-root .empty { padding: 30px 12px 18px; color: var(--fst-muted); }
.fst-root .empty h2 { color: var(--fst-ink); font-size: 21px; }
.fst-row { display: flex; gap: 8px; }
.fst-row .btn { margin: 0; flex: 1; }
.fst-link { position: relative; border: 0; background: none; color: var(--fst-accent-text); font: inherit; font-weight: 700; font-size: 14px; padding: 8px 2px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.fst-loading { text-align: center; color: var(--fst-muted); padding: 70px 20px; font-family: var(--fst-serif); font-size: 18px; }
textarea.fst-tx { display: block; width: 100%; border-radius: 13px; border: 1.5px solid var(--fst-line); background: var(--fst-card); color: var(--fst-ink); padding: 10px 14px; font: inherit; font-size: 16px; line-height: 1.45; resize: vertical; margin: 0 0 10px; }
mark.fst-mark { background: color-mix(in srgb, var(--fst-accent) 32%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- story of the week ---------- */
.fst-week { background: var(--fst-card); border: 1px solid var(--fst-line); border-radius: 20px; padding: 16px 16px 14px; margin: 0 0 12px; }
.fst-kicker { font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--fst-accent-text); }
.fst-week-who { margin: 8px 0 4px; color: var(--fst-muted); font-size: 14px; }
.fst-week-q { font-family: var(--fst-serif); font-size: 21px; line-height: 1.35; margin: 0 0 8px; overflow-wrap: anywhere; }
.fst-week-q::before { content: "\201C"; } .fst-week-q::after { content: "\201D"; }
.fst-week-meta { font-size: 12.5px; color: var(--fst-muted); margin: 0 0 12px; }
.fst-week-actions { display: flex; gap: 8px; }
.fst-week-actions .btn { flex: 1; height: 46px; font-size: 15px; margin: 0; }

/* ---------- the home's section ---------- */
.fst-interview-btn { width: 100%; margin: 0 0 12px; }
.fst-interview-btn .ico svg { width: 30px; height: 30px; }
.fst-search { margin-top: 2px; }
.fst-results { display: grid; gap: 6px; }
.fst-hit { display: block; width: 100%; text-align: left; border: 1px solid var(--fst-line); background: var(--fst-card); color: var(--fst-ink); border-radius: 14px; padding: 10px 12px; font: inherit; }
.fst-hit b { font-family: var(--fst-serif); font-weight: 600; font-size: 15.5px; }
.fst-hit span { display: block; font-size: 12.5px; color: var(--fst-muted); }
.fst-hit p { margin: 5px 0 0; font-size: 13.5px; line-height: 1.4; overflow-wrap: anywhere; }
.fst-people { display: grid; gap: 6px; margin: 0 0 8px; }
.fst-add b { color: var(--fst-accent-text); }
.fst-none { margin: 12px 2px; }

/* ---------- interview: setup ---------- */
.fst-chosen { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--fst-card); border: 1px solid var(--fst-line); border-radius: 14px; padding: 12px 14px; }
.fst-chosen b { display: block; font-family: var(--fst-serif); font-size: 18px; font-weight: 600; }
.fst-chosen span span { font-size: 12.5px; color: var(--fst-muted); }
.fst-themes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fst-theme { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border: 1.5px solid var(--fst-line); background: var(--fst-card); color: var(--fst-ink); border-radius: 16px; padding: 12px; font: inherit; min-height: 96px; }
.fst-theme[aria-pressed="true"] { border-color: var(--fst-accent); box-shadow: inset 0 0 0 1.5px var(--fst-accent); background: color-mix(in srgb, var(--fst-accent) 9%, var(--fst-card)); }
.fst-theme-ico { font-size: 22px; line-height: 1.2; }
.fst-theme b { font-family: var(--fst-serif); font-weight: 600; font-size: 16px; line-height: 1.2; }
.fst-theme span:last-child { font-size: 12px; color: var(--fst-muted); }
.fst-modes { display: flex; gap: 8px; flex-wrap: wrap; }
.fst-start { margin-top: 18px; }

/* ---------- interview: a question ---------- */
.fst-qhead { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--fst-muted); margin: 0 2px 6px; }
.fst-progress { height: 4px; border-radius: 2px; background: var(--fst-line); overflow: hidden; margin-bottom: 14px; }
.fst-progress span { display: block; height: 100%; background: var(--fst-accent); transition: width .3s; }
.fst-qcard { background: var(--fst-card); border: 1px solid var(--fst-line); border-radius: 20px; padding: 18px 18px 8px; }
.fst-ask { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--fst-muted); }
.fst-ai { margin: 0 0 6px; font-size: 12px; font-weight: 800; color: var(--fst-accent-text); }
.fst-q { font-family: var(--fst-serif); font-size: 25px; line-height: 1.3; margin: 0 0 4px; overflow-wrap: anywhere; }
.fst-reword { margin: 4px 0 8px; }
.fst-gentle { font-size: 13.5px; color: var(--fst-muted); font-style: italic; margin: 10px 4px 0; }
.fst-qtools { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 0; }
.fst-qtools .fst-modes { display: contents; }
.fst-stage { margin-top: 12px; }
.fst-stage:empty { display: none; }
.fst-stage video { display: block; width: 100%; max-height: 46vh; object-fit: cover; border-radius: 16px; background: #000; }
.fst-stage video.mirror { transform: scaleX(-1); }
.fst-listening { display: flex; align-items: center; justify-content: center; gap: 10px; height: 54px; color: var(--fst-muted); font-weight: 700; }
.fst-listening i { width: 12px; height: 12px; border-radius: 50%; background: var(--fst-rec); animation: fst-pulse 1.2s ease-in-out infinite; }
@keyframes fst-pulse { 50% { opacity: .25; transform: scale(.7); } }
.fst-recbox { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 18px 0 8px; }
.fst-rec { width: 82px; height: 82px; border-radius: 50%; border: 4px solid var(--fst-ink); background: transparent; display: grid; place-items: center; padding: 0; cursor: pointer; }
.fst-rec::after { content: ""; width: 60px; height: 60px; border-radius: 50%; background: var(--fst-rec); transition: width .18s, height .18s, border-radius .18s; }
.fst-rec.on::after { width: 30px; height: 30px; border-radius: 8px; }
.fst-rec:disabled { opacity: .45; }
.fst-time { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.fst-status { margin: 0; min-height: 1.4em; text-align: center; color: var(--fst-muted); font-size: 13.5px; }
.fst-after:empty { display: none; }
.fst-saved { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: 6px 2px 8px; color: var(--fst-accent-text); }
.fst-saved span { display: inline-grid; width: 22px; height: 22px; border-radius: 50%; background: var(--fst-accent); color: var(--fst-accent-fg); padding: 4px; }
.fst-saved svg { width: 100%; height: 100%; }
.fst-answer { display: block; width: 100%; margin: 0 0 10px; border-radius: 12px; }
video.fst-answer { max-height: 40vh; background: #000; }
.fst-nav { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 8px; }
.fst-nav .btn { margin: 0; }
.fst-finish { display: block; margin: 8px auto 0; }
.fst-done-list { margin: 6px 0 16px; padding-left: 22px; font-family: var(--fst-serif); font-size: 16px; line-height: 1.4; }
.fst-done-list li { margin: 4px 0; }

/* ---------- a person's stories ---------- */
.fst-phead h2 { margin-bottom: 2px; }
.fst-player { background: var(--fst-card); border: 1px solid var(--fst-line); border-radius: 20px; padding: 12px 14px 10px; margin: 8px 0 4px; }
.fst-art { border-radius: 14px; padding: 20px 18px; min-height: 140px; display: flex; flex-direction: column; justify-content: center; gap: 8px;
  background: linear-gradient(140deg, color-mix(in srgb, var(--fst-accent) 22%, var(--fst-paper)), var(--fst-paper)); }
.fst-art-n { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--fst-accent-text); }
.fst-art-q { font-family: var(--fst-serif); font-size: 21px; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
.fst-video { display: block; width: 100%; max-height: 52vh; border-radius: 14px; background: #000; }
.fst-missing { color: var(--fst-muted); font-size: 13.5px; margin: 8px 2px 0; }
.fst-now { font-family: var(--fst-serif); font-weight: 600; font-size: 18px; line-height: 1.3; margin: 12px 2px 2px; overflow-wrap: anywhere; }
.fst-now-meta { margin: 0 2px; font-size: 12.5px; color: var(--fst-muted); }
.fst-now[hidden] + .fst-now-meta { margin-top: 10px; }
.fst-bar { display: flex; gap: 3px; margin: 10px 0 0; }
.fst-seg { position: relative; flex: 1 1 0; min-width: 6px; height: 22px; border: 0; padding: 0; background: none; cursor: pointer; }
.fst-seg::before { content: ""; position: absolute; left: 0; right: 0; top: 8px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--fst-ink) 15%, transparent); }
.fst-seg[aria-current="true"]::before { background: color-mix(in srgb, var(--fst-accent) 30%, transparent); }
.fst-seg-fill { position: absolute; left: 0; top: 8px; height: 6px; width: 0; border-radius: 3px; background: var(--fst-accent); }
.fst-scrub { display: block; width: 100%; height: 28px; margin: 2px 0 0; accent-color: var(--fst-accent); cursor: pointer; }
.fst-times { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--fst-muted); font-variant-numeric: tabular-nums; margin: -2px 2px 0; }
.fst-controls { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 6px; }
.fst-ctl { position: relative; width: 46px; height: 46px; border-radius: 50%; border: 0; background: transparent; color: var(--fst-ink); display: grid; place-items: center; padding: 10px; cursor: pointer; }
.fst-ctl > span, .fst-ctl svg { display: block; width: 100%; height: 100%; }
.fst-ctl .n { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9.5px; font-weight: 800; width: auto; height: auto; padding-top: 2px; }
.fst-play { width: 62px; height: 62px; border-radius: 50%; border: 0; background: var(--fst-accent); color: var(--fst-accent-fg); display: grid; place-items: center; padding: 18px; cursor: pointer; }
.fst-play svg { width: 100%; height: 100%; }
.fst-prow { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--fst-line); padding-top: 8px; font-size: 13.5px; }
.fst-speed { position: relative; min-width: 58px; height: 34px; border-radius: 999px; border: 1px solid var(--fst-line); background: var(--fst-paper); color: var(--fst-ink); font: inherit; font-weight: 800; font-size: 14px; cursor: pointer; font-variant-numeric: tabular-nums; }
/* small controls reach 44px for a finger without looking bigger */
.fst-speed::after, .fst-link::after { content: ""; position: absolute; inset: -5px -2px; }
.fst-transcript { margin: 4px 0 6px; }
.fst-tx-text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--fst-serif); font-size: 16.5px; line-height: 1.55; background: var(--fst-card); border: 1px solid var(--fst-line); border-radius: 14px; padding: 12px 14px; margin: 0 0 8px; }
.fst-order { display: flex; gap: 8px; margin: 16px 0 0; }
.fst-order:empty { display: none; }
.fst-group { font-family: var(--fst-serif); font-size: 16.5px; font-weight: 600; margin: 16px 4px 4px; }
.fst-ch { display: flex; gap: 12px; align-items: center; width: 100%; border: 0; border-bottom: 1px solid var(--fst-line); background: none; color: var(--fst-ink); text-align: left; padding: 10px 6px; font: inherit; cursor: pointer; }
.fst-ch[aria-current="true"] { background: var(--fst-card); border-radius: 12px; border-bottom-color: transparent; }
.fst-ch-n { width: 28px; height: 28px; flex: none; border-radius: 50%; border: 1.5px solid var(--fst-line); display: grid; place-items: center; font-size: 12.5px; font-weight: 800; color: var(--fst-muted); }
.fst-ch[aria-current="true"] .fst-ch-n { background: var(--fst-accent); border-color: var(--fst-accent); color: var(--fst-accent-fg); }
.fst-ch-t { display: flex; flex-direction: column; min-width: 0; }
.fst-ch-t b { font-family: var(--fst-serif); font-weight: 600; font-size: 15.5px; line-height: 1.3; overflow-wrap: anywhere; }
.fst-ch-t span { font-size: 12.5px; color: var(--fst-muted); }
.fst-actions { margin-top: 18px; }
