/* "How Australia eats" page. Builds on style.css. */

:root {
  --c-fruit: #C7861A;
  --c-veg: #278048;
  --c-muted: #B9C4B6;
  --c-light: #E39AAF;
  --c-dark: #8C1F4A;
  --rule: #DDE3D9;
}

.learn-hero { padding-bottom: clamp(2rem, 5vw, 3rem); }
.learn-hero .hero-sub { margin-bottom: 0; }
.back { color: var(--leaf-soft); text-decoration: none; font-weight: 700; display: inline-block; margin-bottom: 1.5rem; }
.back:hover { color: var(--mustard); }

.learn { padding-bottom: 3rem; }

/* Key numbers */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.5rem 2.5rem;
  padding: clamp(2rem, 5vw, 3rem) 0 2rem;
  border-bottom: 2px solid var(--ink);
}
.stat p { margin: 0; color: var(--ink-soft); max-width: 18em; }
.stat .stat-num { font: 800 var(--step-3) var(--display); letter-spacing: -0.02em; color: var(--ink); line-height: 1; margin-bottom: 0.4rem; }
.stat-num small { font-size: 0.6em; }

/* Each story: words on the left, chart on the right */

.story {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 2rem 3rem;
  align-items: start;
  padding: clamp(2.5rem, 6vw, 4rem) 0;
  border-bottom: 1px solid var(--paper-deep);
}
.story-text p { max-width: 34em; }

.chart-card { margin: 0; background: var(--white); border-radius: 12px; padding: 1.3rem 1.3rem 1rem; min-width: 0; }
.chart-card figcaption h3 { font-size: var(--step-0); margin-bottom: 0.4rem; }
.sub-h { font-size: var(--step-0); margin: 1.6rem 0 0.6rem; }
.chart-gap { margin-top: 0.5rem; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; font-size: var(--step--1); color: var(--ink-soft); margin: 0 0 0.8rem; }
.legend .key, .legend .dot-key { margin-left: 0.6rem; }
.legend .key:first-child, .legend .dot-key:first-child { margin-left: 0; }
.key { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 3px; flex: none; }
.k-fruit, .s-fruit { background: var(--c-fruit); }
.k-veg, .s-veg { background: var(--c-veg); }
.s-muted { background: var(--c-muted); }
.k-ow, .s-ow, .k-mod, .s-mod { background: var(--c-light); }
.k-ob, .s-ob, .k-sev, .s-sev { background: var(--c-dark); }
.dot-key { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 50%; background: var(--ink); }
.dot-key.hollow { background: var(--white); box-shadow: inset 0 0 0 2px var(--ink-soft); }
.source { font-size: 0.78rem; color: var(--ink-soft); margin: 0.9rem 0 0; }

/* Bar charts */

.chart { --label: 7.5rem; font-size: var(--step--1); }
#chart-trend, #chart-risk, #chart-diet-risk, #chart-weight, #chart-food, #chart-disc, #chart-reasons, #chart-shop, #chart-serve { --label: 12rem; }
.plot { position: relative; }
.row { display: grid; grid-template-columns: var(--label) minmax(0, 1fr); gap: 0.75rem; align-items: center; padding: 0.3rem 0; }
.row-label { color: var(--ink); line-height: 1.2; }
/* Room on the right for the value labels, so bars never shrink to fit them. */
.row-bars, .axis-row .axis { margin-right: 3.5rem; }
.row-bars { position: relative; display: grid; gap: 2px; }
.bar-row { display: flex; align-items: center; gap: 0.4rem; min-height: 14px; }
.bar, .stack { flex: none; }
.bar { display: block; height: 14px; min-width: 2px; border-radius: 0 4px 4px 0; cursor: default; }
.bar:hover, .bar:focus-visible, .seg:hover, .seg:focus-visible { filter: brightness(1.12); outline-offset: 2px; }
.bar-val { white-space: nowrap; color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 0.8rem; }

.stack { display: flex; gap: 2px; height: 18px; }
.stack .seg { display: block; height: 100%; min-width: 2px; }
.stack .seg:last-child { border-radius: 0 4px 4px 0; }

