/*
 * Metamorphosis on the web — the text version: a journey is a log of typed
 * events (docs: mechanics v4 §11), each type with its own look. No pictures yet.
 * Built on Me Across Time's site.css: the same names for the same things.
 */
:root {
  --bg: #15141B; --raised: #201E28; --sunken: #1A1821; --line: #34303F; --ink: #ECE8F2; --muted: #A29DB0;
  --button: #E9E3F5; --accent: #B9A2E8; --mine: #2D2840; --error: #FF8A80; --ok: #8FCB9B;
  /* One colour per space, used only as a mark. */
  --body: #E8A87C; --activity: #E2C35E; --relationships: #E58FA6; --meaning: #7FB3E0; --emotions: #B9A2E8;
  --serif: Georgia, 'EB Garamond', 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--error); }
.notice { color: var(--accent); }
.hidden { display: none !important; }
.small { font-size: 14px; }
.tiny { font-size: 12px; }

.page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px 16px; gap: 14px; }
.column { width: 100%; max-width: 720px; margin: 0 auto; padding: 20px 16px 32px; display: flex; flex-direction: column; gap: 18px; flex: 1; }
.welcome { max-width: 560px; margin: 0 auto; }
.welcome .intro { line-height: 1.6; }
.mark { font-family: var(--serif); color: var(--accent); }
.welcome .mark { font-size: 64px; line-height: 1; margin: 0; }
.title { font-size: 44px; }
.heading { font-size: 30px; line-height: 1.2; }
.actions { display: flex; flex-direction: column; align-items: center; gap: 16px; margin: 20px 0; }

.brand { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink); text-decoration: none; font-family: var(--serif); font-size: 19px; }
.brand .mark { font-size: 22px; }
.topbar { display: flex; align-items: center; gap: 12px; }
.topbar .brand { justify-content: flex-start; }
.topbar .right { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.topbar .right a, .topbar .right button { color: var(--muted); font-size: 13px; text-decoration: none; }
.topbar .right a:hover, .topbar .right button:hover { color: var(--ink); }

.card { background: var(--sunken); border: 1px solid var(--line); border-radius: 16px; padding: 24px 20px; display: flex; flex-direction: column; gap: 14px; }
.card p { margin: 0; }
.column > .card { max-width: 520px; width: 100%; margin: 0 auto; }
.links { font-size: 14px; color: var(--muted); }

label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }

.pill { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 24px; border: 0; border-radius: 999px;
  background: var(--button); color: var(--bg); font: 500 15px var(--sans); text-decoration: none; cursor: pointer; }
.pill:disabled { opacity: .45; cursor: default; }
.pill.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.pill.small { min-height: 34px; padding: 0 16px; font-size: 14px; }
.link { color: var(--muted); background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none; padding: 4px; }
.link:hover { color: var(--ink); }

