/* ============================================================
   Werwolf - Familien-Styleguide
   - Tokens kommen aus tokens.css
   - Komponenten 1:1 aus dem Styleguide (Abschnitt 7)
   ============================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 15px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-8);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Focus-Ring (verbindlich auf JEDEM interaktiven Element)
   ============================================================ */
button, input, select, textarea, [tabindex]:not([tabindex="-1"]) {
  outline: none;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ============================================================
   Typografie
   ============================================================ */
h1, h2, h3, h4 {
  font-family: 'Figtree', system-ui, sans-serif;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}
h1 { font-size: 32px; line-height: 40px; font-weight: 800; }
h2 { font-size: 26px; line-height: 34px; font-weight: 700; }
h3 { font-size: 21px; line-height: 28px; font-weight: 700; }
h4 { font-size: 18px; line-height: 24px; font-weight: 600; }

p { margin: 0; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 13px; line-height: 20px; }
.text-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================================
   App-Header (Styleguide 7.3)
   ============================================================ */
.app-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.app-header-title {
  display: flex; align-items: center; gap: var(--space-2);
  min-width: 0;
  flex: 1 1 auto;
}
.app-header-icon {
  display: inline-flex;
  flex-shrink: 0;
}
.app-header-icon img {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: block;
}
.app-header-title h1 {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 22px; line-height: 28px; font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header-actions {
  display: flex; align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.app-header-status {
  position: absolute;
  bottom: -9px;
  right: 0;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 10px; line-height: 14px; font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.25s, background-color 0.2s, border-color 0.2s, color 0.2s;
}
.app-header-status[hidden]                 { display: none; }
.app-header-status[data-status="offline"]  { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.app-header-status[data-status="pending"]  { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info-text); }
.app-header-status[data-status="saved"]    { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }

/* ============================================================
   .btn-pill (Styleguide 7.1) - Header-Actions
   ============================================================ */
.btn-pill {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 0 var(--space-3);
  min-height: 44px;
  min-width: 44px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s;
}
.btn-pill:hover  { background: var(--surface-hover); }
.btn-pill:active { background: var(--surface-active); }

/* ============================================================
   Buttons - primary, accent, ghost, danger
   ============================================================ */
.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 24px;
  padding: var(--space-3) var(--space-5);
  min-height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--action);
  color: var(--on-action);
  border-color: var(--action);
}
.btn-primary:hover:not(:disabled)  { background: var(--action-hover); border-color: var(--action-hover); }
.btn-primary:active:not(:disabled) { background: var(--action-hover); }

.btn-accent {
  background: var(--accent-solid);
  color: var(--on-accent);
  border-color: var(--accent-solid);
}
.btn-accent:hover:not(:disabled)   { background: var(--a-800); border-color: var(--a-800); }
[data-theme="dark"]
  .btn-accent:hover:not(:disabled) { background: var(--a-200); border-color: var(--a-200); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled)  { background: var(--surface-hover); }

.btn-block {
  width: 100%;
}

/* ============================================================
   Inputs
   ============================================================ */
label.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
label.field > span {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.input {
  font-family: inherit;
  font-size: 16px; /* iOS Zoom-Schutz */
  line-height: 24px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  min-height: 48px;
  width: 100%;
}
.input::placeholder { color: var(--text-disabled); }
.input:focus-visible {
  border-color: var(--action);
}

/* Grosse Code-Eingabe (auf dem Beitritts-Screen prominent) */
.input-code {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 32px;
  line-height: 40px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
  padding: var(--space-4);
  min-height: 64px;
}

/* ============================================================
   Card-Container
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--space-4); }

.stack > * + * { margin-top: var(--space-3); }
.stack-lg > * + * { margin-top: var(--space-4); }

/* ============================================================
   Home-Screen (Start / Beitritt)
   ============================================================ */
.home-hero {
  text-align: center;
  margin-bottom: var(--space-5);
}
.home-hero h2 {
  margin-bottom: var(--space-2);
}
.home-hero p {
  color: var(--text-muted);
  font-size: 17px;
  line-height: 26px;
}

.divider-or {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: var(--space-4) 0;
}
.divider-or::before,
.divider-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   Lobby - Code anzeigen, Spielerliste
   ============================================================ */
.code-display {
  text-align: center;
}
.code-display .text-label {
  margin-bottom: var(--space-2);
}
.code-value {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 44px;
  line-height: 52px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--text);
}
.code-hint {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 20px;
  margin-top: var(--space-2);
}

.player-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.player-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.player-list li:last-child { border-bottom: none; }
.player-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--p-100);
  color: var(--p-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
[data-theme="dark"] .player-avatar { background: var(--p-700); color: var(--p-100); }
.player-name {
  flex: 1;
  font-weight: 500;
}
.player-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--p-100);
  color: var(--p-700);
}
[data-theme="dark"] .player-badge { background: var(--p-800); color: var(--p-200); }

