/* ============================================================
   Weight-Loss Pokédex — styles
   Aesthetic: classic red Pokédex device with an LCD screen.
   ============================================================ */

:root {
  --dex-red: #d8213a;
  --dex-red-dark: #a3122a;
  --dex-red-darker: #7d0d20;
  --dex-shadow: rgba(0, 0, 0, 0.35);
  --screen-bg: #dcefc4;      /* pale mint LCD */
  --screen-bg-2: #cfe6ae;
  --screen-ink: #35502a;     /* dark green text */
  --screen-ink-soft: #5c7a4d;
  --lens-blue: #57c8ff;
  --lens-blue-dark: #1f7fc0;
  --ink: #1c1c1c;
  --paper: #f4f6ef;
  --pixel-font: "Press Start 2P", "Courier New", monospace;
  --lcd-font: "VT323", "Courier New", monospace;
  --body-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--body-font);
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, #ffe08a 0%, rgba(255,224,138,0) 45%),
    radial-gradient(circle at 90% 20%, #8ed0ff 0%, rgba(142,208,255,0) 40%),
    linear-gradient(160deg, #2b3a67 0%, #1c2540 100%);
  min-height: 100vh;
  padding: 24px 16px 48px;
  display: flex;
  justify-content: center;
}

.page {
  width: 100%;
  max-width: 640px;
}

/* ---------- Header ---------- */
.page__head { text-align: center; margin-bottom: 18px; }

.page__title {
  font-family: var(--pixel-font);
  font-size: clamp(14px, 4.4vw, 26px);
  line-height: 1.4;
  color: #fff;
  margin: 0 0 10px;
  text-shadow: 3px 3px 0 var(--dex-red-darker), 5px 5px 0 rgba(0,0,0,0.25);
}

.page__tag {
  font-family: var(--lcd-font);
  font-size: clamp(18px, 4.5vw, 24px);
  color: #ffe08a;
  margin: 0;
  letter-spacing: 0.5px;
}

/* ---------- Pokédex body ---------- */
.pokedex {
  position: relative;
  background: linear-gradient(160deg, var(--dex-red) 0%, var(--dex-red-dark) 70%, var(--dex-red-darker) 100%);
  border-radius: 18px 18px 22px 22px;
  padding: 18px 18px 26px;
  box-shadow:
    0 18px 40px var(--dex-shadow),
    inset 0 2px 0 rgba(255,255,255,0.25),
    inset 0 -6px 0 rgba(0,0,0,0.25);
  border: 3px solid var(--dex-red-darker);
}

/* ---------- Top bar ---------- */
.pokedex__topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
}

.lens {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #b9ecff 0%, var(--lens-blue) 35%, var(--lens-blue-dark) 100%);
  border: 4px solid #f4f6ef;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.25), inset 0 0 8px rgba(0,0,0,0.3);
  flex: 0 0 auto;
}
.lens__glare {
  position: absolute;
  top: 9px; left: 12px;
  width: 14px; height: 14px;
  background: rgba(255,255,255,0.85);
  border-radius: 50%;
  filter: blur(1px);
}

