/* ============================================================================
   sugar.css — SugarCheck-only layer. Loads after styles.css + data.css.
   Adds the site accent, the pure-SVG glucose-curve hero, the prominent medical
   disclaimer block, the calculator surface and the result-band colours.
   No images, no libraries, no web fonts beyond the shared Inter.
   The tone is deliberately clinical: this is not a page to be dramatic on.
   ========================================================================== */

/* ------------------------------------------------------------- site accent */
body[data-site="sugar"] {
  --accent: #b91c1c; --accent-2: #7f1d1d; --accent-3: #ef4444;
  --accent-soft: #fdeaea;
  --g-normal: #0f766e; --g-pre: #b45309; --g-dia: #b91c1c;
  --gi-low: #0f766e; --gi-med: #b45309; --gi-high: #b91c1c;
  /* AAA+++ §3.8: the graticule was cool blue-grey (#e6eaf1 / #1e2740), which
     read as a different material from the warm paper it was drawn on — and it
     broke outright in the warm-basalt dark mode. Retuned to the paper's own
     temperature in both modes. */
  --curve-grid: #EAE4D7;
}
:root[data-theme="dark"] body[data-site="sugar"] {
  --accent: #f87171; --accent-2: #fca5a5; --accent-3: #ef4444;
  --accent-soft: rgba(248, 113, 113, .14);
  --g-normal: #2dd4bf; --g-pre: #fbbf24; --g-dia: #f87171;
  --gi-low: #2dd4bf; --gi-med: #fbbf24; --gi-high: #f87171;
  --curve-grid: #2B2822;
}

/* ------------------------------------------------- the medical disclaimer
   Deliberately near the top of every clinical page rather than in the footer.
   It is the first thing under the hero, and it is not collapsible.          */
.disc-top { padding-top: 22px; padding-bottom: 0; }
.med-disc {
  display: grid; grid-template-columns: 22px 1fr; gap: 14px; align-items: start;
  padding: 16px 18px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.med-disc svg { width: 22px; height: 22px; color: var(--accent); margin-top: 1px; }
.med-disc strong { display: block; font-size: .95rem; font-weight: 750; color: var(--ink); margin-bottom: 5px; }
.med-disc p { font-size: .87rem; line-height: 1.62; color: var(--ink-2, var(--muted)); }
.med-disc p b { color: var(--ink); font-weight: 700; }
@media (max-width: 520px) { .med-disc { grid-template-columns: 1fr; } .med-disc svg { display: none; } }

/* ---------------------------------------------------- the SVG glucose hero */
.gcurve { max-width: 620px; margin: 28px auto 0; }
.gcurve svg { width: 100%; height: auto; overflow: visible; display: block; }
.gc-grid line { stroke: var(--curve-grid); stroke-width: 1; }
.gc-line { stroke-width: 3.4; stroke-linecap: round; }
.gc-lab text { fill: var(--muted); font-family: var(--font); font-size: 13px; font-weight: 650; }
.gc-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 3; }
.gc-dot-b { stroke: var(--accent-3); }
.gc-note { font-size: .78rem; color: var(--muted); text-align: center; margin-top: 10px; line-height: 1.55; }

/* One slow draw on load. Nothing loops, nothing pulses — this subject does
   not need animation shouting at the reader. */
.gc-line { stroke-dasharray: 900; stroke-dashoffset: 900; animation: gc-draw 1.9s cubic-bezier(.25,.8,.3,1) forwards; }
.gc-area { opacity: 0; animation: gc-fade 1.2s ease-out .9s forwards; }
.gc-dot { opacity: 0; animation: gc-fade .5s ease-out forwards; }
.gc-dot-a { animation-delay: .35s } .gc-dot-b { animation-delay: 1.0s } .gc-dot-c { animation-delay: 1.5s }
@keyframes gc-draw { to { stroke-dashoffset: 0 } }
@keyframes gc-fade { to { opacity: 1 } }
@media (prefers-reduced-motion: reduce) {
  .gc-line, .gc-area, .gc-dot { animation: none; stroke-dashoffset: 0; opacity: 1; }
}

/* ==========================================================================
   THE GI DIAL — SugarCheck's set piece (AAA+++ §5, "Lab report").
   An instrument, not an infographic: milled bezel, engraved ticks, a squared
   lab field behind it. Nothing here animates layout, so CLS stays 0.00.
   It plots a FOOD's published glycemic index. It never plots a person.
   ========================================================================== */
/* The lab sheet: reported value beside the instrument that produced it, so on
   a wide screen both the figure and the scale it is read against are above the
   fold. Stacks under 900px — value first, instrument second, never reversed. */
.lab-sheet { display: grid; gap: 8px; margin-top: 22px; }
@media (min-width: 900px) {
  .lab-sheet { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 34px; align-items: start; }
  .lab-sheet > * { margin-top: 0; }
  .lab-sheet .answer.aaa { margin: 0; max-width: none; }
  .lab-sheet .gi-dial { margin: 0; max-width: none; }
}

.gi-dial { max-width: 540px; margin: 22px auto 0; }
.gi-dial svg { width: 100%; height: auto; display: block; }

