/* ==========================================================================
   RJ Iammarino // World
   Styles for world.html only. Tokens mirror the :root block in style.css so
   the HUD, cards and type read as the same site. Nothing is loaded from the
   network: the font stacks fall back to system faces.
   ========================================================================== */

/* Cross-fade when navigating to and from the main site, where supported. */
@view-transition { navigation: auto; }

:root {
  --bg: #07060d;
  --ink: #ecebf7;
  --muted: #9a97b5;
  --faint: #615e80;
  --line: #24223b;
  --panel: rgba(14, 13, 27, 0.72);
  --panel-solid: #0e0d1b;

  --cyan: #5ef2ff;
  --violet: #9b7bff;
  --magenta: #ff5fd2;
  --amber: #ffb86b;
  --acid: #c8ff5a;
  --accent: var(--cyan);

  --holo: linear-gradient(90deg, var(--cyan), var(--violet), var(--magenta), var(--amber), var(--acid), var(--cyan));

  --display: "Syne", "Instrument Sans", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --hud-h: 40px;
  --gutter: 24px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

::selection { background: var(--magenta); color: #07060d; }
a { color: inherit; }
p, h1, h2 { margin: 0; }

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-family: var(--mono); font-size: 0.92em; line-height: 1.4;
  color: var(--ink);
  border: 1px solid var(--faint);
  background: rgba(7, 6, 13, 0.55);
}

:focus-visible { outline: 1px solid var(--cyan); outline-offset: 2px; }

/* Scanlines over everything, as on the main site. */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 40;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.05) 0 1px, transparent 1px 3px);
  opacity: 0.3;
}

.w-skip {
  position: fixed; left: 12px; top: -60px; z-index: 50;
  padding: 8px 12px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--bg); background: var(--cyan); text-decoration: none;
}
.w-skip:focus { top: 8px; }

/* 1. THE CANVAS ------------------------------------------------------------ */
#world {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  outline: none;
  background:
    radial-gradient(80% 60% at 50% 62%, rgba(155,123,255,.20), transparent 70%),
    linear-gradient(to bottom, #07060d 0%, #120b2a 58%, #07060d 100%);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#world:active { cursor: grabbing; }
#world:focus-visible { outline: 1px solid color-mix(in srgb, var(--cyan) 60%, transparent); outline-offset: -4px; }
:root.locked #world { cursor: none; }

/* 2. HUD ------------------------------------------------------------------- */
.w-hud {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: var(--hud-h);
  display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; gap: 20px;
  padding: 0 var(--gutter);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.w-back {
  display: inline-flex; align-items: center; gap: 8px;
  height: 26px; padding: 0 10px;
  color: var(--ink); text-decoration: none;
  border: 1px solid var(--faint);
  background: rgba(7, 6, 13, 0.4);
  transition: border-color .15s ease, color .15s ease;
}
.w-back:hover { border-color: var(--cyan); color: var(--cyan); }
.w-id { color: var(--ink); }
.w-id b { color: var(--magenta); font-weight: 500; margin: 0 4px; }
.w-bar { position: relative; height: 2px; background: var(--line); }
.w-bar i {
  display: block; height: 100%; width: 100%;
  transform: scaleX(0); transform-origin: left;
  background: var(--holo); background-size: 200% 100%;
  transition: transform .5s ease;
}
/* one tick per place, placed by script; lit once you have been there */
.w-bar b { position: absolute; top: -3px; width: 1px; height: 8px; background: var(--faint); }
.w-bar b.passed { background: var(--ink); }
.w-clock { color: var(--faint); font-variant-numeric: tabular-nums; }
.w-sec { min-width: 17ch; text-align: right; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.w-sec.on { color: var(--ink); }

/* 3. TOOLS ----------------------------------------------------------------- */
.w-tools {
  position: fixed; z-index: 31;
  top: calc(var(--hud-h) + 12px); right: var(--gutter);
  display: flex; gap: 8px; align-items: flex-start;
}
.w-tool {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 9px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--panel);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
  font-variant-numeric: tabular-nums;
}
.w-tool:hover, .w-tool[aria-pressed="true"], .w-go[open] > summary { color: var(--ink); border-color: var(--faint); }
.w-go { position: relative; }
.w-go > summary { list-style: none; }
.w-go > summary::-webkit-details-marker { display: none; }
.w-go ul {
  position: absolute; right: 0; top: 38px;
  width: min(300px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100vh - var(--hud-h) - 80px); overflow: auto;
  margin: 0; padding: 6px; list-style: none;
  background: color-mix(in srgb, var(--panel-solid) 92%, transparent);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
}
.w-go li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px; }
.w-go li + li { border-top: 1px solid var(--line); }
.w-go button, .w-go li a {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  background: none; border: 0; cursor: pointer; text-decoration: none;
}
.w-go button { display: flex; gap: 10px; padding: 9px 8px; color: var(--ink); text-align: left; }
.w-go button i { font-style: normal; color: var(--dot, var(--cyan)); }
.w-go button:hover { background: rgba(155,123,255,.12); }
.w-go li a { padding: 9px 8px; color: var(--faint); }
.w-go li a:hover { color: var(--cyan); }

/* 4. MINIMAP --------------------------------------------------------------- */
.w-map {
  position: fixed; z-index: 29;
  top: calc(var(--hud-h) + 12px); left: var(--gutter);
  width: 132px; height: 132px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  pointer-events: none;
}
.w-map[hidden] { display: none; }

/* 5. ARRIVAL HINT ---------------------------------------------------------- */
.w-hint {
  position: fixed; z-index: 28;
  left: 50%; bottom: calc(26px + var(--safe-b));
  transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 2 * var(--gutter));
  padding: 10px 14px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  line-height: 2;
  text-align: center; color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  pointer-events: none;
  transition: opacity .9s ease, visibility 0s linear 0s;
}
.w-hint i { font-style: normal; color: var(--magenta); margin: 0 6px; }
.w-hint kbd { margin-right: 3px; }
.w-hint-touch { display: none; }
.w-hint.gone { opacity: 0; visibility: hidden; transition: opacity .9s ease, visibility 0s linear .9s; }
/* with a card up, the hint gets out of the way (world.js adds .lift) */
.w-hint.lift { opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility 0s linear .2s; }
@media (pointer: coarse) {
  .w-hint-keys { display: none; }
  .w-hint-touch { display: block; }
}

