/* ============================================
   FLINT PERFORMANCE — App Theme
   Responsive: mobile-first, scales to desktop
   ============================================ */

:root {
  --black: #060606;
  --white: #ede8df;
  --ember: #f04a0e;
  --ember-hot: #ff6122;
  --ember-dim: #b83a0b;
  --cold: #b8ccda;
  --gray: #0e0e0e;
  --gray-mid: #121212;
  --gray-up: #1a1a1a;
  --muted: #848484;
  --border: rgba(237, 232, 223, 0.06);

  --success: #34D399;
  --warning: #FBBF24;
  --danger: #F87171;
  --info: var(--cold);

  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-logo: 'Barlow Condensed', sans-serif;

  --radius: 2px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--black);
  color: var(--white);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================
   Top Bar
   ============================================ */

.top-bar {
  height: 48px;
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 20px;
  padding-right: 20px;
  background: var(--black);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 50;
}

.top-bar-logo {
  font-family: var(--font-logo);
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--white);
}

.logo-dot {
  color: var(--ember);
  text-shadow: 0 0 12px rgba(240, 74, 14, 0.6);
}

.top-bar-title {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============================================
   Screens
   ============================================ */

.screens {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

.screen-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px 24px;
}

/* Screen Hero */
.screen-hero {
  padding: 28px 0 20px;
}

.screen-title {
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--white);
  line-height: 1;
}

.screen-subtitle {
  font-size: 13px;
  font-weight: 300;
  color: var(--muted);
  margin-top: 4px;
}

/* ============================================
   Form Fields
   ============================================ */

.screen-form {
  padding-bottom: 8px;
}

/* Remove default fieldset styling from unit toggles */
fieldset.unit-toggle {
  border: none;
  padding: 0;
  margin: 0;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-input {
  position: relative;
}

.field-input input {
  width: 100%;
  height: 48px;
  padding: 0 40px 0 14px;
  background: var(--gray-up);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  transition: border-color 0.15s ease;
  -moz-appearance: textfield;
}

.field-input input::-webkit-outer-spin-button,
.field-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field-input input:focus {
  outline: none;
  border-color: var(--ember);
}

.field-input input::placeholder {
  color: rgba(237, 232, 223, 0.15);
}

.field-unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  pointer-events: none;
  letter-spacing: 0.05em;
}

select {
  width: 100%;
  height: 48px;
  padding: 0 36px 0 14px;
  background: var(--gray-up);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23848484' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 5.5l6.5 6.5 6.5-6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border-color 0.15s ease;
}

select:focus {
  outline: none;
  border-color: var(--ember);
}

select option {
  background: var(--gray-mid);
  color: var(--white);
}

/* Unit Toggle */
.unit-toggle {
  display: flex;
  background: var(--gray-up);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 20px;
}

.unit-btn {
  flex: 1;
  height: 34px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
}

.unit-btn.active {
  background: var(--ember);
  color: var(--black);
}

/* Action Button */
.action-btn {
  display: block;
  width: 100%;
  height: 52px;
  margin-top: 8px;
  background: var(--ember);
  border: none;
  border-radius: var(--radius);
  color: var(--black);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.action-btn:hover {
  background: var(--ember-hot);
}

.action-btn:active {
  background: var(--ember-dim);
}

/* ============================================
   Results
   ============================================ */

.screen-result {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.25s ease, margin 0.35s ease;
  margin-top: 0;
}

.screen-result.show {
  max-height: 900px;
  opacity: 1;
  margin-top: 20px;
}

.result-main {
  text-align: center;
  padding: 24px 0 20px;
  border-top: 1px solid var(--border);
}

.result-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  margin-bottom: 6px;
}

.result-value {
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ember);
  line-height: 1;
  text-shadow: 0 0 80px rgba(240, 74, 14, 0.35), 0 0 160px rgba(240, 74, 14, 0.1);
}

.result-unit {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
  letter-spacing: 0.05em;
}

.result-category {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 14px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.result-category.cat-under { background: rgba(184, 204, 218, 0.12); color: var(--cold); }
.result-category.cat-normal { background: rgba(52, 211, 153, 0.12); color: var(--success); }
.result-category.cat-over { background: rgba(251, 191, 36, 0.12); color: var(--warning); }
.result-category.cat-obese { background: rgba(248, 113, 113, 0.12); color: var(--danger); }

/* Result Details */
.result-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1px;
  margin-top: 16px;
}

.result-detail-item {
  background: var(--gray-up);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}

.result-detail-label {
  font-size: 9px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 4px;
}

.result-detail-value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--white);
}

.result-detail-value.accent { color: var(--ember); }

/* Macro section */
.macro-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}

.macro-section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--white);
  margin-bottom: 14px;
}

.macro-bar {
  margin-bottom: 12px;
}

.macro-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
}

.macro-bar-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--white);
}

