/* ════════════════════════════════════════════════════════════════
   喝安 Herbal Ancestry v4 — Mobile-First, Large-Type Style
   Same palette as v3. Base font raised for elderly readability,
   touch targets enlarged, hero simplified for small screens.
   Colors: Navy #0f172a, Cards #1e293b dark / #ffffff light,
           Amber #d4a843, Cream #f8fafc, Jade #2d6a4f
   ════════════════════════════════════════════════════════════════ */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #f8fafc;
  --card:         #ffffff;
  --card-border:  #e2e8f0;
  --card-shadow:  0 1px 3px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.1);
  --navy:         #0f172a;
  --navy-light:   #1e293b;
  --amber:        #d4a843;
  --amber-pale:   #d4a84315;
  --jade:         #2d6a4f;
  --jade-light:   #2d6a4f18;
  --cream:        #f8fafc;
  --text:         #1e293b;
  --text-2:       #475569;
  --text-3:       #64748b;
  --border:       #e2e8f0;
  --radius:       14px;
  --radius-lg:    18px;
  --trans:        all 0.22s ease;

  /* Element colors */
  --el-wood:   #4a7c59;
  --el-fire:   #c0392b;
  --el-earth:  #c8a84b;
  --el-metal:  #7f8c8d;
  --el-water:  #2980b9;
}

html { scroll-behavior: smooth; }

/* Base type is deliberately large (18px) so v4 reads comfortably
   for elderly users without any zooming; scales up further on mobile. */
body {
  font-family: 'DM Sans', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .serif {
  font-family: 'Noto Serif SC', 'Georgia', serif;
  font-weight: 600;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* Language Toggle (floating) — enlarged tap targets */
.lang-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 24px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid var(--card-border);
}

.lang-toggle button {
  border: none;
  background: transparent;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-3);
  transition: var(--trans);
  letter-spacing: 0.04em;
  font-family: 'DM Sans', sans-serif;
  min-height: 44px;
}

.lang-toggle button.active {
  background: var(--jade);
  color: #fff;
}

/* Hero Section */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 64px 5% 56px;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.hero-logo {
  display: block;
  max-width: 320px;
  height: auto;
  margin: 0 auto 24px;
}

.hero-content {
  max-width: 640px;
  width: 100%;
  position: relative;
  z-index: 1;
  text-align: center;
}

.hero-title {
  font-size: clamp(1.9rem, 7vw, 2.6rem);
  line-height: 1.3;
  color: var(--navy);
  margin-bottom: 16px;
  white-space: normal;
  text-align: center;
}

.hero-sub {
  font-size: clamp(1.05rem, 4vw, 1.25rem);
  color: var(--text-2);
  margin-bottom: 32px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  line-height: 1.6;
}

/* Form Card */
.form-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  box-shadow: var(--card-shadow-hover);
  border: 1px solid var(--card-border);
  text-align: left;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.form-row.thirds { grid-template-columns: 1fr; }
.form-row.full { grid-template-columns: 1fr; }
.form-row.time-row { grid-template-columns: 1fr 1fr; }

.field-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
}

.city-wrap { position: relative; }

input, select {
  width: 100%;
  padding: 16px 16px;
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
  font-family: inherit;
  transition: var(--trans);
  appearance: none;
  -webkit-appearance: none;
  min-height: 56px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--jade);
  background: var(--card);
  box-shadow: 0 0 0 4px rgba(45,106,79,0.15);
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--card);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow-hover);
  z-index: 200;
  max-height: 260px;
  overflow-y: auto;
}

.autocomplete-dropdown.hidden { display: none; }

.autocomplete-item {
  padding: 14px 16px;
  cursor: pointer;
  font-size: 1.05rem;
  color: var(--text);
  transition: background 0.15s;
  min-height: 48px;
  display: flex;
  align-items: center;
}

.autocomplete-item:hover { background: var(--jade-light); color: var(--jade); }

