/* Studio 13 — site-wide stylesheet
 *
 * Editorial / literary aesthetic — lifts the visual system from
 * the public research pages (webpage/research-overview.html et al.)
 * site-wide so the script library, account flows, and research
 * arm all share one identity.
 *
 * Color tokens, typography, and layout live in :root. Component
 * classes (territory accordion, script-card, auth-form, etc.) are
 * carried over from the previous stylesheet (saved as
 * style.legacy.css) and restyled to use the new tokens.
 *
 * Print styles preserved at the bottom — script print path
 * depends on them.
 */

:root {
  --paper: #f4f0e6;
  --paper-deep: #ebe4d4;
  --paper-deeper: #e2dac3;
  --ink: #20211d;
  --ink-soft: #4a4a40;
  --ink-faint: #6f6e60;
  --rule: #cfc6b0;
  --rule-soft: #ddd5c0;
  --accent: #7c2d20;
  --accent-soft: #a85a44;
  --accent-glow: #fff3ec;
  --warning: #c47a2a;
  --warning-soft: #fff8ee;
  --max: 760px;
  --max-wide: 1180px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.18rem;
  line-height: 1.66;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── Header / topbar ─────────────────────────────────────── */
/* Dark header so every link reads as white on dark — avoids any
 * fallback to browser-default blue/purple link colors. Paper body
 * stays light beneath. */

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.2rem 2.2rem 1.1rem;
  background: var(--ink);
  color: #fff;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 2rem;
}

/* Every anchor inside the header — site title, browse, admin
 * links, coverage, user, sign-out — defaults to white. Class-
 * specific rules below can shade them but never below this. */
header a {
  color: #fff;
  text-decoration: none;
}

.site-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: .02em;
  color: #fff;
  text-decoration: none;
}

.site-title:hover { color: var(--paper-deep); }

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.4rem;
}

.header-link,
.browse-link {
  font-family: 'Fraunces', serif;
  font-size: .92rem;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .2s, border-color .2s;
}

.header-link:hover,
.browse-link:hover {
  color: var(--paper-deep);
  border-bottom-color: var(--paper-deep);
}

.header-user {
  color: #fff;
  font-style: italic;
}

.admin-nav {
  display: flex;
  gap: .55rem;
  margin-right: 1rem;
  padding-right: 1rem;
  border-right: 1px solid rgba(255,255,255,0.25);
}

/* Admin links: white pill buttons on the dark ink header — same
 * white as the regular nav text, distinguished by the visible
 * border + padding rather than color. */
.admin-link {
  font-family: 'Fraunces', serif;
  font-size: .82rem;
  color: #fff;
  background: transparent;
  text-decoration: none;
  padding: .25rem .65rem;
  border: 1px solid #fff;
  border-radius: 2px;
  transition: background .2s, color .2s;
}

.admin-link:hover {
  background: #fff;
  color: var(--ink);
}

.coverage-nav-link { color: #fff; }
.coverage-nav-link:hover { color: var(--paper-deep); }

/* ── Main content frame ─────────────────────────────────── */

main {
  max-width: var(--max);
  margin: 2rem auto;
  padding: 0 2.2rem;
}

/* ── Typography ──────────────────────────────────────────── */

h1, h2, h3, h4 {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  color: var(--ink);
}

h1 {
  font-size: clamp(2rem, 4.4vw, 3rem);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -.012em;
  margin: 1.2rem 0 .8rem;
}

h2 {
  font-size: 1.6rem;
  line-height: 1.2;
  letter-spacing: -.01em;
  margin: 2.4rem 0 1rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}

h3 {
  font-size: 1.2rem;
  margin: 1.6rem 0 .6rem;
}

h4 {
  font-size: 1rem;
  margin: 1rem 0 .4rem;
}

p { margin: 0 0 1.2rem; }
em { font-style: italic; }
strong { font-weight: 500; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--accent-soft); }

blockquote {
  border-left: 3px solid var(--accent);
  padding: .4rem 0 .4rem 1.6rem;
  margin: 1.6rem 0;
  font-style: italic;
  color: var(--ink-soft);
}

ul, ol { margin: 0 0 1.2rem 1.4rem; }
li { margin-bottom: .4rem; }

.subtitle {
  font-style: italic;
  color: var(--accent-soft);
  margin-bottom: 2rem;
}

/* ── Auth forms (login, register, password reset) ──────── */

.auth-form {
  max-width: 460px;
  margin: 3rem auto;
  padding: 2.5rem 2.2rem;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
}

.auth-form h1 {
  margin-bottom: 1.5rem;
  font-size: 1.6rem;
}

.auth-form label {
  display: block;
  margin-bottom: 1rem;
  font-family: 'Fraunces', serif;
  font-size: .9rem;
  color: var(--ink-soft);
  letter-spacing: .01em;
}

