/* =========================================================================
   MyTDEE — design tokens
   ========================================================================= */

:root {
  /* palette — warm cream + coral, a dash of teal */
  --color-bg: #f8efe1;
  --color-bg-deep: #f1e3cd;
  --color-surface: #fffdf9;
  --color-text: #382c22;
  --color-text-soft: #6f6154;
  --color-text-faint: #a4937f;

  --color-accent: #ff6b47;
  --color-accent-dark: #e2532f;
  --color-accent-soft: #ffe1d3;
  --color-accent-softer: #fff0e8;

  --color-teal: #2f8f83;
  --color-teal-soft: #dff0ec;

  --color-error: #c1443a;

  --color-border: #e6d6bd;
  --color-warn-bg: #fdf0d9;
  --color-warn-border: #f0d29c;
  --color-warn-text: #7a5a17;

  /* type */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* shape */
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-pill: 999px;

  --shadow-soft: 0 8px 24px -8px rgba(56, 44, 34, 0.18);
  --shadow-lift: 0 14px 34px -12px rgba(56, 44, 34, 0.28);

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

/* author `display` rules on an element normally win over the `hidden`
   attribute's UA styling — close that off everywhere, once */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background:
    radial-gradient(circle at 12% -10%, var(--color-accent-softer) 0%, transparent 45%),
    radial-gradient(circle at 100% 0%, var(--color-teal-soft) 0%, transparent 40%),
    var(--color-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button {
  font-family: inherit;
}

/* =========================================================================
   App shell
   ========================================================================= */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
}

/* -- topbar: centered logo, steps line stacked beneath -------------------- */

.topbar {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: var(--space-4) var(--space-5) var(--space-3);
  min-height: 68px;
}

/* -- bottombar: back button, pinned low enough to be a one-handed thumb reach -- */

.bottombar {
  flex: 0 0 auto;
  display: flex;
  padding: var(--space-3) var(--space-5) max(var(--space-4), env(safe-area-inset-bottom, 0px));
  min-height: 72px;
}

.back-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.back-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

.back-btn:active {
  transform: scale(0.92);
}

.topbar-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  max-width: 260px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(155deg, var(--color-accent), var(--color-accent-dark));
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.brand-dot {
  color: var(--color-text-faint);
  font-weight: 500;
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 100%;
}

.progress-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.progress-track {
  width: 100%;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--color-teal), var(--color-accent));
  transition: width 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}

/* =========================================================================
   Screen host + slide/fade transitions
   ========================================================================= */

.screen-host {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.wizard-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: var(--space-5) var(--space-5) var(--space-8);
  transition: transform 0.42s cubic-bezier(0.22, 0.9, 0.32, 1), opacity 0.32s ease;
}

.wizard-screen.enter-right {
  transform: translateX(100%);
  opacity: 0;
}

.wizard-screen.enter-left {
  transform: translateX(-100%);
  opacity: 0;
}

.wizard-screen.center {
  transform: translateX(0);
  opacity: 1;
}

.wizard-screen.exit-left {
  transform: translateX(-100%);
  opacity: 0;
}

.wizard-screen.exit-right {
  transform: translateX(100%);
  opacity: 0;
}

.screen-content {
  width: 100%;
  max-width: 420px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  gap: var(--space-4);
}

/* =========================================================================
   Shared bits: headings, big buttons
   ========================================================================= */

.question-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--color-accent-softer);
  color: var(--color-accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

.question-heading {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  line-height: 1.25;
  color: var(--color-text);
}

.question-sub {
  margin: -8px 0 0;
  font-size: 0.92rem;
  color: var(--color-text-soft);
}

.btn-large {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  font-size: 1rem;
  border-radius: var(--radius-pill);
}

/* =========================================================================
   Welcome screen
   ========================================================================= */

.screen-welcome {
  gap: var(--space-5);
}

.welcome-mark {
  font-size: 2.75rem;
  line-height: 1;
}

.welcome-heading {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 8vw, 2.7rem);
  line-height: 1.15;
  color: var(--color-text);
}

.welcome-body {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text-soft);
}

/* =========================================================================
   Choice cards (sex, activity level)
   ========================================================================= */

.choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  width: 100%;
  margin-top: var(--space-2);
}

.choice-grid[data-columns='2'] {
  grid-template-columns: 1fr 1fr;
}

.choice-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.22, 0.9, 0.32, 1), border-color 0.18s ease, box-shadow 0.18s ease,
    background 0.18s ease;
}

