/* ===================================================================
   BMI Calculator — style
   Zero dependencies. Pure CSS. earth87human design system.
   =================================================================== */

/* ============ Design tokens ============ */
:root {
  --bg: #faf6f1;
  --bg-2: #f3eee5;
  --surface: #ffffff;
  --surface-2: #faf6ed;
  --surface-3: #eee7d8;
  --border: #e8dfcc;
  --border-soft: #f0e9da;
  --text: #1f1a14;
  --text-2: #5c5547;
  --text-3: #6e6557;
  --text-faint: #b5ac9b;
  --accent: #e85f4d;
  --accent-2: #d44a39;
  --accent-soft: rgba(232, 95, 77, 0.10);
  --accent-glow: rgba(232, 95, 77, 0.30);
  --success: #3a9d6f;
  --r-sm: 8px;
  --r-md: 12px;
  --r-xl: 20px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 24px 48px rgba(0,0,0,0.12);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
             "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK",
             sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* BMI category colors */
  --cat-blue: #3b82f6;
  --cat-blue-bg: rgba(59, 130, 246, 0.10);
  --cat-green: #22c55e;
  --cat-green-bg: rgba(34, 197, 94, 0.10);
  --cat-yellow: #eab308;
  --cat-yellow-bg: rgba(234, 179, 8, 0.12);
  --cat-red: #ef4444;
  --cat-red-bg: rgba(239, 68, 68, 0.10);
}

/* ============ Reset ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
html, body {
  font-family: var(--font-ui);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 235, 220, 0.55) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
ul, ol { padding-left: 1.25em; }
[hidden] { display: none !important; }

/* ============ Skip link ============ */
.skip-link {
  position: absolute;
  left: -9999px; top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

/* ============ Layout ============ */
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px) clamp(12px, 3vw, 24px) 80px;
}

/* ============ Top bar ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 28px;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-2);
}
.brand:hover { color: var(--accent); }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-link {
  font-size: 13px;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { color: var(--accent); background: var(--surface-2); }

/* ============ Lang switcher ============ */
.lang-switcher {
  appearance: none;
  -webkit-appearance: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 10px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237a7973' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.lang-switcher:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.lang-switcher:hover { border-color: var(--accent); }

/* ============ Page title ============ */
.page-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  text-align: center;
  margin-top: 4px;
}
.page-sub {
  font-size: 14px;
  color: var(--text-3);
  text-align: center;
  margin: 6px 0 32px;
  letter-spacing: -0.01em;
}

/* ============ Workspace ============ */
.workspace {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============ Input card ============ */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.input-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.input-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ============ Unit toggle chips ============ */
.unit-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  padding: 3px;
}

.chip {
  padding: 8px 14px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip.is-active:hover { color: #fff; }
.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============ Number inputs ============ */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.number-input {
  width: 100%;
  padding: 14px 52px 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  -moz-appearance: textfield;
}
.number-input::-webkit-inner-spin-button,
.number-input::-webkit-outer-spin-button {
  opacity: 1;
  height: 30px;
}
.number-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.number-input::placeholder {
  color: var(--text-faint);
  font-weight: 500;
}

.unit-suffix {
  position: absolute;
  right: 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
  pointer-events: none;
}

/* ============ Dual inputs (ft + in) ============ */
.input-double {
  display: flex;
  gap: 10px;
}

.input-double .input-group {
  flex: 1;
}

.input-double .number-input {
  padding-right: 40px;
}

/* ============ Result card ============ */
.result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px 24px;
  box-shadow: var(--shadow-md);
  min-height: 130px;
}

.result-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.result-label-sm {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.result-number {
  font-family: var(--font-mono);
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  transition: color var(--transition-slow);
}

.result-category {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  letter-spacing: -0.01em;
  align-self: flex-start;
  transition: background var(--transition-slow), color var(--transition-slow);
}

/* Category color states */
.result-category.cat-blue {
  background: var(--cat-blue-bg);
  color: var(--cat-blue);
}
.result-category.cat-green {
  background: var(--cat-green-bg);
  color: #16a34a;
}
.result-category.cat-yellow {
  background: var(--cat-yellow-bg);
  color: #ca8a04;
}
.result-category.cat-red {
  background: var(--cat-red-bg);
  color: var(--cat-red);
}

/* ============ Gauge canvas ============ */
.result-right {
  flex-shrink: 0;
}

.gauge-canvas {
  display: block;
  width: 76px;
  height: 76px;
}

/* ============ Info section ============ */
.info {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 0 4px;
}

.info h2 {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 600;
  color: var(--text);
  margin: 26px 0 10px;
  letter-spacing: -0.015em;
}

.info h2:first-child {
  margin-top: 0;
}

.info h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 20px 0 6px;
  letter-spacing: -0.01em;
}

.info p {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-2);
  margin-bottom: 10px;
}

.info ol {
  margin-bottom: 8px;
}

.info li {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-2);
  margin-bottom: 6px;
}

.info em {
  font-style: italic;
  color: var(--text);
}

/* ============ Category info grid ============ */
.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-underweight .cat-dot { background: var(--cat-blue); }
.cat-underweight { background: var(--cat-blue-bg); color: #2563eb; }
.cat-normal .cat-dot { background: var(--cat-green); }
.cat-normal { background: var(--cat-green-bg); color: #16a34a; }
.cat-overweight .cat-dot { background: var(--cat-yellow); }
.cat-overweight { background: var(--cat-yellow-bg); color: #ca8a04; }
.cat-obese .cat-dot { background: var(--cat-red); }
.cat-obese { background: var(--cat-red-bg); color: #dc2626; }

/* ============ FAQ accordion ============ */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--transition);
}
.faq-item:hover { border-color: var(--text-3); }

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  gap: 12px;
  transition: background var(--transition);
}
.faq-question:hover { background: var(--surface-2); }
.faq-question svg {
  flex-shrink: 0;
  width: 16px; height: 16px;
  color: var(--text-3);
  transition: transform var(--transition);
}
.faq-item.is-open .faq-question svg {
  transform: rotate(45deg);
}

.faq-answer {
  display: none;
  padding: 0 16px 14px;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
}
.faq-item.is-open .faq-answer {
  display: block;
}

/* ============ Footer ============ */
.site-footer {
  max-width: 720px;
  margin: 56px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-3);
}

.site-footer-row a {
  color: var(--text-3);
  font-size: 13px;
  transition: color var(--transition);
}
.site-footer-row a:hover { color: var(--accent); }

.site-footer .sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 8px;
}

/* ============ Focus / A11y ============ */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible) { outline: none; }

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

/* ============ Responsive ============ */
@media (max-width: 480px) {
  .topbar-right {
    gap: 8px;
  }

  .lang-switcher {
    font-size: 12px;
    padding: 5px 24px 5px 8px;
  }

  .result-card {
    padding: 18px 18px;
  }

  .result-number {
    font-size: 42px;
  }

  .gauge-canvas {
    width: 64px;
    height: 64px;
  }

  .number-input {
    font-size: 18px;
    padding: 12px 48px 12px 14px;
  }
}

@media (max-width: 420px) {
  .topbar-right .nav-link {
    display: none;
  }

  .topbar-right {
    gap: 6px;
  }

  .lang-switcher {
    max-width: 130px;
    font-size: 12px;
    padding: 4px 22px 4px 8px;
  }
}

@media (max-width: 380px) {
  .input-double {
    flex-direction: column;
    gap: 8px;
  }

  .result-card {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }

  .result-left {
    align-items: center;
  }

  .result-category {
    align-self: center;
  }
}
