/* SpreadMind 2026.
   Layout: an instrument. The plate (the world, time × location) leads, with its transport bar
   underneath like a player; the experience selector and settings sit in a side column; the
   reading notes close the page. Three skins: light blue (default), night, and the 2014 classic. */
:root {
    /* light blue */
    --bg: #e9f3fd;
    --bg-glow: #d3e8fb;
    --surface: #ffffff;
    --surface-2: #f3f8fe;
    --ink: #0f2a44;
    --muted: #5d7c99;
    --line: #d2e3f4;
    --accent: #0a7cff;
    --accent-soft: #dcecff;
    --accent-ink: #ffffff;
    --effect: #ff5a3c;
    --genealogy: #7a5cff;
    --shadow: 0 1px 2px rgba(15, 42, 68, .05), 0 8px 24px -12px rgba(15, 42, 68, .18);
    --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
    --font-ui: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-prose: "Newsreader", "Iowan Old Style", Georgia, serif;
    --font-data: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    --radius: 16px;
    --radius-s: 10px;
    color-scheme: light;
}
:root[data-skin="dark"] {
    --bg: #060914;
    --bg-glow: #0f1a3a;
    --surface: #0e1425;
    --surface-2: #121a2e;
    --ink: #e3eaff;
    --muted: #8291b6;
    --line: #1e2841;
    --accent: #3ad0ff;
    --accent-soft: #10324a;
    --accent-ink: #041320;
    --effect: #ff4fa3;
    --genealogy: #a98bff;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 12px 32px -16px rgba(0, 0, 0, .7);
    color-scheme: dark;
}
:root[data-skin="classic"] {
    --bg: #ececec;
    --bg-glow: #ececec;
    --surface: #ffffff;
    --surface-2: #f6f6f6;
    --ink: #1a1a1a;
    --muted: #666666;
    --line: #d4d4d4;
    --accent: #d40000;
    --accent-soft: #ffe1e1;
    --accent-ink: #ffffff;
    --effect: #d40000;
    --genealogy: #1f6fd6;
    --shadow: none;
    --radius: 4px;
    --radius-s: 3px;
    color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: radial-gradient(1200px 600px at 15% -10%, var(--bg-glow), transparent 70%), var(--bg);
    background-attachment: fixed;
    color: var(--ink);
    font: 15px/1.5 var(--font-ui);
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-block: env(safe-area-inset-top, 0px) env(safe-area-inset-bottom, 0px);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }

.app { max-width: 1480px; margin: 0 auto; padding-block: 24px 48px; display: grid; gap: 24px; }

