/* Nutshell Health — views.css
 * Styles specific to individual screens: onboarding, dashboard, search,
 * food detail, log, insights, comparison, recipes and the assistant.
 */

/* --------------------------------------------------------- onboarding */

.onboard {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-6) var(--sp-4);
  background:
    radial-gradient(1000px 500px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.onboard-inner { width: min(560px, 100%); display: flex; flex-direction: column; flex: 1; }

.onboard-progress { display: flex; gap: 6px; margin: var(--sp-6) 0 var(--sp-8); }
.onboard-progress span {
  height: 4px;
  flex: 1;
  border-radius: var(--r-full);
  background: var(--border);
  transition: background var(--dur) var(--ease);
}
.onboard-progress span[data-done="true"] { background: var(--accent); }

.onboard-step { flex: 1; animation: viewIn var(--dur) var(--ease); }
.onboard-eyebrow {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent-text);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}
.onboard-title { font-size: var(--fs-2xl); margin-bottom: var(--sp-3); }
.onboard-lead {
  color: var(--text-muted);
  font-size: var(--fs-md);
  line-height: var(--lh-relaxed);
  margin-bottom: var(--sp-6);
}
.onboard-foot {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-5) 0 var(--sp-2);
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, var(--bg) 30%);
}
.onboard-foot .btn-primary { flex: 1; }

.hero-mark {
  width: 68px; height: 68px;
  border-radius: 20px;
  background: linear-gradient(140deg, var(--accent), #34d399);
  display: grid; place-items: center;
  color: #04231b;
  box-shadow: var(--shadow-lg);
  margin-bottom: var(--sp-6);
}
.hero-mark svg { width: 36px; height: 36px; }

/* A gently staggered row of food illustrations on the welcome screen. */
.art-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-6) 0 var(--sp-2);
}
.art-strip-item {
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-sm);
  animation: artIn var(--dur-slow) var(--ease) both;
}
@keyframes artIn {
  from { opacity: 0; transform: translateY(8px) scale(.9); }
  to { opacity: 1; transform: none; }
}

.feature-list { display: flex; flex-direction: column; gap: var(--sp-4); margin: var(--sp-6) 0; }
.feature { display: flex; gap: var(--sp-3); align-items: flex-start; }
.feature-icon {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid; place-items: center;
  flex: none;
}
.feature-icon svg { width: 16px; height: 16px; }
.feature-title { font-weight: 620; font-size: var(--fs-base); }
.feature-text { font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-relaxed); }

.target-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.target-cell {
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.target-cell-value { font-size: var(--fs-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.target-cell-label { font-size: var(--fs-xs); color: var(--text-muted); }

/* --------------------------------------------------------- dashboard */

.hero-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-6);
  align-items: center;
}
@media (max-width: 640px) {
  .hero-card { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: var(--sp-4); }
  .hero-metrics { width: 100%; }
}

.ring-wrap { position: relative; display: grid; place-items: center; flex: none; }
.ring-center {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}
.ring-value { font-size: var(--fs-2xl); font-weight: 720; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ring-label { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 560; }
.ring-track { stroke: var(--bg-soft); }
.ring-fill { transition: stroke-dashoffset var(--dur-slow) var(--ease); }

.hero-metrics { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.hero-headline { font-size: var(--fs-md); font-weight: 600; line-height: var(--lh-normal); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--sp-3);
}
.stat {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--grad-surface);
  border: 1px solid var(--border);
  box-shadow: var(--edge-light);
}
.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: 3px;
}
.stat-value {
  font-size: var(--fs-lg);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.stat-sub { font-size: var(--fs-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; margin-top: 1px; }

/* The saturated-fat feature card. */
.satfat-card { border-left: 3px solid var(--n-satfat); }
.satfat-head { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.satfat-value {
  font-size: var(--fs-3xl);
  font-weight: 740;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.satfat-unit { font-size: var(--fs-lg); font-weight: 600; color: var(--text-muted); }
.satfat-sentence {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-relaxed);
  margin-top: var(--sp-3);
}

.level-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 680;
}
.level-pill::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: var(--r-full);
  background: currentColor;
  flex: none;
}
.level-pill--good { background: var(--good-soft); color: var(--good); }
.level-pill--ok { background: var(--ok-soft); color: var(--ok); }
.level-pill--warn { background: var(--warn-soft); color: var(--warn); }
.level-pill--alert { background: var(--alert-soft); color: var(--alert); }

.meal-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.meal-strip:last-child { border-bottom: none; }
.meal-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--bg-soft);
  display: grid; place-items: center;
  color: var(--text-subtle);
  flex: none;
}
.meal-icon svg { width: 18px; height: 18px; }
.meal-thumb {
  width: 38px; height: 38px;
  border-radius: 12px;
  overflow: hidden;
  flex: none;
  box-shadow: 0 0 0 1px var(--border);
}

