/* StorySpark v2 — one small stylesheet. Tokens from docs/specs/06-ui-and-datastar.md. */

:root {
  --bg: #faf4f0;
  --surface: #f5f0ec;
  --border: #e8d5c7;
  --primary: #8c6a56;
  --primary-hover: #6d5242;
  --text: #3a3226;
  --muted: #7a6a5a;
  --danger: #a3402f;
  --ok: #4a7a4a;
  --radius: 8px;
  --font-body: Georgia, "Times New Roman", serif;
  --font-heading: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
}

main { max-width: 60rem; margin: 0 auto; padding: 1rem; }

h1, h2, h3 { font-family: var(--font-heading); line-height: 1.25; }

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header nav {
  max-width: 60rem; margin: 0 auto; padding: 0.6rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.wordmark { font-size: 1.35rem; font-weight: 700; text-decoration: none; color: var(--text); }
.nav-links { list-style: none; display: flex; gap: 1rem; margin: 0; padding: 0; align-items: center; }
.inline-form { display: inline; margin: 0; }

/* Buttons */
button, .btn {
  font: inherit; cursor: pointer;
  background: var(--primary); color: #fff;
  border: 1px solid var(--primary); border-radius: var(--radius);
  padding: 0.45rem 1rem;
}
button:hover, .btn:hover { background: var(--primary-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary, .btn.secondary { background: transparent; color: var(--primary); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.linklike {
  background: none; border: none; padding: 0; color: var(--primary);
  text-decoration: underline; cursor: pointer;
}

/* Forms */
form { margin: 0.75rem 0; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0.75rem 0; }
legend { font-weight: 700; padding: 0 0.4rem; }
label { display: block; margin: 0.6rem 0 0.2rem; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="week"], select, textarea {
  font: inherit; width: 100%; max-width: 32rem;
  padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--text);
}
textarea { min-height: 6rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0.2rem 0 0; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; }
.form-row > div { flex: 1 1 12rem; }

/* Panels, cards, alerts */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin: 1rem 0; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0.5rem 0; background: #fff; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.two-col { display: grid; gap: 1.5rem; grid-template-columns: minmax(16rem, 1fr) 2fr; }
@media (max-width: 48rem) { .two-col { grid-template-columns: 1fr; } }

.alert { border-left: 4px solid var(--primary); padding: 0.75rem 1rem; border-radius: var(--radius); background: var(--surface); }
.alert.error { border-color: var(--danger); color: var(--danger); }
.alert.ok { border-color: var(--ok); color: var(--ok); }

.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
code { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 0 0.3rem; font-size: 0.9em; }
.student-list { list-style: none; padding: 0; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.pill { display: inline-block; border: 1px solid var(--border); border-radius: 999px; padding: 0.1rem 0.7rem; font-size: 0.85rem; background: var(--surface); }
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); font-size: 0.85rem; }
.badge.earned { border-color: var(--primary); background: var(--primary); color: #fff; }

/* Story display */
.story-text { font-size: 1.25rem; line-height: 1.8; }
.story-text p { margin: 0 0 1em; }
.choice-interlude { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0.5rem 0; font-style: italic; color: var(--muted); }
.choice-grid { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.choice-grid button { background: var(--surface); color: var(--text); border-color: var(--border); text-align: left; }
.choice-grid button:hover { border-color: var(--primary); color: var(--primary-hover); }
.caret::after {
  content: "▍"; margin-left: 1px; color: var(--primary);
  animation: blink 1s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Question gate */
.question-gate { border: 2px solid var(--primary); border-radius: var(--radius); padding: 1.25rem; margin: 1rem 0; background: var(--surface); }
.question-type { font-size: 0.85rem; }

/* Toast */
.toast {
  position: fixed; right: 1rem; bottom: 1rem; max-width: 22rem;
  background: var(--text); color: var(--bg);
  padding: 0.7rem 1rem; border-radius: var(--radius);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.toast:not(:empty) { opacity: 1; }

/* Progress bars (admin) */
.bar { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; height: 0.8rem; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 2rem; color: var(--muted); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .caret::after { animation: none; }
  .toast { transition: none; }
}

/* Lists and dashboard bits */
.home-grid { display: grid; gap: 1rem; }
.story-list, .character-list { list-style: none; padding: 0; }
.stat { font-size: 1.8rem; margin: 0.2rem 0; }
.badge + .badge { margin-left: 0.25rem; }
details summary { cursor: pointer; margin: 0.5rem 0; }
