/* =========================================================
   Crew Alert – Website
   Hell: „Gerät“ (Gehäuse, Platten, eingelassene Bildschirme)
   Dunkel: Aegis (kühl, präzise, Rot nur für Knöpfe)
   Werte und Regeln siehe docs/DESIGN.md
   ========================================================= */

:root {
    /* Hell – „Gerät“ */
    --casing: #c9d1d6;
    --plate: #e4e9ec;
    --plate-edge: #ffffff;
    --plate-shadow: 0 1px 0 #00000022, 0 6px 14px -10px #1d232766;
    --ink: #1d2327;
    --mist: #5d6a72;
    --glass: #0f2a33;
    --glass-edge: #ffffff14;
    --readout: #bff3ff;
    --readlabel: #7fb3c2;
    --signal: #ff8a3d;
    --signal-hover: #ff9a57;
    --signal-ink: #1d1208;
    --nav-on: #1d2327;
    --highlight: #1d2327;   /* Hervorhebung und Fokus – nie die Signalfarbe */
    --nav-on-ink: #e4e9ec;
    --rule: #0000001a;
    --field: #f4f7f8;
    --field-line: #9aa7af;
    --disabled: #b6bfc5;
    --disabled-ink: #5d6a72;
    --ok: #1f8a4c;
    --busy: #a8690f;
    --bad: #c2412d;
    --rust: #d4572a;        /* Rostorange aus dem Logo – nur der Admin-Knopf des Streamers */
    --rust-hover: #e0683b;
    --r: 4px;

    --display: "Big Shoulders Text", "Bahnschrift", "Segoe UI", sans-serif;
    --body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;

    color-scheme: light;
}

:root[data-theme="dark"] {
    /* Dunkel – Aegis */
    --casing: #1d242b;
    --plate: #262f38;
    --plate-edge: #ffffff0f;
    --plate-shadow: inset 0 0 0 1px #ffffff0f;
    --ink: #e3e8ec;
    --mist: #8796a3;
    --glass: #0d1216;
    --glass-edge: #ffffff12;
    --readout: #f2f5f7;
    --readlabel: #7d8e9b;
    --signal: #d23c32;
    --signal-hover: #e0483d;
    --signal-ink: #ffffff;
    --nav-on: #e3e8ec;
    --highlight: #e3e8ec;
    --nav-on-ink: #1d242b;
    --rule: #ffffff12;
    --field: #1a2128;
    --field-line: #3b4855;
    --disabled: #323d48;
    --disabled-ink: #8796a3;
    --ok: #4cc38a;
    --busy: #e0b341;
    --bad: #f0a33c;   /* Fehlschlag/gesperrt: orange-gelb, Rot gehört den Knöpfen */
    --r: 2px;

    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    min-height: 100vh;
    background: var(--casing);
    color: var(--ink);
    font-family: var(--body);
    font-size: 16px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: underline; text-decoration-color: var(--mist); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--ink); }

h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.1; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px 48px; }

/* ---- Kopf ---- */

.head { padding: 24px 0 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.title { font-size: 38px; margin: 0; letter-spacing: 0.01em; }
.title a { text-decoration: none; display: block; line-height: 0; }
.title .logo { height: 46px; width: auto; }
.title .logo.on-dark, :root[data-theme="dark"] .title .logo.on-light { display: none; }
:root[data-theme="dark"] .title .logo.on-dark { display: block; }

/* Twitch-Knopf: Farbe von Twitch, nicht die Signalfarbe – er führt aus der Seite heraus */
.twitch {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: calc(var(--r) - 1px);
    background: #9146ff; color: #fff; font-weight: 600; font-size: 14px; text-decoration: none;
}
.twitch:hover { background: #a970ff; }
.twitch:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }

/* LIVE/OFFLINE: kleines eingelassenes Anzeigefeld wie die Bildschirme */
.live-badge {
    display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: calc(var(--r) - 1px);
    background: var(--glass); color: var(--readlabel); box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 3px 8px #00000066;
    font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: 0.06em;
}
.live-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.5; }
.live-badge.is-live { color: #ff4d5e; }
.live-badge.is-live::before { opacity: 1; box-shadow: 0 0 8px currentColor; animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .live-badge.is-live::before { animation: none; } }
.subtitle { color: var(--mist); font-size: 15px; margin: 2px 0 0; }
.who { color: var(--mist); font-size: 15px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.who strong { color: var(--ink); font-weight: 600; }
.who-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }

/* Hell/Dunkel-Schalter: Kippschalter mit Sonne und Mond */
.theme-toggle {
    position: relative; display: inline-flex; align-items: center; justify-content: space-between;
    width: 64px; height: 30px; padding: 0 8px; border-radius: 15px; cursor: pointer;
    background: var(--glass); border: 0; box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 3px 8px #00000066;
    color: var(--readlabel); font-size: 14px;
}
.theme-toggle .knob {
    position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
    background: var(--plate); box-shadow: 0 1px 2px #00000066; transition: transform 0.2s ease;
}
:root[data-theme="dark"] .theme-toggle .knob { transform: translateX(34px); }
.theme-toggle:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }

nav.tabs {
    display: flex; flex-wrap: wrap; gap: 2px; width: max-content; max-width: 100%;
    margin-bottom: 20px; padding: 3px; background: var(--plate); border-radius: var(--r);
    box-shadow: var(--plate-shadow);
}
nav.tabs a { padding: 6px 13px; border-radius: calc(var(--r) - 1px); color: var(--mist); text-decoration: none; font-weight: 500; }
nav.tabs a:hover { color: var(--ink); }
nav.tabs a.active { background: var(--nav-on); color: var(--nav-on-ink); }

/* ---- Platten (Karten) ---- */

.card, .option, .slot, .podium-place, .module, .achievement {
    background: var(--plate); border-radius: var(--r);
    box-shadow: inset 0 1px 0 var(--plate-edge), var(--plate-shadow);
}
.card { position: relative; padding: 18px 20px; margin-bottom: 14px; }
.card h2 { font-size: 26px; margin: 0 0 6px; }
.card.plain { background: transparent; box-shadow: none; padding: 4px 0; }
.card.accent { box-shadow: inset 0 1px 0 var(--plate-edge), inset 3px 0 0 var(--highlight), var(--plate-shadow); }
.muted { color: var(--mist); }
.card p.report { white-space: pre-line; }   /* mehrzeilige Spielmeldungen: eine Zeile je Chatnachricht */
.card .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--ok); }

/* Aegis: obere rechte Ecke schräg abgeschnitten */
:root[data-theme="dark"] :is(.card:not(.plain), .option, .slot, .podium-place) {
    clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}

/* ---- Bildschirme: eingelassene Felder für wichtige Zahlen ---- */

.screen {
    margin-top: 12px; padding: 12px 14px; border-radius: calc(var(--r) - 1px);
    background: var(--glass); color: var(--readout);
    box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 10px 30px #00000066;
}
.screen.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px 16px; }
.screen .k { font-size: 12px; color: var(--readlabel); }
.screen .v { font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.1; color: var(--readout); overflow-wrap: anywhere; }
.screen .v .muted, .screen .v small { color: var(--readlabel); font-size: 0.7em; }
:root[data-theme="dark"] .screen { background-image: linear-gradient(#ffffff08 1px, transparent 1px); background-size: 100% 8px; }

/* ---- Status ---- */

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status.green { color: var(--ok); }
.status.yellow { color: var(--busy); }
.status.red { color: var(--bad); }

.countdown { font-family: var(--display); font-weight: 600; font-size: 34px; letter-spacing: 0.02em; }
.screen .countdown { color: var(--readout); }

/* ---- Knöpfe: einzige Stelle mit der Signalfarbe (Test prüft das) ---- */

.btn { background: var(--signal); color: var(--signal-ink); }
.btn {
    display: inline-block; font-family: var(--body); font-size: 15px; font-weight: 600;
    padding: 9px 16px; border: 0; border-radius: calc(var(--r) - 1px);
    cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--signal-hover); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--field-line); }