.macro-bar-value {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.result-bar {
  height: 6px;
  background: rgba(237, 232, 223, 0.04);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-bar-fill {
  height: 100%;
  border-radius: var(--radius);
  background: var(--ember);
  transition: width 0.5s ease;
}

.macro-bar .result-bar-fill.protein { background: var(--ember); }
.macro-bar .result-bar-fill.carbs { background: var(--cold); }
.macro-bar .result-bar-fill.fat { background: var(--warning); }

/* Rep max table */
.rep-max-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.rep-max-table th,
.rep-max-table td {
  padding: 8px 10px;
  text-align: center;
  font-size: 13px;
}

.rep-max-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  border-bottom: 1px solid var(--border);
}

.rep-max-table td {
  color: var(--white);
  font-weight: 400;
  border-bottom: 1px solid var(--border);
}

.rep-max-table tr:last-child td { border-bottom: none; }
.rep-max-table td:first-child { color: var(--muted); }

.rep-max-table td:last-child {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--ember);
}

/* ============================================
   Bottom Tab Bar
   ============================================ */

.tab-bar {
  height: auto;
  padding-top: 6px;
  padding-bottom: calc(16px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--gray-mid);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 50;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 0;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.tab-icon {
  width: 22px;
  height: 22px;
}

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

.tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--ember);
  border-radius: 0 0 2px 2px;
}

/* ============================================
   Skip Link & Accessibility
   ============================================ */

.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--ember);
  color: var(--black);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: var(--radius);
  z-index: 999;
  transition: top 0.2s;
}

.skip-link:focus { top: 16px; }

*:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

/* ============================================
   Desktop — Tablet (600px+)
   ============================================ */

@media (min-width: 600px) {
  .screen-scroll {
    padding: 0 32px 32px;
  }

  .screen-hero {
    padding: 32px 0 24px;
  }

  .screen-title {
    font-size: 3.8rem;
  }

  .screen-subtitle {
    font-size: 14px;
  }

  .field label {
    font-size: 11px;
  }

  .result-value {
    font-size: 5rem;
  }

  .result-detail-value {
    font-size: 1.6rem;
  }

  .tab {
    font-size: 10px;
    gap: 4px;
  }

  .tab-icon {
    width: 24px;
    height: 24px;
  }
}

/* ============================================
   Desktop — Medium (768px+)
   ============================================ */

@media (min-width: 768px) {
  /* Allow normal scrolling on desktop */
  html, body {
    overflow: auto;
  }

  body {
    background: var(--gray);
  }

  #app {
    max-width: 640px;
    margin: 24px auto;
    height: auto;
    min-height: calc(100vh - 48px);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow:
      0 0 0 1px rgba(240, 74, 14, 0.06),
      0 20px 60px rgba(0, 0, 0, 0.5);
  }

  .top-bar {
    border-radius: 12px 12px 0 0;
  }

  .tab-bar {
    border-radius: 0 0 12px 12px;
    padding-bottom: 10px;
  }

  .screens {
    min-height: 500px;
  }

  .screen-scroll {
    padding: 0 40px 40px;
  }

  .screen-hero {
    padding: 36px 0 28px;
  }

  .screen-title {
    font-size: 4rem;
  }

  .field-input input {
    height: 50px;
  }

  select {
    height: 50px;
  }

  .action-btn {
    height: 54px;
    font-size: 13px;
  }
}

/* ============================================
   Desktop — Large (1024px+)
   ============================================ */

@media (min-width: 1024px) {
  #app {
    max-width: 720px;
    margin: 40px auto;
  }

  .screen-scroll {
    padding: 0 48px 48px;
  }

  .screen-hero {
    padding: 40px 0 32px;
  }

  .screen-title {
    font-size: 4.5rem;
  }

  .screen-subtitle {
    font-size: 15px;
    margin-top: 6px;
  }

  .field {
    margin-bottom: 20px;
  }

  .field label {
    font-size: 11px;
    margin-bottom: 8px;
  }

  .field-row {
    gap: 14px;
  }

  .field-input input {
    height: 52px;
    font-size: 16px;
  }

  select {
    height: 52px;
    font-size: 16px;
  }

  .action-btn {
    height: 56px;
    margin-top: 12px;
  }

  .result-value {
    font-size: 5.5rem;
  }

  .result-details {
    gap: 4px;
  }

  .result-detail-item {
    padding: 16px 12px;
  }

  .result-detail-value {
    font-size: 1.7rem;
  }

  .macro-bar-name {
    font-size: 14px;
  }

  .macro-bar-value {
    font-size: 13px;
  }

  .result-bar {
    height: 8px;
  }

  .rep-max-table th,
  .rep-max-table td {
    padding: 10px 14px;
    font-size: 14px;
  }

  .rep-max-table th {
    font-size: 10px;
  }

  .rep-max-table td:last-child {
    font-size: 1.15rem;
  }

  .tab {
    font-size: 10px;
    padding: 8px 0;
  }

  .tab-icon {
    width: 24px;
    height: 24px;
  }

  .info-note {
    font-size: 13px;
  }
}

/* ============================================
   Desktop — Wide (1440px+)
   ============================================ */

@media (min-width: 1440px) {
  #app {
    max-width: 780px;
    margin: 60px auto;
  }
}

/* ============================================
   Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Utility
   ============================================ */

.text-accent { color: var(--ember); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-info { color: var(--cold); }
.text-muted { color: var(--muted); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }

.info-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.6;
  font-weight: 300;
}