.light {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.3);
  box-shadow: inset 0 0 4px rgba(255,255,255,0.6);
  flex: 0 0 auto;
}
.light--red { background: #ff5a5a; }
.light--yellow { background: #ffd93b; }
.light--green { background: #62d16a; }
.topbar__spacer { flex: 1; }

/* ---------- Screen ---------- */
.screen-frame {
  background: #2a2a2a;
  border-radius: 12px;
  padding: 14px 14px 8px;
  box-shadow: inset 0 3px 10px rgba(0,0,0,0.5);
}

.screen-frame__lights {
  display: flex; gap: 8px; padding: 0 4px 8px;
}
.mini-light {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ff5a5a; box-shadow: 0 0 4px #ff5a5a;
}
.mini-light:last-child { background: #62d16a; box-shadow: 0 0 4px #62d16a; }

.screen {
  position: relative;
  min-height: 300px;
  border-radius: 8px;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.05) 0 2px, rgba(0,0,0,0) 2px 4px),
    linear-gradient(160deg, var(--screen-bg) 0%, var(--screen-bg-2) 100%);
  border: 2px solid #1a1a1a;
  padding: 20px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.screen__placeholder {
  font-family: var(--lcd-font);
  font-size: 22px;
  line-height: 1.35;
  color: var(--screen-ink-soft);
  text-align: center;
  margin: 0;
  max-width: 34ch;
}
.screen__placeholder strong { color: var(--screen-ink); }

.screen-frame__foot {
  display: flex; justify-content: flex-end; gap: 6px; padding: 8px 4px 0;
}
.speaker { width: 34px; height: 3px; border-radius: 2px; background: rgba(255,255,255,0.15); }

/* ---------- Result (inside screen) ---------- */
.result { width: 100%; text-align: center; animation: pop 0.35s ease; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.result__eyebrow {
  font-family: var(--pixel-font);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--screen-ink-soft);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.result__amount {
  font-family: var(--lcd-font);
  font-size: 46px;
  line-height: 1;
  color: var(--screen-ink);
  margin-bottom: 4px;
}
.result__amount--sm { font-size: 34px; }
/* Weight Then → Now shows a headline Pokémon AND the comparison — shrink the main so it all fits */
.result--compact .result__art { width: 120px; height: 120px; }
.result--compact .result__amount { font-size: 38px; }
.result__art {
  width: 168px; height: 168px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(3px 4px 3px rgba(0,0,0,0.25));
  margin: 2px auto;
}
.result__name {
  font-family: var(--pixel-font);
  font-size: 15px;
  color: var(--screen-ink);
  margin: 6px 0 2px;
}
.result__weight {
  font-family: var(--lcd-font);
  font-size: 20px;
  color: var(--screen-ink-soft);
}
.result__cat {
  font-family: var(--lcd-font);
  font-size: 19px;
  color: var(--screen-ink);
  margin-bottom: 4px;
}
.result__note {
  font-family: var(--body-font);
  font-size: 11px;
  line-height: 1.3;
  color: var(--screen-ink-soft);
  margin: 10px auto 0;
  max-width: 32ch;
  opacity: 0.85;
}

/* Then -> Now comparison */
.compare {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px dashed rgba(53,80,42,0.35);
  flex-wrap: nowrap;
}
.compare figure { margin: 0; text-align: center; flex: 0 1 auto; }
.compare__art {
  width: 78px; height: 78px; object-fit: contain;
  image-rendering: pixelated;
}
.compare figcaption {
  font-family: var(--lcd-font);
  font-size: 17px;
  line-height: 1.15;
  color: var(--screen-ink);
}
.compare figcaption .cap-label {
  display: block;
  font-family: var(--pixel-font);
  font-size: 8px;
  color: var(--screen-ink-soft);
  margin-bottom: 3px;
  letter-spacing: 1px;
}
.compare__arrow {
  font-size: 30px;
  color: var(--screen-ink-soft);
  flex: 0 0 auto;
}

/* Larger twins for BMI Then → Now (the comparison is the main event there) */
.compare--lg { gap: 14px; margin-top: 6px; padding-top: 0; border-top: none; }
.compare--lg .compare__art { width: 96px; height: 96px; }
.compare--lg figcaption { font-size: 16px; }
.compare--lg .compare__arrow { font-size: 30px; }

.screen__msg {
  font-family: var(--lcd-font);
  font-size: 24px;
  color: var(--screen-ink);
  text-align: center;
  margin: 0;
}

/* ---------- Controls ---------- */
.controls { margin-top: 20px; }

.segmented {
  display: flex;
  background: rgba(0,0,0,0.22);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
}
.seg {
  flex: 1 1 0;
  min-width: 0;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.85);
  font-family: var(--body-font);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.15;
  padding: 10px 6px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg.is-active {
  background: var(--paper);
  color: var(--dex-red-dark);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.segmented--view { margin-top: -4px; }

.field { margin-bottom: 12px; }
.field__label {
  display: block;
  font-family: var(--body-font);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255,255,255,0.9);
  margin-bottom: 5px;
}

.inputs { display: flex; flex-direction: column; gap: 12px; }
.inputs .field { margin-bottom: 0; }
.then-now-label {
  font-family: var(--pixel-font);
  font-size: 10px;
  letter-spacing: 1px;
  color: #ffe08a;
  text-transform: uppercase;
  margin-top: 4px;
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; margin-bottom: 0; }
.weight-row { display: flex; gap: 8px; }
.weight-row .input { flex: 1; }

.input {
  width: 100%;
  font-family: var(--body-font);
  font-size: 16px;
  padding: 12px 12px;
  border-radius: 9px;
  border: 2px solid var(--dex-red-darker);
  background: var(--paper);
  color: var(--ink);
  outline: none;
}
.input:focus { border-color: #ffd93b; box-shadow: 0 0 0 3px rgba(255,217,59,0.5); }
.input--select { appearance: none; background-image: none; cursor: pointer; }

.dual { display: flex; gap: 8px; }
.dual .stack { flex: 1; }
.dual .stack .sub {
  display:block; font-size: 11px; color: rgba(255,255,255,0.8);
  margin-bottom: 3px; font-weight: 700;
}

/* ---------- Buttons ---------- */
.buttons { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  font-family: var(--pixel-font);
  font-size: 13px;
  border: none;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
.btn:active { transform: translateY(2px); }
.btn--scan {
  flex: 2;
  background: linear-gradient(#3aa0ff, #1f7fc0);
  color: #fff;
  box-shadow: 0 4px 0 #145a8c;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.btn--scan:active { box-shadow: 0 2px 0 #145a8c; }
.btn--ghost {
  flex: 1;
  background: #ffd93b;
  color: #6b4e00;
  box-shadow: 0 4px 0 #b89400;
  font-size: 11px;
}
.btn--ghost:active { box-shadow: 0 2px 0 #b89400; }

/* ---------- Decorative d-pad ---------- */
.dpad { position: relative; width: 54px; height: 54px; margin: 20px 0 0 auto; opacity: 0.85; }
.dpad__v, .dpad__h { position: absolute; background: #1c1c1c; border-radius: 4px; }
.dpad__v { width: 18px; height: 54px; left: 18px; }
.dpad__h { width: 54px; height: 18px; top: 18px; }

/* ---------- Footer ---------- */
.page__foot {
  text-align: center;
  margin-top: 20px;
  font-family: var(--body-font);
  font-size: 13px;
  color: rgba(255,255,255,0.8);
}
.page__foot a { color: #ffe08a; }

/* ---------- Layout halves: open-Pokédex in landscape, stacked in portrait ---------- */
.dex-hinge { display: none; }

@media (orientation: landscape) {
  .page { max-width: 940px; }

  /* Locked device size: stays constant when switching tabs/modes. Only the
     viewport height (not the amount of content) changes it. */
  .pokedex {
    display: flex;
    align-items: stretch;
    height: clamp(400px, calc(100vh - 130px), 600px);
  }
  .dex-left {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    padding-right: 18px;
    min-height: 0;
  }
  .dex-right {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    padding-left: 18px;
    min-height: 0;
    overflow-y: auto;   /* tall controls scroll here — the device itself stays put */
  }
  .dex-hinge {
    display: block;
    align-self: stretch;
    width: 8px;
    margin: 4px 0;
    border-radius: 4px;
    background: linear-gradient(180deg, #7d0d20, #5c0a18);
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.2);
  }

  /* Screen fills the left panel at a fixed height */
  .screen-frame { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .screen { flex: 1; min-height: 0; overflow-y: auto; align-items: safe center; }

  /* Controls sit at the top of the right panel; hide the decorative d-pad here to save height */
  .controls { margin-top: 0; }
  .dpad { display: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 420px) {
  .result__amount { font-size: 38px; }
  .result__art { width: 140px; height: 140px; }
  .compare__art { width: 62px; height: 62px; }
  .lens { width: 46px; height: 46px; }
  .seg { font-size: 11px; padding: 8px 3px; }
}