/* ---------------------------------------------------------------- header */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mark { width: 44px; height: 44px; flex: none; }
.mark-cell { fill: var(--surface); stroke: var(--accent); stroke-width: 1.6; }
.mark-effect { fill: var(--effect); }
.mark-arrow { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; }
.brand h1 { font-family: var(--font-display); font-weight: 400; font-size: 2.6rem; line-height: 1; letter-spacing: -0.01em; }
.subtitle { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }
.header-tools { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- shared controls */
.seg { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill-group { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; box-shadow: var(--shadow); }
.pill {
    display: inline-flex; align-items: center; gap: 7px;
    border: 0; background: transparent; border-radius: 999px; padding: 6px 13px;
    cursor: pointer; font-size: 0.86rem; font-weight: 600; color: var(--muted);
    transition: background .2s, color .2s;
}
.pill:hover { color: var(--ink); }
.pill.on { background: var(--ink); color: var(--surface); }
.pill.small { padding: 4px 10px; font-size: 0.8rem; }
.swatch-dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(127, 127, 127, .45); }
.sw-blue { background: linear-gradient(135deg, #e9f3fd 50%, #0a7cff 50%); }
.sw-dark { background: linear-gradient(135deg, #0b1020 50%, #3ad0ff 50%); }
.sw-classic { background: linear-gradient(135deg, #ffffff 50%, #d40000 50%); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px;
    padding: 8px 16px; cursor: pointer; font-weight: 600; font-size: 0.88rem; white-space: nowrap;
    transition: border-color .2s, transform .1s, background .2s;
}
.btn svg { width: 14px; height: 14px; fill: currentColor; }
.btn svg.stroke { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.small { padding: 4px 12px; font-size: 0.8rem; }

.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px; display: grid; gap: 14px; min-width: 0;
}
.eyebrow { font-family: var(--font-ui); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; color: var(--muted); }

/* ---------------------------------------------------------------- layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1060px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.stage-col, .controls { display: grid; gap: 20px; min-width: 0; }

/* ---------------------------------------------------------------- plate */
.plate-card { padding: 14px; gap: 12px; }
.readout { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 2px 4px; }
.stat { display: inline-flex; align-items: baseline; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 0.85rem; }
.stat-k { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }
.stat.kind { background: var(--accent-soft); border-color: transparent; color: var(--ink); font-weight: 600; }
.axis-note { margin-left: auto; font-size: 0.75rem; color: var(--muted); }
.plate { overflow-x: auto; border-radius: calc(var(--radius) - 6px); }
.board { display: block; width: max(100%, 680px); max-width: none; height: auto; user-select: none; }
.board .hit { cursor: pointer; }
.transport { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 2px 4px; }
.transport .speed { margin-left: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }

/* motion on the modern plate (absent from exported files, by design) */
.board.modern .glow { filter: drop-shadow(0 0 6px currentColor); }
.board.modern .flow { stroke-dasharray: 5 5; animation: flow .6s linear infinite; }
.board.modern .pop { animation: pop .45s cubic-bezier(.2, 1.4, .4, 1); transform-box: fill-box; transform-origin: center; }
.board.modern .spin { animation: dash 1.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -10; } }
@keyframes dash { to { stroke-dashoffset: -18; } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------------------------------------------------------------- current object */
.dashboard { min-height: 110px; }
.hint { color: var(--muted); }
.focus-line { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.glyph { font-family: var(--font-display); font-style: italic; font-size: 2.6rem; line-height: .9; color: var(--accent); min-width: 1ch; }
.coords { font-size: 0.85rem; color: var(--muted); }
.tag { font-size: 0.78rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.tag.pin { color: var(--genealogy); border-color: var(--genealogy); background: transparent; }
.set { font-family: var(--font-display); font-style: italic; font-size: 1.5rem; line-height: 1.35; overflow-wrap: anywhere; }
.brace { color: var(--muted); font-style: normal; }
.count { font-style: normal; font-size: 0.8rem; color: var(--muted); vertical-align: middle; margin-left: 6px; }
.genealogy { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.genealogy label { font-size: 0.86rem; font-weight: 600; }
.genealogy input[type=range] { width: 170px; accent-color: var(--genealogy); }
.generations { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; width: 100%; }
.generations li { font-size: 0.8rem; color: var(--genealogy); border: 1px solid var(--genealogy); border-radius: 999px; padding: 1px 10px; }

/* ---------------------------------------------------------------- experience */
.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kind-tile {
    display: grid; gap: 3px; text-align: left; cursor: pointer;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px;
    transition: border-color .2s, background .2s, transform .1s;
}
.kind-tile:hover { border-color: var(--accent); }
.kind-tile:active { transform: scale(.98); }
.kind-tile.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.kind-name { font-weight: 700; font-size: 0.92rem; }
.kind-rule { font-family: var(--font-data); font-size: 0.68rem; line-height: 1.35; opacity: .75; }
.gloss { font-family: var(--font-prose); font-size: 1.05rem; line-height: 1.55; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; border-radius: 999px; padding: 6px 8px; cursor: pointer; font-weight: 600; font-size: 0.84rem; color: var(--muted); transition: background .2s, color .2s; }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }

.toggle { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; font-weight: 600; font-size: 0.86rem; padding: 4px 6px 4px 0; }
.knob { width: 32px; height: 18px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; }
.knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .2s; }
.toggle.on .knob { background: var(--accent); }
.toggle.on .knob::after { transform: translateX(14px); }
.color { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }

details.card { gap: 12px; }
details.card summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after { content: "+"; font-size: 1.1rem; font-weight: 400; color: var(--muted); }
details.card[open] summary::after { content: "–"; }
.form { display: grid; grid-template-columns: 1fr 100px; gap: 8px 12px; align-items: center; font-size: 0.85rem; }
.form input { width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-family: var(--font-data); font-size: 0.82rem; }
.form .inline { display: flex; gap: 4px; }
.form .inline .btn { padding: 2px 8px; }
.note { font-size: 0.8rem; color: var(--muted); }
.share-url { width: 100%; font-family: var(--font-data); font-size: 0.72rem; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }

/* ---------------------------------------------------------------- about */
.about { display: grid; gap: 20px; padding-top: 12px; }
.about-intro { display: grid; gap: 10px; max-width: 72ch; }
.about h2 { font-family: var(--font-display); font-weight: 400; font-size: 2rem; }
.about-intro p { font-family: var(--font-prose); font-size: 1.12rem; line-height: 1.6; }
.kinds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.kind-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 6px; align-content: start; transition: border-color .2s; }
.kind-card.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kind-card h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; }
.kind-card .kind-rule { color: var(--accent); opacity: 1; }
.kind-card p:last-child { font-family: var(--font-prose); font-size: 1rem; line-height: 1.55; }
.credits { font-size: 0.8rem; color: var(--muted); }

/* classic skin: square, flat, as in 2014 */
:root[data-skin="classic"] .brand h1, :root[data-skin="classic"] .about h2, :root[data-skin="classic"] .kind-card h3 { font-family: "Times New Roman", Times, serif; }

/* ---------------------------------------------------------------- boot */
.boot { display: grid; justify-items: center; padding-top: 18vh; color: var(--muted); }
.boot-title { font-family: var(--font-display); font-size: 1.8rem; }
.loading-progress { width: 5rem; height: 5rem; }
.loading-progress circle { fill: none; stroke: var(--line); stroke-width: 0.4rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: var(--accent); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; transition: stroke-dasharray 0.05s ease-in-out; }
.loading-progress-text { margin: 4px 0; font-family: var(--font-data); font-size: 0.8rem; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "…"); }

#blazor-error-ui { background: #fff3cd; color: #1b1f27; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

@media (max-width: 560px) {
    .brand h1 { font-size: 2.1rem; }
    .transport .speed { margin-left: 0; }
    .axis-note { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, .board.modern .flow, .board.modern .pop, .board.modern .spin { animation: none !important; transition: none !important; }
}
