/* =========================================================
   Styles for the 3D world page (index.html)
   ========================================================= */

/* ===== COLOURS AND FONTS ===== */
:root {
  --bg: #070b14;
  --surface: rgba(10, 16, 28, 0.92);
  --border: #1d2a40;
  --text: #d8e4f0;
  --muted: #7f8ea6;
  --accent: #39f5c2;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ===== PAGE BASICS ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  -webkit-user-select: none; user-select: none;
}

/* ===== 3D CANVAS (fills the whole screen) ===== */
#world {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none;
  cursor: crosshair;
  touch-action: none;   /* stop the page scrolling/zooming while dragging on the world */
}

/* ===== BOOT SCREEN ===== */
#intro {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background:
    repeating-linear-gradient(0deg, rgba(57,245,194,.03) 0 1px, transparent 1px 3px),
    radial-gradient(circle at 50% 40%, #0f1b2e 0%, #070b14 70%);
  transition: opacity .6s ease;
}
#intro.gone { opacity: 0; pointer-events: none; }
.intro-box { text-align: center; padding: 24px; max-width: 100%; }
/* --- Boot screen: typed-out start-up messages --- */
#boot {
  font-family: var(--mono); font-size: .8rem; color: var(--muted);
  text-align: left; display: inline-block; min-height: 6.5em; margin-bottom: 18px;
  white-space: pre-wrap;
}
/* --- Boot screen: name heading with blinking cursor --- */
.intro-box h1 {
  font-family: var(--mono); font-size: clamp(2rem, 7vw, 4rem); font-weight: 800; letter-spacing: -1px;
}
.intro-box h1 span { color: var(--accent); text-shadow: 0 0 18px rgba(57,245,194,.5); }
.cursor { font-style: normal; color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.intro-box p { color: var(--muted); margin-top: 8px; }
.intro-box .small { font-family: var(--mono); font-size: .85rem; margin-top: 26px; }
/* --- Boot screen: Start button and 2D link --- */
#startBtn {
  margin-top: 14px; padding: 14px 34px; font-size: 1.05rem; font-weight: 700;
  font-family: var(--mono); color: #04110d; background: var(--accent);
  border: none; border-radius: 8px; cursor: pointer;
  box-shadow: 0 0 24px rgba(57,245,194,.35);
  transition: transform .15s, opacity .2s;
}
#startBtn:hover:not(:disabled) { transform: translateY(-2px); }
#startBtn:disabled { opacity: .35; cursor: default; box-shadow: none; }
.skip { display: block; margin-top: 18px; color: var(--muted); font-size: .9rem; text-decoration: none; }
.skip:hover { color: var(--accent); }

/* ===== HUD (name tag and 3D/2D switch at the top) ===== */
#hud {
  position: fixed; top: 16px; left: 16px; right: 16px; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none;
}
.hud-name {
  font-family: var(--mono); font-weight: 700; color: var(--accent); font-size: 1rem;
  background: var(--surface); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 8px;
}
.hud-btn {
  pointer-events: auto; text-decoration: none; font-weight: 600; font-size: .9rem;
  background: var(--surface); color: var(--text); padding: 9px 16px;
  border-radius: 8px; border: 1px solid var(--border);
}
.hud-btn:hover { border-color: var(--accent); color: var(--accent); }

/* --- 3D / 2D switch --- */
.view-switch {
  pointer-events: auto; display: flex; padding: 3px; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  font-family: var(--mono); font-weight: 700; font-size: .85rem;
}
.view-switch a {
  padding: 6px 14px; border-radius: 999px; color: var(--muted); text-decoration: none;
  transition: background .2s, color .2s;
}
.view-switch a:hover { color: var(--accent); }
.view-switch a.on { background: var(--accent); color: #04110d; }

/* ===== CONTROLS HINT BAR (bottom of screen) ===== */
#hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  padding: 10px 18px; border-radius: 10px; font-size: .82rem; font-family: var(--mono);
  max-width: calc(100% - 32px);
}
#hint b { color: var(--accent); }

/* ===== ZONE POPUP PANEL ===== */
#panel {
  position: fixed; bottom: 112px; left: 50%; z-index: 10;
  transform: translate(-50%, 0);
  width: min(360px, calc(100% - 32px));
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: 12px; padding: 20px 22px; text-align: center;
  box-shadow: 0 0 40px rgba(57,245,194,.18), 0 20px 50px rgba(0,0,0,.5);
  transition: opacity .25s, transform .25s;
}
#panel.hidden { opacity: 0; pointer-events: none; transform: translate(-50%, 12px); }
#panel h2 { font-family: var(--mono); font-size: 1.3rem; color: var(--accent); }
#panel h2::before { content: "> "; color: var(--muted); }
#panel p { color: var(--muted); margin: 8px 0 16px; font-size: .95rem; line-height: 1.5; }
#panelBtn {
  display: inline-block; padding: 10px 22px; border-radius: 8px;
  background: var(--accent); color: #04110d; font-weight: 700; text-decoration: none;
  font-family: var(--mono);
}
kbd {
  font-family: var(--mono); font-size: .72rem; background: rgba(0,0,0,.2);
  padding: 2px 6px; border-radius: 4px; margin-left: 6px;
}

/* ===== TOUCH CONTROLS (phones and tablets only) ===== */
#touch, #touchHint { display: none; }

/* --- Joystick: appears where you put your finger down --- */
#joystick {
  position: fixed; z-index: 7; left: 0; top: 0;
  width: 120px; height: 120px; margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 2px solid rgba(57,245,194,.6);
  background: radial-gradient(circle, rgba(57,245,194,.12), rgba(7,11,20,.35));
  pointer-events: none; opacity: 0; transition: opacity .15s;
}
#joystick.on { opacity: 1; }
#joystick .knob {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 20px rgba(57,245,194,.6);
}

@media (hover: none) and (pointer: coarse) {
  /* --- Jump button (bottom right) --- */
  #touch { display: block; position: fixed; bottom: 22px; right: 16px; z-index: 6; }
  #touch button {
    width: 72px; height: 72px; border-radius: 50%;
    border: 2px solid rgba(57,245,194,.7); background: rgba(7,11,20,.75);
    color: var(--accent); font-size: 1.4rem; line-height: 1; touch-action: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  }
  #touch button span { font-family: var(--mono); font-size: .6rem; font-weight: 700; }
  #touch button.on { background: var(--accent); color: #04110d; }

  /* --- Touch hint: fades away once you start moving --- */
  #touchHint {
    display: block; position: fixed; bottom: 34px; left: 16px; right: 104px; z-index: 5;
    font-family: var(--mono); font-size: .78rem; color: var(--muted);
    background: var(--surface); border: 1px solid var(--border);
    padding: 10px 12px; border-radius: 10px; pointer-events: none;
    transition: opacity .6s;
  }
  #touchHint.gone { opacity: 0; }
  #hint { display: none; }
  #panel { bottom: 104px; }
  #panel kbd { display: none; }
}

/* ===== NO-JAVASCRIPT MESSAGE ===== */
.noscript {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text); z-index: 30;
}
.noscript a { color: var(--accent); margin-left: 6px; }