.choice-grid[data-columns='2'] .choice-card {
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
}

.card-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-accent-softer);
  color: var(--color-text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, color 0.18s ease;
}

.choice-card.selected .card-icon {
  background: var(--color-accent);
  color: #fff;
}

.card-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.choice-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.choice-card.selected {
  border-color: var(--color-accent);
  background: var(--color-accent-softer);
  transform: scale(1.03);
  box-shadow: var(--shadow-lift);
}

.choice-label {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-text);
}

.choice-card.selected .choice-label {
  color: var(--color-accent-dark);
}

.choice-sublabel {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-soft);
}

/* =========================================================================
   Text input screens (age, height, weight)
   ========================================================================= */

.text-input-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.screen-input {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.3rem;
  text-align: center;
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.screen-input::placeholder {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--color-text-faint);
}

.screen-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px var(--color-accent-soft);
}

.screen-input.input-error {
  border-color: var(--color-error);
}

.input-feedback {
  min-height: 1.3em;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.input-feedback.show {
  opacity: 1;
  transform: translateY(0);
}

.input-feedback.feedback-confirm {
  color: var(--color-teal);
}

.input-feedback.feedback-error {
  color: var(--color-error);
}

/* =========================================================================
   Optional health-context screen
   ========================================================================= */

.chips-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-2);
}

.chip-toggle {
  padding: var(--space-2) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text-soft);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.chip-toggle.selected {
  background: var(--color-teal);
  border-color: var(--color-teal);
  color: #fff;
}

.medical-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  margin-top: var(--space-3);
}

.link-btn {
  background: none;
  border: none;
  padding: var(--space-1);
  color: var(--color-text-faint);
  font-weight: 600;
  font-size: 0.86rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.18s ease;
}

.link-btn:hover {
  color: var(--color-text-soft);
}

/* =========================================================================
   Calculating screen
   ========================================================================= */

.screen-calculating {
  gap: var(--space-3);
}

.screen-calculating p {
  margin: 0;
  color: var(--color-text-soft);
  font-size: 0.9rem;
  font-weight: 600;
}

.calc-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid var(--color-accent-soft);
  border-top-color: var(--color-accent);
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================================
   Buttons (shared)
   ========================================================================= */

.btn {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1.5px solid transparent;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
  background: var(--color-accent-dark);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-soft);
  border-color: var(--color-border);
}

.btn-ghost:hover {
  border-color: var(--color-text-faint);
  color: var(--color-text);
}

/* =========================================================================
   Results screen (content unchanged from the original build)
   ========================================================================= */

.screen-results {
  max-width: 560px;
  align-items: stretch;
  text-align: left;
}

.results-inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.results-eyebrow {
  margin: 0;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-teal);
}

.results-hero {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: var(--space-3);
}

.hero-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-5) var(--space-3);
  border-radius: var(--radius-lg);
  text-align: center;
}

.hero-stat-bmr {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
}

.hero-stat-tdee {
  background: linear-gradient(160deg, var(--color-accent), var(--color-accent-dark));
  color: #fff;
  box-shadow: var(--shadow-lift);
}

.hero-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.75;
}

.hero-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 9vw, 3rem);
  line-height: 1.1;
}

.hero-unit {
  font-size: 0.74rem;
  opacity: 0.75;
  font-weight: 500;
}

.results-explainer {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--color-text-soft);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.results-explainer strong {
  color: var(--color-text);
}

.goal-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.goal-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
}

.goal-card-accent {
  background: var(--color-accent-softer);
  border-color: var(--color-accent-soft);
}

.goal-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-soft);
}

.goal-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  color: var(--color-text);
}

.goal-card-accent .goal-value {
  color: var(--color-accent-dark);
}

.goal-sub {
  font-size: 0.72rem;
  color: var(--color-text-faint);
  font-weight: 500;
}

.caveat {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--color-warn-text);
  background: var(--color-warn-bg);
  border: 1.5px solid var(--color-warn-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.results-actions {
  display: flex;
  gap: var(--space-2);
}

.results-actions .btn {
  flex: 1;
}

.results-footnote {
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--color-text-faint);
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (min-width: 480px) {
  .goal-cards {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 374px) {
  .topbar,
  .bottombar,
  .wizard-screen {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  .choice-grid[data-columns='2'] {
    gap: var(--space-2);
  }

  .choice-card {
    padding: var(--space-3) var(--space-4);
  }
}
