/* app.css — gemeinsame Oberfläche der Strukturanalyse-Apps.
   Aisthesis-Palette, Raleway. Die Akzentfarben der Dimensionen kommen
   aus den Deck-Dateien und werden inline gesetzt. */

:root {
  --bg: #F4EEE3;
  --ink: #141113;
  --muted: #6b5d53;
  --line: #DCD3C8;
  --panel: #fffdfa;
  --shadow: 0 24px 80px rgba(20, 17, 19, .16);
  --font-display: 'Raleway', sans-serif;
  font-family: 'Raleway', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255,255,255,.78), rgba(255,255,255,.15)), var(--bg);
  hyphens: auto;
  -webkit-hyphens: auto;
  text-wrap: pretty;
}

button { font: inherit; border: 0; cursor: pointer; }
a { color: #004A63; }
a:hover { color: #952D1F; }

.app { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }

header {
  display: block;
  padding: calc(22px + env(safe-area-inset-top)) clamp(18px, 4vw, 52px) 18px;
  background: linear-gradient(160deg, #1d2a30 0%, #141113 100%);
  color: #F4EEE3;
}

.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand-text { flex: 1; min-width: 0; }

/* Logo sitzt in derselben Zeile wie der Titel, auf Höhe des großen „S“. */
.header-logo { display: inline-block; vertical-align: -0.08em; margin-right: .34em; }
.header-logo img { width: auto; height: .82em; display: block; }
.header-logo:hover { opacity: .75; }
.cover-link { flex: 0 0 auto; }
.cover-link img {
  display: block; height: 72px; width: auto; border-radius: 3px;
  box-shadow: 0 6px 18px rgba(0,0,0,.4); transition: transform .15s ease;
}
.cover-link:hover img { transform: scale(1.06); }
@media (max-width: 600px) { .cover-link { display: none; } }

.title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 200;
  font-size: clamp(2.4rem, 7vw, 3.4rem);
  line-height: .98;
  letter-spacing: -.01em;
  hyphens: manual;
}
.h1-sub {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1rem, 2vw, 1.3rem);
  line-height: 1.25;
  color: rgba(244,238,227,.86);
}

/* Verlaufsbalken sitzt unter dem Kartenstapel. */
.status {
  width: min(660px, 92vw); display: flex; align-items: center; gap: 14px;
  color: var(--muted); font-size: .9rem; white-space: nowrap;
}
.progress {
  flex: 1; min-width: 112px; height: 8px; border-radius: 999px;
  overflow: hidden; background: rgba(20,17,19,.12);
}
.progress span { display: block; width: 0%; height: 100%; border-radius: inherit; background: #004A63; transition: width .25s ease; }
body.is-finished .status { display: none; }

main { display: grid; place-items: start center; padding: 16px clamp(16px, 4vw, 52px) 34px; }

.stage {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(420px, 680px) minmax(260px, 1fr);
  gap: clamp(22px, 4vw, 56px);
  align-items: start;
}
.stage.is-single { grid-template-columns: minmax(0, 1fr); }

/* ═══ Auswahl der Stapel ═══ */
.picker { width: min(980px, 100%); display: flex; flex-direction: column; gap: 22px; }
.picker-intro { margin: 0; max-width: 60ch; font-size: 1.02rem; line-height: 1.55; color: var(--muted); }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.deck-card {
  text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-left: 6px solid var(--accent, var(--ink)); border-radius: 10px;
  padding: 20px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 10px 28px rgba(42,35,25,.07); transition: transform .15s ease, box-shadow .15s ease;
}
.deck-card:hover { transform: translateY(-2px); box-shadow: 0 16px 38px rgba(42,35,25,.12); }
.deck-card h2 { margin: 0; font-family: var(--font-display); font-size: 1.22rem; font-weight: 600; hyphens: manual; }
.deck-card p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.deck-card .deck-cover {
  width: 78px; height: auto; border-radius: 3px; align-self: flex-start;
  box-shadow: 0 6px 18px rgba(20,17,19,.22);
}
.deck-card .deck-cover-link { color: #004A63; font-size: .84rem; text-decoration: underline; text-underline-offset: 2px; }
.deck-card .deck-meta { color: var(--muted); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; }

/* ═══ Kartenstapel ═══ */
.deck-shell { display: grid; justify-items: center; gap: 18px; }
.deck { position: relative; width: min(660px, 92vw); aspect-ratio: 16 / 9; touch-action: none; }

.card {
  position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto;
  padding: clamp(24px, 5vw, 40px); border-radius: 8px; background: var(--panel);
  border: 1px solid rgba(38,31,23,.1); box-shadow: var(--shadow);
  user-select: none; transform-origin: 50% 95%;
  transition: transform .22s ease, opacity .22s ease; overflow: hidden;
}
.card.next { transform: translateY(16px) scale(.94); opacity: .44; pointer-events: none; box-shadow: 0 16px 42px rgba(42,35,25,.1); }
.card.third { transform: translateY(30px) scale(.88); opacity: .2; pointer-events: none; }

.term {
  align-self: center; text-align: center; font-weight: 800; line-height: 1.15;
  font-size: clamp(1.15rem, 6vw, 4.15rem); max-width: 100%;
  overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; padding-bottom: .15em;
}
/* Mehrwortige Begriffe brechen am Leerzeichen, nicht mit Trennstrich. */
.term-words { hyphens: manual; -webkit-hyphens: manual; }
.card-id { color: var(--muted); font-size: .95rem; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(660px, 92vw); }
.action {
  height: 54px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line);
  color: var(--ink); font-weight: 700; box-shadow: 0 10px 28px rgba(42,35,25,.08);
}
.action.reject { color: #952D1F; }
.action.accept { color: #00323F; }
.action.undo { width: 140px; color: var(--muted); }
.action:active { transform: translateY(1px); }
.action:focus-visible, .restart:focus-visible, .download-btn:focus-visible, .deck-card:focus-visible {
  outline: 3px solid #0777D0; outline-offset: 2px;
}

kbd {
  display: inline-block; font: 700 .7em/1 inherit; padding: 2px 5px; border-radius: 4px;
  border: 1px solid currentColor; opacity: .55; vertical-align: middle; margin-left: 5px;
}

.name-row { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; text-align: center; }
.name-row label { font-weight: 700; font-size: 1rem; }
.name-input {
  width: min(460px, 90%); height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255,255,255,.9); font: inherit;
  font-size: 1rem; font-weight: 700; text-align: center; outline: none; transition: border-color .15s;
}
.name-input::placeholder { font-weight: 400; color: #A39184; }
.name-input:focus { border-color: #0777D0; box-shadow: 0 0 0 3px rgba(7,119,208,.18); }

.intro-text { margin: 0; max-width: min(660px, 92vw); text-align: center; font-size: 1.02rem; line-height: 1.5; }
.hint-box {
  width: min(660px, 92vw); padding: 14px 18px; border: 1px solid var(--line);
  border-radius: 12px; background: rgba(255,255,255,.72); box-shadow: 0 4px 14px rgba(42,35,25,.06);
}
.hint-text { margin: 0; font-size: .85rem; color: var(--muted); line-height: 1.5; text-align: center; }
.empty-note { display: none; color: var(--muted); text-align: center; line-height: 1.4; }

/* ═══ Auswertung ═══ */
.side { align-self: stretch; display: grid; align-content: center; gap: 18px; }
.score-grid { display: none; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
body.is-finished .score-grid { display: grid; }
.score-pill { min-height: 78px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.58); }
.score-pill strong { display: block; font-size: 1.45rem; line-height: 1; margin-top: 8px; }
.score-pill span { color: var(--muted); font-size: .86rem; }

.result { display: none; width: 100%; gap: 22px; }
.result.is-visible { display: grid; }
.chart-box { padding: clamp(14px, 2vw, 22px); border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.72); }
canvas.radar { max-width: 100%; display: block; margin-inline: auto; }

.explain-text { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.55; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.info {
  padding: 14px; border-left: 6px solid var(--accent); border-radius: 8px;
  background: rgba(255,255,255,.68); border-top: 1px solid var(--line);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.info h2 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 600; font-size: 1rem; }
.info p { margin: 0; color: var(--muted); line-height: 1.45; font-size: .95rem; }

.chart-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.download-btn {
  height: 46px; padding: 0 18px; border-radius: 8px; background: rgba(255,255,255,.72);
  border: 1px solid var(--line); color: var(--ink); font-weight: 700; box-shadow: 0 6px 18px rgba(42,35,25,.07);
}
.download-btn:hover { background: #fff; }
.restart { height: 46px; padding: 0 18px; border-radius: 8px; background: var(--ink); color: #fff; font-weight: 700; }

.book-tip {
  display: flex; gap: 14px; align-items: center; border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px; background: rgba(255,255,255,.6);
}
.book-tip img { width: 72px; height: auto; border-radius: 4px; box-shadow: 0 4px 14px rgba(20,17,19,.18); }
.book-tip p { margin: 0; font-size: .88rem; line-height: 1.45; }

footer.site-footer {
  text-align: center; font-size: 12px; color: rgba(20,17,19,.65);
  padding: 24px 0 calc(8px + env(safe-area-inset-bottom));
}
.footer-logo { display: inline-block; margin: 0 0 8px; line-height: 0; }
.footer-logo img { width: 26px; height: 26px; display: block; }
.footer-logo:hover { opacity: .75; }

/* ═══ Auswertung: einspaltig, ohne den Platz des Kartenstapels ═══ */
body.is-finished .stage { grid-template-columns: minmax(0, 1fr); }
body.is-finished #deck,
body.is-finished .actions,
body.is-finished #switchRow,
body.is-finished .hint-box,
body.is-finished #deckIntro { display: none; }
body.is-finished .deck-shell { gap: 12px; }
#switchRow { width: min(660px, 92vw); display: flex; justify-content: center; gap: 10px; }
body.is-finished .info-grid { grid-template-columns: minmax(0, 1fr); }
body.is-finished .score-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
body.is-finished .side { align-content: start; }
body.is-finished .chart-box { max-width: 600px; width: 100%; justify-self: center; }
.result:focus { outline: none; }

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; gap: 26px; }
  .side { align-content: start; }
}
@media (max-width: 560px) {
  main { padding-inline: 12px; }
  .deck, .actions, .hint-box { width: min(560px, 94vw); }
  .term { font-size: clamp(1rem, 11vw, 3.35rem); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
