/* Academy research pages (draft): rule cards, the research maps, plan cards and the calculator. On top of site.css,
   with its tokens. The Academy-level scale (--g0..--g9) is one blue ramp, light to dark in the light scheme and dark
   to light in the dark one, each step with the text colour that reads on it; the number is printed on the step too,
   so the colour never carries the level alone. */
:root {
  --g0: #86b6ef; --g1: #6da7ec; --g2: #5598e7; --g3: #3987e5; --g4: #2975d1; --g5: #256abf; --g6: #1c5cab; --g7: #184f95; --g8: #104281; --g9: #0d366b;
  --gt0: #0b1a2c; --gt1: #0b1a2c; --gt2: #0b1a2c; --gt3: #0b1a2c; --gt4: #fff; --gt5: #fff; --gt6: #fff; --gt7: #fff; --gt8: #fff; --gt9: #fff;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --g0: #184f95; --g1: #1c5cab; --g2: #256abf; --g3: #2975d1; --g4: #3987e5; --g5: #5598e7; --g6: #6da7ec; --g7: #86b6ef; --g8: #9ec5f4; --g9: #b7d3f6;
  --gt0: #fff; --gt1: #fff; --gt2: #fff; --gt3: #fff; --gt4: #0b1a2c; --gt5: #0b1a2c; --gt6: #0b1a2c; --gt7: #0b1a2c; --gt8: #0b1a2c; --gt9: #0b1a2c } }
:root[data-theme="dark"] {
  --g0: #184f95; --g1: #1c5cab; --g2: #256abf; --g3: #2975d1; --g4: #3987e5; --g5: #5598e7; --g6: #6da7ec; --g7: #86b6ef; --g8: #9ec5f4; --g9: #b7d3f6;
  --gt0: #fff; --gt1: #fff; --gt2: #fff; --gt3: #fff; --gt4: #0b1a2c; --gt5: #0b1a2c; --gt6: #0b1a2c; --gt7: #0b1a2c; --gt8: #0b1a2c; --gt9: #0b1a2c }
.g0 { --gc: var(--g0); --gtc: var(--gt0) } .g1 { --gc: var(--g1); --gtc: var(--gt1) } .g2 { --gc: var(--g2); --gtc: var(--gt2) }
.g3 { --gc: var(--g3); --gtc: var(--gt3) } .g4 { --gc: var(--g4); --gtc: var(--gt4) } .g5 { --gc: var(--g5); --gtc: var(--gt5) }
.g6 { --gc: var(--g6); --gtc: var(--gt6) } .g7 { --gc: var(--g7); --gtc: var(--gt7) } .g8 { --gc: var(--g8); --gtc: var(--gt8) }
.g9 { --gc: var(--g9); --gtc: var(--gt9) }

.acpage, .acsec { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0 }
.acpage { gap: 30px }
.acsec { scroll-margin-top: 72px }
.acsec h2 { margin-top: 2px }
.acrules { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 12px }
.acrule { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 7px; align-content: start; font-size: 14px }
.acrule h3 { font: 400 17px/1.25 var(--display) }
.acrule ul { margin: 0; padding-left: 1.1em; display: grid; gap: 4px }
.actab { font: 400 18px var(--display); margin: 6px 0 -4px }
#acTabs table tr.mark td { background: var(--accent-soft) }
#acTabs .acopen { text-align: left; min-height: 32px; font-weight: 600 }
#acTabs td, #acTabs th { vertical-align: middle }

/* Controls row above the map */
.acbar { align-items: end }
.acbar select { min-height: 40px; max-width: min(100%, 280px) }
.acfind { position: relative }
.acfind input { width: min(260px, 100%); min-height: 40px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px }
.acfind > label { font-weight: 600 }
.acfound { position: absolute; top: calc(100% + 4px); left: 0; z-index: 15; width: min(340px, calc(100vw - 48px)); background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--accent); border-radius: var(--r); box-shadow: 0 12px 30px rgba(0,0,0,.22); padding: 4px; display: grid; gap: 2px }
.acfound[hidden] { display: none }
.acfound button { display: grid; gap: 0; justify-items: start; text-align: left; border: 0; min-height: 40px; padding: 5px 9px; color: var(--ink); background: transparent }
.acfound button:hover, .acfound button:focus-visible { background: var(--sunk) }
.acfound small { color: var(--muted); font-size: 12px; font-weight: 400 }
.acfound p { padding: 8px; color: var(--muted); font-size: 13px }
.aczoom { display: inline-flex; gap: 6px }
.aczoom button { min-width: 44px; min-height: 40px; justify-content: center; font-size: 19px; line-height: 1; padding: 0 10px }
.aczoom button:disabled { opacity: .4; cursor: default }
.aclegend { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; color: var(--muted) }
#acLegend { display: inline-flex; flex-wrap: wrap; gap: 3px }
.acgate { font-family: var(--body); display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 4px; border-radius: 4px; background: var(--gc); color: var(--gtc); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums }

/* The map: a scrolling canvas, arrows underneath, research buttons on top. */
.acmapwrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start }
@media (min-width: 1180px) { .acmapwrap { grid-template-columns: minmax(0, 1fr) 360px } .acdetail { position: sticky; top: 76px; max-height: calc(100dvh - 92px); overflow: auto } }
.acmap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--sunk); overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; min-height: 120px; max-height: 70vh }
.acm-canvas { position: relative }
.acm-edges { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible }
.acm-edges path { fill: none; stroke: var(--muted); stroke-width: 1.4; opacity: .65 }
.acm-edges path.later { stroke-dasharray: 5 4 }
.acm-edges path.on { stroke: var(--accent); stroke-width: 2.4; opacity: 1 }
.acm-edges marker path { fill: var(--muted); stroke: none; opacity: 1 }
.acm-edges #acArrOn path { fill: var(--accent) }
.acn { position: absolute; display: grid; grid-template-columns: calc(19px * var(--z)) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 0;
  padding: 0; margin: 0; min-height: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); text-align: left;
  overflow: hidden; font-size: calc(11.5px * var(--z)); font-weight: 500; line-height: 1.15; box-shadow: 0 1px 2px rgba(0,0,0,.08); align-items: stretch }