.btn.secondary:hover { background: var(--rule); }
.btn.rust { background: var(--rust); color: #fff; }
.btn.rust:hover, .btn.rust.active { background: var(--rust-hover); }
.btn:disabled, .btn.secondary:disabled { background: var(--disabled); color: var(--disabled-ink); box-shadow: none; cursor: not-allowed; }

form.inline { display: inline; }
.abort-form { margin-top: 12px; }

/* ---- Formularfelder ---- */

input[type=number], input[type=text], input[type=datetime-local], input[type=date], select {
    font-family: var(--body); font-size: 15px; padding: 8px 10px;
    background: var(--field); color: var(--ink); border: 1px solid var(--field-line); border-radius: calc(var(--r) - 1px);
}
input[type=number] { width: 160px; }
input:focus, select:focus { outline: 2px solid var(--highlight); outline-offset: 1px; }
.copy-field { width: 100%; font-size: 13px !important; }
.form-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 8px; align-items: center; }
.form-grid input { width: 100%; }
.form-grid .colhead { color: var(--mist); font-size: 13px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; margin-top: 8px; }
.check-list label { display: flex; gap: 8px; align-items: center; }
code { font-size: 0.92em; background: var(--rule); padding: 1px 5px; border-radius: 3px; }

/* ---- Meldungen ---- */

.flash {
    background: var(--plate); border-radius: var(--r); padding: 12px 16px; margin-bottom: 14px; white-space: pre-line;
    box-shadow: inset 4px 0 0 var(--busy), var(--plate-shadow);
}
.flash.ok { box-shadow: inset 4px 0 0 var(--ok), var(--plate-shadow); }

/* ---- Missionen: alle Kästen gleich hoch, Knopf immer unten ---- */

.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); grid-auto-rows: 1fr; gap: 14px; }
.option { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.option form { margin-top: auto; }
.option h3 { font-size: 22px; margin: 0 0 4px; }
.option .row { display: flex; justify-content: space-between; gap: 10px; color: var(--mist); font-size: 15px; padding: 3px 0; border-bottom: 1px dashed var(--rule); }
.option .row span:last-child { color: var(--ink); text-align: right; }
.option .btn { margin-top: 10px; }
.option.risk { box-shadow: inset 0 1px 0 var(--plate-edge), inset 0 -3px 0 var(--bad), var(--plate-shadow); }

/* ---- Tabellen ---- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { color: var(--mist); font-size: 13px; font-weight: 600; }
tr.current td { font-weight: 600; background: var(--rule); }
tr.done td { color: var(--mist); }
.table-scroll { overflow-x: auto; }

/* ---- Module, Komponenten ---- */

.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); grid-auto-rows: 1fr; gap: 8px; margin-top: 10px; }
.module { padding: 10px 12px; font-size: 15px; display: flex; flex-direction: column; background: var(--casing); box-shadow: inset 0 1px 3px #0000002a; }
.module .bottom { margin-top: auto; padding-top: 8px; }
.module.built { box-shadow: inset 0 0 0 2px var(--ok); }
.module .id { font-size: 13px; color: var(--mist); font-weight: 600; }

/* ---- Logbuch ---- */

.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 3px; background: var(--rule); color: var(--mist); text-decoration: none; }
a.tag:hover { color: var(--ink); }
td.good { color: var(--ok); }
td.bad { color: var(--bad); }
.logbook td { font-size: 15px; }

/* ---- Erfolge, Fortschritt ---- */

