/* ------------------------------------------------------------------
   ATL-2026 board world. Every visible rule here is scoped to
   html.mode-3d (set by assets/world/main.js after the first frame),
   so the classic page is untouched when the 3D view is off.
   ------------------------------------------------------------------ */

#world-root { display: none; }
.world-hud { display: none; }
.world-close { display: none; }
/* the Map button exists for the 3D view only */
html:not(.mode-3d) #map-toggle { display: none !important; }

@media screen {
  html.mode-3d,
  html.mode-3d body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
  html.mode-3d body { background: #06130e; }

  html.mode-3d #world-root {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1;
  }
  html.mode-3d #world {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
  }
  /* soft shade on the side where the card opens, so the card reads well */
  html.mode-3d.card-open #world-root::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(6, 19, 14, 0) 38%, rgba(6, 19, 14, .55));
    animation: world-fade .4s ease both;
  }

  html.mode-3d .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
  }
  /* Once the map is ready (nav.js sets html.has-map and un-hides #map-toggle) it
     replaces the section links; until then the links keep working. Below 960px
     the bar then has one row instead of two. */
  html.mode-3d.has-map .topbar .nav { display: none; }
  html.mode-3d #map-toggle:not([hidden]) {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    font: 500 13px/1 "IBM Plex Mono", ui-monospace, Consolas, monospace;
    letter-spacing: .04em;
    color: #f4f2e9;
    background: #0f271e;
    border: 1px solid rgba(224, 169, 74, .6);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color .18s, background-color .18s;
  }
  html.mode-3d #map-toggle:hover { background: #16362a; border-color: #e0a94a; }
  @media (max-width: 959px) {
    html.mode-3d.has-map { --topbar-h: 53px; }
  }
  /* phones: Map, the view toggle and CV need the room; the brand keeps its chip
     icon (the link's aria-label still names it) */
  @media (max-width: 439px) {
    html.mode-3d.has-map .topbar .mark > span { display: none; }
  }
  html.mode-3d body > footer,
  html.mode-3d .foot { display: none; }

  /* main becomes a click-through overlay; only the open card is shown */
  html.mode-3d #content {
    position: fixed;
    inset: 0;
    z-index: 30;
    margin: 0;
    padding: 0;
    width: auto;
    max-width: none;
    background: none;
    transform: none;
    pointer-events: none;
  }
  html.mode-3d #content > * { display: none; }
  /* While About is not open as a card, its name heading and role line stay in the
     accessibility tree (visually hidden), so screen readers do not meet an empty
     <main> without an h1. Nothing focusable is kept. */
  html.mode-3d #content > #about:not(.is-open) {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  html.mode-3d #about:not(.is-open) .hero-fig,
  html.mode-3d #about:not(.is-open) .hero-copy > :not(h1):not(.role) { display: none; }
  html.mode-3d #content .is-path { display: contents !important; }
  html.mode-3d #content .is-path::before,
  html.mode-3d #content .is-path::after { display: none !important; }
  html.mode-3d #content .is-path > :not(.is-path):not(.is-open) { display: none !important; }

  html.mode-3d #content .is-open {
    display: block !important;
    position: fixed;
    z-index: 35;
    top: calc(var(--topbar-h, 62px) + 14px);
    right: 18px;
    width: min(660px, calc(100vw - 36px));
    max-height: calc(100vh - var(--topbar-h, 62px) - 32px);
    max-height: calc(100dvh - var(--topbar-h, 62px) - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0;
    padding: 24px 28px 30px;
    box-sizing: border-box;
    pointer-events: auto;
    color: #c6d0c8;
    background: rgba(10, 28, 21, .96);
    border: 1px solid rgba(224, 169, 74, .6);
    border-radius: 16px;
    box-shadow: 0 26px 70px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 212, 130, .1);
    opacity: 1;
    visibility: visible !important;
    transform: none;
    scrollbar-width: thin;
    scrollbar-color: #8f6c2c transparent;
    animation: world-card-in .38s cubic-bezier(.2, .8, .2, 1) both;
  }
  html.mode-3d #content .is-open::before,
  html.mode-3d #content .is-open::after { display: none !important; }
  html.mode-3d #content .is-open:focus { outline: none; }
  html.mode-3d #content .is-open:focus-visible { outline: 2px solid #ffd482; outline-offset: 3px; }

  /* close button injected by the world */
  html.mode-3d #content .is-open > .world-close {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    float: right;
    z-index: 3;
    min-height: 40px;
    margin: -6px -10px 10px 14px;
    padding: 0 14px 0 8px;
    font: 600 14px/1 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    color: #f4f2e9;
    background: #16362a;
    border: 1px solid rgba(244, 242, 233, .3);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color .18s, border-color .18s;
  }
  html.mode-3d #content .is-open > .world-close:hover { background: #1d4a38; border-color: #e0a94a; }
  html.mode-3d #content .is-open > .world-close:focus-visible { outline: 2px solid #f4f2e9; outline-offset: 2px; }
  .world-close-key {
    padding: 5px 7px;
    font: 500 11px/1 "IBM Plex Mono", ui-monospace, Consolas, monospace;
    letter-spacing: .06em;
    color: #ffd482;
    border: 1px solid rgba(224, 169, 74, .6);
    border-radius: 999px;
  }
  /* touch-only devices have no Esc key */
  @media (hover: none) and (pointer: coarse) {
    html.mode-3d #content .is-open > .world-close { padding-left: 14px; }
    .world-close-key { display: none; }
  }

  /* ---------------- HUD ---------------- */
  html.mode-3d .world-hud {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 32;
    pointer-events: none;
    font: 500 12px/1.2 "IBM Plex Mono", ui-monospace, Consolas, monospace;
    color: #c6d0c8;
  }
  .wh-keys {
    position: absolute;
    left: 18px;
    bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    max-width: calc(100vw - 240px);
    padding: 9px 14px;
    background: rgba(6, 19, 14, .74);
    border: 1px solid rgba(244, 242, 233, .14);
    border-radius: 12px;
    letter-spacing: .04em;
  }
  .wh-keys span { white-space: nowrap; }
  .wh-keys kbd {
    display: inline-grid;
    place-items: center;
    min-width: 21px;
    height: 21px;
    margin-right: 3px;
    padding: 0 5px;
    font: 600 11px/1 "IBM Plex Mono", ui-monospace, Consolas, monospace;
    color: #f4f2e9;
    border: 1px solid rgba(244, 242, 233, .38);
    border-bottom-width: 2px;
    border-radius: 5px;
  }
  .wh-map {
    position: absolute;
    right: 16px;
    bottom: 16px;
    padding: 6px 6px 5px;
    pointer-events: auto;
    background: rgba(6, 19, 14, .74);
    border: 1px solid rgba(244, 242, 233, .14);
    border-radius: 12px;
  }
  .wh-map canvas { display: block; border-radius: 6px; cursor: pointer; }
  .wh-map-cap {
    display: block;
    margin-top: 5px;
    font-size: 10px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #93a69b;
  }
  .wh-prompt {
    position: absolute;
    left: 50%;
    bottom: 30px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    max-width: calc(100vw - 32px);
    padding: 6px 22px 6px 7px;
    transform: translateX(-50%);
    pointer-events: auto;
    font: 700 16px/1.15 "Archivo", "Arial Narrow", Arial, sans-serif;
    font-stretch: 112%;
    color: #1a1204;
    background: #e0a94a;
    border: 0;
    border-radius: 999px;
    box-shadow: 0 0 0 6px rgba(224, 169, 74, .2), 0 12px 32px rgba(0, 0, 0, .45);
    cursor: pointer;
    animation: world-pop .32s cubic-bezier(.2, .9, .3, 1.3) both;
  }
  .wh-prompt[hidden] { display: none; }
  .wh-prompt:hover { background: #ffd482; }
  .wh-prompt-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wh-prompt-key {
    flex: none;
    padding: 9px 12px;
    font: 600 12px/1 "IBM Plex Mono", ui-monospace, Consolas, monospace;
    letter-spacing: .06em;
    color: #ffd482;
    background: #1a1204;
    border-radius: 999px;
  }
  .wh-stick {
    display: none;
    position: absolute;
    left: 20px;
    bottom: 24px;
    width: 128px;
    height: 128px;
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
    border: 2px solid rgba(244, 242, 233, .3);
    background: radial-gradient(circle, rgba(224, 169, 74, .14), rgba(6, 19, 14, .6) 70%);
  }
  .wh-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 54px;
    height: 54px;
    margin: -27px 0 0 -27px;
    border-radius: 50%;
    background: #e0a94a;
    box-shadow: 0 0 0 6px rgba(224, 169, 74, .22), 0 6px 16px rgba(0, 0, 0, .4);
    transition: transform .14s ease-out;
  }
  .wh-stick.is-held .wh-knob { transition: none; background: #ffd482; }
  .wh-toast {
    position: absolute;
    left: 50%;
    top: calc(var(--topbar-h, 62px) + 18px);
    max-width: calc(100vw - 32px);
    padding: 10px 16px;
    transform: translateX(-50%);
    font: 600 13px/1.35 "IBM Plex Mono", ui-monospace, Consolas, monospace;
    letter-spacing: .04em;
    text-align: center;
    color: #ff9a76;
    background: rgba(6, 19, 14, .92);
    border: 1px dashed rgba(255, 154, 118, .7);
    border-radius: 10px;
  }
  .wh-toast.is-in { animation: world-pop .3s ease both; }
  .wh-toast[hidden] { display: none; }

  .world-hud.is-touch .wh-keys { display: none; }
  @media (max-width: 1180px) { .world-hud.has-prompt .wh-keys { display: none; } }
  .world-hud.is-touch .wh-stick { display: block; }
  .world-hud.card-open .wh-prompt,
  .world-hud.card-open .wh-stick,
  .world-hud.card-open .wh-keys,
  .world-hud.card-open .wh-map { display: none; }

  /* phones: bottom sheet card, map in the top right corner */
  @media (max-width: 759px) {
    html.mode-3d #content .is-open {
      top: auto;
      left: 8px;
      right: 8px;
      bottom: 8px;
      width: auto;
      max-height: 70vh;
      max-height: 70dvh;
      padding: 18px 18px 26px;
      border-radius: 18px;
      animation-name: world-sheet-in;
    }
    html.mode-3d.card-open #world-root::after {
      background: linear-gradient(180deg, rgba(6, 19, 14, 0) 20%, rgba(6, 19, 14, .6));
    }
    /* touch only: the joystick owns the bottom left. In a narrow desktop window the
       map stays at the bottom so it does not cover the name row. */
    .world-hud.is-touch .wh-map { top: calc(var(--topbar-h, 56px) + 10px); bottom: auto; right: 10px; padding: 4px; }
    .wh-map { padding: 4px; }
    .wh-map-cap { display: none; }
    .wh-keys { display: none; }
    .wh-prompt { bottom: 172px; font-size: 15px; }
    .world-hud:not(.is-touch) .wh-prompt { bottom: 24px; }
  }

  /* <feature:sea> (component sea, assets/world/sea.js) */
  /* "Lost at sea" hint: shown when the rover is far out in the heap; a click or
     tap does the same as R (back to the start) */
  html.mode-3d .sea-hint {
    position: absolute;
    left: 50%;
    bottom: 92px;
    display: inline-flex;
    align-items: center;
    max-width: calc(100vw - 32px);
    min-height: 44px;
    padding: 8px 18px;
    transform: translateX(-50%);
    pointer-events: auto;
    font: 600 13px/1.3 "IBM Plex Mono", ui-monospace, Consolas, monospace;
    letter-spacing: .04em;
    color: #62e6a4;
    background: rgba(6, 19, 14, .9);
    border: 1px solid rgba(98, 230, 164, .5);
    border-radius: 999px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .4);
    cursor: pointer;
    animation: world-pop .3s ease both;
  }
  html.mode-3d .sea-hint:hover { border-color: #62e6a4; }
  html.mode-3d .sea-hint[hidden],
  html.mode-3d .world-hud.card-open .sea-hint { display: none; }
  html.mode-3d.map-open .sea-hint { visibility: hidden; }
  html.mode-3d .sea-hint kbd {
    display: inline-grid;
    place-items: center;
    min-width: 21px;
    height: 21px;
    margin: 0 2px;
    padding: 0 5px;
    font: 600 11px/1 "IBM Plex Mono", ui-monospace, Consolas, monospace;
    color: #f4f2e9;
    border: 1px solid rgba(244, 242, 233, .38);
    border-bottom-width: 2px;
    border-radius: 5px;
  }
  html.mode-3d .sea-hint-touch,
  html.mode-3d .world-hud.is-touch .sea-hint-keys { display: none; }
  html.mode-3d .world-hud.is-touch .sea-hint-touch { display: inline; }
  @media (max-width: 759px) {
    html.mode-3d .sea-hint { bottom: 24px; }
    html.mode-3d .world-hud.is-touch .sea-hint { bottom: 172px; }
  }
  @media (prefers-reduced-motion: reduce) {
    html.mode-3d .sea-hint { animation: none; }
  }
  /* </feature:sea> */

  @keyframes world-card-in { from { opacity: 0; transform: translateX(24px) scale(.98); } }
  @keyframes world-sheet-in { from { opacity: 0; transform: translateY(40px); } }
  @keyframes world-pop { from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(.94); } }
  @keyframes world-fade { from { opacity: 0; } }

  @media (prefers-reduced-motion: reduce) {
    html.mode-3d #content .is-open,
    .wh-prompt,
    .wh-toast.is-in,
    html.mode-3d.card-open #world-root::after { animation: none; }
  }
}
