/* Told Out Loud — Loire Valley companion
   Palette taken from the valley's two building materials: pale tuffeau
   limestone and the blue-black slate of the château roofs. The one accent
   is river green. Everything is high-contrast because this gets read on a
   phone in August sunlight. */

:root {
  --ink:        #14181c;
  --ink-soft:   #3a4a56;
  --slate:      #26313a;
  --stone:      #edebe3;
  --stone-2:    #e2dfd4;
  --stone-3:    #d4d0c2;
  --loire:      #35604e;
  --loire-lift: #eaf0ec;
  --ember:      #9c3f28;

  --display: "Fraunces", Georgia, serif;
  --body:    "Literata", Georgia, serif;
  --mono:    "Courier Prime", ui-monospace, "Courier New", monospace;

  --pad: 20px;
  --rule: 1px solid var(--stone-3);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Class selectors like .gate and .view set display, which would otherwise
   beat the browser's own [hidden] rule and leave invisible panels on top
   of the page swallowing taps. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--stone);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea, select { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ gate */

.gate {
  position: fixed; inset: 0; z-index: 50;
  background: var(--slate); color: var(--stone);
  display: flex; align-items: center; justify-content: center;
  padding: var(--pad);
  overflow-y: auto;
}
.gate-inner { width: 100%; max-width: 420px; padding: 32px 0; }
.gate-title {
  font-family: var(--display);
  font-size: clamp(46px, 15vw, 68px);
  font-weight: 600; line-height: 0.94;
  margin: 6px 0 14px; letter-spacing: -0.02em;
}
.gate-lede { margin: 0 0 32px; opacity: 0.8; }
.gate .slug { color: var(--stone-3); }
.gate .field { display: block; margin-bottom: 14px; }
.gate .label { color: var(--stone-3); }
.gate input {
  width: 100%; margin-top: 8px; padding: 14px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 3px; color: var(--stone);
}
.gate input:focus { outline: 2px solid var(--stone); outline-offset: 1px; }

.member-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.member-grid button {
  padding: 16px 10px; border-radius: 3px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.28);
  color: var(--stone); font-family: var(--display); font-size: 18px;
}
.member-grid button:active { background: rgba(255,255,255,0.18); }

/* ------------------------------------------------------- shared elements */

.slug, .label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  margin: 0;
}
.label { color: var(--ink-soft); }

.btn {
  border: 1px solid var(--ink); background: none; color: var(--ink);
  padding: 12px 16px; border-radius: 3px;
  font-family: var(--mono); font-size: 13px;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--loire); border-color: var(--loire); color: #fff; }
.btn-block { display: block; width: 100%; }
.btn-quiet { border-color: var(--stone-3); color: var(--ink-soft); }
.btn-danger { border-color: var(--ember); color: var(--ember); }

.error { color: #ffb9a4; font-size: 15px; margin: 0 0 12px; }
.icon-btn {
  background: none; border: 0; font-size: 22px; line-height: 1;
  padding: 6px 12px 6px 0; color: var(--ink);
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) var(--pad) 10px;
  background: var(--stone); border-bottom: var(--rule);
}
.topbar-title {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.lang-toggle, .who {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  background: none; border: 1px solid var(--stone-3);
  border-radius: 3px; padding: 5px 9px; color: var(--ink-soft);
  text-transform: uppercase;
}
.who { border-style: dashed; }

.offline-bar {
  background: var(--slate); color: var(--stone);
  font-family: var(--mono); font-size: 12px;
  padding: 9px var(--pad);
}

main { padding-bottom: 96px; }
.view { max-width: 680px; margin: 0 auto; }

/* --------------------------------------------------------------- library */

.search-wrap { padding: 14px var(--pad) 8px; }
#search {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--stone-3); border-radius: 3px;
  background: #f6f5f0;
}
#search:focus { outline: 2px solid var(--loire); outline-offset: -1px; }

.chips {
  display: flex; gap: 7px; overflow-x: auto;
  padding: 6px var(--pad) 14px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 7px 11px; border-radius: 999px;
  border: 1px solid var(--stone-3); background: none; color: var(--ink-soft);
}
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--stone); }