.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 10px; }
.achievement { padding: 10px 12px; background: var(--casing); box-shadow: inset 0 1px 3px #0000002a; color: var(--mist); }
.achievement.unlocked { background: var(--plate); color: var(--ink); box-shadow: inset 0 1px 0 var(--plate-edge), inset 3px 0 0 var(--ok), var(--plate-shadow); }
.achievement .name { font-family: var(--display); font-weight: 800; font-size: 19px; margin-bottom: 2px; }
.achievement .muted { font-size: 14px; }
.achievement .when { font-size: 12px; color: var(--mist); margin-top: 4px; }

.progress { height: 10px; margin-top: 8px; border-radius: 2px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 2px 4px #00000066; overflow: hidden; }
.progress > div { height: 100%; background: var(--readout); }
.progress.small { height: 6px; }
.goal-numbers { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.screen .progress { margin-top: 8px; box-shadow: inset 0 0 0 1px var(--glass-edge); background: #ffffff12; }
.ship-title { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.1; overflow-wrap: anywhere; }
.pilot-title { color: var(--mist); font-size: 14px; font-weight: 600; }

/* ---- Schiffsbilder ---- */

.shipimg {
    background: var(--glass); overflow: hidden; border-radius: calc(var(--r) - 1px);
    display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9;
    box-shadow: inset 0 0 0 1px var(--glass-edge);
}
.shipimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shipimg span { font-family: var(--display); font-weight: 600; color: var(--readlabel); font-size: 22px; }

.card.with-ship { display: flow-root; }
.shipimg.side { float: right; width: 240px; margin: 0 0 8px 18px; }

/* ---- Hangar: 4 Slots, gleich hoch, Knopf unten ---- */

.hangar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 14px; }
@media (max-width: 900px) { .hangar { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .hangar { grid-template-columns: 1fr; } }
.slot { padding: 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.slot.active { box-shadow: inset 0 1px 0 var(--plate-edge), inset 0 3px 0 var(--highlight), var(--plate-shadow); }
.slot.locked { opacity: 0.8; }
.slot h3 { font-size: 21px; margin: 6px 0 0; overflow-wrap: anywhere; }
.slot-head { display: flex; justify-content: space-between; align-items: center; }
.slot .exp-line { display: flex; justify-content: space-between; gap: 8px; color: var(--mist); font-size: 15px; margin-top: 4px; }
.slot .exp-line span:last-child { color: var(--ink); text-align: right; }
.slot .screen { margin-top: 8px; padding: 8px 10px; }
.slot .due { color: var(--busy); font-size: 14px; margin: 6px 0 0; }
.slot .rename { display: flex; gap: 6px; margin-top: 8px; }
.slot .rename input { flex: 1; min-width: 0; font-size: 14px; padding: 6px 8px; }
.slot .rename .btn { padding: 6px 10px; }
.slot .bottom { margin-top: auto; padding-top: 10px; }

.due-banner { box-shadow: inset 0 1px 0 var(--plate-edge), inset 4px 0 0 var(--busy), var(--plate-shadow) !important; }

/* ---- Rangliste ---- */

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; align-items: end; }
.podium-place { padding: 12px; text-align: center; }
.podium-place .rank { font-family: var(--display); font-weight: 800; font-size: 30px; margin-top: 8px; }
.podium-place .name { font-family: var(--display); font-weight: 600; font-size: 19px; overflow-wrap: anywhere; }
.podium-place.place-1 { order: 2; box-shadow: inset 0 1px 0 var(--plate-edge), inset 0 3px 0 var(--highlight), var(--plate-shadow); }
.podium-place.place-2 { order: 1; }
.podium-place.place-3 { order: 3; }

.foot {
    color: var(--mist); font-size: 13px; margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--rule);
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.foot a { color: var(--mist); }
.foot-main { display: flex; align-items: center; gap: 12px; }
.fan-note { font-size: 12px; opacity: 0.8; }
/* Fan-Abzeichen: Weiß verschmilzt mit dem Gehäuse (hell) bzw. wird invertiert (dunkel), gedämpft wie der übrige Fußtext */
.community-badge { flex: none; width: 48px; height: 48px; border-radius: 50%; mix-blend-mode: multiply; opacity: 0.55; }
:root[data-theme="dark"] .community-badge { filter: invert(1); mix-blend-mode: screen; }
address.imprint { font-style: normal; margin: 8px 0 12px; }

/* ---- Handy ---- */

@media (max-width: 600px) {
    .title { font-size: 30px; }
    .title .logo { height: 36px; }
    .shipimg.side { float: none; width: 100%; margin: 0 0 12px; }
    .podium { grid-template-columns: 1fr; }
    .podium-place { order: 0 !important; }
    .form-grid { grid-template-columns: 1fr 1fr !important; }
    .form-grid > * { min-width: 0; }
    /* Breite Tabellen scrollen in sich, die Seite bleibt fest */
    table { display: block; overflow-x: auto; }
    input[type=number] { width: 100%; max-width: 160px; }
    nav.tabs { width: 100%; }
}