/* Gender Radio — large tap targets */
.gender-row { display: flex; gap: 12px; }

.gender-option { flex: 1; position: relative; }

.gender-option input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}

.gender-option label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.05rem;
  background: var(--bg);
  transition: var(--trans);
  color: var(--text-2);
  font-weight: 600;
  min-height: 56px;
}

.gender-option input:checked + label {
  border-color: var(--jade);
  background: var(--jade-light);
  color: var(--jade);
  font-weight: 700;
}

/* WA Input */
.wa-wrap { display: flex; gap: 8px; }
.wa-wrap select { width: auto; flex-shrink: 0; min-width: 120px; }
.wa-wrap input { flex: 1; }

/* Analyze Button — large, thumb-friendly */
.analyze-btn {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--jade) 0%, #1b4d3e 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  margin-top: 8px;
  letter-spacing: 0.02em;
  transition: var(--trans);
  min-height: 60px;
}

.analyze-btn:hover {
  box-shadow: 0 4px 16px rgba(45,106,79,0.35);
  transform: translateY(-1px);
}

.analyze-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Scroll Hint */
.scroll-hint {
  text-align: center;
  margin-top: 16px;
  font-size: 0.95rem;
  color: var(--text-2);
  letter-spacing: 0.02em;
  animation: bob 2s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}

/* ─── Results Section ──────────────────────────────────────────── */
.results-section {
  padding: 32px 5% 48px;
  max-width: 1200px;
  margin: 0 auto;
}

.results-section.hidden { display: none; }

.solar-badge {
  font-size: 1rem;
  color: var(--text-2);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.solar-badge strong { color: var(--amber); }

.section-divider {
  border: none;
  border-top: 1px solid var(--card-border);
  margin: 20px 0 28px;
}

/* ─── Bento Grid — single column on mobile by default ──────────── */
.bento-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.bento-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--card-shadow);
  transition: var(--trans);
}

.bento-card:hover {
  box-shadow: var(--card-shadow-hover);
}

.bento-half { grid-column: span 1; }
.bento-span-full { grid-column: 1 / -1; }

/* ─── Drinks Section (below bento grid) ────────────────────────── */
.drinks-section {
  margin-top: 28px;
}

.drinks-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 10px;
}

.drinks-sub {
  font-size: 1.05rem;
  color: var(--text-2);
  margin-bottom: 20px;
}

.bento-tag {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.bento-card-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
}

.bento-card-sub {
  font-size: 1rem;
  color: var(--text-2);
  margin-bottom: 16px;
  margin-top: -8px;
}

/* ─── Pillars (inside bento card) ──────────────────────────────── */
.pillars-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.pillar-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 18px 12px;
  border: 1px solid var(--card-border);
  text-align: center;
  border-top: 4px solid var(--pillar-color, var(--el-earth));
  transition: var(--trans);
}

.pillar-card:hover { box-shadow: var(--card-shadow-hover); }

.pillar-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  font-weight: 700;
  margin-bottom: 10px;
}

.pillar-chinese {
  font-family: 'Noto Serif SC', serif;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--navy);
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}

.pillar-element-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.pillar-details { text-align: left; }

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 5px 0;
  border-top: 1px solid var(--card-border);
}

.detail-key { color: var(--text-2); }

/* ─── Day Master ───────────────────────────────────────────────── */
#daymaster-display {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
}

.dm-item {}
.dm-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  font-weight: 700;
  margin-bottom: 6px;
}

.dm-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
  font-family: 'Noto Serif SC', serif;
}

/* ─── Life Gua ─────────────────────────────────────────────────── */
#lifegua-display {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.gua-number {
  font-family: 'Noto Serif SC', serif;
  font-size: 3.4rem;
  font-weight: 900;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 8px;
}

.gua-label {
  font-size: 0.95rem;
  color: var(--text-2);
  font-weight: 600;
}