.acn:hover { border-color: var(--accent) }
.acn-g { grid-row: 1 / span 2; display: grid; place-items: center; background: var(--gc); color: var(--gtc); font-size: .82em; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em }
.acn-t { padding: calc(3px * var(--z)) calc(5px * var(--z)) 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; hyphens: auto }
.acn-b { padding: 0 calc(5px * var(--z)) calc(3px * var(--z)); font-size: .86em; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.acn-x { color: var(--gold); font-weight: 700 }
.acn.sel { outline: 3px solid var(--accent); outline-offset: 1px; z-index: 2 }
.acn.hit { box-shadow: 0 0 0 4px var(--gold); z-index: 3 }
.acn.goal { border: 2px solid var(--accent) }
.acn.req { border: 2px dashed var(--accent) }
.acn.have { background: var(--accent-soft) }
.acn.full .acn-b, .acn.goal .acn-b, .acn.req .acn-b { color: var(--accent); font-weight: 700 }
@media (prefers-reduced-motion: no-preference) { .acn { transition: box-shadow .2s, border-color .15s } }

/* The detail panel */
.acdetail { display: grid; gap: 10px; min-width: 0; font-size: 14px; align-content: start }
.acdh { display: flex; gap: 8px; align-items: center; font: 400 19px/1.2 var(--display) }
.acdk { color: var(--muted); font-size: 13px }
.acdk b { color: var(--ink); font-weight: 600 }
table.aclv { font-size: 12.5px }
table.aclv th, table.aclv td { padding: 5px 6px; vertical-align: middle }
table.aclv th { white-space: normal }
table.aclv tr.acreq td { border-top: 0; padding: 0 6px 6px 1.6em; font-size: 12px; white-space: normal }
table.aclv tr:has(+ tr.acreq) td { border-bottom: 0 }
table.aclv td.aclvn { white-space: nowrap }
table.aclv td.aclvn .acgate { height: 18px; font-size: 11px; margin-left: 4px }
table.aclv td.odd { color: var(--gold); white-space: normal; min-width: 6em }
table.aclv tr.had td { background: var(--accent-soft) }
table.aclv tr.plan td { background: var(--gold-soft) }
table.aclv tfoot th, table.aclv tfoot td { border-top: 2px solid var(--line); background: var(--sunk); color: var(--ink); font-size: 12.5px; text-align: left }
table.aclv tfoot td.n { text-align: right }
table.aclv tfoot tr.all th, table.aclv tfoot tr.all td { border-top: 1px solid var(--line); font-weight: 400 }
table.aclv tfoot tr.all b { font-weight: 600 }
.acsumcur { display: block; font-size: 11px; color: var(--muted); font-weight: 400 }
.acjump { display: inline; white-space: normal; border: 0; background: none; padding: 2px 0; min-height: 0; color: var(--accent); text-decoration: underline; font-size: inherit; font-weight: 500; text-align: left }
@media (pointer: coarse) { .acjump { display: inline-flex; min-height: 40px; align-items: center } }

/* Plan cards */
.acplans { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 14px }
.acplan { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 10px; align-content: start; min-width: 0 }
.acplan h3 { font: 400 18px var(--display) }
.acpstats { grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr)); gap: 8px }
.acpstats .stat { padding: 8px 10px; background: var(--bg) }
.acpstats .stat .v { font-size: 17px }
.acpick { gap: 10px 14px }
.acpick select { min-height: 40px; max-width: 100% }
.acplan .btn, .acdetail .btn { min-height: 40px; border-color: var(--accent); color: var(--accent); font-weight: 600 }