.place-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 22px var(--pad) 8px;
}
.place-head .place-name {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.16em; text-transform: uppercase;
}
.place-head .rule { flex: 1; height: 1px; background: var(--stone-3); }
.place-head .count { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }

.story-row {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; border-top: var(--rule);
  padding: 14px var(--pad);
}
.story-row:first-of-type { border-top: 0; }
.story-row:active { background: var(--stone-2); }
.story-row h3 {
  font-family: var(--display); font-weight: 400;
  font-size: 20px; line-height: 1.25; margin: 0 0 5px;
}
.row-meta {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.06em; color: var(--ink-soft);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.row-meta .dot { color: var(--stone-3); }
.tag-spare { color: var(--loire); }
.tag-draft { color: var(--ember); }

.empty {
  padding: 40px var(--pad); text-align: center; color: var(--ink-soft);
}

/* ------------------------------------------------------------------ days */

.day-card { border-top: var(--rule); }
.day-head {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; padding: 16px var(--pad);
}
.day-head .label { color: var(--ink-soft); }
.day-head h2 {
  font-family: var(--display); font-weight: 400;
  font-size: 22px; margin: 4px 0 0;
}
.day-body { padding: 0 var(--pad) 18px; }
.order-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-top: var(--rule);
}
.order-row .n {
  font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
  width: 20px; flex: 0 0 20px;
}
.order-row .t { flex: 1; font-family: var(--display); font-size: 17px; line-height: 1.3; }
.order-row .t small { display: block; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-top: 3px; }
.mini {
  background: none; border: 1px solid var(--stone-3); border-radius: 3px;
  width: 34px; height: 34px; flex: 0 0 34px; color: var(--ink-soft); font-size: 15px;
}
.mini:active { background: var(--stone-2); }

/* ----------------------------------------------------- story: script page
   The signature of the whole app. These stories were written to be spoken,
   so they are set like a page from a script: a slug line, a stage direction
   in the margin, then the speech itself at a size you can read at arm's
   length in bright sun. */

.script { padding: 8px var(--pad) 40px; }
.script .slugline {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-soft);
  padding-bottom: 10px; border-bottom: 2px solid var(--ink);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.script h1 {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(28px, 8vw, 38px); line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 20px 0 0;
}
.script .byline {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
  color: var(--ink-soft); margin: 10px 0 0; text-transform: uppercase;
}

.direction {
  margin: 24px 0 28px;
  padding: 12px 0 12px 16px;
  border-left: 3px solid var(--loire);
  font-family: var(--mono); font-style: italic;
  font-size: 14px; line-height: 1.5; color: var(--slate);
  background: var(--loire-lift);
}

.speech { font-size: 19px; line-height: 1.68; }
.speech p { margin: 0 0 1.05em; }
.speech ul { margin: 0 0 1.05em; padding-left: 1.1em; }
.speech li { margin-bottom: 0.55em; }
.speech strong { font-weight: 600; }
.speech em { font-style: italic; }

.lang-switch { display: flex; gap: 8px; margin: 0 0 20px; }
.lang-switch button {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 6px 12px; border-radius: 3px;
  border: 1px solid var(--stone-3); background: none; color: var(--ink-soft);
}
.lang-switch button.is-on { background: var(--ink); border-color: var(--ink); color: var(--stone); }
.fallback-note {
  font-family: var(--mono); font-size: 12px; color: var(--ember);
  margin: 0 0 18px;
}

.script-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 34px; padding-top: 20px; border-top: var(--rule);
}

/* ----------------------------------------------------------------- media */

.media-block { margin-top: 34px; padding-top: 20px; border-top: 2px solid var(--ink); }
.media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px; margin: 14px 0;
}
.media-cell {
  position: relative; aspect-ratio: 1; border: 1px solid var(--stone-3);
  border-radius: 3px; overflow: hidden; background: var(--stone-2);
  padding: 0;
}
.media-cell img, .media-cell video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-cell .who-tag {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  background: rgba(20,24,28,0.72); color: #fff; padding: 3px 5px;
  text-align: left; text-transform: uppercase;
}
.media-cell .play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 26px; text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}
.media-add { display: flex; gap: 10px; flex-wrap: wrap; }
.progress { height: 3px; background: var(--stone-3); margin-top: 12px; border-radius: 2px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--loire); transition: width .2s; }