/* ============================================================
   Btn-Small (sekundaere Buttons in Cards)
   ============================================================ */
.btn-small {
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
  padding: var(--space-2) var(--space-3);
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-family: inherit;
}
.btn-small:hover { background: var(--surface-hover); }

/* ============================================================
   Rollen-Liste + Stepper (Lobby)
   ============================================================ */
.role-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.role-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.role-item:last-child { border-bottom: none; }

.role-item-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s, color 0.15s;
}
.role-item-active .role-item-icon {
  background: var(--p-100);
  color: var(--action);
}
[data-theme="dark"] .role-item-active .role-item-icon {
  background: var(--p-800);
  color: var(--p-200);
}

.role-item-text {
  flex: 1;
  min-width: 0;
}
.role-item-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 20px;
}
.role-item-short {
  font-size: 13px;
  line-height: 18px;
  color: var(--text-muted);
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
  flex-shrink: 0;
}
.stepper-btn {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.stepper-btn:hover:not(:disabled) { background: var(--surface-hover); }
.stepper-btn:disabled { color: var(--text-disabled); cursor: not-allowed; }
.stepper-value {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.role-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}
.role-summary-ok {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}
.role-summary-warn {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

/* Preview-Mode (Nicht-Hosts sehen die Rollen-Liste informativ) */
.role-list-preview .role-item {
  border-bottom: 1px dashed var(--border);
}

/* ============================================================
   Reveal-View
   ============================================================ */
.reveal-intro {
  text-align: center;
  margin-bottom: var(--space-5);
}
.reveal-intro .text-label {
  margin-bottom: var(--space-2);
}
.reveal-intro h2 {
  margin-bottom: var(--space-2);
}

.role-card-wrap {
  perspective: 1200px;
  margin: 0 auto;
  max-width: 320px;
}
.role-card {
  width: 100%;
  min-height: 380px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: transform 0.4s ease, box-shadow 0.2s;
  box-shadow: var(--shadow-md);
}
.role-card:hover { box-shadow: var(--shadow-lg); }

.role-card-closed {
  background:
    radial-gradient(circle at 50% 30%, var(--p-200) 0%, var(--surface) 70%);
  border-color: var(--border-strong);
  color: var(--action);
}
[data-theme="dark"] .role-card-closed {
  background:
    radial-gradient(circle at 50% 30%, var(--p-700) 0%, var(--surface) 70%);
  color: var(--p-200);
}
.role-card-back-mark {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}
.role-card-tap-hint {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.role-card-open {
  cursor: default;
  animation: card-flip-in 0.35s ease;
}
@keyframes card-flip-in {
  0%   { transform: rotateY(90deg); opacity: 0; }
  100% { transform: rotateY(0deg);  opacity: 1; }
}
.role-card-village {
  background: linear-gradient(160deg, var(--p-50) 0%, var(--surface) 60%);
  border-color: var(--p-200);
}
[data-theme="dark"] .role-card-village {
  background: linear-gradient(160deg, var(--p-800) 0%, var(--surface) 60%);
  border-color: var(--p-700);
}
.role-card-wolf {
  background: linear-gradient(160deg, var(--a-50) 0%, var(--surface) 60%);
  border-color: var(--a-200);
}
[data-theme="dark"] .role-card-wolf {
  background: linear-gradient(160deg, var(--a-800) 0%, var(--surface) 60%);
  border-color: var(--a-700);
}

.role-card-team {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.role-card-icon {
  width: 56px; height: 56px;
  color: var(--action);
  margin: var(--space-2) 0;
}
.role-card-wolf .role-card-icon { color: var(--accent-solid); }
[data-theme="dark"] .role-card-wolf .role-card-icon { color: var(--accent); }

.role-card-name {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 28px;
  line-height: 32px;
  font-weight: 800;
  margin: 0;
}
.role-card-desc {
  font-size: 14px;
  line-height: 22px;
  color: var(--text-2);
  margin: 0;
}
.role-card-hide {
  margin-top: var(--space-2);
}

.role-card-empty {
  cursor: default;
  background: var(--surface-2);
  color: var(--text-muted);
}

.ready-confirmed {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-md);
  color: var(--success-text);
  font-weight: 600;
}

/* ============================================================
   Master-Uebersicht (Reveal-Phase, nur Host)
   ============================================================ */
.master-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.master-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.master-list li:last-child { border-bottom: none; }
.master-name {
  flex: 1;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.master-role {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 12px;
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  flex-shrink: 0;
}
.master-check   { color: var(--success); flex-shrink: 0; }
.master-pending { color: var(--text-disabled); flex-shrink: 0; }
.master-item-ready .master-name { color: var(--text-muted); }

/* ============================================================
   Utility
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