/* The calculator */
.acinputs input[type="number"] { width: 7em; min-height: 40px }
.acstats { position: static }
@media (min-width: 700px) { .acstats { position: sticky; top: 60px; z-index: 5; padding: 8px 0; background: var(--bg) } }
.acstats .stats { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 8px }
.acstats .stat { padding: 8px 12px }
.acstats .stat .v { font-size: 19px }
.acstats .stat .k b { color: var(--gold) }
.acgoals td, .acgoals th { vertical-align: middle }
.acgoals input[type="number"] { width: 4.6em; min-height: 36px; padding: 4px 6px }
.acgoals .rm { min-width: 40px; min-height: 40px; justify-content: center; padding: 0 }
.acadd { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end }
.acpresets { display: flex; flex-wrap: wrap; gap: 6px }
.acpresets button, .acadd button, .achave button { min-height: 40px }
.achave { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: end }
.achave select, .acadd select { min-height: 40px }
.ackeys { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); align-items: center }
.ackeys i { display: inline-block; width: 22px; height: 14px; border-radius: 3px; border: 1px solid var(--line); background: var(--surface); vertical-align: -2px; margin-right: 4px }
.ackeys i.goal { border: 2px solid var(--accent) } .ackeys i.req { border: 2px dashed var(--accent) } .ackeys i.have { background: var(--accent-soft) }
.acstepper { display: flex; flex-wrap: wrap; gap: 6px; align-items: center }
.acstepper button { min-width: 44px; min-height: 40px; justify-content: center; padding: 0 10px }
.acstepper input { width: 4.4em; min-height: 40px; text-align: center }
.acstepper .lbl { font-weight: 600; color: var(--muted); font-size: 13px; margin-right: 4px }
#acStepRows td { vertical-align: middle }
#acStepRows input[type="checkbox"] { width: 20px; height: 20px }
#acStepRows td:first-child { width: 2.6em }
#acStepRows td:nth-child(3) { min-width: 11em }
#acStepRows td.n { padding-left: 6px; padding-right: 8px }
#acStepRows label.tick { display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; margin: -8px 0; cursor: pointer }
#acStepRows tr.acup td { background: var(--gold-soft) }
#acStepRows .sub { display: block; font-size: 12px; color: var(--muted) }
#acStepRows tr.speed td:nth-child(3) { font-weight: 600 }
#acAcadBody { display: grid; gap: 10px }
