/* GameDraft — shell.css (Redesign 0.41 «Draft Deck», Etappe 1)
 * Neue App-Shell: Sidebar + Topbar + Viewport, gd-Namespace.
 * Lädt NACH brand.css → gewinnt die Kaskade ohne neue !important-Schlachten.
 * legacy.css bleibt für Altbestand; neues Markup nutzt ausschliesslich gd-Klassen.
 */

/* ==== Design-Tokens v2 ==================================================== */
:root {
  --gd2-surface-0: #08090c;   /* App-Hintergrund */
  --gd2-surface-1: #0d0f14;   /* Shell-Flächen (Sidebar/Topbar) */
  --gd2-surface-2: #12151c;   /* Karten */
  --gd2-surface-3: #181c25;   /* Erhabene Controls/Hover */
  --gd2-border: rgba(255, 255, 255, .06);
  --gd2-border-strong: rgba(255, 255, 255, .12);
  --gd2-text: #e8ecf4;
  --gd2-text-mute: #97a0b5;
  --gd2-text-dim: #6b7488;
  --gd2-accent: #5b8cff;
  --gd2-accent-soft: rgba(91, 140, 255, .14);
  --gd2-grad: linear-gradient(120deg, #00d7ff, #3d7bff 52%, #7c4dff);
  --gd2-gold: #e8c268;
  --gd2-r-control: 10px;
  --gd2-r-card: 16px;
  --gd2-r-panel: 20px;
  --gd2-shadow-card: 0 8px 24px rgba(0, 0, 0, .35);
  --gd2-sidebar-w: 248px;
  --gd2-rail-w: 76px;
  --gd2-topbar-h: 56px;
}

/* Sticky-Grundlage: legacy.css setzt html/body overflow-x:hidden — das macht body
   zum Scroll-Container und toetet position:sticky der Shell. clip clippt ohne
   Scroll-Container (Verify-Pass P1). */
html, body { overflow-x: clip !important; }

/* ==== Shell-Grid =========================================================== */
.gd-shell {
  display: grid;
  grid-template-columns: var(--gd2-sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--gd2-surface-0);
}
body.gd-rail .gd-shell { grid-template-columns: var(--gd2-rail-w) minmax(0, 1fr); }

/* ==== Sidebar =============================================================== */
.gd-sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--gd2-surface-1);
  border-right: 1px solid var(--gd2-border);
  padding: 14px 12px;
  gap: 6px;
  z-index: 46;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin;
}
.gd-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 16px; cursor: pointer; border: 0; background: none; text-align: left;
  width: 100%;
}
.gd-logo .gd-logo-icon {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px;
  background-image: url("../icon-192.png"); background-size: cover; background-position: center;
}
.gd-logo .gd-logo-word {
  font-size: 16px; font-weight: 800; letter-spacing: -.01em; color: var(--gd2-text);
  white-space: nowrap;
}
.gd-logo .gd-logo-word em {
  font-style: normal;
  background: var(--gd2-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gd-nav-group { display: flex; flex-direction: column; gap: 2px; }
.gd-nav-group + .gd-nav-group { margin-top: 14px; }
.gd-nav-group-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--gd2-text-dim); padding: 0 10px 6px; white-space: nowrap;
}
.gd-nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  height: 40px; padding: 0 10px; border-radius: var(--gd2-r-control);
  border: 0; background: none; cursor: pointer; width: 100%; text-align: left;
  color: var(--gd2-text-mute);
  font: inherit; font-size: 14px; font-weight: 600;
  transition: background .14s ease, color .14s ease;
  white-space: nowrap;
}
.gd-nav-item:hover { background: var(--gd2-surface-3); color: var(--gd2-text); }
.gd-nav-item.active {
  background: var(--gd2-accent-soft); color: #fff;
}
.gd-nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--gd2-accent);
}
.gd-nav-item svg {
  width: 20px; height: 20px; flex: 0 0 20px; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.gd-nav-item .gd-nav-label { overflow: hidden; text-overflow: ellipsis; }
.gd-sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 14px; }

/* Premium-Mini-Karte (nur Free/Gast) */
.gd-premium-mini {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid rgba(232, 194, 104, .28); border-radius: var(--gd2-r-card);
  background: linear-gradient(160deg, rgba(232, 194, 104, .10), rgba(232, 194, 104, .03));
  padding: 12px 12px 11px; color: var(--gd2-text);
}
.gd-premium-mini .gd-pm-title { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 800; color: var(--gd2-gold); }
.gd-premium-mini .gd-pm-title svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.gd-premium-mini .gd-pm-sub { font-size: 12px; line-height: 1.4; color: var(--gd2-text-mute); margin-top: 4px; }
.gd-premium-mini:hover { border-color: rgba(232, 194, 104, .5); }

