/* Shared styles for both /index.html and /coaches.html.
   Each page sets its own color tokens via :root before this loads. */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Trebuchet MS", Verdana, sans-serif;
  font-size: 17px; line-height: 1.6; color: var(--ink); background: var(--cream); min-height: 100vh;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
header { text-align: center; border-bottom: 3px double var(--green); padding-bottom: 22px; margin-bottom: 28px; position: relative; }
header .crest { font-family: Garamond, "EB Garamond", Georgia, serif; font-size: 14px; letter-spacing: 4px; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
header h1 { font-family: Garamond, "EB Garamond", Georgia, serif; font-size: clamp(28px, 5vw, 44px); margin: 0 0 8px; color: var(--green); font-weight: 600; letter-spacing: 0.5px; }
header .sub { font-size: 15px; color: var(--muted); font-style: italic; max-width: 560px; margin: 0 auto; }
header .nav { position: absolute; top: 6px; right: 6px; display: flex; gap: 12px; }
header .nav a { font-size: 13px; color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 14px; border: 1px solid transparent; }
header .nav a.current { color: var(--green); border-color: var(--green); background: var(--paper); }
header .nav a:not(.current):hover { color: var(--green); border-color: var(--rule); }

section { margin-bottom: 28px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.section-num { font-family: Garamond, Georgia, serif; font-size: 22px; color: var(--gold); }
h2 { font-family: Garamond, Georgia, serif; font-size: 22px; color: var(--green); margin: 0; font-weight: 600; }
.section-help { font-size: 14px; color: var(--muted); margin: 4px 0 14px; font-style: italic; }

.cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.persona { background: var(--paper); border: 2px solid var(--rule); border-radius: 12px; padding: 12px 14px; cursor: pointer; transition: all 0.15s ease; user-select: none; position: relative; }
.persona:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(20,40,30,0.08); }
.persona.on { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.persona.on::after { content: "✓"; position: absolute; top: 8px; right: 10px; color: var(--green); font-weight: 700; font-size: 16px; }
.persona .name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.persona .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.persona .blurb { font-size: 13px; color: var(--muted); margin-top: 4px; }
.persona .philo-label { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 10px; font-weight: 600; }
.persona .philo-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.persona .philo-chip { font-size: 11px; padding: 3px 8px; border-radius: 10px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer; font-weight: 500; transition: all 0.12s ease; }
.persona .philo-chip:hover { border-color: var(--gold); color: var(--gold); }
.persona .philo-chip.on { background: var(--gold); border-color: var(--gold); color: var(--paper); }
.speaker-pill .philo-badge { background: var(--gold); color: var(--paper); padding: 2px 7px; border-radius: 9px; font-size: 11px; font-weight: 600; opacity: 0.85; }

.scenarios { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-bottom: 12px; }
.scenario-card { background: var(--paper); border: 2px solid var(--rule); border-radius: 10px; padding: 10px 12px; cursor: pointer; transition: all 0.15s ease; }
.scenario-card:hover { border-color: var(--green); box-shadow: 0 4px 14px rgba(20,40,30,0.08); }
.scenario-card.on { border-color: var(--green); background: var(--green-soft); }
.scenario-card .title { font-weight: 700; font-size: 14px; color: var(--green); }
.scenario-card .desc { font-size: 13px; color: var(--muted); margin-top: 4px; }

textarea, input[type=text] { width: 100%; font-family: inherit; font-size: 16px; padding: 12px 14px; border: 2px solid var(--rule); border-radius: 10px; background: var(--paper); color: var(--ink); resize: vertical; }
textarea:focus, input:focus { border-color: var(--green); outline: none; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.controls select { font-family: inherit; font-size: 15px; padding: 8px; border-radius: 6px; border: 2px solid var(--rule); background: var(--paper); margin-left: 6px; }
button { font-family: inherit; font-size: 15px; font-weight: 600; padding: 11px 20px; border-radius: 10px; border: 2px solid var(--green); background: var(--green); color: var(--paper); cursor: pointer; transition: all 0.15s ease; }
button:hover:not(:disabled) { background: var(--green-deep); border-color: var(--green-deep); }
button.ghost { background: var(--paper); color: var(--green); }
button.ghost:hover:not(:disabled) { background: var(--green-soft); color: var(--green); }
button.tiny { padding: 5px 10px; font-size: 12px; border-width: 1px; border-radius: 14px; font-weight: 500; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

#status { margin-top: 12px; font-size: 14px; color: var(--muted); min-height: 20px; font-style: italic; }
.thinking { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin: 0 2px; animation: bounce 1.4s infinite ease-in-out both; }
.thinking:nth-child(1) { animation-delay: -0.32s; }
.thinking:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

#chat-container { background: var(--paper); border: 2px solid var(--rule); border-radius: 12px; overflow: hidden; }
#speaker-bar { display: none; flex-wrap: wrap; gap: 8px; padding: 12px 14px; background: var(--green-soft); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 5; }
.speaker-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 18px; background: var(--paper); border: 1px solid var(--rule); font-size: 13px; }
.speaker-pill .speaker-name { font-weight: 600; }
.speaker-pill .direction-badge { background: var(--gold); color: var(--paper); padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.speaker-pill.has-direction { border-color: var(--gold); }
.speaker-pill .pill-btn { background: transparent; color: var(--green); border: 1px solid var(--rule); padding: 3px 9px; font-size: 12px; border-radius: 12px; font-weight: 500; }
.speaker-pill .pill-btn:hover { background: var(--green-soft); border-color: var(--green); }

#chat { padding: 18px; min-height: 240px; max-height: 60vh; overflow-y: auto; }
#chat:empty::before { content: "The room is silent. Press “Begin the conversation.”"; display: block; text-align: center; font-style: italic; color: #8a937e; padding: 60px 10px; font-family: Garamond, Georgia, serif; font-size: 18px; }
.bubble { margin: 16px 0; padding: 12px 16px; border-radius: 12px; border-left: 5px solid; background: #f7f4ea; position: relative; animation: fadeIn 0.35s ease-out; }
.bubble .speaker { font-weight: 700; font-size: 14px; letter-spacing: 0.4px; text-transform: uppercase; margin-bottom: 4px; }
.bubble .stage { font-style: italic; color: #6b7166; font-size: 14px; margin: 4px 0; }
.bubble .line { font-size: 17px; line-height: 1.55; }
.bubble.scene { background: #efece1; border-left-color: #6b7166; font-style: italic; color: #4a4f48; font-size: 15px; }
.bubble.scene .speaker { color: #6b7166; font-weight: 600; letter-spacing: 1px; }
.bubble.typing { background: #f3efe1; border-left-style: dashed; opacity: 0.85; }
.bubble.typing .line { color: var(--muted); font-style: italic; }

.controls-bottom { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
footer { margin-top: 36px; font-size: 12px; color: #8a937e; text-align: center; padding-top: 18px; border-top: 1px dashed var(--rule); font-family: Garamond, Georgia, serif; letter-spacing: 1px; }
.error { background: #fff3d6; border: 2px solid #c2871b; border-radius: 8px; padding: 12px 14px; color: #5a3e0a; margin-top: 10px; font-size: 14px; display: none; }
.error.show { display: block; }

/* Chip popup */
.chip-popup { position: absolute; background: var(--paper); border: 2px solid var(--green); border-radius: 12px; padding: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); z-index: 100; width: 340px; }
.chip-popup .chip-head { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.chip-popup .chip-head .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip-popup .chips { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.chip-popup textarea { font-size: 13px; padding: 6px 8px; min-height: 50px; }
.chip-popup .popup-controls { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }

/* Fullscreen mode */
body.fullscreen .wrap { max-width: 100%; padding: 0; }
body.fullscreen header,
body.fullscreen section:nth-of-type(1),
body.fullscreen section:nth-of-type(2),
body.fullscreen footer,
body.fullscreen #status,
body.fullscreen #error { display: none; }
body.fullscreen section:nth-of-type(3) { margin: 0; }
body.fullscreen .section-head { display: none; }
body.fullscreen #chat-container { border-radius: 0; border: none; height: 100vh; display: flex; flex-direction: column; }
body.fullscreen #chat { max-height: none; flex: 1; padding: 24px clamp(20px, 5vw, 80px); }
body.fullscreen .controls-bottom { padding: 12px 16px; border-top: 1px solid var(--rule); margin: 0; background: var(--paper); }
body.fullscreen #fullscreen { position: fixed; top: 12px; right: 12px; z-index: 50; }

@media (max-width: 600px) {
  .wrap { padding: 20px 14px 40px; }
  header h1 { font-size: 26px; }
  header .nav { position: static; justify-content: center; margin-bottom: 8px; }
  .bubble { padding: 10px 12px; }
  .chip-popup { width: calc(100vw - 30px); max-width: 340px; }
}