/* The password strength line (public/js/strength.js). */
.pw { margin-top: -6px; font-size: 13px; }
.pw[hidden] { display: none; }
.pw-track { display: flex; gap: 5px; margin-bottom: 5px; }
.pw-track span { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.pw-label { color: var(--muted); }
.pw[data-score="0"] .pw-track span:nth-child(1) { background: #b4584f; }
.pw[data-score="0"] .pw-label { color: var(--error); }
.pw[data-score="1"] .pw-track span:nth-child(1) { background: #c98a3c; }
.pw[data-score="2"] .pw-track span:nth-child(-n+2) { background: var(--accent); }
.pw[data-score="3"] .pw-track span { background: var(--ok); }
.pw[data-score="2"] .pw-label, .pw[data-score="3"] .pw-label { color: var(--ink); }

/* ---- Home: a new journey, and the journeys so far. ---- */
.new-journey textarea { min-height: 96px; }
.new-journey .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.journeys { display: flex; flex-direction: column; gap: 8px; }
.journey-row { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; background: var(--sunken); }
.journey-row:hover { border-color: var(--accent); }
.journey-row .q { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.journey-row .meta { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.status { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.status.completed { color: var(--ok); border-color: var(--ok); }
.status.paused { color: var(--activity); border-color: var(--activity); }

/* ---- A journey. ---- */
.journey-page { height: 100vh; height: 100dvh; }
.journey-page .column { min-height: 0; padding-bottom: 12px; gap: 12px; }
.question { font-family: var(--serif); font-size: 19px; line-height: 1.35; }

/* The five spaces: where the focus is, and how far each is explored. */
.spaces { display: flex; gap: 6px; flex-wrap: wrap; }
.space-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: none; color: var(--muted); font: 13px var(--sans); cursor: pointer; }
.space-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); opacity: .35; }
.space-chip .st { font-family: var(--mono); font-size: 12px; }
.space-chip.in_progress .dot, .space-chip.reopened .dot { opacity: .7; }
.space-chip.sufficient_for_now { color: var(--ink); }
.space-chip.sufficient_for_now .dot { opacity: 1; }
.space-chip.current { border-color: var(--c); color: var(--ink); }
.space-chip:disabled { cursor: default; }
.space-body { --c: var(--body); } .space-activity { --c: var(--activity); } .space-relationships { --c: var(--relationships); }
.space-meaning { --c: var(--meaning); } .space-emotions { --c: var(--emotions); }

.log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 8px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.bubble .who { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.bubble.theirs { background: var(--raised); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.mine { background: var(--mine); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.pending { opacity: .6; }

/* Engine events: one line across the log. */
.sys { align-self: stretch; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.sys::before, .sys::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.sys b { color: var(--ink); font-weight: 500; }
.sys .why { display: block; font-size: 12px; }
.sys-block { align-self: center; text-align: center; color: var(--muted); font-size: 13px; max-width: 90%; }
.sys-block ul { margin: 4px 0 0; padding: 0; list-style: none; }

/* Mechanics, archetypes, cards: framed, with their name above. */
.event { align-self: flex-start; max-width: 90%; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 12px; padding: 10px 14px; background: var(--sunken); }
.event .kind { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.event .poles { font-family: var(--serif); font-size: 17px; margin-top: 6px; }
.event .word { font-family: var(--serif); font-style: italic; }
.event.archetype { border-left-color: var(--activity); }
.event.archetype .kind { color: var(--activity); }
.event.archetype .speech { font-family: var(--serif); font-size: 17px; white-space: pre-wrap; }
.event.resource { border-left-color: var(--ok); } .event.resource .kind { color: var(--ok); }
.event.shadow { border-left-color: #7d7790; } .event.shadow .kind { color: #a7a1b8; }

.cards { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.mak { width: 190px; text-align: left; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--bg); color: var(--ink); font: inherit; }
button.mak { cursor: pointer; }
button.mak:hover:not(:disabled) { border-color: var(--accent); }
.mak:disabled { cursor: default; }
.mak .no { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.mak .name { display: block; font-family: var(--serif); font-size: 19px; margin: 2px 0 6px; }
.mak .field { font-size: 13px; color: var(--muted); }
.mak .group { display: block; font-size: 11px; color: var(--muted); margin-top: 8px; }
.mak.chosen { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.mak.faded { opacity: .45; }

.options { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 8px; max-width: 95%; }
.option { border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; background: none; color: var(--ink); font: 14px var(--sans); cursor: pointer; }
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled { cursor: default; color: var(--muted); }
.option.chosen { border-color: var(--accent); color: var(--ink); background: var(--mine); }

.event.check { border-left-color: var(--meaning); align-self: stretch; max-width: none; }
.event.check .kind { color: var(--meaning); }
.event.check blockquote { margin: 10px 0 2px; padding: 8px 12px; border-left: 2px solid var(--meaning); font-family: var(--serif); font-size: 17px; }
.flight { align-self: stretch; text-align: center; border: 1px solid var(--accent); border-radius: 16px; padding: 22px 18px; background: var(--sunken); }
.flight .mark { font-size: 40px; display: block; }
.flight h2 { font-size: 26px; margin: 4px 0 10px; }
.flight blockquote { font-family: var(--serif); font-size: 18px; margin: 0 auto; max-width: 560px; }

/* What only "Show internal" reveals: the Director's notes, the Engine's corrections, reasons. */
.internal { align-self: stretch; font-family: var(--mono); font-size: 11.5px; color: #8c86a0; border: 1px dashed var(--line); border-radius: 8px; padding: 6px 10px; white-space: pre-wrap; }
.reason { display: block; margin-top: 4px; font-family: var(--mono); font-size: 11.5px; color: #8c86a0; }

.thinking { color: var(--muted); font-size: 13px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* The bottom: what the player can do now. */
.dock { display: flex; flex-direction: column; gap: 8px; }
.composer { display: flex; gap: 6px; align-items: flex-end; background: var(--raised); border-radius: 22px; padding: 4px 4px 4px 6px; }
.composer textarea { flex: 1; min-height: 44px; max-height: 180px; background: transparent; border: 0; padding: 11px 10px; resize: none; }
.dock .tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.dock .tools .spacer { flex: 1; }
.confirm-row { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.toggle input { width: auto; }

@media (max-width: 520px) {
  .mak { width: calc(50% - 5px); }
  .bubble, .event { max-width: 100%; }
  .journey-row .meta { display: none; }
}

/* The language switcher: a small select, top right on every page. */
.lang { width: auto; padding: 4px 26px 4px 10px; font-size: 13px; border-radius: 999px; color: var(--muted); background-color: transparent; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
.lang:hover, .lang:focus { color: var(--ink); border-color: var(--accent); }
.lang option { background: var(--raised); color: var(--ink); }
.corner { position: absolute; top: 16px; right: 16px; }
.page { position: relative; }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
