/* ============================================================
   app.css — styles for the interactive pages
   (self-test, detox protocol, admin dashboard)
   Builds on styles.css design tokens. Coffee-brown palette.
   ============================================================ */

/* --- Page intro --- */
.page-hero {
  padding: 40px 0 8px;
}
.page-hero .eyebrow { color: var(--coffee-500); }
.page-hero h1 {
  font-family: var(--serif);
  font-size: clamp(28px, 4.4vw, 44px);
  line-height: 1.1;
  margin: 6px 0 14px;
  color: var(--coffee-900);
}
.page-hero .lede {
  font-size: 1.12rem;
  max-width: 62ch;
  color: var(--ink);
}

/* --- Privacy banner --- */
.privacy-band {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--good-bg);
  border: 1px solid #cfe6d9;
  color: #1f4b38;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 18px 0 8px;
  font-size: .96rem;
}
.privacy-band svg { flex: 0 0 auto; margin-top: 2px; }
.privacy-band strong { color: #163a2a; }

/* --- Quiz --- */
.quiz { margin: 26px 0 10px; }
.quiz-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
  overflow: hidden;
}
.quiz-group > header {
  padding: 16px 20px;
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  border-bottom: 1px solid var(--line);
}
.quiz-group > header h2 {
  font-family: var(--serif);
  font-size: 1.28rem;
  margin: 0 0 3px;
  color: var(--coffee-800);
}
.quiz-group > header p { margin: 0; color: var(--muted); font-size: .92rem; }
.q {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.q:last-child { border-bottom: 0; }
.q-text { font-weight: 600; color: var(--ink); margin: 0 0 10px; }
.q-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.q-scale.binary { grid-template-columns: repeat(2, 1fr); max-width: 320px; }
.q-scale label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 10px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
  font-size: .82rem;
  color: var(--muted);
  background: var(--paper);
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}
.q-scale label:hover { border-color: var(--coffee-400); }
.q-scale input { position: absolute; opacity: 0; width: 0; height: 0; }
.q-scale label .dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line-strong);
  display: inline-block;
}
.q-scale input:checked + .dot { border-color: var(--coffee-600); background: var(--coffee-600); box-shadow: inset 0 0 0 3px var(--paper); }
.q-scale input:checked ~ .lbl { color: var(--coffee-800); font-weight: 600; }
.q-scale label:has(input:checked) { border-color: var(--coffee-600); background: var(--crema-100); color: var(--coffee-800); }
.q-scale input:focus-visible + .dot { outline: 2px solid var(--coffee-500); outline-offset: 2px; }

.intake-row {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
  padding: 16px 20px;
}
.intake-row .field { display: flex; flex-direction: column; gap: 6px; }
.intake-row label { font-weight: 600; font-size: .9rem; color: var(--ink); }
.intake-row input[type="number"], .intake-row select {
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  font: inherit; background: var(--paper); color: var(--ink); min-width: 120px;
}
.hint { font-size: .82rem; color: var(--muted); }

.quiz-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 4px; }

/* --- Results --- */
.results { margin-top: 8px; }
.results[hidden] { display: none; }
.result-head {
  background: var(--coffee-900);
  color: var(--crema-100);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.result-head h2 { font-family: var(--serif); margin: 0 0 6px; color: #fff; font-size: 1.5rem; }
.result-head .band-name { font-size: 1.1rem; font-weight: 700; }
.result-head p { margin: 8px 0 0; color: var(--crema-200); max-width: 68ch; }

.score-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.score-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.score-card h3 { margin: 0 0 4px; font-size: .95rem; color: var(--coffee-700); font-family: var(--sans); }
.score-card .num { font-size: 2rem; font-weight: 800; color: var(--coffee-900); font-family: var(--serif); }
.score-card .num small { font-size: .9rem; color: var(--muted); font-weight: 600; }
.score-card .meter { height: 8px; border-radius: 99px; background: var(--cream-2); overflow: hidden; margin-top: 10px; }
.score-card .meter > span { display: block; height: 100%; border-radius: 99px; }
.score-card .tag { display: inline-block; margin-top: 10px; font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.tag.low { background: var(--good-bg); color: #1f6b48; }
.tag.moderate { background: var(--caution-bg); color: #8a5417; }
.tag.high { background: var(--risk-bg); color: #8f2f2a; }

.charts-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
@media (max-width: 720px){ .charts-2 { grid-template-columns: 1fr; } }
.charts-2 .chart-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 16px; box-shadow: var(--shadow-sm); }
.charts-2 canvas { max-height: 300px; }

.result-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.save-note { font-size: .86rem; color: var(--muted); margin-top: 6px; }
.save-status { font-size: .9rem; font-weight: 600; }
.save-status.ok { color: var(--good); }
.save-status.err { color: var(--risk); }

/* --- Protocol --- */
.step-list { counter-reset: step; list-style: none; padding: 0; margin: 22px 0; }
.step-list > li {
  position: relative; padding: 18px 20px 18px 66px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.step-list > li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 16px; top: 18px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--coffee-700); color: #fff; font-weight: 700; font-family: var(--serif);
  display: grid; place-items: center; font-size: 1.05rem;
}
.step-list h3 { margin: 0 0 6px; font-family: var(--serif); color: var(--coffee-800); font-size: 1.16rem; }
.step-list p { margin: 0 0 6px; }
.taper-table td .bar { display:inline-block; height:12px; background:var(--coffee-500); border-radius:3px; vertical-align: middle; }

.benefit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 16px; margin: 20px 0; }
.benefit-card { border:1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 18px; box-shadow: var(--shadow-sm); }
.benefit-card .big { font-family: var(--serif); font-size: 1.9rem; font-weight: 800; color: var(--coffee-900); line-height:1; }
.benefit-card p { margin: 8px 0 0; font-size: .95rem; }
.benefit-card cite { display:block; margin-top:10px; font-size:.8rem; color: var(--muted); font-style: normal; }
.benefit-card a { color: var(--coffee-600); }

/* --- Admin --- */
.admin-shell { max-width: 980px; margin: 0 auto; }
.signin-box { text-align:center; padding: 48px 20px; }
.signin-box .btn { font-size: 1rem; }
.kpi-row { display:grid; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); gap:16px; margin: 18px 0; }
.kpi { border:1px solid var(--line); border-radius:var(--radius); background:var(--paper); padding:16px 18px; box-shadow:var(--shadow-sm); }
.kpi .num { font-family:var(--serif); font-size:2rem; font-weight:800; color:var(--coffee-900); }
.kpi .lbl { color:var(--muted); font-size:.85rem; }
.admin-bar { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:8px; }
.admin-who { font-size:.9rem; color:var(--muted); }
.data-table.small th, .data-table.small td { padding:8px 10px; font-size:.86rem; }

/* print */
@media print {
  .site-header, .site-footer, .utility-bar, .quiz, .result-actions, .back-to-top, .privacy-band { display:none !important; }
  .results[hidden] { display:block !important; }
  body { background:#fff; }
}