/* 6. PLACE CARD ------------------------------------------------------------ */
.w-card {
  --accent: var(--cyan);
  position: fixed; z-index: 29;
  left: 50%; bottom: calc(26px + var(--safe-b));
  width: min(460px, calc(100vw - 2 * var(--gutter)));
  transform: translate(-50%, 12px);
  padding: 16px 18px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
  opacity: 0; visibility: hidden;
  transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
}
.w-card::before {
  content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 2px;
  background: var(--holo); background-size: 200% 100%;
}
.w-card.on { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.w-card-tag {
  display: flex; gap: 10px; margin-bottom: 6px;
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}
.w-card-tag i { font-style: normal; color: var(--accent); font-variant-numeric: tabular-nums; }
.w-card h2 {
  margin-bottom: 8px;
  font-family: var(--display); font-size: 24px; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em;
}
.w-card-lines p { color: var(--muted); font-size: 14.5px; line-height: 1.5; text-wrap: pretty; }
.w-card-lines p:first-child { color: var(--ink); }
.w-card-lines p + p { margin-top: 5px; }
.w-card-link {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 14px; padding: 8px 12px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  transition: background .15s ease, border-color .15s ease;
}
.w-card-link:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); }
.w-card-link kbd { color: var(--muted); }
@media (pointer: coarse) { .w-card-link kbd { display: none; } }

/* 7. TOUCH STICK ----------------------------------------------------------- */
.w-stick {
  position: fixed; z-index: 27; left: 0; top: 0;
  width: 116px; height: 116px; margin: -58px 0 0 -58px;
  border: 1px solid color-mix(in srgb, var(--cyan) 45%, transparent);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(94,242,255,.08), transparent 70%);
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
}
.w-stick.on { opacity: 1; }
.w-stick i {
  position: absolute; left: 50%; top: 50%;
  width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%;
  border: 1px solid var(--cyan);
  background: rgba(94,242,255,.16);
}

