/* atlas.css — the research map page. Loads after tabloid.css and uses its
   colours and faces: white paper, near-black ink, red, pink tint, Archivo
   condensed for heads and labels, PP Neue Montreal Text for running text.
   Brutalist rules: square corners, 3px ink frames, hard offset shadows with
   no blur, opaque fills only. */

.atlas-page { background: var(--paper); color: var(--ink); }
.atlas { --frame: 3px; --drop: 8px; padding: 0 var(--gut) 72px; }
:where(.atlas) button { font: inherit; color: inherit; cursor: pointer; border-radius: 0; }
.atlas :focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* Intro */
.atlas__intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: end; padding: 48px 0 40px; }
.atlas__h { margin: 0; font-family: var(--cond); font-weight: 900; font-stretch: 62%; font-variation-settings: "wdth" 62; text-transform: uppercase; font-size: clamp(64px, 9vw, 150px); line-height: .82; letter-spacing: -.01em; }
.atlas__lede { margin: 0; max-width: 54ch; font-family: var(--serif); font-size: clamp(18px, 1.55vw, 24px); line-height: 1.38; }

/* Stage */
.atlas__stage { position: relative; }
.atlas__controls { position: absolute; z-index: 3; top: 16px; right: 16px; display: flex; gap: 10px; }
.atlas__controls button,
.cross button { background: var(--paper); border: var(--frame) solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 6px 14px; font-family: var(--cond); font-weight: 800; font-stretch: 87%; font-variation-settings: "wdth" 87; font-size: 17px; line-height: 1.1; transition: transform .1s ease, box-shadow .1s ease, background-color .1s ease, color .1s ease; }
.atlas__controls button:hover,
.cross button:hover { background: var(--blue); color: #fff; transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.atlas__controls button:active,
.cross button:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.atlas__controls #out, .atlas__controls #in { min-width: 44px; font-size: 22px; padding: 2px 10px; }

#viewport { position: relative; overflow: hidden; touch-action: none; height: clamp(560px, 66vw, 960px); border: var(--frame) solid var(--ink); box-shadow: var(--drop) var(--drop) 0 var(--ink); background: var(--paper); cursor: grab; }
#viewport.drag { cursor: grabbing; }
#game { position: absolute; inset: 0; }
#game canvas { position: absolute; inset: 0; display: block; width: 100% !important; height: 100% !important; }
#labels { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; pointer-events: none; }

/* Labels. In the map the slab is drawn by Phaser; the button is the text
   and the hit area, and it moves with the slab when it lifts or presses. */
.mark { position: absolute; pointer-events: auto; display: flex; align-items: center; margin: 0; padding: 0 22px; border: 0; background: transparent; text-align: left; color: var(--ink); overflow-wrap: normal; hyphens: none; will-change: transform; }
.mark--field { font-family: var(--cond); font-weight: 700; font-stretch: 87%; font-variation-settings: "wdth" 87; font-size: 22px; line-height: 1.02; }
.mark--concept { font-family: var(--cond); font-weight: 900; font-stretch: 62%; font-variation-settings: "wdth" 62; text-transform: uppercase; font-size: 36px; line-height: .9; color: #fff; }
.mark.is-active { color: #fff; }
.mark.is-near { color: var(--ink); }
.mark.is-dim { color: var(--muted); }
.mark:focus-visible { outline: 4px solid var(--blue); outline-offset: 6px; }

/* Flat fallback: Phaser did not load. The buttons become CSS slabs in a grid. */
#viewport.is-flat { height: auto; cursor: auto; padding: 24px; touch-action: auto; }
#viewport.is-flat #game { display: none; }
#viewport.is-flat #labels { position: static; width: auto; height: auto; transform: none !important; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
#viewport.is-flat .mark { position: static; transform: none !important; width: auto !important; height: auto !important; min-height: 72px; padding: 12px 18px; background: var(--paper); border: var(--frame) solid var(--ink); box-shadow: 6px 6px 0 var(--ink); }
#viewport.is-flat .mark--concept { order: -1; background: var(--ink); box-shadow: 6px 6px 0 var(--blue); }
#viewport.is-flat .mark.is-active { background: var(--blue); }
#viewport.is-flat .mark.is-near { background: var(--blue-tint); color: var(--ink); }
#viewport.is-flat .mark.is-dim { opacity: .5; }
.atlas-page.is-flat .atlas__controls { display: none; }

/* Reading panel */
.atlas__reading { padding: 64px 0 0; scroll-margin-top: 16px; }
.reading__head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 40px; align-items: start; padding-bottom: 36px; }
.reading__head h2 { margin: 0; font-family: var(--cond); font-weight: 900; font-stretch: 62%; font-variation-settings: "wdth" 62; text-transform: uppercase; font-size: clamp(48px, 6vw, 104px); line-height: .84; letter-spacing: -.01em; }
#context { font-family: var(--serif); font-size: clamp(18px, 1.4vw, 22px); line-height: 1.42; }
#context p { margin: 0 0 12px; max-width: 62ch; }
#context a { text-decoration-color: var(--blue); text-decoration-thickness: 3px; text-underline-offset: 4px; }
#context a:hover { color: var(--blue); }

#sources { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 26px; }
.source { background: var(--paper); border: var(--frame) solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 18px 20px 20px; transition: transform .1s ease, box-shadow .1s ease; }
.source:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--blue); }
.source a { font-family: var(--cond); font-weight: 800; font-stretch: 87%; font-variation-settings: "wdth" 87; font-size: 25px; line-height: 1.04; text-decoration: none; }
.source a:hover { color: var(--blue); }
.source time { display: block; margin-top: 8px; font-family: "Azeret Mono", ui-monospace, Menlo, monospace; font-size: 13px; color: var(--muted); }
.source p { margin: 10px 0 0; max-width: 60ch; font-family: var(--serif); font-size: 17px; line-height: 1.45; }
.cross { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 14px 16px; padding-top: 18px; }

@media (max-width: 760px) {
  .atlas__intro, .reading__head { grid-template-columns: 1fr; gap: 18px; }
  .atlas__intro { padding: 32px 0 28px; }
  #viewport { height: 620px; box-shadow: 6px 6px 0 var(--ink); }
  .atlas__controls { top: 10px; right: 10px; gap: 8px; }
  #sources { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .atlas__controls button, .cross button, .source { transition: none; }
}
