/* learn/learn.css - the reading guides (/learn/<slug> and the list at /learn/). It loads after /pages.css, which
   holds the site's tokens, type, background, logo header and buttons; this file adds only what the guides need:
   the flat 2D diagrams, the glance box, badges, the questions, the contents list and each guide's accent.
   Every colour is a custom property on :root, redefined for the dark theme. Each guide sets --path to its
   pathway's colour (the site-wide palette in modules/home/shared.js). */
:root {
  --path: #b82a42;   /* glycolysis #d8364c, darkened for text on paper */
  --invest: #f3d9c4; --payoff: #cfe6d6;   /* the glycolysis model's floor plates */
  --atp: #ffd23f; --atp-ink: #4a3000; --atp-ring: #c28500;
  --nadh: #bfd0fa; --nadh-ink: #152c66;   /* the model's NADH token */
  --water: #cfe9fb; --water-ink: #12405f;
  --act: #267b43; --inh: #c0392b;   /* --act #2b8a4b, darkened to 4.5:1 on the paper */
  --bead: #4a5560; --bead-ink: #ffffff;
  --fadh: #d6eb9c; --fadh-ink: #34450b; --co2: #e3e5e8; --co2-ink: #2b3038;
  --gtp: #ffb84d; --gtp-ink: #4a2500; --nadph: #cbbdf6; --nadph-ink: #24135f;
  --acoa: #c9efe9; --acoa-ink: #0d4a48; --o2: #fbd1cc; --o2-ink: #6e1a15; --hplus: #d93a34; --hplus-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --invest: rgba(240, 150, 90, 0.15); --payoff: rgba(110, 200, 140, 0.13);
    --atp: #f2c94c; --nadh: #b3c8f8; --water: #b7def6;
    --act: #6fd08c; --inh: #ff8a7a;
    --bead: #aab6c0; --bead-ink: #0f1b1d;
    --fadh: #c9e08a; --co2: #d2d6db; --gtp: #f2ac45; --nadph: #bcaef0; --acoa: #b5e6df; --o2: #f5beb7;
    --hplus: #e0322b; --hplus-ink: #ffffff;   /* #e5524c, darkened so its white label reads at 4.5:1 */
  }
}
/* the default accent in the dark theme; kept apart from the block above, whose selector is stronger than
   [data-path], so each guide's own accent still wins */
@media (prefers-color-scheme: dark) { :root { --path: #ff8597; } }
body { line-height: 1.65; }
.crumbs { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); }
.crumbs a { color: inherit; }
h3 .n { color: var(--path); margin-right: 4px; }
li { margin: 0 0 8px; }

/* a reaction line under each step heading */
.rxn {
  margin: 0 0 10px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--card-bg); font-size: 15px; overflow-wrap: anywhere;
}
@supports (background-color: color-mix(in srgb, red, blue)) {
  .rxn {
    border-color: color-mix(in srgb, var(--path) 36%, transparent);
    background: color-mix(in srgb, var(--path) 8%, var(--card-bg));
  }
}
.eq { font-weight: 600; }

/* the key facts at the top */
.glance { margin: 22px 0 8px; padding: 6px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--card-bg); }
.glance dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; column-gap: 18px; }
.glance dt, .glance dd { margin: 0; padding: 10px 0; border-top: 1px solid var(--line); }
.glance dt:first-of-type, .glance dt:first-of-type + dd { border-top: 0; }
.glance dt { font-weight: 600; }
@media (max-width: 520px) {
  .glance dl { grid-template-columns: 1fr; }
  .glance dt { padding-bottom: 0; }
  .glance dd { border-top: 0; padding-top: 2px; }
}

