/* The Folly Players — theatrical design system
   Ink stage, gilded gold, curtain red, parchment cream. */
:root {
  --ink: #14101c;
  --ink-2: #1d1728;
  --ink-3: #262033;
  --line: #3a3149;
  --gold: #d4a946;
  --gold-soft: #b8963e;
  --red: #8e2432;
  --red-bright: #c0392b;
  --cream: #f2e8d5;
  --cream-dim: #cfc3ae;
  --muted: #9a8fae;
  --ok: #6fbf73;
  --serif: "Playfair Display", Georgia, serif;
  --garamond: "EB Garamond", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--ink); color: var(--cream);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--sans); cursor: pointer; }

/* ------------------------------------------------ header */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #1a1426, var(--ink));
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--gold); }
.brand:hover { text-decoration: none; }
.brand-masks { width: 44px; height: 30px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-kicker { font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 19px; color: var(--cream); }
.site-nav { display: flex; align-items: center; gap: 18px; }
.site-nav a { color: var(--cream-dim); font-size: 14px; font-weight: 500; }
.site-nav a.active, .site-nav a:hover { color: var(--gold); text-decoration: none; }
.nav-cta {
  background: var(--gold); color: #241c0a !important; padding: 8px 16px;
  border-radius: 999px; font-weight: 600;
}
.nav-cta:hover { background: #e4bd5b; }
.nav-user { color: var(--cream); font-size: 14px; }

/* ------------------------------------------------ layout */
.view { flex: 1; width: 100%; }
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 24px; }
.center { text-align: center; }

/* ------------------------------------------------ hero */
.hero {
  position: relative; overflow: hidden; padding: 96px 24px 84px; text-align: center;
  background:
    radial-gradient(ellipse 75% 90% at 50% -15%, rgba(212,169,70,.16), transparent 60%),
    radial-gradient(ellipse 50% 60% at 50% 0%, rgba(142,36,50,.25), transparent 65%),
    linear-gradient(180deg, #1b1327 0%, var(--ink) 90%);
}
.hero::before, .hero::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 90px;
  background: linear-gradient(90deg, rgba(142,36,50,.35), transparent);
  pointer-events: none;
}
.hero::before { left: 0; }
.hero::after { right: 0; transform: scaleX(-1); }
.hero-kicker {
  font-size: 12px; letter-spacing: .32em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 18px;
}
.hero h1 {
  font-family: var(--serif); font-weight: 900; margin: 0 0 18px;
  font-size: clamp(42px, 7vw, 76px); line-height: 1.05; color: var(--cream);
}
.hero h1 em { font-style: italic; color: var(--gold); }
.hero-sub {
  max-width: 620px; margin: 0 auto 34px; color: var(--cream-dim);
  font-family: var(--garamond); font-size: 21px;
}
.hero-ctas { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; padding: 13px 26px; font-size: 15px; font-weight: 600;
  border: 1px solid transparent; transition: all .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-gold { background: linear-gradient(180deg, #e2bc57, var(--gold-soft)); color: #241c0a; box-shadow: 0 6px 22px rgba(212,169,70,.28); }
.btn-ghost { border-color: var(--line); color: var(--cream); background: rgba(255,255,255,.03); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-red { background: var(--red); color: var(--cream); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ------------------------------------------------ sections */
.section { padding: 56px 0; }
.section-title {
  font-family: var(--serif); font-weight: 700; font-size: 32px;
  margin: 0 0 8px; color: var(--cream);
}
.section-sub { color: var(--muted); margin: 0 0 32px; max-width: 640px; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 24px; background: var(--ink-2); position: relative;
}
.step-num {
  font-family: var(--serif); font-size: 42px; font-weight: 900; color: var(--gold);
  opacity: .9; line-height: 1; margin-bottom: 12px;
}
.step h3 { margin: 0 0 8px; font-size: 17px; }
.step p { margin: 0; color: var(--muted); font-size: 14.5px; }

/* ------------------------------------------------ play cards */
.play-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.play-card {
  display: block; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(160deg, var(--ink-2), var(--ink-3));
  padding: 26px 24px 22px; color: var(--cream); transition: all .18s ease;
  position: relative; overflow: hidden;
}
.play-card:hover { text-decoration: none; border-color: var(--gold); transform: translateY(-3px); box-shadow: var(--shadow); }
.play-card .ribbon {
  position: absolute; top: 14px; right: -34px; transform: rotate(38deg);
  background: var(--red); color: var(--cream); font-size: 10px; font-weight: 600;
  letter-spacing: .14em; padding: 4px 40px; text-transform: uppercase;
}
.play-card .ribbon.done { background: #2e5d33; }
.play-author { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.play-title { font-family: var(--serif); font-weight: 700; font-size: 24px; margin: 0 0 16px; line-height: 1.2; }
.play-meta { display: flex; gap: 14px; color: var(--muted); font-size: 13px; margin-top: 12px; }

/* marquee progress bar */
.bar { height: 12px; border-radius: 999px; background: #0d0a13; border: 1px solid var(--line); overflow: hidden; position: relative; }
.bar-fill {
  height: 100%; border-radius: 999px; min-width: 0;
  background: linear-gradient(90deg, #a87e2a, var(--gold) 55%, #efd48a);
  position: relative; transition: width .6s ease;
}
.bar-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.35) 48%, transparent 60%);
  animation: shimmer 3.2s infinite;
}
.bar-fill.full { background: linear-gradient(90deg, #4d8a52, var(--ok) 60%, #a5dba8); }
@keyframes shimmer { 0% { transform: translateX(-100%);} 60%,100% { transform: translateX(100%);} }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-row .bar { flex: 1; }
.bar-label { font-size: 13px; color: var(--cream-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ play page: roles */
.play-hero { padding: 52px 0 26px; }
.back-link { font-size: 13px; color: var(--muted); display: inline-block; margin-bottom: 14px; }
.play-hero h1 { font-family: var(--serif); font-weight: 900; font-size: clamp(30px, 5vw, 48px); margin: 0 0 8px; }
.play-hero .bar-row { max-width: 560px; margin-top: 18px; }

.role-list { display: flex; flex-direction: column; gap: 12px; margin: 26px 0 60px; }
.role-card {
  display: grid; grid-template-columns: 1fr 2fr auto; gap: 18px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--ink-2); padding: 18px 22px;
}
.role-card.sd { border-style: dashed; }
.role-name { font-family: var(--serif); font-weight: 700; font-size: 19px; }
.role-stats { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.role-readers { font-size: 12.5px; color: var(--muted); margin-top: 7px; }
.role-readers b { color: var(--cream-dim); font-weight: 500; }
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; border-radius: 999px; padding: 3px 10px; margin-left: 8px;
  vertical-align: 2px;
}
.badge-open { background: rgba(142,36,50,.25); color: #e6899a; border: 1px solid rgba(142,36,50,.6); }
.badge-cast { background: rgba(111,191,115,.14); color: var(--ok); border: 1px solid rgba(111,191,115,.4); }
.badge-mine { background: rgba(212,169,70,.14); color: var(--gold); border: 1px solid rgba(212,169,70,.45); }

/* ------------------------------------------------ booth */
.booth { max-width: 860px; margin: 0 auto; padding: 26px 20px 130px; }
.booth-top { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.booth-part { font-size: 13px; color: var(--muted); }
.booth-part b { color: var(--gold); font-weight: 600; }
.booth-progress { flex: 1; min-width: 220px; }
.booth-stage {
  border: 1px solid var(--line); border-radius: 18px; margin-top: 14px;
  background:
    radial-gradient(ellipse 90% 70% at 50% -20%, rgba(212,169,70,.10), transparent 60%),
    linear-gradient(170deg, var(--ink-2), var(--ink));
  padding: 40px 36px 34px; min-height: 320px;
  display: flex; flex-direction: column; justify-content: center;
}
.booth-scene { font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--muted); margin-bottom: 20px; text-align: center; }
.booth-cue { text-align: center; color: var(--muted); font-family: var(--garamond); font-style: italic; font-size: 16.5px; max-width: 620px; margin: 0 auto 22px; }
.booth-cue b { color: var(--cream-dim); font-style: normal; font-variant: small-caps; }
.booth-line {
  font-family: var(--garamond); font-size: clamp(21px, 2.6vw, 27px); line-height: 1.55;
  color: var(--cream); text-align: center; max-width: 680px; margin: 0 auto; white-space: pre-wrap;
}
.booth-speaker { text-align: center; font-variant: small-caps; letter-spacing: .12em; color: var(--gold); font-size: 17px; margin-bottom: 10px; }
.booth-status { text-align: center; min-height: 26px; margin-top: 20px; font-size: 14px; color: var(--muted); }
.booth-status.rec { color: var(--red-bright); font-weight: 600; }
.booth-status.ok { color: var(--ok); }

.level-wrap { max-width: 320px; margin: 12px auto 0; height: 6px; border-radius: 999px; background: #0d0a13; overflow: hidden; }
.level-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ok), var(--gold), var(--red-bright)); transition: width .06s linear; }

.booth-controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(20,16,28,.6), #100c18 40%);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
}
.booth-controls-inner { max-width: 860px; margin: 0 auto; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.rec-btn {
  width: 74px; height: 74px; border-radius: 50%; border: 3px solid var(--red-bright);
  background: radial-gradient(circle at 35% 30%, #d24a3c, var(--red));
  color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .08em;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 0 rgba(192,57,43,.5); flex-shrink: 0;
}
.rec-btn.recording { animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(192,57,43,.55);} 70% { box-shadow: 0 0 0 22px rgba(192,57,43,0);} 100% { box-shadow: 0 0 0 0 rgba(192,57,43,0);} }
.kbd-hints { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.kbd-hints kbd {
  background: var(--ink-3); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; font-family: var(--sans); font-size: 10.5px;
}

.line-nav { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 18px; }
.line-dot {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--ink-2); color: var(--muted); font-size: 10.5px; display: flex;
  align-items: center; justify-content: center; padding: 0;
}
.line-dot.done { background: rgba(111,191,115,.18); border-color: rgba(111,191,115,.5); color: var(--ok); }
.line-dot.cur { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 0 2px rgba(212,169,70,.25); }

/* ------------------------------------------------ forms */
.auth-card {
  max-width: 430px; margin: 60px auto; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--ink-2); padding: 36px 34px;
}
.auth-card h1 { font-family: var(--serif); font-size: 28px; margin: 0 0 6px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--cream-dim); margin-bottom: 6px; }
.field input[type=text], .field input[type=email], .field input[type=password] {
  width: 100%; background: #0e0a16; color: var(--cream); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; font-size: 15px; font-family: var(--sans);
}
.field input:focus { outline: none; border-color: var(--gold); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--cream-dim); margin: 18px 0; }
.check input { margin-top: 3px; accent-color: var(--gold); }
.form-error { color: #e6899a; font-size: 13.5px; min-height: 20px; margin: 6px 0 10px; }
.auth-swap { text-align: center; font-size: 13.5px; color: var(--muted); margin-top: 18px; }

/* ------------------------------------------------ prose (about/license) */
.prose { max-width: 720px; margin: 48px auto 70px; padding: 0 24px; }
.prose h1 { font-family: var(--serif); font-size: 36px; }
.prose h2 { font-family: var(--serif); font-size: 22px; margin-top: 34px; }
.prose p, .prose li { color: var(--cream-dim); font-size: 15.5px; }

/* ------------------------------------------------ catalogue browse */
.browse-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 0 0 18px; }
.search-wrap { position: relative; flex: 1; min-width: 240px; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search-input {
  width: 100%; background: #0e0a16; color: var(--cream); border: 1px solid var(--line);
  border-radius: 999px; padding: 11px 18px 11px 40px; font-size: 15px; font-family: var(--sans);
}
.search-input:focus { outline: none; border-color: var(--gold); }
.sort-select {
  background: #0e0a16; color: var(--cream-dim); border: 1px solid var(--line);
  border-radius: 999px; padding: 11px 14px; font-size: 13.5px; font-family: var(--sans);
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 22px; }
.chip {
  border: 1px solid var(--line); background: var(--ink-2); color: var(--cream-dim);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 500;
}
.chip.active { border-color: var(--gold); color: var(--gold); background: rgba(212,169,70,.1); }
.play-cat {
  display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 9px; margin-top: 14px;
}
.load-more-row { text-align: center; margin: 28px 0 8px; }
.result-count { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

/* ------------------------------------------------ recovery code */
.recovery-box {
  border: 1px dashed var(--gold); border-radius: var(--radius); background: rgba(212,169,70,.06);
  padding: 22px; text-align: center; margin: 18px 0;
}
.recovery-code {
  font-family: ui-monospace, Consolas, monospace; font-size: 26px; letter-spacing: .12em;
  color: var(--gold); margin: 10px 0 14px; user-select: all;
}
.recovery-warn { font-size: 13px; color: var(--cream-dim); margin: 0 0 4px; }

/* ------------------------------------------------ misc */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink-3); color: var(--cream); border: 1px solid var(--gold);
  border-radius: 10px; padding: 12px 22px; font-size: 14px; opacity: 0;
  pointer-events: none; transition: all .25s ease; z-index: 60; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.spinner {
  width: 34px; height: 34px; border-radius: 50%; margin: 70px auto;
  border: 3px solid var(--line); border-top-color: var(--gold);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

.site-footer { border-top: 1px solid var(--line); background: #100c18; margin-top: auto; }
.footer-inner { max-width: 1060px; margin: 0 auto; padding: 26px 24px; font-size: 13px; color: var(--muted); }
.footer-inner p { margin: 4px 0; }

@media (max-width: 760px) {
  .steps { grid-template-columns: 1fr; }
  .role-card { grid-template-columns: 1fr; gap: 10px; }
  .site-header { padding: 12px 16px; }
  .site-nav { gap: 12px; }
  .brand-kicker { display: none; }
  .booth-stage { padding: 28px 18px; }
  .hero { padding: 64px 18px 56px; }
}
