/* ============================================================
   PULSE — FitnessTracker WebApp · Design System
   Energetisch · Dark · Teal/Cyan-Akzente
   ============================================================ */

:root {
  /* Surfaces (deep teal-black) */
  --bg:        #0a1014;
  --surface-1: #101a1f;
  --surface-2: #16242b;
  --surface-3: #1d3038;
  --hairline:  rgba(120, 200, 210, 0.10);
  --hairline-strong: rgba(120, 200, 210, 0.18);

  /* Accents — shared chroma, varied hue */
  --green:   #2ee6a8;
  --green-d: #1fb88a;
  --blue:    #1fb6ff;
  --blue-d:  #1488d6;

  /* Text */
  --text:    #eaf6f4;
  --muted:   rgba(213, 235, 235, 0.62);
  --faint:   rgba(213, 235, 235, 0.52);

  /* Status */
  --warn: #ffb24d;

  /* Geometry */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-xl: 34px;

  /* Shadows / glows */
  --glow-green: 0 0 0 1px rgba(46,230,168,0.35), 0 8px 28px -8px rgba(46,230,168,0.45);
  --glow-blue:  0 0 0 1px rgba(31,182,255,0.30), 0 8px 28px -8px rgba(31,182,255,0.4);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.03) inset, 0 12px 30px -16px rgba(0,0,0,0.7);

  /* Translucent chrome (bottom nav, rest-timer overlay) — themed separately
     because their content uses --text and needs a matching backdrop. */
  --nav-bg:     rgba(10, 16, 20, 0.82);
  --overlay-bg: rgba(6, 12, 15, 0.86);

  /* Text on accent fills, fonts, primary button fill — varied per theme */
  --on-green: #04201a;
  --on-blue:  #032231;
  --font-body:    'Barlow', system-ui, sans-serif;
  --font-display: 'Barlow Semi Condensed', 'Barlow', sans-serif;
  --btn-primary-bg: linear-gradient(180deg, var(--green), var(--green-d));
  --btn-blue-bg:    linear-gradient(180deg, var(--blue), var(--blue-d));

  --app-w: 440px;
}

/* ============================================================
   Themes — ein Design = ein Block hier + ein Eintrag in
   window.THEMES (data.jsx). :root oben ist das Dark-Default.
   ============================================================ */

[data-theme="light"] {
  --bg:        #eef4f4;
  --surface-1: #ffffff;
  --surface-2: #e2ecec;
  --surface-3: #d2e2e2;
  --hairline:  rgba(15, 60, 70, 0.10);
  --hairline-strong: rgba(15, 60, 70, 0.20);

  /* Same hues, darkened for contrast on light surfaces */
  --green:   #0ebe8b;
  --green-d: #0a9a70;
  --blue:    #0e93d8;
  --blue-d:  #0a71a8;

  --text:    #10262b;
  --muted:   rgba(16, 48, 54, 0.66);
  --faint:   rgba(16, 48, 54, 0.68);

  --warn: #d9861f;

  --glow-green: 0 0 0 1px rgba(14,190,139,0.35), 0 8px 24px -10px rgba(14,190,139,0.45);
  --glow-blue:  0 0 0 1px rgba(14,147,216,0.30), 0 8px 24px -10px rgba(14,147,216,0.4);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.6) inset, 0 10px 24px -14px rgba(15,60,70,0.22);

  --nav-bg:     rgba(238, 244, 244, 0.85);
  --overlay-bg: rgba(230, 240, 240, 0.9);
}

/* Pure-black surfaces for OLED displays — inherits accents/text from :root */
[data-theme="oled"] {
  --bg:        #000000;
  --surface-1: #0a0f12;
  --surface-2: #111b20;
  --surface-3: #192930;
  --nav-bg:    rgba(0, 0, 0, 0.85);
}

/* André Krämer Design System (D:\DEV\FUELD\…\_ds\andr-kr-mer-design-system…):
   Space Grotesk, Blau→Violett statt Grün/Cyan. --green = Primärakzent,
   --blue = Sekundärakzent — die Namen bleiben, damit die JSX unverändert gilt. */
