/* Metabolism map workspace and the record pages beneath it (dark system, violet selection). */

.page-atlas .fg-footer { margin-top: 0; }
/* Fills the viewport below the header. --fg-header-h is the header's measured height (site.js), with the
   shared per-width value as the fallback; no fixed floor, so a landscape phone still sees the bottom controls. */
.map-app { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100svh - var(--fg-header-h, 53px)); min-height: 260px; border-bottom: 1px solid var(--fg-line); background: #15171a; }
.map-stage { position: relative; min-width: 0; overflow: hidden; }
.map-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
.map-stage canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.map-app.dragging canvas { cursor: grabbing; }
.map-status { position: absolute; left: 50%; top: 45%; margin: 0; padding: 8px 14px; border: 1px solid var(--fg-line); border-radius: var(--fg-r-ctl); color: var(--fg-secondary); background: var(--fg-surface); transform: translate(-50%, -50%); }
.map-app.ready .map-status { display: none; }

.map-toolbar { position: absolute; top: 10px; right: 10px; left: 10px; z-index: 3; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; pointer-events: none; }
.map-toolbar > * { pointer-events: auto; }
.map-search { position: relative; width: min(400px, 100%); }
.map-search input { width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--fg-line-strong); border-radius: var(--fg-r-ctl); color: var(--fg-text); background: rgba(30, 33, 36, 0.96); font-size: 13px; box-shadow: var(--fg-shadow); }
.map-search input:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-dim), var(--fg-shadow); }
#map-results { position: absolute; top: 40px; right: 0; left: 0; max-height: 60vh; margin: 0; padding: 4px; overflow-y: auto; border: 1px solid var(--fg-line-strong); border-radius: var(--fg-r-ctl); background: var(--fg-surface); list-style: none; box-shadow: var(--fg-shadow); }
#map-results li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 8px; border-radius: var(--fg-r-chip); cursor: pointer; font-size: 13px; }
#map-results li[aria-selected="true"], #map-results li:hover { background: var(--accent-dim); }
#map-results strong { font-weight: 600; }
#map-results span { overflow: hidden; color: var(--fg-secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.map-focus { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; max-width: 100%; min-height: 36px; margin: 0; padding: 4px 4px 4px 12px; border: 1px solid var(--accent-line); border-radius: var(--fg-r-ctl); color: var(--fg-text); background: rgba(30, 33, 36, 0.96); font-size: 13px; line-height: 1.25; box-shadow: var(--fg-shadow); }
/* long pathway names wrap inside the bar, and the button drops below them on narrow screens */
.map-focus span { flex: 1 1 12em; min-width: 0; overflow-wrap: break-word; }
.map-focus b { color: var(--accent); font-weight: 600; }
.map-focus button { flex: none; min-height: 28px; padding: 0 10px; border: 1px solid var(--fg-line-strong); border-radius: var(--fg-r-chip); color: var(--fg-text); background: var(--fg-raised); font-size: 12px; font-weight: 500; white-space: nowrap; }
.map-focus[hidden] { display: none; }
.map-zoom { display: flex; align-items: center; gap: 2px; margin-left: auto; padding: 3px; border: 1px solid var(--fg-line-strong); border-radius: var(--fg-r-ctl); background: rgba(30, 33, 36, 0.96); box-shadow: var(--fg-shadow); }
.map-zoom button { min-width: 30px; height: 28px; border: 0; border-radius: var(--fg-r-chip); color: var(--fg-text); background: transparent; font-size: 15px; font-weight: 500; }
.map-zoom button:hover { background: var(--fg-raised); }
.map-zoom #map-fit { padding: 0 9px; font-size: 12px; }
.map-zoom output { min-width: 46px; color: var(--fg-secondary); font: 12px var(--fg-mono); text-align: center; }
.map-tip { position: absolute; top: 0; left: 0; z-index: 4; max-width: 320px; padding: 5px 9px; border: 1px solid var(--fg-line-strong); border-radius: var(--fg-r-chip); color: var(--fg-text); background: var(--fg-raised); font-size: 12.5px; font-weight: 500; pointer-events: none; box-shadow: var(--fg-shadow); }

