/* =============================================================
   Ascend · Shared Design Tokens + Base
   Single source of truth. Used by ascend.html and design.html.
   Komponenten-Styles leben weiterhin in den jeweiligen HTML-Dateien.
   ============================================================= */

/* ── Self-hosted Fonts (DSGVO: keine Google-Fonts-Requests) ─────────────────── */
/* Alfa Slab One · Display */
@font-face {
  font-family: 'Alfa Slab One';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/alfa-slab-one-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Alfa Slab One';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/alfa-slab-one-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* JetBrains Mono · Tabular / Mono — ein Subset deckt 400 + 600 ab */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Themes (Farben) ── */
:root, [data-theme="default"] {
  --bg:          #0c0c14;
  --surface:     #13131f;
  --surface2:    #1c1c2e;
  --surface3:    #24243a;
  --border:      #252538;
  --border-strong: #3a3a54;
  --primary:     #7c3aed;
  --accent:      #ec4899;
  --xp:          #a855f7;
  --text:        #f1f5f9;
  --muted:       #8a8aa8;
  --muted-deep:  #4a4a6a;
  --success:     #22c55e;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --info:        #3b82f6;
  --c-fit:       #ef4444;
  --c-hab:       #f59e0b;
  --c-hom:       #22c55e;
  --c-ler:       #3b82f6;
}
[data-theme="neon"] {
  --bg:          #060010;
  --surface:     #0e0020;
  --surface2:    #160030;
  --surface3:    #1e0040;
  --border:      #2a0050;
  --border-strong: #3e0070;
  --primary:     #d946ef;
  --accent:      #06b6d4;
  --xp:          #c084fc;
  --text:        #f0f9ff;
  --muted:       #9a70aa;
  --muted-deep:  #503060;
  --success:     #22d3ee;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --info:        #06b6d4;
}
[data-theme="forest"] {
  --bg:          #090f09;
  --surface:     #0f1a0f;
  --surface2:    #162416;
  --surface3:    #1e321e;
  --border:      #1e341e;
  --border-strong: #2c4c2c;
  --primary:     #16a34a;
  --accent:      #ca8a04;
  --xp:          #4ade80;
  --text:        #f0fdf4;
  --muted:       #7a9a7a;
  --muted-deep:  #3a5a3a;
  --success:     #4ade80;
  --warning:     #ca8a04;
  --danger:      #dc2626;
  --info:        #0ea5e9;
}
[data-theme="dark"] {
  --bg:          #020408;
  --surface:     #0d1117;
  --surface2:    #161b22;
  --surface3:    #202833;
  --border:      #21262d;
  --border-strong: #333c48;
  --primary:     #6366f1;
  --accent:      #f43f5e;
  --xp:          #818cf8;
  --text:        #e6edf3;
  --muted:       #7a8898;
  --muted-deep:  #3d444d;
  --success:     #3fb950;
  --warning:     #d29922;
  --danger:      #f85149;
  --info:        #58a6ff;
}

/* ── Typografie ── */
:root {
  --font-display: 'Alfa Slab One', Georgia, serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --fs-display: clamp(44px, 7vw, 72px);
  --fs-h1: 36px;
  --fs-h2: 28px;
  --fs-h3: 20px;
  --fs-h4: 16px;
  --fs-body-lg: 17px;
  --fs-body: 15px;
  --fs-small: 13px;
  --fs-micro: 11px;

  --lh-tight: 1.1;
  --lh-snug: 1.25;
  --lh-normal: 1.5;

  --tracking-tight: -0.01em;
  --tracking-normal: 0;
  --tracking-wide:  0.06em;
  --tracking-wider: 0.1em;

  /* Spacing (4px base, nicht-linear) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-14: 56px; --s-20: 80px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px; --r-full: 999px;

  /* Borders */
  --border-w: 1px;

  /* Elevation — bewusst minimal */
  --shadow-lift: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px -12px rgba(0,0,0,0.6);
  --shadow-pop:  0 10px 40px -10px rgba(0,0,0,0.7), 0 0 0 1px var(--border);

  /* Motion */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Abgeleitet */
  --primary-soft: color-mix(in srgb, var(--primary) 14%, transparent);
  --accent-soft:  color-mix(in srgb, var(--accent) 14%, transparent);
}

/* =============================================================
   RESET + BASE
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  height: 100%;
  /* overflow:hidden auf html + body verhindert das iOS-Rubberband-Bouncing
     der gesamten Seite, das auf manchen iOS-Versionen position:fixed-Elemente
     waehrend des Bouncings mitziehen kann. */
  overflow: hidden;
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  background: var(--bg);
  color: var(--text);
  /* App-Shell-Layout: body ist Flex-Column, Topbar + Page-Content + Bottomnav
     sind reale Flex-Children. Damit sitzt die Navbar physisch am Ende des
     Body = Ende des Viewports — unabhaengig von iOS-PWA-Quirks mit
     position:fixed (die nach Body-Scroll oder app-resume das fixierte
     Element kurzzeitig falsch positionieren). Gescrollt wird ausschliesslich
     im #page-content, der zwischen Top- und Bottom-Bar als flex:1 sitzt. */
  /* height: 100dvh statt 100% — auf iOS-PWA-Standalone resolved height:100%
     nicht zuverlaessig zur vollen Geraete-Hoehe (Body bleibt kuerzer als
     Viewport, Navbar als letzte Flex-Row sitzt dann oberhalb der Geraete-
     Kante). dvh = dynamic viewport height bezieht die Safe-Areas korrekt
     ein. Fallback fuer alte Browser via 100vh. */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  /* Doppelklick-Zoom deaktivieren (Pinch-Zoom bleibt fuer Accessibility erhalten). */
  /* Entfernt nebenbei den 300 ms-Tap-Delay auf Mobile.                            */
  touch-action: manipulation;
  /* Feine Grain-Textur — subtile Flächentrennung statt Gradient-Blobs */
  background-image:
    radial-gradient(1px 1px at 25% 30%, rgba(255,255,255,0.015) 1px, transparent 0),
    radial-gradient(1px 1px at 75% 70%, rgba(255,255,255,0.012) 1px, transparent 0);
  background-size: 140px 140px, 200px 200px;
}
::selection { background: var(--accent); color: #fff; }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }

/* Utility-Klassen */
.slab { font-family: var(--font-display); font-weight: 400; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* =============================================================
   FRIENDS-SECTION (Profile)
   Markup wird von app/profile-friends.js erzeugt; Styles hier weil
   neue Komponenten ab jetzt aus der Inline-<style>-Sektion in
   ascend.html in app.css wandern.
   ============================================================= */

.friends-subhead {
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--muted);
  margin: var(--s-4) 0 var(--s-2);
}
.friends-subhead:first-child { margin-top: 0; }

.friends-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.friend-card,
.friend-request-row {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  text-align: left;
  color: var(--text);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.friend-card:hover { background: var(--surface3); border-color: var(--border-strong); }
.friend-card:active { transform: translateY(1px); }

.friend-avatar {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: var(--surface3);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.friend-avatar-pending { opacity: 0.55; }

.friend-meta {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.friend-name {
  font-size: var(--fs-body);
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.friend-sub,
.friend-stats-inline {
  font-size: var(--fs-micro);
  color: var(--muted);
  display: flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}

.friend-arrow {
  font-size: 24px;
  color: var(--muted-deep);
  flex-shrink: 0;
  padding-right: var(--s-1);
}

.friend-actions { display: flex; gap: var(--s-2); flex-shrink: 0; }
.friend-btn {
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-small);
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface3);
  color: var(--text);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.friend-btn:hover { border-color: var(--border-strong); }
.friend-btn-accept { background: var(--primary); color: #fff; border-color: transparent; }
.friend-btn-accept:hover { filter: brightness(1.1); }
.friend-btn-decline { background: transparent; color: var(--muted); }
.friend-btn-decline:hover { color: var(--text); border-color: var(--danger); }

.friends-empty {
  font-size: var(--fs-small);
  color: var(--muted);
  padding: var(--s-3) 0;
  text-align: center;
}

.friends-add-btn {
  width: 100%;
  margin-top: var(--s-4);
  padding: 12px;
  border-radius: var(--r-md);
  font-size: var(--fs-small);
  font-weight: 700;
}

/* =============================================================
   CREW-SECTION (Work-in-Progress-Stub)
   ============================================================= */
.crew-card.wip {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%;
  background: var(--surface2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--s-3);
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.crew-card.wip:hover { background: var(--surface3); }
.crew-card-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.crew-card-title { font-size: var(--fs-body); font-weight: 600; }
.crew-card-sub { font-size: var(--fs-micro); color: var(--muted); }
.crew-wip-badge {
  font-family: var(--font-display);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  background: var(--warning);
  color: #1a1a1a;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}

/* =============================================================
   FRIENDS / CREW MODALS (eigenes .modal-overlay-Pattern, getrennt
   von den IDs der bestehenden Modale in ascend.html)
   ============================================================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center; justify-content: center;
  padding: var(--s-5);
}
.modal-overlay.show { display: flex; }
.modal-overlay .modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-5);
  max-width: 380px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-drop 320ms var(--ease-spring);
}
.modal-overlay .modal-title {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  line-height: var(--lh-snug);
  margin-bottom: var(--s-2);
}
.modal-overlay .modal-desc {
  font-size: var(--fs-small);
  color: var(--muted);
  line-height: var(--lh-normal);
  margin-bottom: var(--s-4);
}
.modal-overlay .modal-actions {
  display: flex; gap: var(--s-2);
  margin-top: var(--s-5);
}
.modal-overlay .modal-actions > * { flex: 1; padding: 12px; border-radius: var(--r-sm); font-size: var(--fs-small); font-weight: 700; }

.friend-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease);
}
.friend-input:focus { border-color: var(--primary); }
.friend-input-err {
  font-size: var(--fs-micro);
  color: var(--danger);
  min-height: 16px;
  margin-top: var(--s-2);
}

/* Friend-Detail-Modal */
.friend-detail-card { padding: var(--s-6) var(--s-5); }
.friend-detail-hero {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-5);
}
.friend-detail-avatar {
  width: 72px; height: 72px;
  border-radius: var(--r-full);
  background: var(--surface3);
  border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
}
.friend-detail-name {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  line-height: var(--lh-tight);
}
.friend-detail-stage {
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--primary);
}
.friend-detail-stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.friend-detail-stats .stat-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  text-align: center;
}
.friend-detail-stats .stat-num {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-variant-numeric: tabular-nums;
}
.friend-detail-stats .stat-lbl {
  font-size: var(--fs-micro);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-top: 2px;
}
.friend-detail-xp {
  margin-bottom: var(--s-2);
}
.friend-detail-xp-label {
  font-size: var(--fs-micro);
  color: var(--muted);
  text-align: center;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.friend-detail-xp-bar {
  width: 100%; height: 6px;
  background: var(--surface3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.friend-detail-xp-fill {
  height: 100%;
  background: var(--xp);
  transition: width var(--dur-base) var(--ease);
}
.friend-detail-loading {
  text-align: center;
  color: var(--muted);
  padding: var(--s-10) 0;
  font-size: var(--fs-h2);
}

/* Toast */
.friends-toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--r-full);
  font-size: var(--fs-small);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
  box-shadow: var(--shadow-pop);
  max-width: calc(100vw - 32px);
}
.friends-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes modal-drop {
  from { transform: translateY(-30px) scale(0.94); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