[data-theme="ak-dark"], [data-theme="ak-light"] {
  --font-body:    'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --on-green: #ffffff;
  --on-blue:  #ffffff;
  --btn-primary-bg: linear-gradient(90deg, #1d4ed8, #7c3aed);
  --btn-blue-bg:    linear-gradient(90deg, #7c3aed, #8b5cf6);

  --r-sm: 10px;
  --r-md: 13px;
  --r-lg: 16px;
  --r-xl: 20px;
}

[data-theme="ak-dark"] {
  --bg:        #080e1e;
  --surface-1: #0f1627;
  --surface-2: #161f33;
  --surface-3: #1e2940;
  --hairline:  rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.12);

  --green:   #3b82f6;
  --green-d: #1d4ed8;
  --blue:    #8b5cf6;
  --blue-d:  #7c3aed;

  --text:    #e4eaf6;
  --muted:   #8f9bb0;
  --faint:   #7a8698;

  --warn: #fb923c;

  --glow-green: 0 4px 24px rgba(29, 78, 216, 0.35);
  --glow-blue:  0 4px 24px rgba(124, 58, 237, 0.35);
  --shadow-card: 0 12px 36px rgba(0, 0, 0, 0.35);

  --nav-bg:     rgba(8, 14, 30, 0.93);
  --overlay-bg: rgba(5, 9, 24, 0.88);
}

[data-theme="ak-light"] {
  --bg:        #f1f5f9;
  --surface-1: #ffffff;
  --surface-2: #e8eef5;
  --surface-3: #e2e8f0;
  --hairline:  rgba(15, 23, 42, 0.08);
  --hairline-strong: rgba(15, 23, 42, 0.14);

  --green:   #1d4ed8;
  --green-d: #1e40af;
  --blue:    #7c3aed;
  --blue-d:  #7c3aed;

  --text:    #0f172a;
  --muted:   #64748b;
  /* DS tertiary #94a3b8 fails contrast on white; secondary reused */
  --faint:   #64748b;

  --warn: #f97316;

  --glow-green: 0 4px 24px rgba(29, 78, 216, 0.25);
  --glow-blue:  0 4px 24px rgba(124, 58, 237, 0.25);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px -16px rgba(15, 23, 42, 0.18);

  --nav-bg:     rgba(255, 255, 255, 0.92);
  --overlay-bg: rgba(241, 245, 249, 0.9);
}

/* Keksverse Design System v3 (Plattform-Standard 0.3, Abschnitt 7): Cream, Schoko, Keks-Gold, Akzent Fitness = Tomate.
   Nur hell (der Standard kennt keinen Dark Mode). --green = App-Akzent in der 700-Stufe (Text und Flächen),
   --blue = Keks-Gold-Familie als Zweitakzent. Primäraktion = Keks-Gold mit Schoko-900-Text und "gebackener Kante". */
[data-theme="keks"] {
  --bg:        #FFFBF5;
  --surface-1: #FFFFFF;
  --surface-2: #FBF3E7;
  --surface-3: #F4E7D5;
  --hairline:  #F4E7D5;
  --hairline-strong: #EADAC3;

  --green:   #B8391D;
  --green-d: #B8391D;
  --blue:    #8F5212;
  --blue-d:  #683C12;

  --text:    #2A1B14;
  --muted:   #6A4836;
  --faint:   #8A6650;

  --warn: #8A5A00;

  --glow-green: 0 3px 0 #B86C14;
  --glow-blue:  0 3px 0 #683C12;
  --shadow-card: 0 8px 20px -6px rgba(59, 38, 28, 0.16);

  --nav-bg:     rgba(255, 251, 245, 0.88);
  --overlay-bg: rgba(255, 251, 245, 0.92);

  --on-green: #FFFFFF;
  --on-blue:  #FFFFFF;
  --font-body:    'Figtree', system-ui, sans-serif;
  --font-display: 'Fredoka', ui-rounded, system-ui, sans-serif;
  --btn-primary-bg: #E9A23C;
  --btn-blue-bg:    #8F5212;

  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;
}
/* Buttons: Satzschreibung, kurze Verben; Text auf Gold immer Schoko-900 */
[data-theme="keks"] .btn { text-transform: none; letter-spacing: 0; font-weight: 600; }
[data-theme="keks"] .btn-primary { color: #1C120D; }

@font-face { font-display: swap; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  /* Desktop: phone column on a textured dark backdrop */
  display: flex;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--blue) 7%, transparent), transparent 60%),
    radial-gradient(900px 500px at 50% 110%, color-mix(in srgb, var(--green) 6%, transparent), transparent 60%),
    var(--bg);
}