.map-panel { overflow-y: auto; overscroll-behavior: contain; border-left: 1px solid var(--fg-line); background: var(--fg-surface); }
.map-sheet-toggle { display: none; }
.map-panel-body { padding: 0 14px 24px; }
.map-tabs { position: sticky; top: 0; z-index: 2; display: flex; margin: 0 -14px 12px; border-bottom: 1px solid var(--fg-line); background: var(--fg-sunk); }
.map-tabs button { position: relative; flex: 1; min-height: 38px; padding: 0 8px; border: 0; border-right: 1px solid var(--fg-line); color: var(--fg-secondary); background: transparent; font-size: 13px; font-weight: 500; }
.map-tabs button:last-child { border-right: 0; }
.map-tabs button[aria-selected="true"] { color: var(--fg-text); background: var(--fg-surface); }
.map-tabs button[aria-selected="true"]::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--accent); content: ""; }
.map-panel h1 { margin: 2px 0 6px; font-size: 18px; }
.map-panel h2 { margin: 8px 0 6px; font-size: 15px; }
.map-panel h3 { margin: 16px 0 6px; color: var(--fg-secondary); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.map-panel [role="tabpanel"] > h2 { margin-top: 18px; font-size: 13px; }
.map-intro { color: #c5cad0; font-size: 13px; }
.map-help, .map-empty, .map-source { color: var(--fg-secondary); font-size: 12.5px; }
.map-source { margin-top: 8px; font-size: 12px; }
.map-kicker { margin: 0; color: var(--fg-secondary); font-size: 12px; font-weight: 600; }
.map-territories { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.map-territories button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid transparent; border-radius: var(--fg-r-chip); color: var(--fg-text); background: transparent; font-size: 13px; text-align: left; }
.map-territories button:hover { background: var(--fg-raised); }
.map-territories button[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-dim); }
.map-territories i { width: 24px; height: 14px; flex: none; border-radius: 4px; background: var(--wash); box-shadow: inset 0 0 0 1.5px var(--ink); }
.map-key { display: grid; gap: 7px; margin: 0; padding: 0; color: #c5cad0; font-size: 12.5px; list-style: none; }
.map-key li { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 10px; }
.map-key i { display: block; height: 16px; }
.key-node { width: 9px; height: 9px !important; margin-left: 12px; border-radius: 50%; background: #e6e9ec; }
.key-flow { position: relative; background: linear-gradient(#c5cad0, #c5cad0) left center / 26px 2px no-repeat; }
.key-flow::after { position: absolute; top: 3px; left: 22px; border: 5px solid transparent; border-left: 8px solid #c5cad0; content: ""; }
.key-side { background: linear-gradient(#8d939a, #8d939a) left 3px / 24px 2px no-repeat, linear-gradient(#8d939a, #8d939a) left 9px / 16px 2px no-repeat; }
.key-alias { width: 16px; height: 16px !important; margin-left: 9px; border: 1.5px dashed #8d939a; border-radius: 50%; }
.key-mito { height: 14px !important; border: 3px double rgb(228 183 80 / 0.7); border-radius: 7px; }
.key-transfer { position: relative; width: 12px; height: 12px !important; margin-left: 11px; border: 1.5px solid #c5cad0; border-radius: 50%; }
.key-transfer::after { position: absolute; top: 2px; left: 3px; width: 3px; height: 3px; border-top: 1.5px solid #c5cad0; border-right: 1.5px solid #c5cad0; transform: rotate(45deg); content: ""; }
.key-process { width: 10px; height: 10px !important; margin-left: 12px; border: 1.5px solid #c5cad0; transform: rotate(45deg); }
.map-structure { display: block; width: auto; max-width: 100%; height: auto; max-height: 170px; margin: 6px 0 10px; }
.map-facts { display: grid; gap: 0; margin: 0; }
.map-facts div { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-top: 1px solid var(--fg-line); }
.map-facts dt { color: var(--fg-secondary); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.map-facts dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.map-note { margin-top: 10px; padding: 8px 10px; border-radius: var(--fg-r-ctl); background: #23262a; font-size: 12.5px; }
.map-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.map-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid #23262a; font-size: 13px; }
.map-list li > span { color: var(--fg-secondary); font-size: 12px; white-space: nowrap; }
.map-list.papers li { display: grid; gap: 2px; }
.map-list.papers li > span { white-space: normal; }
.map-panel button[data-node], .map-panel button[data-rx], .map-panel button[data-pathway], .map-equation button { padding: 0; border: 0; color: var(--accent); background: none; font-weight: 500; text-align: left; text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
.map-panel button[data-node]:hover, .map-panel button[data-rx]:hover, .map-panel button[data-pathway]:hover { color: var(--brand-bright); text-decoration-color: currentColor; }
.map-equation { font-size: 14px; line-height: 1.7; }
.map-equation .side { color: var(--fg-secondary); font-size: 12.5px; }
.map-event { padding: 8px 0; border-top: 1px solid var(--fg-line); }
.map-event h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.map-event p { margin: 2px 0; font-size: 12.5px; }
.map-event .muted { color: var(--fg-secondary); }
.map-event .refs { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
.map-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.map-btn { display: inline-flex; min-height: 30px; align-items: center; padding: 0 11px; border: 1px solid var(--fg-line-strong); border-radius: var(--fg-r-ctl); color: var(--fg-text); background: var(--fg-raised); font-size: 12.5px; font-weight: 500; text-decoration: none; }
.map-btn:hover { border-color: var(--accent); color: var(--fg-text); text-decoration: none; }
.map-pathways { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.map-pathways h3 { margin: 0 0 4px; }
.map-pathways ul { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.map-pathways li li { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.map-pathways li li span { color: var(--fg-secondary); font: 12px var(--fg-mono); }
.map-tree, .map-tree ul { margin: 0; padding-left: 0; list-style: none; }
.map-tree ul { margin-left: 4px; padding-left: 12px; border-left: 1px solid var(--fg-line); }
.map-tree li { padding: 2px 0; font-size: 13px; }
.map-tree summary { cursor: pointer; }

@media (max-width: 900px) {
  .map-app { grid-template-columns: minmax(0, 1fr); }
  .map-panel { position: fixed; right: 0; bottom: 0; left: 0; z-index: 40; max-height: 72svh; border-top: 1px solid var(--fg-line-strong); border-left: 0; border-radius: var(--fg-r-dialog) var(--fg-r-dialog) 0 0; box-shadow: 0 -12px 30px rgb(0 0 0 / 0.5); transform: translateY(calc(100% - 51px)); transition: transform .22s ease; }
  .map-panel.open { transform: translateY(0); }
  .map-panel.peek { max-height: 44svh; transform: translateY(0); }
  .map-sheet-toggle { position: sticky; top: 0; z-index: 3; display: block; width: 100%; height: 50px; border: 0; color: var(--fg-text); background: var(--fg-surface); font-size: 13px; font-weight: 600; }
  .map-sheet-toggle::before { display: block; width: 36px; height: 4px; margin: 0 auto 7px; border-radius: 4px; background: var(--fg-line-strong); content: ""; }
  .map-tabs { top: 50px; }
  .map-zoom output { display: none; }
  .map-toolbar { top: 8px; right: 8px; left: 8px; }
  .map-search { width: 100%; }
  .map-zoom { margin-left: 0; }
}

/* records under the map */
.atlas-records { max-width: var(--max); margin: 0 auto; padding: 16px var(--gutter) 24px; }
.atlas-records .crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; color: var(--fg-muted); font-size: 12px; }
.atlas-records .crumbs span[aria-hidden] { color: var(--fg-line-strong); }
.records-head { max-width: 860px; margin-bottom: 12px; }
.records-head p { color: var(--fg-secondary); }
.record-card { max-width: 980px; padding: 16px 18px; border: 1px solid var(--fg-line); border-radius: var(--fg-r-panel); background: var(--fg-surface); }
.record-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 0; margin: 0; padding: 0; overflow: hidden; border: 1px solid var(--fg-line); border-radius: var(--fg-r-panel); background: var(--fg-surface); list-style: none; }
.record-list li { border-right: 1px solid var(--fg-line); border-bottom: 1px solid var(--fg-line); margin: 0 -1px -1px 0; }
.record-list a { display: grid; gap: 2px; padding: 9px 14px; color: var(--fg-text); text-decoration: none; }
.record-list a:hover { background: var(--fg-raised); }
.record-list a:hover strong { color: var(--accent); }
.record-list strong { font-weight: 600; }
.record-list span { color: var(--fg-secondary); font-size: 12.5px; overflow-wrap: anywhere; }
.territory-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: var(--fg-gap); }
.territory { padding: 12px 14px 14px; border: 1px solid var(--fg-line); border-top: 2px solid var(--terr-ink, var(--fg-line-strong)); border-radius: var(--fg-r-panel); background: var(--fg-surface); }
.territory h3 { font-size: 14px; }
.territory h3 a { color: var(--terr-ink, var(--fg-text)); text-decoration: none; }
.territory h3 a:hover { text-decoration: underline; }
.territory p { color: var(--fg-secondary); font-size: 13px; }
.territory ul { margin: 0; padding-left: 1.1em; font-size: 13px; }
.atlas-archive { margin-top: 14px; color: var(--fg-secondary); font-size: 12.5px; }
.reaction-record h3 { margin: 16px 0 6px; color: var(--fg-secondary); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.reaction-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 0 24px; }
.participant-list, .catalyst-list { margin: 0; padding: 0; list-style: none; }
.participant-list li, .catalyst-list li { display: grid; gap: 1px; padding: 6px 0 7px; border-top: 1px solid var(--fg-line); }
.participant-list small, .catalyst-list small, .citation-list small { color: var(--fg-secondary); font-size: 12px; overflow-wrap: anywhere; }
.citation-list { display: grid; gap: 6px; margin: 0; padding-left: 1.4em; }
.more-note { color: var(--fg-secondary); font-size: 12.5px; }
.territory-carbohydrate-core { --terr-ink: #a0bcff; } .territory-sugar-branches-glycans { --terr-ink: #86c5fa; } .territory-central-energy { --terr-ink: #f0ad7e; }
.territory-metabolic-integration { --terr-ink: #d9ba70; } .territory-fatty-acid-flow { --terr-ink: #f7a693; } .territory-complex-lipids { --terr-ink: #f2a3c1; }
.territory-lipid-mediators { --terr-ink: #cbaef3; } .territory-amino-acid-carbon { --terr-ink: #b3b6fd; } .territory-nitrogen-one-carbon { --terr-ink: #dbb970; }
.territory-nucleotides { --terr-ink: #8cc3fc; } .territory-vitamins-cofactors { --terr-ink: #e2b572; } .territory-heme-oxidations { --terr-ink: #f8a59c; }