/* the lab field: squared paper under the instrument, faded at the edges so it
   reads as a sheet the dial sits on rather than a border */
.gd-gridline { stroke: var(--curve-grid); stroke-width: 1; }
.gd-gridline-m { stroke-width: 1.5; }
.gd-field { opacity: .85; }

/* bands: the published categories, held back to instrument-plate saturation.
   Loud traffic-light fills would read as a verdict; these read as a scale. */
.gd-band { fill: none; stroke-linecap: butt; opacity: .38; }
.gd-band-low  { stroke: var(--gi-low); }
.gd-band-med  { stroke: var(--gi-med); }
.gd-band-high { stroke: var(--gi-high); }

/* bezel + engraving */
.gd-bezel { fill: none; stroke: var(--ink-2, var(--muted)); stroke-width: 1.4; opacity: .55; }
.gd-bezel-i { stroke-width: 1; opacity: .34; }
.gd-base { stroke: var(--line-2, var(--line)); stroke-width: 1.2; }
.gd-tick { stroke: var(--muted); stroke-width: 1; stroke-linecap: butt; opacity: .6; }
.gd-tick-m { stroke: var(--ink-2, var(--ink)); stroke-width: 1.6; opacity: .9; }
.gd-num {
  fill: var(--muted); font-family: var(--mono); font-size: 12px;
  letter-spacing: .06em; font-variant-numeric: tabular-nums lining-nums;
}

/* the two published cut-points, flagged as markings ON THE SCALE */
.gd-cut { stroke: var(--accent); stroke-width: 1.4; opacity: .8; }
.gd-cutn {
  fill: var(--accent-deep, var(--accent)); font-family: var(--mono); font-size: 12px;
  font-weight: 600; letter-spacing: .06em; font-variant-numeric: tabular-nums lining-nums;
}

/* needle in ink, not in the band colour — the pointer is an instrument part,
   not a judgement, and colouring it red inside the high band would make it one */
.gd-needle { fill: var(--ink); }
.gd-hub { fill: var(--surface); stroke: var(--ink); stroke-width: 2.4; }
.gd-hub-i { fill: var(--ink); }

/* the instrument's engraved plate. In HTML rather than inside the viewBox, so
   it stays legible when the SVG scales down instead of shrinking with it. */
.gd-plates {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 18px;
  margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint, var(--muted));
}

/* engraved numerals scale with the viewBox, so they get a size per breakpoint
   rather than one size that is either huge on desktop or unreadable on a phone */
@media (max-width: 560px) {
  .gd-num, .gd-cutn { font-size: 17px; }
  .gd-plates { justify-content: flex-start; }
}

/* The needle's angle is a DATUM, so it is never animated: it is written into
   the SVG server-side and nothing in CSS may move it. (An earlier revision
   swung it in from -34deg; a tab that is not compositing freezes a CSS
   animation at its first keyframe, which left the needle pointing at the wrong
   glycemic index. A drawing that can be caught mid-lie is not a drawing.)
   What fades is only its ink, so the worst possible frozen state is a
   correctly-positioned needle rendered faint. */
@media (prefers-reduced-motion: no-preference) {
  .gd-swing { animation: gd-settle 700ms var(--ease-out, cubic-bezier(.25,1,.4,1)) both; }
  @keyframes gd-settle { from { opacity: .25; } }
}

.gd-key {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; margin-top: 12px;
  font-family: var(--mono); font-size: var(--fs-mono, .8125rem); letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.gd-key span { display: inline-flex; align-items: center; gap: 7px; }
.gd-key b { color: var(--ink-2, var(--ink)); font-weight: 600; }
.gd-sw { width: 16px; height: 4px; border-radius: 1px; background: currentColor; opacity: .55; }
.gd-sw.gd-band-low  { color: var(--gi-low); }
.gd-sw.gd-band-med  { color: var(--gi-med); }
.gd-sw.gd-band-high { color: var(--gi-high); }
.gi-dial figcaption { margin-top: 12px; text-align: center; line-height: 1.6; text-transform: none; }

/* ---------------- the reported-value block (answer.aaa, lab-report voice) -- */
.answer.aaa { max-width: 62ch; margin: 24px auto 0; text-align: left; }
/* font-size is restated here because .answer.aaa p below is more specific than
   data.css's .stat-display, and without it the figure collapsed to body size */
.answer.aaa .stat-display {
  display: block; color: var(--ink); margin-bottom: 4px;
  font-size: var(--fs-stat); line-height: .92;
}
.answer.aaa .stat-display .u { color: var(--muted); }
.answer.aaa .rv-band { font-family: var(--mono); font-size: var(--fs-mono); letter-spacing: .06em; text-transform: uppercase; }
.answer.aaa p { font-size: .95rem; line-height: 1.7; color: var(--ink-2, var(--muted)); margin-top: 10px; }
/* the answer's own h2 is a lab-report FIELD LABEL, not a section head — it
   keeps the §6.2 heading contract without shouting over the figure it labels */
.answer.aaa h2.sec {
  font-family: var(--mono); font-size: var(--fs-mono); font-weight: 500;
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--accent-deep, var(--accent)); margin-bottom: 10px;
}