.auth-form input {
  display: block;
  width: 100%;
  margin-top: .35rem;
  padding: .65rem .8rem;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 2px;
  transition: border-color .2s;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-form button {
  width: 100%;
  padding: .75rem;
  background: var(--accent);
  color: var(--paper);
  border: none;
  border-radius: 2px;
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  margin-top: .5rem;
  transition: background .2s;
}

.auth-form button:hover { background: var(--accent-soft); }

.auth-error {
  background: var(--accent-glow);
  border: 1px solid var(--accent-soft);
  color: var(--accent);
  padding: .6rem .8rem;
  margin-bottom: 1rem;
  font-size: .9rem;
  font-style: italic;
}

.auth-alt {
  margin-top: 1rem;
  font-size: .9rem;
  color: var(--ink-faint);
}
.auth-alt a { color: var(--accent); }

/* ── Audience pages (research, facilitators, coordinators) ── */

.audience-page { padding: 1rem 0 4rem; }

.audience-page .breadcrumb {
  font-family: 'Fraunces', serif;
  font-size: .82rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 2rem;
  border: none;
}
.audience-page .breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.audience-intro {
  margin: 1.5rem 0 2.5rem;
  font-size: 1.1rem;
}

.resource-section { margin: 2.5rem 0; }
.resource-section h2 {
  font-size: 1.3rem;
  margin: 0 0 1rem;
  padding: 0;
  border: none;
}

.resource-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.resource-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.resource-link {
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  color: var(--accent);
  text-decoration: none;
}
.resource-link:hover { color: var(--accent-soft); }

.resource-link.disabled {
  color: var(--ink-faint);
  pointer-events: none;
  cursor: default;
  font-style: italic;
}

.resource-desc {
  font-family: 'Fraunces', serif;
  font-size: .88rem;
  color: var(--ink-faint);
  letter-spacing: .01em;
}

/* ── Browse — territory / emotion accordion ─────────────── */

.territory {
  border: 1px solid var(--rule);
  border-radius: 2px;
  margin-bottom: .8rem;
  background: var(--paper-deep);
}

.territory-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.2rem;
  background: var(--paper-deep);
  border: none;
  cursor: pointer;
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  color: var(--ink);
  text-align: left;
  transition: background .2s;
}

.territory-header:hover { background: var(--paper-deeper); }

.territory-count {
  font-family: 'Fraunces', serif;
  color: var(--ink-faint);
  font-size: .85rem;
}

.territory-tagline {
  display: block;
  font-style: italic;
  color: var(--ink-faint);
  font-size: .9rem;
  margin-top: .25rem;
}

.emotions { display: none; padding: .5rem 1.2rem 1.2rem; }
.territory.open .emotions { display: block; }

.emotion { margin-bottom: .5rem; }

.emotion-header {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1rem;
  color: var(--accent);
  padding: .3rem .5rem;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-align: left;
}

.emotion-header:hover { color: var(--accent-soft); }

.scripts-container {
  padding-left: 1rem;
  margin-top: .5rem;
}

/* ── Script cards (in browse + emotion listing) ────────── */

.script-card {
  border: 1px solid var(--rule-soft);
  border-radius: 2px;
  padding: 1rem 1.2rem;
  margin-bottom: .6rem;
  background: var(--paper);
}

.card-rating {
  color: var(--warning);
  font-size: .9rem;
  margin: .25rem 0;
}
.card-rating-count {
  color: var(--ink-faint);
}

.script-title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 1rem;
  color: var(--ink);
}

.script-meta {
  color: var(--ink-faint);
  font-size: .88rem;
  margin: .2rem 0 .5rem;
  font-style: italic;
}

.script-text.gauntlet { white-space: normal; }

.no-scripts {
  color: var(--ink-faint);
  font-size: .92rem;
  padding: .5rem;
  font-style: italic;
}

/* ── Download / action buttons ────────────────────────── */

.download-btn {
  display: inline-block;
  padding: .35rem .9rem;
  background: var(--accent);
  color: var(--paper);
  border-radius: 2px;
  text-decoration: none;
  font-family: 'Fraunces', serif;
  font-size: .88rem;
  letter-spacing: .02em;
  transition: background .2s;
}

.download-btn:hover { background: var(--accent-soft); color: var(--paper); }

.download-btn.large {
  padding: .65rem 1.4rem;
  font-size: 1rem;
}

/* ── Breadcrumb (generic) ───────────────────────────────── */

.breadcrumb {
  margin-bottom: 1.5rem;
  font-family: 'Fraunces', serif;
  font-size: .9rem;
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.breadcrumb a:hover { border-bottom-color: var(--accent); }

/* ── Script detail page ────────────────────────────────── */

.script-detail { max-width: var(--max); }

.script-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.2rem;
}

.script-number {
  color: var(--ink-faint);
  font-family: 'Fraunces', serif;
  font-size: .82rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: .4rem;
}

.script-header h1 {
  font-size: clamp(1.6rem, 3.4vw, 2.2rem);
  color: var(--ink);
  margin: 0 0 .4rem;
  padding: 0;
  border: none;
}

.script-source {
  color: var(--ink-soft);
  margin-top: .3rem;
  font-style: italic;
}

.field-section,
.character-section,
.levels-section,
.fire-keeper-section {
  margin-bottom: 2rem;
}