/* diagrams */
.fig { margin: 22px 0 24px; }
.fig figcaption { margin-top: 10px; font-size: 14px; color: var(--ink-2); text-align: center; text-wrap: balance; }
.dg { display: block; width: 100%; max-width: 460px; height: auto; margin: 0 auto; font-family: inherit; }
.dg text { fill: var(--ink); font-size: 14px; }
.dg .t-name, .dg .t-name text { font-weight: 600; }
.dg .t-big, .dg .t-big text { font-weight: 700; font-size: 17px; }
.dg .t-enz, .dg .t-enz text { font-size: 12.5px; fill: var(--ink-2); }
.dg .t-enz-strong, .dg .t-enz-strong text { font-size: 12.5px; font-weight: 600; }
.dg .t-small, .dg .t-small text { font-size: 12px; fill: var(--ink-2); }
.dg .t-num, .dg .t-num text { font-weight: 700; fill: var(--path); }
.dg .t-path, .dg .t-path text { fill: var(--path); font-weight: 600; font-size: 12px; }
.dg .t-act, .dg .t-act text { fill: var(--act); font-weight: 600; font-size: 12.5px; }
.dg .t-inh, .dg .t-inh text { fill: var(--inh); font-weight: 600; font-size: 12.5px; }
.dg .pill { fill: var(--card-bg); stroke: var(--line-strong); stroke-width: 1.2; }
.dg .pill-key { fill: var(--card-bg); stroke: var(--path); stroke-width: 2.2; }
.dg .ar { fill: none; stroke: var(--ink-3); stroke-width: 1.6; }
.dg .ar-one { fill: none; stroke: var(--path); stroke-width: 3.2; stroke-linecap: round; }
.dg .ar-act { fill: none; stroke: var(--act); stroke-width: 2.4; }
.dg .ar-inh { fill: none; stroke: var(--inh); stroke-width: 2.4; }
.dg .band-invest { fill: var(--invest); }
.dg .band-payoff { fill: var(--payoff); }
.dg .b-atp { fill: var(--atp); }
.dg .b-nadh { fill: var(--nadh); }
.dg .b-water { fill: var(--water); }
.dg text.ti-atp { fill: var(--atp-ink); font-size: 12.5px; font-weight: 600; }
.dg text.ti-nadh { fill: var(--nadh-ink); font-size: 12.5px; font-weight: 600; }
.dg text.ti-water { fill: var(--water-ink); font-size: 12.5px; font-weight: 600; }
.dg .bead { fill: var(--bead); }
.dg .bond { fill: none; stroke: var(--bead); stroke-width: 4; }
.dg text.bead-t { fill: var(--bead-ink); font-size: 13px; font-weight: 700; }
.dg .p-dot { fill: var(--atp); stroke: var(--atp-ring); stroke-width: 1.2; }
.dg text.p-t { fill: var(--atp-ink); font-size: 11px; font-weight: 700; }
.dg .cut { fill: none; stroke: var(--path); stroke-width: 2; stroke-dasharray: 5 4; }
.dg .grid { fill: none; stroke: var(--line); stroke-width: 1; }
.dg .zero { fill: none; stroke: var(--line-strong); stroke-width: 1.2; stroke-dasharray: 4 4; }
.dg .line-main { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.dg .dot { fill: var(--path); }
.mk-ink { fill: var(--ink-3); }
.mk-acc { fill: var(--path); }
.mk-act { fill: var(--act); }
.mk-inh { stroke: var(--inh); stroke-width: 2.6; }

/* check yourself: the sidebar's part rows (a chevron that turns over, content that settles in from 4 px
   above); learn/learn.js animates the height, with the site's easing */
details { margin: 0 0 10px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-bg); transition: border-color 0.16s ease; }
details:hover { border-color: var(--line-strong); }
summary { display: block; position: relative; padding: 12px 30px 12px 0; font-weight: 600; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after {
  content: ""; position: absolute; right: 0; top: 16px; width: 16px; height: 16px; background: var(--ink-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E") center / 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E") center / 16px no-repeat;
  transition: transform 0.2s ease, background-color 0.16s ease;
}
details[open]:not(.closing) > summary::after { transform: rotate(180deg); background: var(--ink-2); }
details[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }
details p:last-child { margin-bottom: 12px; }
@media (prefers-reduced-motion: reduce) { details, summary::after { transition: none; } }

/* Moving between pages (Rayyan's "Carry", engine/transition.js): the old page fades out, the new one rises
   8 px, and the title travels to its place (a model's sidebar title to the guide's heading, and guide to
   guide); the logo stays put. Browsers without cross-document view transitions, and reduced motion, change
   at once. index.html opts in with the same rules. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
h1 { view-transition-name: mm-title; }
.logo { view-transition-name: mm-logo; }
::view-transition-old(root) { animation: mm-out 150ms ease-out both; }
::view-transition-new(root) { animation: mm-rise 240ms cubic-bezier(0.2, 0.7, 0.2, 1) 80ms both; }
::view-transition-group(mm-title) { animation-duration: 360ms; animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1); }
::view-transition-old(mm-title), ::view-transition-new(mm-title) { height: 100%; width: auto; object-fit: fill; }
::view-transition-old(mm-title) { animation: mm-out 70ms ease-out both; }
::view-transition-new(mm-title) { animation: mm-in 90ms ease-in 40ms both; }
::view-transition-group(mm-logo) { animation-duration: 360ms; animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes mm-out { to { opacity: 0; } }
@keyframes mm-in { from { opacity: 0; } }
@keyframes mm-rise { from { opacity: 0; transform: translateY(8px); } }

/* each guide's accent: its library tile colour (index.html, modules/home/shared.js), darkened on the
   light paper and lightened on the dark one until text in it reads at 4.5:1 on the page and on a card.
   <html data-path="slug"> picks it (and an <li data-path> on the guides list). */
[data-path="glycolysis"] { --path: #c8273d; }   /* #d8364c */
[data-path="pyruvate-dehydrogenase"] { --path: #a95215; }   /* #d2661a */
[data-path="citric-acid-cycle"] { --path: #1e763d; }   /* #25934c */
[data-path="electron-transport-chain"] { --path: #1170a4; }   /* #1486c4 */
[data-path="gluconeogenesis"] { --path: #b03896; }   /* #c23fa6 */
[data-path="glycogen"] { --path: #876409; }   /* #ad800b */
[data-path="pentose-phosphate-pathway"] { --path: #09756c; }   /* #0b9186 */
[data-path="beta-oxidation"] { --path: #8847cf; }   /* #8b4bd0 */
[data-path="fatty-acid-synthesis"] { --path: #577111; }   /* #6f9016 */
[data-path="ketone-bodies"] { --path: #9b5837; }   /* #a35c3a */
[data-path="urea-cycle"] { --path: #3364d5; }   /* #3767d6 */
[data-path="liver-cell-map"] { --path: #5b6c7e; }   /* #5f7184 */
[data-path="fed-fasting-starvation"] { --path: #5b6c7e; }   /* #5f7184 */
[data-path="rna-processing"] { --path: #a65021; }   /* #d9763f */
[data-path="translation"] { --path: #565bce; }   /* #5a5fcf */
@media (prefers-color-scheme: dark) {
  [data-path="glycolysis"] { --path: #e26878; }
  [data-path="pyruvate-dehydrogenase"] { --path: #e26e1c; }
  [data-path="citric-acid-cycle"] { --path: #29a455; }
  [data-path="electron-transport-chain"] { --path: #1797dd; }
  [data-path="gluconeogenesis"] { --path: #d06bbb; }
  [data-path="glycogen"] { --path: #b7870c; }
  [data-path="pentose-phosphate-pathway"] { --path: #0ca194; }
  [data-path="beta-oxidation"] { --path: #a97adc; }
  [data-path="fatty-acid-synthesis"] { --path: #779b18; }
  [data-path="ketone-bodies"] { --path: #c57e5c; }
  [data-path="urea-cycle"] { --path: #698de0; }
  [data-path="liver-cell-map"] { --path: #7f91a4; }
  [data-path="fed-fasting-starvation"] { --path: #7f91a4; }
  [data-path="rna-processing"] { --path: #d9763f; }
  [data-path="translation"] { --path: #8488db; }
}

/* shared extras for every guide: a neutral band, and badges in the colours of the 3D models' tokens
   (engine/kit3d.js and the modules' own TOKENS) */
.dg .band { fill: var(--control); }
.dg .b-fadh { fill: var(--fadh); }   .dg text.ti-fadh { fill: var(--fadh-ink); font-size: 12.5px; font-weight: 600; }
.dg .b-co2 { fill: var(--co2); }     .dg text.ti-co2 { fill: var(--co2-ink); font-size: 12.5px; font-weight: 600; }
.dg .b-gtp { fill: var(--gtp); }     .dg text.ti-gtp { fill: var(--gtp-ink); font-size: 12.5px; font-weight: 600; }
.dg .b-nadph { fill: var(--nadph); } .dg text.ti-nadph { fill: var(--nadph-ink); font-size: 12.5px; font-weight: 600; }
.dg .b-acoa { fill: var(--acoa); }   .dg text.ti-acoa { fill: var(--acoa-ink); font-size: 12.5px; font-weight: 600; }
.dg .b-o2 { fill: var(--o2); }       .dg text.ti-o2 { fill: var(--o2-ink); font-size: 12.5px; font-weight: 600; }
.dg .b-h { fill: var(--hplus); }     .dg text.ti-h { fill: var(--hplus-ink); font-size: 12.5px; font-weight: 700; }

/* "On this page": learn/learn.js builds it after the glance box from the page's h2 headings (without the
   script the page is as it was). A small label and a plain list of links, two columns where there is room. */
.toc { margin: 22px 0 0; }
.toc-h { margin: 0 0 2px; font: 600 13px/1.3 var(--font-body); color: var(--ink-2); }
.toc ul { margin: 0; padding: 0; list-style: none; columns: 2; column-gap: 28px; font: 500 14px/1.35 var(--font-body); }
.toc li { margin: 0; break-inside: avoid; }
.toc a {
  display: flex; align-items: center; min-height: 34px; padding: 4px 0;
  color: var(--ink-2); text-decoration: none; transition: color 0.16s ease;
}
.toc a:hover { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; }
@media (pointer: coarse) { .toc a { min-height: 44px; } }
@media (max-width: 560px) { .toc ul { columns: 1; } }
@media (prefers-reduced-motion: reduce) { .toc a { transition: none; } }

/* the guides list (/learn/): one row per guide, the pathway's colour dot, its name */
.guide-list { margin: 0 0 8px; padding: 0; list-style: none; border-bottom: 1px solid var(--line); }
.guide-list li { margin: 0; }
.guide-list a {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 2px;
  border-top: 1px solid var(--line); font-weight: 600; text-decoration: none;
  transition: background-color 0.16s ease;
}
.guide-list a:hover { background: var(--control); }
.guide-list a:hover .guide-nm { text-decoration: underline; text-decoration-thickness: 1px; }
.guide-dot { flex: none; width: 10px; height: 10px; margin-left: 4px; border-radius: 50%; background: var(--path); }
.guide-nm { flex: 1; min-width: 0; }
.guide-go { flex: none; width: 16px; height: 16px; margin-right: 4px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.guide-list + h2 { margin-top: 36px; }
@media (prefers-reduced-motion: reduce) { .guide-list a { transition: none; } }

/* Diagrams on a phone: the drawings are 420 units wide, so on a narrow screen they take the whole width (into
   the page's side gutters) and their smallest labels step up a little, so no label renders much under 11.5 px
   at 390 px wide. */
@media (max-width: 500px) {
  .fig {
    margin-left: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
    margin-right: calc(-1 * max(16px, env(safe-area-inset-right, 0px)));
  }
  .fig figcaption { padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
  .dg .t-small, .dg .t-small text, .dg .t-path, .dg .t-path text { font-size: 12.5px; }
}