.grid { position: absolute; inset: 0 3.5rem 0 calc(var(--label) + 0.75rem); pointer-events: none; }
.grid span { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--rule); }
.axis-row { padding-top: 0; }
.axis { position: relative; height: 1.2rem; border-top: 1px solid var(--ink-soft); }
.tick { position: absolute; top: 0; transform: translateX(-50%); font-size: 0.72rem; color: var(--ink-soft); padding-top: 0.15rem; }
.tick:first-child { transform: none; }
.tick:last-child { transform: translateX(-100%); }

/* Dumbbell: 2017–18 to 2022 */

.dumb { height: 1.6rem; display: block; margin-right: 6.5rem; }
.dumb-line { position: absolute; top: 50%; height: 2px; background: var(--ink-soft); transform: translateY(-50%); }
.dumb-dot { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); transform: translate(-50%, -50%); box-shadow: 0 0 0 2px var(--white); }
.dumb-dot.hollow { background: var(--white); box-shadow: inset 0 0 0 2px var(--ink-soft), 0 0 0 2px var(--white); }
.dumb-val { position: absolute; top: 50%; transform: translateY(-50%); padding-left: 0.7rem; white-space: nowrap; font-size: 0.8rem; color: var(--ink-soft); }
.dumb-val b { color: var(--ink); }
#chart-trend .axis-row .axis { margin-right: 6.5rem; }
#chart-trend .grid { right: 6.5rem; }

/* NOVA split */

.nova-stack { display: flex; gap: 2px; height: 34px; }
.nova-stack .seg { display: block; height: 100%; }
.nova-stack .seg:first-child { border-radius: 4px 0 0 4px; }
.nova-stack .seg:last-child { border-radius: 0 4px 4px 0; }
.nova-keys { list-style: none; margin: 0.9rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.6rem 1.2rem; font-size: var(--step--1); }
.nova-keys li { display: flex; gap: 0.5rem; align-items: baseline; }
.nova-keys small { display: block; color: var(--ink-soft); font-size: 0.78rem; }

/* Tables and tooltip */

.as-table { margin-top: 0.8rem; font-size: 0.8rem; }
.as-table summary { cursor: pointer; color: var(--leaf); font-weight: 700; }
.as-table table { border-collapse: collapse; margin-top: 0.5rem; width: 100%; }
.as-table th, .as-table td { text-align: left; padding: 0.25rem 0.5rem; border-bottom: 1px solid var(--rule); }
.as-table td { font-variant-numeric: tabular-nums; }

.tip-box {
  position: fixed; z-index: 10; max-width: 18rem; pointer-events: none;
  background: var(--ink); color: var(--paper); font-size: var(--step--1); line-height: 1.35;
  padding: 0.45rem 0.7rem; border-radius: 6px; box-shadow: 0 6px 18px -8px rgba(20, 34, 24, 0.6);
}

/* Planner link and sources */

.planner-link { padding: clamp(2.5rem, 6vw, 4rem) 0 1rem; }
.planner-link ul { padding-left: 1.2rem; max-width: 46em; }
.planner-link li { margin-bottom: 0.6rem; }
.planner-link .go { display: inline-block; text-decoration: none; margin-top: 1rem; }
.sources { padding-top: 2rem; }
.sources ol { padding-left: 1.3rem; font-size: var(--step--1); }
.sources li { margin-bottom: 0.4rem; }
.sources a { color: var(--leaf); }
.sources .fine { color: var(--ink-soft); }

.learn-link { color: var(--mustard); font-weight: 700; }
.method .learn-link { display: inline-block; margin-top: 1rem; }

@media (max-width: 860px) {
  .story { grid-template-columns: 1fr; }
  .chart { --label: 5.5rem; }
  #chart-risk, #chart-diet-risk, #chart-weight, #chart-food, #chart-disc, #chart-reasons, #chart-shop, #chart-serve { --label: 7.5rem; }
  /* Narrow axes only have room for every second number. */
  .axis .tick:nth-child(even) { visibility: hidden; }
  /* Labels go above each line so the dots get the full width. */
  #chart-trend .row { grid-template-columns: 1fr; gap: 0.1rem; }
  #chart-trend .grid { left: 0; }
  #chart-trend .axis-row .row-label { display: none; }
}