/* 8. FALLBACK LIST --------------------------------------------------------- */
/* Hidden while the island is running; shown on its own without WebGL or JS. */
.js .w-fallback { display: none; }
.js.no-gl .w-fallback { display: block; }
.w-fallback {
  max-width: 720px; margin: 0 auto;
  padding: calc(var(--hud-h) + 48px) var(--gutter) 64px;
}
.w-fallback h1 {
  font-family: var(--display); font-weight: 800; font-size: clamp(36px, 8vw, 64px); line-height: 1; letter-spacing: -0.03em;
  background: var(--holo); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  width: max-content; max-width: 100%;
}
.w-fb-note { margin: 16px 0 32px; max-width: 56ch; color: var(--muted); }
.w-fb-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; counter-reset: place; }
.w-fb-list li {
  position: relative;
  padding: 18px 20px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.w-fb-list li::before {
  content: attr(data-num) "  " attr(data-label);
  display: block; margin-bottom: 6px; white-space: pre;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--cyan);
}
.w-fb-list h2 { margin-bottom: 8px; font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.w-fb-list p { color: var(--muted); font-size: 15px; }
.w-fb-list p + p { margin-top: 4px; }
.w-fb-list a, .w-fb-back a {
  display: inline-block; margin-top: 12px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--cyan); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--cyan) 45%, transparent);
}
.w-fb-list a:hover, .w-fb-back a:hover { border-bottom-color: var(--cyan); }
.w-fb-back { margin-top: 28px; }

/* Without the island: let the page scroll and drop the world-only chrome. */
html:not(.js), html:not(.js) body, html.no-gl, html.no-gl body { height: auto; }
html:not(.js) body, html.no-gl body { overflow: hidden auto; min-height: 100%; }
html:not(.js) #world, html.no-gl #world,
html:not(.js) .w-tools, html.no-gl .w-tools,
html:not(.js) .w-map, html.no-gl .w-map,
html:not(.js) .w-hint, html.no-gl .w-hint,
html:not(.js) .w-card, html.no-gl .w-card,
html:not(.js) .w-stick, html.no-gl .w-stick,
html:not(.js) .w-clock, html.no-gl .w-clock,
html:not(.js) .w-sec, html.no-gl .w-sec { display: none; }

/* 9. SMALL SCREENS --------------------------------------------------------- */
@media (max-width: 900px) {
  .w-clock { display: none; }
  .w-hud { grid-template-columns: auto auto 1fr auto; }
}

@media (max-width: 560px) {
  :root { --gutter: 12px; }
  .w-id, .w-bar { display: none; }
  .w-hud { grid-template-columns: auto 1fr; gap: 10px; }
  .w-sec { min-width: 0; }
  .w-map { width: 96px; height: 96px; }
  .w-tool { height: 34px; padding: 0 8px; gap: 6px; }
  .w-tool kbd { display: none; }
  .w-card { bottom: calc(12px + var(--safe-b)); padding: 13px 14px 14px; }
  .w-card h2 { font-size: 20px; margin-bottom: 6px; }
  .w-card-lines p { font-size: 13.5px; line-height: 1.45; }
  .w-card-link { margin-top: 10px; padding: 9px 12px; }
  .w-hint { bottom: calc(14px + var(--safe-b)); font-size: 10.5px; line-height: 1.7; }
}

/* short landscape phones: keep the card out of the middle of the view */
@media (max-height: 460px) {
  .w-card { left: auto; right: var(--gutter); bottom: 10px; width: min(360px, 52vw); transform: translate(0, 12px); padding: 10px 12px 12px; }
  .w-card.on { transform: none; }
  .w-card h2 { font-size: 18px; }
  .w-card-lines p + p { display: none; }
  .w-map { width: 84px; height: 84px; }
}

/* 10. REDUCED MOTION ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .w-card, .w-card.on { transition: opacity .15s linear, visibility 0s; }
  .w-card { transform: translate(-50%, 0); }
  .w-bar i { transition: none; }
  .w-hint, .w-hint.gone { transition: opacity .2s linear, visibility 0s linear .2s; }
}
@media (prefers-reduced-motion: reduce) and (max-height: 460px) {
  .w-card { transform: none; }
}