/* The app shell — fills viewport on mobile, centered column on desktop */
#root { width: 100%; display: flex; justify-content: center; }

.app {
  width: 100%;
  max-width: var(--app-w);
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
  overflow: hidden;
  /* This is an app, not a document — text (numbers, labels, buttons)
     shouldn't turn into a selection on tap/drag. Inputs opt back in below. */
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
}
@media (min-width: 480px) {
  .app {
    min-height: min(940px, 100dvh);
    margin: clamp(0px, 4vh, 40px) 0;
    border-radius: 38px;
    border: 1px solid var(--hairline-strong);
    box-shadow: 0 50px 120px -40px rgba(0,0,0,0.9), 0 0 0 1px rgba(0,0,0,0.4);
    overflow: hidden;
  }
}

/* ---- Typography helpers ---- */
.display {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 0.95;
}
.num {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.eyebrow {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--faint);
}

/* ---- Scrollable content region ---- */
.screen {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-overflow-scrolling: touch;
}

/* Viewport anchored inside the phone-width app column. Unlike an absolute
   child of .screen this cannot be scrolled above the visible viewport — an
   absolute overlay opened from a scrolled screen leaves the region below it
   undimmed and strands a bottom sheet mid-screen instead of at the edge. */
.workout-rest-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: var(--app-w);
  margin-inline: auto;
}
/* .sheet-overlay carries the same anchoring inline (see sheet.jsx) so a stale
   copy of this file can never leave the sheet unpositioned; only the cosmetic
   corner rounding lives here. */
@media (min-width: 480px) {
  .workout-rest-overlay, .sheet-overlay { border-radius: 38px; }
}

/* ---- Hide scrollbars everywhere — app never shows a native scrollbar track ---- */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

/* ---- Generic card ---- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}

/* ---- Buttons ---- */
/* Ein natives <button> zeigt den Pfeil, nicht die Hand — cursor: pointer hing
   bisher nur an .btn. Die App hat aber reichlich anklickbare Karten
   (<button class="card row">), die .btn nicht tragen; die sahen dadurch
   unklickbar aus. Eine Regel für alle statt einer Inline-Angabe pro Stelle. */
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: default; }

.btn {
  border: none;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .12s ease, filter .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.97); }

:where(button, input, textarea, select, [tabindex]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 75%, transparent);
  outline-offset: 3px;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--on-green);
  box-shadow: var(--glow-green);
}
.btn-blue {
  background: var(--btn-blue-bg);
  color: var(--on-blue);
  box-shadow: var(--glow-blue);
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--hairline-strong);
}
.btn-lg { height: 58px; padding: 0 26px; font-size: 18px; }
.btn-md { height: 46px; padding: 0 20px; font-size: 15px; }

/* utility */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.grow { flex: 1; }

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
/* Entrance: animate movement only — opacity stays 1 so content is never
   stuck invisible if the document is hidden (animation clock paused at t=0). */
@keyframes fadeUp {
  from { transform: translateY(12px); }
  to   { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  [style*="fadeUp"], [style*="popIn"] { animation: none !important; }
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 50%, transparent); }
  70% { box-shadow: 0 0 0 18px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.pulse-loader {
  width: 60px;
  height: 60px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--on-green);
  background: var(--green);
  box-shadow: var(--glow-green);
  animation: pulse-loader 1.25s ease-in-out infinite;
}
.pulse-loader .display { font-size: 29px; }
@keyframes pulse-loader {
  0%, 100% { transform: scale(.94); box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 34%, transparent); }
  50% { transform: scale(1); box-shadow: 0 0 0 14px transparent; }
}

@media (max-width: 360px) {
  .workout-set-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px !important;
  }
  .workout-stepper { width: 100%; }
  .workout-set-divider {
    width: 100% !important;
    height: 1px;
    align-self: auto !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-loader { animation: none; }
}