.script-detail h2 {
  font-size: 1.2rem;
  color: var(--ink);
  margin: 1.6rem 0 .8rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  border-bottom: none;
}

.script-detail h3 {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 1.2rem 0 .5rem;
  font-weight: 500;
}

.field-definition {
  font-style: italic;
  color: var(--ink-soft);
}

.territory-header-text {
  color: var(--ink-faint);
  font-size: .92rem;
}

.contrasts { padding-left: 1.2rem; }
.contrasts li {
  margin-bottom: .4rem;
  font-size: .98rem;
}

.read-silently {
  font-size: .82rem;
  color: var(--ink-faint);
  font-weight: normal;
  font-style: italic;
}

.as-if { font-style: italic; }

.level-block {
  margin-bottom: 1.5rem;
  padding: 1rem 1.2rem;
  background: var(--paper-deep);
  border-left: 3px solid var(--rule);
  border-radius: 0;
}

.script-text {
  white-space: pre-wrap;
  line-height: 1.7;
}

.actor-line { margin-bottom: .8rem; }

/* Antagonist + voice label — preserve the original chalk/cursive
 * intent (it's deliberate authoring) but in the new ink palette. */
.antagonist-line {
  margin: .8rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--ink-faint);
  font-family: "Comic Sans MS", "Chalkboard SE", cursive;
  color: var(--ink);
}

.voice-label {
  font-size: .82rem;
  font-weight: bold;
  color: var(--ink-soft);
  margin-right: .5rem;
  font-family: "Comic Sans MS", "Chalkboard SE", cursive;
}

/* ── Fire Keeper section (special-cased) ─────────────────── */

.fire-keeper-section {
  background: var(--warning-soft);
  border: 1px solid #e8c97a;
  border-radius: 2px;
  padding: 1rem 1.2rem;
}

.fk-note {
  font-size: .82rem;
  color: var(--ink-faint);
  font-weight: normal;
  font-style: italic;
}

.provocations { padding-left: 1.2rem; }
.provocations li { margin-bottom: .5rem; }

/* ── Download + rating sections (script detail tail) ────── */

.download-section {
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}

.rating-section {
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}

.rating-summary {
  color: var(--ink-soft);
  font-size: .92rem;
  margin-bottom: .5rem;
}

.star-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: .5rem;
}

.star-label { cursor: pointer; }
.star-label input { display: none; }

.star {
  font-size: 1.6rem;
  color: var(--rule);
  transition: color .15s;
  cursor: pointer;
}

.star.filled { color: var(--warning); }

.star-label:hover .star,
.star-label input:checked ~ .star {
  color: var(--warning);
}

.star-hint {
  color: var(--ink-faint);
  font-size: .88rem;
  margin-left: 6px;
  font-style: italic;
}

.rating-notes {
  display: block;
  width: 100%;
  max-width: 500px;
  height: 60px;
  margin-bottom: .5rem;
  padding: .5rem;
  font-family: 'Newsreader', Georgia, serif;
  font-size: .95rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  resize: vertical;
}

.rate-btn {
  padding: .35rem .9rem;
  background: var(--accent);
  color: var(--paper);
  border: none;
  border-radius: 2px;
  font-family: 'Fraunces', serif;
  font-size: .9rem;
  cursor: pointer;
  letter-spacing: .02em;
  transition: background .2s;
}

.rate-btn:hover { background: var(--accent-soft); }

.rating-msg {
  color: var(--ink-faint);
  font-size: .9rem;
  font-style: italic;
}

/* ── Tables (papers index, etc.) ─────────────────────────── */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.6rem 0;
  font-size: .96rem;
}

th, td {
  border: 1px solid var(--rule);
  padding: .5rem .7rem;
  text-align: left;
}

th {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  background: var(--paper-deep);
}

/* ── Small-screen ────────────────────────────────────────── */

@media (max-width: 640px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.2rem 1.4rem;
  }
  .header-nav { flex-wrap: wrap; gap: .75rem; }
  main { padding: 0 1.4rem; margin: 1.5rem auto 3rem; }
  body { font-size: 1.08rem; }
}

/* ── Print styles (preserve from legacy — script_print.html
 *    depends on these) ─────────────────────────────────── */

@media print {
  header,
  .header-left,
  .header-nav,
  .site-title,
  .breadcrumb,
  .download-section,
  .rating-section,
  nav {
    display: none !important;
    visibility: hidden !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-family: Georgia, serif !important;
    margin: 0;
    padding: 0.5in;
  }
  main { margin: 0; padding: 0; max-width: none; }
  .script-detail { max-width: none; }

  .fire-keeper-section,
  .level-block {
    background: #fff !important;
    border: none !important;
  }

  body.print-script-only .fire-keeper-section { display: none !important; }
  body.print-script-only .field-section { display: none !important; }

  body.print-firekeeper-only .script-header,
  body.print-firekeeper-only .field-section,
  body.print-firekeeper-only .character-section,
  body.print-firekeeper-only .levels-section {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
  }
}