/* Rail-Zustand (eingeklappt) */
body.gd-rail .gd-sidebar { padding: 14px 10px; }
body.gd-rail .gd-logo .gd-logo-word,
body.gd-rail .gd-nav-group-label,
body.gd-rail .gd-nav-item .gd-nav-label,
body.gd-rail .gd-premium-mini { display: none; }
body.gd-rail .gd-nav-item { justify-content: center; padding: 0; }
body.gd-rail .gd-logo { justify-content: center; padding-left: 0; padding-right: 0; }

/* ==== Topbar ================================================================ */
.gd-main { display: flex; flex-direction: column; min-width: 0; }
.gd-topbar {
  position: sticky; top: 0; z-index: 45;
  display: flex; align-items: center; gap: 14px;
  height: var(--gd2-topbar-h);
  padding: 0 20px;
  background: color-mix(in srgb, var(--gd2-surface-0) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--gd2-border);
}
.gd-topbar-toggle {
  width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center;
  border: 0; border-radius: var(--gd2-r-control); background: none; color: var(--gd2-text-mute); cursor: pointer;
}
.gd-topbar-toggle:hover { background: var(--gd2-surface-3); color: var(--gd2-text); }
.gd-topbar-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.gd-topbar-title {
  font-size: 18px; font-weight: 600; color: var(--gd2-text);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gd-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Bestehender Settings-Cluster (Sound/Sprache/Konto) kompakt in der Topbar.
   Die alten Header-Kaskaden (header.css/polish.css/brand.css Header-Cluster)
   matchen hier nicht mehr (kein .headerRight-Vorfahre) → frisch definiert. */
.gd-topbar .headerTopActions {
  display: flex !important; flex-direction: row !important; align-items: center !important;
  width: auto !important; grid-template-columns: none !important; gap: 6px !important;
  margin: 0 !important; padding: 0 !important;
}
.gd-topbar .headerTopActions .settingBtn,
.gd-topbar .headerTopActions .iconButton {
  height: 36px !important; min-height: 36px !important; max-height: 36px !important;
  width: auto !important; min-width: 0 !important; padding: 0 10px !important;
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--gd2-r-control);
  background: none; color: var(--gd2-text-mute); cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.gd-topbar .headerTopActions .settingBtn:hover,
.gd-topbar .headerTopActions .iconButton:hover { background: var(--gd2-surface-3); color: var(--gd2-text); }
.gd-topbar #soundToggleBtn { width: 36px !important; padding: 0 !important; justify-content: center; }
.gd-topbar .langDropdownBtn .flag { width: 18px; height: 13px; border-radius: 2px; }
.gd-topbar .langCaret svg, .gd-topbar .authCaret svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.gd-topbar .langMenu, .gd-topbar .authMenu {
  top: calc(100% + 8px); right: 0; left: auto;
  background: var(--gd2-surface-2); border: 1px solid var(--gd2-border-strong);
  border-radius: 12px; box-shadow: var(--gd2-shadow-card);
}
.gd-topbar .authControl, .gd-topbar .langDropdown { position: relative; }

/* ==== Viewport ============================================================== */
.gd-viewport { flex: 1; min-width: 0; padding: 28px 32px 48px; }
/* !important nötig: legacy.css:3416 erzwingt Breite/Padding mit !important —
   der Viewport übernimmt jetzt Rahmen und Innenabstand. */
.gd-viewport > .wrap { max-width: 1240px !important; margin: 0 auto !important; padding: 0 !important; width: auto !important; }
/* Alt-Header-Reste im Wrap (falls JS/Legacy sie noch erwartet) nie anzeigen */
.gd-viewport .wrap > header, #headerScrim, #primaryNav { display: none !important; }

/* ==== Immersiver Duell-Modus =============================================== */
/* Aktives Duell: Shell-Chrome tritt zurück, die Bühne gehört den zwei Karten. */
@media (min-width: 641px) {
  body.gd-immersive .gd-sidebar { display: none; }
  body.gd-immersive .gd-shell { grid-template-columns: minmax(0, 1fr); }
  body.gd-immersive .gd-topbar { display: none; }
  body.gd-immersive .gd-viewport { padding-top: 18px; }
}
body.gd-immersive .duelMenuBtn {
  position: sticky; top: 14px; z-index: 44;
}

/* ==== Tablet (641–1023px): Sidebar als Icon-Rail ============================ */
@media (min-width: 641px) and (max-width: 1023px) {
  .gd-shell { grid-template-columns: var(--gd2-rail-w) minmax(0, 1fr); }
  .gd-sidebar { padding: 14px 10px; }
  .gd-logo .gd-logo-word, .gd-nav-group-label, .gd-nav-item .gd-nav-label, .gd-premium-mini { display: none; }
  .gd-nav-item { justify-content: center; padding: 0; }
  .gd-logo { justify-content: center; padding-left: 0; padding-right: 0; }
  .gd-topbar-toggle { display: none; }   /* Rail ist fix — Collapse-Toggle nur Desktop */
}

/* ==== Mobile (≤640px) ======================================================= */
@media (max-width: 640px) {
  .gd-shell { grid-template-columns: minmax(0, 1fr); }
  .gd-sidebar { display: none; }
  .gd-topbar { height: 48px; padding: 0 12px; gap: 10px; }
  .gd-topbar-toggle { display: none; }
  .gd-topbar-title { font-size: 16px; }
  .gd-topbar .langDropdownBtn .langCurrentName { display: none; }
  .gd-topbar .authControl .iconBtnLabel { display: none; }
  .gd-viewport { padding: 16px 14px 90px; }
}
@media (min-width: 641px) { #mobileNav { display: none !important; } }

/* «Mehr»-Sheet (Mobile): restliche Ziele + Konto */
.gd-more-sheet {
  position: fixed; inset: auto 0 0 0; z-index: 60;
  background: var(--gd2-surface-2);
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--gd2-border-strong); border-bottom: 0;
  padding: 10px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateY(105%);
  transition: transform .24s ease;
  box-shadow: 0 -18px 48px rgba(0, 0, 0, .5);
}
.gd-more-sheet.open { transform: translateY(0); }
.gd-more-backdrop {
  position: fixed; inset: 0; z-index: 59; background: rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.gd-more-backdrop.open { opacity: 1; pointer-events: auto; }
.gd-more-grip { width: 36px; height: 4px; border-radius: 999px; background: var(--gd2-border-strong); margin: 2px auto 12px; }
.gd-more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gd-more-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 12px; border-radius: var(--gd2-r-control);
  border: 1px solid var(--gd2-border); background: var(--gd2-surface-3);
  color: var(--gd2-text); font-size: 14px; font-weight: 600; cursor: pointer; text-align: left;
}
.gd-more-item svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ==== Primitives (für alle Folge-Etappen) ================================== */
.gd-btn, .gd-btn-primary, .gd-btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--gd2-r-control);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform .12s ease, background .14s ease, border-color .14s ease;
}
.gd-btn { background: var(--gd2-surface-3); border: 1px solid var(--gd2-border-strong); color: var(--gd2-text); }
.gd-btn:hover { border-color: rgba(255, 255, 255, .22); transform: translateY(-1px); }
.gd-btn-primary { background: var(--brand-grad-btn, var(--gd2-grad)); border: 0; color: #fff; }
.gd-btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.gd-btn-ghost { background: none; border: 0; color: var(--gd2-text-mute); }
.gd-btn-ghost:hover { color: var(--gd2-text); background: var(--gd2-surface-3); }
.gd-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  background: var(--gd2-surface-3); border: 1px solid var(--gd2-border);
  font-size: 12px; font-weight: 600; color: var(--gd2-text-mute); white-space: nowrap;
}
.gd-chip.is-premium { color: var(--gd2-gold); border-color: rgba(232, 194, 104, .4); background: rgba(232, 194, 104, .08); }
.gd-chip.is-accent { color: #cfe0ff; border-color: rgba(91, 140, 255, .45); background: var(--gd2-accent-soft); }
.gd-card {
  background: var(--gd2-surface-2); border: 1px solid var(--gd2-border);
  border-radius: var(--gd2-r-card);
  transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease;
}
.gd-card:hover { border-color: var(--gd2-border-strong); }
.gd-card.is-clickable { cursor: pointer; }
.gd-card.is-clickable:hover { transform: translateY(-1px); box-shadow: var(--gd2-shadow-card); }

/* Fokus einheitlich */
.gd-nav-item:focus-visible, .gd-btn:focus-visible, .gd-btn-primary:focus-visible,
.gd-btn-ghost:focus-visible, .gd-logo:focus-visible, .gd-more-item:focus-visible,
.gd-topbar .settingBtn:focus-visible, .gd-topbar-toggle:focus-visible {
  outline: 2px solid rgba(122, 162, 255, .85); outline-offset: 2px;
}