.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(10,12,14,0.94);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.lightbox img, .lightbox video { max-width: 100%; max-height: 86vh; }
.lightbox .close {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px;
  background: none; border: 1px solid rgba(255,255,255,0.5); color: #fff;
  border-radius: 3px; padding: 8px 12px; font-family: var(--mono); font-size: 12px;
}

/* ---------------------------------------------------------------- editor */

.editor { padding: 8px var(--pad) 40px; }
.editor h1 {
  font-family: var(--display); font-weight: 600; font-size: 26px; margin: 6px 0 22px;
}
.field { display: block; margin-bottom: 18px; }
.field > .label { display: block; margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px;
  border: 1px solid var(--stone-3); border-radius: 3px; background: #f6f5f0;
}
.field textarea { min-height: 220px; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--loire); outline-offset: -1px;
}
.field .hint { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); margin-top: 6px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor-actions { display: flex; gap: 10px; margin-top: 8px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.check input { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- tabbar */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--stone);
  border-top: 2px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: 0; padding: 14px 4px 15px;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft);
}
.tab.is-on { color: var(--ink); }
.tab.is-on span { border-bottom: 2px solid var(--loire); padding-bottom: 3px; }

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 70;
  background: var(--slate); color: var(--stone);
  font-family: var(--mono); font-size: 13px;
  padding: 11px 16px; border-radius: 3px; max-width: 90vw;
}

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

:focus-visible { outline: 2px solid var(--loire); outline-offset: 2px; }

/* ------------------------------------------------- told it, margins, voice */

.tag-told { color: var(--loire); font-weight: 700; }

.told-block {
  margin-top: 30px; padding-top: 20px;
  border-top: 2px solid var(--ink);
}
.told-none {
  font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
  margin: 12px 0 0;
}
.told-log { margin-top: 14px; }
.told-line {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--mono); font-size: 12px; color: var(--slate);
  padding: 7px 0; border-top: var(--rule);
}
.told-line span { flex: 1; }
.linkish {
  background: none; border: 0; padding: 2px 0;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-soft); text-decoration: underline;
}

.margins { margin-top: 30px; padding-top: 20px; border-top: var(--rule); }
.note {
  border-left: 3px solid var(--stone-3);
  padding: 2px 0 2px 14px; margin: 14px 0;
}
.note-body { font-size: 17px; line-height: 1.55; }
.note-body p { margin: 0 0 0.6em; }
.note-body p:last-child { margin-bottom: 0; }
.note-foot {
  display: flex; align-items: baseline; gap: 10px; margin-top: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-soft);
}
.note-foot span { flex: 1; }
.note-add { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.note-add textarea {
  width: 100%; padding: 12px; line-height: 1.5;
  border: 1px solid var(--stone-3); border-radius: 3px; background: #f6f5f0;
  resize: vertical;
}
.note-add textarea:focus { outline: 2px solid var(--loire); outline-offset: -1px; }
.note-add .btn { align-self: flex-start; }

.btn-voice { border-color: var(--ember); color: var(--ember); }

.rec-panel {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding: 12px 14px;
  background: var(--slate); border-radius: 3px; color: var(--stone);
}
.rec-panel .btn { border-color: rgba(255,255,255,0.45); color: var(--stone); }
.rec-panel .btn-primary { background: var(--loire); border-color: var(--loire); }
.rec-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--ember); flex: 0 0 11px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.rec-time {
  flex: 1; font-family: var(--mono); font-size: 15px; letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.media-cell.is-audio {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: var(--slate); border-color: var(--slate); color: var(--stone);
}
.audio-mark { font-size: 26px; line-height: 1; }
.audio-len { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; }
.audio-play { width: 100%; max-width: 420px; text-align: left; }

.book-link { padding: 30px var(--pad) 10px; border-top: 2px solid var(--ink); margin-top: 8px; }
.book-link a { display: inline-block; text-decoration: none; }
.book-link .hint { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); margin: 10px 0 0; }