/* ------------------------------------------------------------ calculator UI */
.sc-calc { max-width: 700px; margin: 26px auto 0; text-align: left; }
.sc-calc .card-body { padding: 22px; }
.sc-out {
  margin-top: 18px; padding: 18px; border-radius: var(--radius);
  background: var(--surface-2, var(--bg-tint)); border: 1px solid var(--line); text-align: center;
}
.sc-out .v { font-size: clamp(2.2rem, 8vw, 3.2rem); font-weight: 800; letter-spacing: -.05em; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }
.sc-out .u { font-size: .9rem; color: var(--muted); font-weight: 650; margin-top: 6px; }
.sc-out .u2 { font-size: .95rem; color: var(--ink); font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; }
.sc-out .verdict { margin-top: 13px; font-size: .98rem; font-weight: 700; line-height: 1.45; }
.sc-nojs { margin-top: 14px; font-size: .82rem; color: var(--muted); line-height: 1.6; }

/* ------------------------------------------------------------ band colours */
.g-normal { color: var(--g-normal); font-weight: 700; }
.g-pre    { color: var(--g-pre);    font-weight: 700; }
.g-dia    { color: var(--g-dia);    font-weight: 700; }
.gi-low   { color: var(--gi-low);   font-weight: 700; }
.gi-med   { color: var(--gi-med);   font-weight: 700; }
.gi-high  { color: var(--gi-high);  font-weight: 700; }
.gl-low   { color: var(--gi-low);   font-weight: 700; }
.gl-med   { color: var(--gi-med);   font-weight: 700; }
.gl-high  { color: var(--gi-high);  font-weight: 700; }

table.data tr.grp th {
  background: var(--bg-tint); font-size: .8rem; font-weight: 750;
  letter-spacing: .02em; text-transform: none; color: var(--ink); text-align: left;
}
table.data tr.self th, table.data tr.self td { font-weight: 750; background: var(--accent-soft); }
table.data td.hi, table.data th.hi { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
table.data .sm { font-size: .8rem; color: var(--muted); font-weight: 500; }

/* --------------------------------------------------- two published rulebooks */
.dual { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 6px; }
@media (max-width: 720px) { .dual { grid-template-columns: 1fr; } }
.dual-col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-xs); }
.dual-col.lead { border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent), var(--shadow-sm); }
.dual-col h3 { font-size: 1rem; font-weight: 750; letter-spacing: -.02em; margin-bottom: 3px; }
.dual-col .who { font-size: .77rem; color: var(--muted); margin-bottom: 12px; }
.dual-col p { font-size: .88rem; line-height: 1.6; color: var(--muted); }
.dual-tag { display: inline-block; font-size: .64rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; margin-bottom: 9px; }

/* ------------------------------------------------------------- quick jumps */
.jump { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 7px; }
.jump a {
  display: block; text-align: center; padding: 11px 8px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none;
  font-size: .87rem; font-weight: 700; color: var(--ink); transition: .16s; box-shadow: var(--shadow-xs);
}
.jump a small { display: block; font-weight: 500; font-size: .71rem; color: var(--muted); margin-top: 3px; }
.jump a:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.jump a[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------- tool cards */
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.tool {
  display: block; text-decoration: none; color: inherit; padding: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); transition: .2s; position: relative; overflow: hidden;
}
.tool::after {
  content: ""; position: absolute; inset: auto -30% -60% auto; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%); pointer-events: none;
}
.tool:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 50%, transparent); box-shadow: var(--shadow); }
.tool .ti { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 13px; }
.tool .ti svg { width: 20px; height: 20px; }
.tool h3 { font-size: 1.02rem; font-weight: 750; letter-spacing: -.025em; margin-bottom: 6px; line-height: 1.3; }
.tool p { font-size: .86rem; color: var(--muted); line-height: 1.55; }
.tool .go { display: inline-block; margin-top: 12px; font-size: .83rem; font-weight: 700; color: var(--accent); }

/* ------------------------------------------------------- formulas & cites */
.formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem;
  background: var(--bg-tint); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 16px; color: var(--ink); overflow-x: auto; line-height: 1.9;
}
.cite { font-size: .77rem; color: var(--muted); margin-top: 12px; line-height: 1.6; }
.cite b { color: var(--ink); font-weight: 650; }

/* ------------------------------------- the medical caution block, inline use */
.caution {
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line)); border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  border-radius: var(--radius-sm); padding: 15px 18px; font-size: .89rem;
  color: var(--muted); line-height: 1.62; margin-top: 18px;
}
.caution strong { color: var(--ink); }

/* the big answer number in a hero */
.answer .big {
  display: block; font-size: clamp(2rem, 7vw, 2.9rem); font-weight: 800;
  letter-spacing: -.045em; color: var(--accent); line-height: 1.05; margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

/* the caveat that travels with the PeakForm placement on this site */
.pf-med {
  margin-top: 14px; font-size: .8rem; color: var(--muted); line-height: 1.6;
  text-align: center; max-width: 62ch; margin-left: auto; margin-right: auto;
}
