/* ═══════════════════════════════════════════════
   WORKOUTPAL — main.css
   Design system: variables, reset, layout shell
   ═══════════════════════════════════════════════ */

/* ── Google Fonts fallback if offline ─── */
@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  /* Colors */
  --bg:               #F7F7F5;
  --surface:          #FFFFFF;
  --surface-2:        #F0F0EE;
  --accent:           #FF4D00;
  --accent-hover:     #E04300;
  --accent-light:     #FFF0EB;
  --accent-muted:     rgba(255, 77, 0, 0.12);
  --text-primary:     #141414;
  --text-secondary:   #6B6B6B;
  --text-tertiary:    #A8A8A8;
  --border:           #E8E8E6;
  --border-strong:    #D0D0CC;
  --success:          #00C271;
  --success-light:    #E6FAF3;
  --warning:          #F5A623;
  --warning-light:    #FEF6E7;
  --danger:           #FF3B30;
  --danger-light:     #FFF0EF;

  /* Typography */
  --font-display:     'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body:        'DM Sans', 'Helvetica Neue', sans-serif;

  /* Spacing scale (4px base) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  28px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border radius */
  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-accent: 0 4px 16px rgba(255,77,0,0.30);

  /* Layout */
  --header-height:   58px;
  --nav-height:      72px;
  --nav-safe-bottom: env(safe-area-inset-bottom, 0px);
  --content-max:     480px;

  /* Transitions */
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:    cubic-bezier(0.4, 0, 1, 1);
  --ease-inout: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:   150ms;
  --dur-mid:    250ms;
  --dur-slow:   400ms;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  font-family: var(--font-body);
  font-weight: 400;
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

/* ── App Shell ───────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;          /* dynamic viewport height (iOS safari fix) */
  max-width: var(--content-max);
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* ── Header ──────────────────────────────────────────────── */
#app-header {
  flex-shrink: 0;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
  position: relative;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-5);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.app-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── Screen Container ────────────────────────────────────── */
#screen-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(12px);
  transition:
    opacity var(--dur-mid) var(--ease-out),
    transform var(--dur-mid) var(--ease-out);
  will-change: opacity, transform;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.screen.exit {
  opacity: 0;
  transform: translateX(-12px);
}

.screen-scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: var(--space-5) var(--space-5) var(--space-6);
}

/* ── Bottom Navigation ───────────────────────────────────── */
#bottom-nav {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--nav-safe-bottom);
  position: relative;
  z-index: 100;
}

.nav-inner {
  display: flex;
  height: var(--nav-height);
  align-items: stretch;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-tertiary);
  position: relative;
  transition: color var(--dur-fast) var(--ease-out);
  touch-action: manipulation;
  min-height: 44px; /* iOS minimum touch target */
}

.nav-tab::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 28px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
  transition: transform var(--dur-mid) var(--ease-out);
}

.nav-tab.active {
  color: var(--accent);
}

.nav-tab.active::before {
  transform: translateX(-50%) scaleX(1);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  transition: transform var(--dur-fast) var(--ease-out);
}

.nav-tab.active .nav-icon {
  transform: translateY(-1px);
}

.nav-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  line-height: 1;
}

/* ── Tap feedback ────────────────────────────────────────── */
.nav-tab:active .nav-icon {
  transform: scale(0.88);
}

/* ── Screen title ────────────────────────────────────────── */
.screen-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 32px;
  letter-spacing: 0.5px;
  line-height: 1;
  color: var(--text-primary);
  text-transform: uppercase;
  margin-bottom: var(--space-6);
}

.screen-title span {
  color: var(--accent);
}

/* ── Section heading ─────────────────────────────────────── */
.section-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-3);
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  gap: var(--space-4);
}

.empty-state svg {
  opacity: 0.2;
}

.empty-state p {
  font-size: 15px;
  color: var(--text-tertiary);
  max-width: 240px;
  line-height: 1.6;
}

/* ── 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;
}

.text-accent { color: var(--accent); }
.text-muted  { color: var(--text-secondary); }
.text-small  { font-size: 13px; }
.fw-600      { font-weight: 600; }
.mt-4        { margin-top: var(--space-4); }
.mt-6        { margin-top: var(--space-6); }
.mb-4        { margin-bottom: var(--space-4); }
.mb-6        { margin-bottom: var(--space-6); }