.water-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.water-dot {
  width: 26px; height: 34px;
  border-radius: 6px 6px 9px 9px;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.water-dot[data-filled="true"] { background: var(--n-water); border-color: var(--n-water); }

/* ------------------------------------------------------------ search */

.search-bar { position: relative; }
.search-bar .input {
  padding-left: 42px;
  min-height: 48px;
  font-size: var(--fs-md);
  border-radius: var(--r-lg);
}
.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}
.search-icon svg { width: 19px; height: 19px; }
.search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

/* ------------------------------------------------------- category tiles */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: var(--sp-3);
}
.cat-tile {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  min-height: 64px;
  transition: border-color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.cat-tile:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.cat-art {
  flex: none;
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border);
}
.cat-meta { display: flex; flex-direction: column; min-width: 0; }
.cat-name {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-count { font-size: var(--fs-xs); color: var(--text-subtle); }

.autocomplete {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  max-height: 340px;
  overflow-y: auto;
  padding: var(--sp-2);
}
.ac-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  min-height: 42px;
}
.ac-item:hover, .ac-item[data-active="true"] { background: var(--accent-soft); }
.ac-art {
  flex: none;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border);
  display: block;
}
.ac-name { flex: 1; min-width: 0; }
.ac-kcal { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }

.food-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: left;
}
.food-row:last-child { border-bottom: none; }
.food-row:hover { background: var(--surface-2); }
.food-thumb {
  width: 40px; height: 40px;
  border-radius: 13px;
  display: grid; place-items: center;
  flex: none;
  overflow: hidden;
  /* A hairline ring keeps the pale illustration tints from bleeding into the
     card behind them, in either theme. */
  box-shadow: 0 0 0 1px var(--border);
  transition: transform var(--dur-fast) var(--ease);
}
.food-art { display: block; }

/* The illustrations use fixed food colours so a banana is always yellow. On
   dark surfaces the pale background tints would glare, so they are eased back
   slightly — enough to sit calmly, not enough to lose the identity. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .food-art { filter: saturate(.88) brightness(.9); }
}
:root[data-theme="dark"] .food-art { filter: saturate(.88) brightness(.9); }
.food-row:hover .food-thumb { transform: scale(1.06); }
.food-main { flex: 1; min-width: 0; }
/* When the row opens a detail page, the info block itself is the button. */
button.food-main {
  display: block;
  width: 100%;
  cursor: pointer;
  border-radius: var(--r-sm);
}
button.food-main:hover .food-name { color: var(--accent-text); }
.food-name { font-weight: 580; display: flex; align-items: center; gap: var(--sp-2); }
.food-brand { font-size: var(--fs-sm); color: var(--text-muted); }
.food-nutri {
  display: flex;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 3px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.food-nutri b { color: var(--text); font-weight: 620; }
.food-actions { display: flex; gap: var(--sp-1); flex: none; }

@media (max-width: 560px) {
  .food-row { padding: var(--sp-3); gap: var(--sp-3); }
}
/* The artwork is the main way a result is recognised at a glance, so it stays
   down to very narrow screens and only drops on the smallest phones. */
@media (max-width: 380px) {
  .food-thumb { display: none; }
}

/* ------------------------------------------------------- food detail */

.detail-hero { display: flex; flex-direction: column; gap: var(--sp-2); }
.detail-name { font-size: var(--fs-2xl); letter-spacing: -.02em; }
.detail-brand { color: var(--text-muted); font-size: var(--fs-md); }
.detail-art {
  flex: none;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-sm);
}
@media (max-width: 560px) {
  /* Scale the artwork down rather than dropping it — it is how the food is
     recognised at a glance. */
  .detail-art { border-radius: 16px; }
  .detail-art svg { width: 54px; height: 54px; }
  .detail-name { font-size: var(--fs-xl); }
}

.portion-bar {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-end;
  flex-wrap: wrap;
}
.portion-qty { width: 110px; flex: none; }
.portion-unit { flex: 1; min-width: 160px; }

.nutrient-table { width: 100%; font-size: var(--fs-sm); }
.nutrient-table tr { border-bottom: 1px solid var(--border); }
.nutrient-table tr:last-child { border-bottom: none; }
.nutrient-table td { padding: var(--sp-3) 0; }
.nutrient-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 620; }
.nutrient-table .indent { padding-left: var(--sp-5); color: var(--text-muted); font-weight: 500; }
.nutrient-table .major td { font-weight: 680; font-size: var(--fs-base); }
.nutrient-dv {
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  font-weight: 500;
  margin-left: var(--sp-2);
}

.mini-bar {
  height: 5px;
  border-radius: var(--r-full);
  background: var(--bg-soft);
  overflow: hidden;
  margin-top: 5px;
  width: 100%;
}
.mini-bar span { display: block; height: 100%; border-radius: var(--r-full); }

