/* The 3D campus: the view fills the window; everything else floats on it in
   Wilkipedia's own look (Newsreader titles, ink, Wilcox gold, white cards). */

@font-face {
  font-family: 'Newsreader';
  src: url('../assets/fonts/Newsreader.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --ink: #111; --paper: #fff; --card: #fbfbf8; --muted: #5e5e5a; --rule: #e4e2da;
  --gold: #f5c400; --accent: #806200;
  --serif: 'Newsreader', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 6px 20px rgba(0,0,0,.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1322; color: var(--ink); font-family: var(--sans); }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; outline: none; }

/* ── top bar ── */
.bar { position: fixed; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 10px; pointer-events: none; z-index: 5; }
.bar > * { pointer-events: auto; }
.back, .title, .tools button {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow);
  height: 40px; display: inline-flex; align-items: center; padding: 0 14px; color: var(--ink); text-decoration: none; font: 500 14px var(--sans);
}
.back:hover, .tools button:hover { border-color: #c9c6bb; }
.title { font: 500 19px var(--serif); gap: 10px; }
.title .w { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; background: var(--gold); font: 700 14px var(--serif); }
.tools { margin-left: auto; display: flex; gap: 8px; position: relative; }
.tools button { cursor: pointer; gap: 6px; }
.tools button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tools kbd { font: 600 11px var(--sans); color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px; }
.tools button[aria-pressed="true"] kbd { color: #bbb; border-color: #444; }
#qmenu { position: absolute; top: 46px; right: 50px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 220px; }
#qmenu button { all: unset; cursor: pointer; padding: 8px 10px; border-radius: 6px; font: 14px var(--sans); }
#qmenu button small { display: block; color: var(--muted); font-size: 12px; }
#qmenu button:hover { background: #f3f1ea; }
#qmenu button[aria-pressed="true"] { background: #fff4c7; }

/* ── minimap ── */
#minimap { position: fixed; left: 12px; bottom: 12px; width: 190px; height: 190px; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--paper); box-shadow: var(--shadow), 0 0 0 1px var(--rule); cursor: pointer; z-index: 4; background: #eceae3; }
#minimap canvas { width: 100%; height: 100%; display: block; }
#minimap .n { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); font: 700 12px var(--serif); background: var(--paper); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; box-shadow: 0 0 0 1px var(--rule); }

/* ── centre ── */
#crosshair { position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px var(--ink); z-index: 3; display: none; }
body[data-locked="1"] #crosshair { display: block; }
/* key hints along the bottom, and the name of where you are, as in a game */
#keys { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px;
  background: rgba(255,255,255,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid rgba(0,0,0,.06);
  border-radius: 10px; padding: 6px 12px; font: 12px var(--sans); color: #3b3b38; z-index: 3; max-width: calc(100vw - 440px); }
#keys span { white-space: nowrap; cursor: default; }
#keys span:has(kbd:not(:empty)) { cursor: pointer; }
#keys kbd { font: 600 11px var(--sans); background: #fff; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; margin-right: 5px; color: var(--ink); }
body[data-mode="fly"] #keys span:nth-child(2), body[data-mode="fly"] #keys span:nth-child(3) { display: none; }
#place { position: fixed; top: 62px; left: 12px; background: rgba(255,255,255,.86); border: 1px solid rgba(0,0,0,.06); border-radius: 8px;
  padding: 5px 11px; font: 500 15px var(--serif); z-index: 3; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
#place:empty { display: none; }
#place.in { animation: placeIn .5s ease-out; }
@keyframes placeIn { from { opacity: 0; transform: translateY(-4px); } }
#credit { position: fixed; right: 10px; bottom: 6px; font: 10px var(--sans); color: rgba(255, 255, 255, 0.55); text-decoration: none; }
#credit:hover { color: #fff; text-decoration: underline; }
body.hide-ui .bar, body.hide-ui #minimap, body.hide-ui #keys, body.hide-ui #place, body.hide-ui #tip, body.hide-ui #toast, body.hide-ui #crosshair { display: none !important; }
#tip { position: fixed; left: 50%; top: calc(50% + 26px); transform: translateX(-50%); background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow); padding: 7px 12px; font: 14px var(--sans); z-index: 3; pointer-events: none; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
#tip b { font: 600 17px var(--serif); }
#tip span { color: var(--muted); }
#tip kbd { font: 600 11px var(--sans); background: var(--gold); border-radius: 4px; padding: 2px 6px; }
#toast { position: fixed; left: 50%; top: 66px; transform: translate(-50%, -8px); opacity: 0; transition: .25s; background: var(--ink); color: #fff; padding: 9px 14px; border-radius: var(--r); font: 14px var(--sans); z-index: 6; max-width: min(560px, calc(100vw - 32px)); text-align: center; pointer-events: none; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── room card ── */
#room-card { position: fixed; right: 12px; bottom: 12px; width: min(360px, calc(100vw - 24px)); background: var(--paper); border: 1px solid var(--rule); border-radius: 14px; box-shadow: var(--shadow); padding: 18px 20px 16px; z-index: 6; }
#room-card h2 { font: 500 34px/1.05 var(--serif); margin: 4px 0 8px; }
#room-card .rc-k { font: 600 11px var(--sans); letter-spacing: .04em; color: var(--accent); }
#room-card p { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.45; }
#room-card .rc-a { margin: 0; }
.btn { display: inline-flex; align-items: center; background: var(--gold); color: var(--ink); border-radius: 8px; padding: 9px 14px; font: 600 14px var(--sans); text-decoration: none; }
.btn:hover { filter: brightness(.96); }
.x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font: 26px/1 var(--sans); color: var(--muted); cursor: pointer; padding: 4px 8px; }

/* ── big map ── */
#bigmap, #help { position: fixed; inset: 0; background: rgba(17,17,17,.45); z-index: 8; display: grid; place-items: center; padding: 16px; }
#bigmap[hidden], #help[hidden] { display: none; }
.sheet { position: relative; background: var(--paper); border-radius: 16px; box-shadow: var(--shadow); width: min(1100px, 100%); padding: 16px; }
.sheet h2 { font: 500 26px var(--serif); margin: 0 0 4px; }
.sheet p.meta { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
#bigmap canvas { width: 100%; height: min(70vh, 640px); display: block; border-radius: 10px; background: #eceae3; cursor: crosshair; }
#room-form { display: flex; gap: 8px; margin: 0 0 12px; }
#room-form input { flex: 1; max-width: 260px; font: 15px var(--sans); padding: 8px 12px; border: 1px solid var(--rule); border-radius: 8px; text-transform: uppercase; }
#room-form button { border: 0; background: var(--ink); color: #fff; border-radius: 8px; padding: 0 14px; font: 600 14px var(--sans); cursor: pointer; }
#help .sheet { width: min(560px, 100%); }
#help dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 12px 0 4px; font-size: 14px; }
#help dt { font-weight: 600; }
#help dd { margin: 0; color: var(--muted); }
#help kbd { font: 600 12px var(--sans); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; background: var(--card); color: var(--ink); }

/* ── loader ── */
#loader { position: fixed; inset: 0; z-index: 20; background: #faf8f2; display: grid; place-items: center; transition: opacity .6s; }
#loader.done { opacity: 0; pointer-events: none; }
.load-in { width: min(420px, calc(100vw - 48px)); }
.load-in .kicker { font: 600 12px var(--sans); letter-spacing: .06em; color: var(--accent); margin: 0 0 6px; }
.load-in h1 { font: 500 44px/1.05 var(--serif); margin: 0 0 10px; }
.load-in p { color: var(--muted); margin: 0 0 22px; line-height: 1.5; }
.track { height: 6px; border-radius: 3px; background: #ece8dc; overflow: hidden; }
#load-bar { height: 100%; background: var(--gold); transform-origin: left; transform: scaleX(0); transition: transform .3s; }
#load-msg { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 1.2em; }
#load-msg a { color: var(--accent); }

.back, .tools button { white-space: nowrap; }
@media (max-width: 640px) {
  .title { display: none; }
  .bar { gap: 6px; left: 8px; right: 8px; top: 8px; }
  .back, .tools button { padding: 0 9px; font-size: 12.5px; height: 36px; }
  #btn-help { display: none; }
  .back .long, .tools kbd { display: none; }
  .tools { gap: 6px; }
  #minimap { width: 120px; height: 120px; left: 8px; bottom: 8px; }
  #qmenu { right: 0; }
  #room-card { bottom: 12px; }
  #keys { display: none; }
  #place { top: 54px; left: 8px; font-size: 14px; }
}
@media (pointer: coarse) {
  #keys { display: none; }
}