/* ─── Five Factors Bars ────────────────────────────────────────── */
.ff-row {
  display: grid;
  grid-template-columns: 84px 1fr 56px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.ff-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.ff-symbol {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.15rem;
}

.ff-bar-wrap {
  background: var(--bg);
  border-radius: 8px;
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--card-border);
}

.ff-bar {
  height: 100%;
  border-radius: 8px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ff-pct {
  font-size: 0.95rem;
  font-weight: 700;
  text-align: right;
}

/* ─── Chart Containers ─────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.chart-container-wide {
  max-width: 100%;
}

.chart-container canvas {
  width: 100% !important;
  height: auto !important;
}

/* ─── Drink Cards ──────────────────────────────────────────────── */
.weak-el-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  align-items: center;
}

.weak-el-label {
  font-size: 0.9rem;
  color: var(--text-2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}

.el-chip {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.92rem;
  font-weight: 700;
}

.drink-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.drink-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: var(--trans);
}

.drink-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}

.drink-icon-wrap {
  width: 72px;
  height: 72px;
  min-width: 72px;
  min-height: 72px;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--muted);
}

.drink-icon-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.drink-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.drink-header-text { flex: 1; }

.drink-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
}

.drink-alt {
  font-size: 0.88rem;
  color: var(--text-2);
  margin-top: 3px;
}

.drink-el-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 4px;
}

.drink-why {
  font-size: 1rem;
  color: var(--text-2);
  line-height: 1.6;
}

.drink-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.meta-row {
  font-size: 0.92rem;
  color: var(--text-2);
}

.meta-row.warn { color: #92400e; }
.meta-row.note { color: var(--jade); }

/* ─── PDF Button ───────────────────────────────────────────────── */
.pdf-btn-wrap {
  text-align: center;
  margin-top: 36px;
  margin-bottom: 32px;
}

.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 32px;
  border: 2px solid var(--jade);
  background: transparent;
  color: var(--jade);
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: var(--trans);
  letter-spacing: 0.02em;
  min-height: 56px;
}

.pdf-btn:hover { background: var(--jade); color: #fff; }
.pdf-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Footer ───────────────────────────────────────────────────── */
footer {
  background: var(--navy);
  color: var(--amber);
  text-align: center;
  padding: 56px 5% 40px;
}

.contact-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 32px;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: var(--trans);
  margin-bottom: 32px;
  min-height: 60px;
  max-width: 100%;
}

.contact-cta-btn span {
  white-space: normal;
}

.contact-cta-btn:hover {
  background: #1da855;
  box-shadow: 0 4px 18px rgba(37,211,102,0.35);
}

.footer-logo {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.6rem;
  color: var(--amber);
  margin-bottom: 10px;
}

.footer-note {
  font-size: 0.92rem;
  color: var(--text-3);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.7;
}

.footer-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 28px 0 20px;
}

/* ─── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--navy);
  color: #fff;
  padding: 14px 26px;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 600;
  z-index: 9999;
  transition: transform 0.3s ease, opacity 0.3s;
  opacity: 0;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--card-shadow-hover);
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: #166534; }
.toast.warn    { background: #92400e; }
.toast.error   { background: #991b1b; }

/* ─── Larger screens: relax back to a denser layout ─────────────
   Mobile is the default in v4; tablets/desktops get the roomier
   multi-column arrangement once there's space for it. ────────── */
@media (min-width: 640px) {
  .form-row { grid-template-columns: 1fr 1fr; }
  .form-row.thirds { grid-template-columns: 1fr 1fr 1fr; }
  .form-row.full { grid-template-columns: 1fr; }
  .pillars-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 860px) {
  .bento-grid { grid-template-columns: repeat(2, 1fr); }
  .bento-half { grid-column: span 1; }
  .bento-span-full { grid-column: 1 / -1; }
  .drink-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-logo { max-width: 400px; }
}

@media (min-width: 1080px) {
  .drink-grid { grid-template-columns: repeat(3, 1fr); }
}