/* Personal Nutrition Fit */
.score-card { display: flex; gap: var(--sp-5); align-items: center; flex-wrap: wrap; }
.score-dial { position: relative; display: grid; place-items: center; flex: none; }
.score-num {
  position: absolute;
  font-size: var(--fs-2xl);
  font-weight: 740;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.score-num small { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }

.factor {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: left;
}
.factor:last-child { border-bottom: none; }
.factor-points {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: var(--fs-sm);
  width: 46px;
  flex: none;
  text-align: right;
}
.factor-points--plus { color: var(--good); }
.factor-points--minus { color: var(--alert); }
.factor-label { font-weight: 580; font-size: var(--fs-base); }
.factor-detail { font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-relaxed); margin-top: 2px; }

/* ------------------------------------------------------------ charts */

.chart { width: 100%; overflow: visible; }
.chart-wrap { position: relative; width: 100%; }
.chart-axis { font-size: 10px; fill: var(--text-subtle); font-weight: 550; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-target { stroke: var(--text-subtle); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-bar { transition: opacity var(--dur-fast) var(--ease); cursor: pointer; }
.chart-bar:hover { opacity: .78; }
.chart-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { opacity: .12; }
.chart-point { cursor: pointer; }

.chart-tooltip {
  position: absolute;
  z-index: 20;
  padding: var(--sp-2) var(--sp-3);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 560;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, -100%);
  line-height: 1.45;
}

.legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-3); }
.legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 550;
}
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* A text alternative to every chart, for screen readers and for exactness. */
.chart-table { margin-top: var(--sp-3); }
.chart-table summary {
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
  padding: var(--sp-2) 0;
}
.chart-table summary:hover { color: var(--text); }

/* --------------------------------------------------------- comparison */

.compare-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-3);
}
.compare-slot {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 108px;
  color: var(--text-muted);
  text-align: center;
}
.compare-slot--filled {
  border-style: solid;
  border-color: var(--border);
  background: var(--surface-2);
  align-items: stretch;
  text-align: left;
}
.compare-winner {
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}

/* ------------------------------------------------------------- log */

.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.day-nav-label { font-weight: 640; font-size: var(--fs-base); }

.entry-time {
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  flex: none;
  width: 62px;
}
@media (max-width: 560px) { .entry-time { display: none; } }

/* --------------------------------------------------------- assistant */

.chat { display: flex; flex-direction: column; gap: var(--sp-4); min-height: 320px; }
.msg { display: flex; gap: var(--sp-3); max-width: 100%; }
.msg-avatar {
  width: 30px; height: 30px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  flex: none;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.msg-avatar svg { width: 16px; height: 16px; }
.msg-bubble {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
  white-space: pre-wrap;
  max-width: 90%;
}
.msg--user { flex-direction: row-reverse; }
.msg--user .msg-bubble {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
  font-weight: 550;
}
.msg--user .msg-avatar { background: var(--bg-soft); color: var(--text-muted); }

.typing { display: flex; gap: 4px; padding: var(--sp-2) 0; }
.typing span {
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: var(--text-subtle);
  animation: blink 1.3s infinite;
}
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* ------------------------------------------------------------ scanner */

.scanner-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--r-lg);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; }
.scanner-reticle {
  position: absolute;
  inset: 18% 12%;
  border: 2px solid rgba(255, 255, 255, .85);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
}

/* ------------------------------------------------------------ profile */

.profile-hero {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.avatar-lg {
  width: 60px; height: 60px;
  border-radius: var(--r-full);
  background: linear-gradient(140deg, var(--accent), #34d399);
  color: #04231b;
  display: grid; place-items: center;
  font-weight: 720;
  font-size: var(--fs-xl);
  flex: none;
}

.setting-group { display: flex; flex-direction: column; }
.setting-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: left;
}
.setting-row:last-child { border-bottom: none; }
.setting-main { flex: 1; min-width: 0; }
.setting-title { font-weight: 580; }
.setting-desc { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; line-height: var(--lh-relaxed); }

/* --------------------------------------------------------- insights */

.insight-row {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.insight-row:last-child { border-bottom: none; }
.insight-dot {
  width: 24px; height: 24px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  flex: none;
  margin-top: 1px;
}
.insight-dot svg { width: 13px; height: 13px; }
.insight-label { font-weight: 620; font-size: var(--fs-base); }
.insight-text { font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-relaxed); margin-top: 2px; }

.consistency-grid { display: flex; gap: 3px; flex-wrap: wrap; }
.consistency-cell {
  width: 15px; height: 15px;
  border-radius: 4px;
  background: var(--bg-soft);
}
.consistency-cell[data-level="0"] { background: var(--bg-soft); }
.consistency-cell[data-level="1"] { background: color-mix(in srgb, var(--accent) 30%, var(--bg-soft)); }
.consistency-cell[data-level="2"] { background: color-mix(in srgb, var(--accent) 60%, var(--bg-soft)); }
.consistency-cell[data-level="3"] { background: var(--accent); }

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-xs);
  font-weight: 660;
  font-variant-numeric: tabular-nums;
}
.trend svg { width: 12px; height: 12px; }
.trend--up { color: var(--good); }
.trend--down { color: var(--alert); }
.trend--flat { color: var(--text-subtle); }
