/* ---------------------------------------------------------------
   AfterHours · styles.css
   ---------------------------------------------------------------
   DOM chrome around the engine canvas: splash, dialog, content
   modal, zoom HUD, walk prompt. The world is drawn on #game by
   the CabinEngine.
   --------------------------------------------------------------- */

:root {
  --navy:  #0D2545;
  --cream: #F5EBD6;
  --gold:  #B8893E;
  --rust:  #A14E36;
  --void:  #b299b4;   /* matches scene.palette.void so edges blend */
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body {
  background: var(--void);
  color: var(--cream);
  font-family: Inter, system-ui, sans-serif;
}

#game {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  height: 100dvh;                 /* track the visible viewport on mobile */
  display: block;
  image-rendering: pixelated;
  touch-action: none;
}

/* --- walk prompt (proximity to interact) ---------------------- */
#walk-prompt {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 400;
  font-family: JetBrains Mono, monospace; font-size: 13px;
  color: #f0e3d2;
  background: rgba(13,37,69,0.82); border: 1px solid var(--gold);
  border-radius: 7px; padding: 9px 14px; backdrop-filter: blur(4px);
}
#walk-prompt kbd {
  background: #51465e; border-radius: 3px; padding: 2px 7px; margin-right: 8px;
  font-family: inherit; font-size: 12px;
}

/* --- hint (controls) ------------------------------------------ */
#hint {
  position: fixed; left: 14px; top: 14px; z-index: 400;
  display: none;
  font-family: JetBrains Mono, monospace; font-size: 11px; color: #e7dfd0;
  background: rgba(13,37,69,0.78); border: 1px solid rgba(245,235,214,.14);
  border-radius: 6px; padding: 8px 11px; backdrop-filter: blur(4px);
}
#hint.is-visible { display: block; }
#hint kbd {
  background: #35435c; border-radius: 3px; padding: 1px 5px; margin: 0 1px;
  font-family: inherit; font-size: 10px;
}

/* --- zoom HUD ------------------------------------------------- */
#zoom-hud {
  position: fixed; right: 14px; bottom: 14px; z-index: 400;
  display: none; flex-direction: column; gap: 6px;
}
#zoom-hud.is-visible { display: flex; }
#zoom-hud button {
  width: 38px; height: 38px;
  border: 1px solid var(--gold); background: rgba(13,37,69,0.8);
  color: var(--cream); font-family: JetBrains Mono, monospace;
  font-size: 20px; line-height: 1; border-radius: 4px; cursor: pointer;
  backdrop-filter: blur(4px); transition: background .12s, transform .08s;
}
#zoom-hud button:hover  { background: rgba(184,137,62,0.3); }
#zoom-hud button:active { transform: scale(0.94); }

/* --- splash --------------------------------------------------- */
#splash {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 90% at 50% 20%, #c3a9c4 0%, var(--void) 70%);
  transition: opacity 0.6s ease; padding: 24px;
}
#splash.is-gone { opacity: 0; pointer-events: none; }
.splash-card { max-width: 440px; text-align: center; }
.splash-portrait {
  width: 112px; height: 112px; image-rendering: pixelated;
  margin-bottom: 18px; filter: drop-shadow(0 8px 18px rgba(0,0,0,0.35));
}
.splash-greeting p { margin: 0 0 12px; font-size: 16px; line-height: 1.6; color: #241530; }
.splash-greeting p:last-child {
  color: #5c3b1f; font-family: JetBrains Mono, monospace; font-size: 14px; margin-top: 18px;
}
.clone-bar {
  height: 6px; width: 240px; margin: 18px auto 0;
  border: 1px solid var(--gold); border-radius: 4px; overflow: hidden;
  opacity: 0; transition: opacity 0.2s;
}
#splash.is-loading .clone-bar { opacity: 1; }
#clone-bar-fill { height: 100%; width: 0; background: var(--gold); }
#load-clone {
  margin-top: 22px; font-family: JetBrains Mono, monospace; font-size: 15px;
  color: var(--navy); background: var(--gold); border: 0; border-radius: 5px;
  padding: 12px 26px; cursor: pointer; transition: transform 0.08s, background 0.12s, opacity 0.2s;
}
#load-clone:hover { background: #cc9c4c; }
#load-clone:active { transform: scale(0.96); }
#splash.is-loading #load-clone { opacity: 0.4; pointer-events: none; }

/* --- dialog box ----------------------------------------------- */
#dialog-root {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8000;
  display: none; justify-content: center; padding: 0 16px 20px; pointer-events: none;
}
#dialog-root.is-open { display: flex; }
.dialog-box {
  pointer-events: auto; position: relative; width: min(640px, 100%);
  background: var(--cream); color: var(--navy);
  border: 2px solid var(--gold); border-radius: 8px;
  padding: 16px 20px 28px; box-shadow: 0 16px 40px rgba(0,0,0,0.45); cursor: pointer;
}
.dialog-speaker { font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 15px; color: var(--rust); margin-bottom: 4px; }
.dialog-text { font-size: 17px; line-height: 1.5; min-height: 1.5em; }
.dialog-box.is-narrator .dialog-text { font-style: italic; color: #3a4a63; }
.dialog-prompt { position: absolute; right: 14px; bottom: 7px; font-family: JetBrains Mono, monospace; font-size: 11px; color: #7a8aa0; }
.dialog-prompt kbd { border: 1px solid rgba(13,37,69,0.3); border-radius: 3px; padding: 0 5px; background: rgba(13,37,69,0.06); font-family: inherit; }

/* --- content modal -------------------------------------------- */
#modal-root {
  position: fixed; inset: 0; z-index: 10000;
  display: none; align-items: center; justify-content: center;
  background: rgba(13,37,69,0.78); backdrop-filter: blur(4px); padding: 24px;
}
#modal-root.is-open { display: flex; }
.modal-panel {
  position: relative; width: min(620px, 100%); max-height: 85vh; overflow-y: auto;
  background: var(--cream); color: var(--navy);
  border: 2px solid var(--gold); border-radius: 6px; padding: 32px 36px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45); line-height: 1.55;
}
.modal-close { position: absolute; top: 10px; right: 14px; background: transparent; border: 0; color: var(--navy); font-size: 28px; line-height: 1; cursor: pointer; padding: 4px 8px; opacity: 0.6; }
.modal-close:hover { opacity: 1; color: var(--rust); }
.modal-title { font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 28px; margin: 0 0 14px; }
.modal-intro { color: #3a4a63; margin-bottom: 20px; }
.modal-sublabel { font-family: JetBrains Mono, monospace; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold); margin: 6px 0 8px; }
.modal-empty { color: #3a4a63; font-style: italic; }
.modal-list { list-style: none; padding: 0; margin: 0; }
.modal-list > li { padding: 14px 0; border-top: 1px solid rgba(13,37,69,0.12); }
.modal-list > li:first-child { border-top: 0; padding-top: 0; }
.modal-item-title { font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 18px; margin-bottom: 4px; }
.modal-item-note { color: #3a4a63; font-size: 15px; }
.modal-item-note p { margin: 0; }
.modal-spotify { width: 100%; height: 152px; border: 0; border-radius: 12px; margin-bottom: 16px; }
.modal-covers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cover-card { text-align: center; }
.cover-card img { width: 100%; height: auto; border-radius: 4px; border: 1px solid var(--gold); image-rendering: pixelated; }
.cover-title { font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 15px; margin-top: 8px; }
.cover-note { color: #3a4a63; font-size: 13px; margin-top: 2px; }
.cover-note p { margin: 0; }
.modal-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-gallery figure { margin: 0; }
.modal-gallery img { width: 100%; height: auto; display: block; border: 3px solid var(--gold); }
.modal-gallery figcaption { font-family: JetBrains Mono, monospace; font-size: 12px; color: #3a4a63; margin-top: 5px; }

@media (max-width: 520px) {
  .modal-covers { grid-template-columns: 1fr 1fr; }
  .modal-gallery { grid-template-columns: 1fr; }
  #hint { font-size: 10px; }
  .modal-panel { padding: 24px 20px; }
  .dialog-text { font-size: 16px; }
}

/* --- touch controls (joystick + interact button) -------------- */
#touch-controls {
  position: fixed; inset: 0; z-index: 500; pointer-events: none;
  display: none;
}
body.is-touch #touch-controls.is-live { display: block; }
/* on touch, the keyboard hint is noise; the zoom HUD moves out of thumb range */
body.is-touch #hint { display: none !important; }
body.is-touch #zoom-hud { top: 14px; right: 14px; bottom: auto; flex-direction: row; }
body.is-touch #zoom-hud button { width: 44px; height: 44px; font-size: 22px; }

#joystick {
  position: absolute; width: 132px; height: 132px; border-radius: 50%;
  background: rgba(13,37,69,0.28); border: 2px solid rgba(245,235,214,0.35);
  pointer-events: none; opacity: 0; transition: opacity 0.12s;
  transform: translate(-50%, -50%);
}
#joystick.is-active { opacity: 1; }
#joystick-thumb {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px;
  margin: -29px 0 0 -29px; border-radius: 50%;
  background: rgba(184,137,62,0.7); border: 2px solid rgba(245,235,214,0.6);
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
#btn-a {
  position: absolute; right: 26px; bottom: 34px; width: 82px; height: 82px;
  border-radius: 50%; pointer-events: auto;
  background: rgba(184,137,62,0.82); border: 3px solid rgba(245,235,214,0.7);
  color: var(--navy); font-family: JetBrains Mono, monospace; font-weight: 600;
  font-size: 15px; letter-spacing: 0.04em;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4); -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s, background 0.12s;
}
#btn-a:active { transform: scale(0.92); background: rgba(204,156,76,0.95); }
#btn-a.is-ready { animation: a-pulse 1.4s ease-in-out infinite; }
@keyframes a-pulse { 0%,100% { box-shadow: 0 6px 16px rgba(0,0,0,0.4); } 50% { box-shadow: 0 6px 22px rgba(184,137,62,0.8); } }

/* the on-screen walk prompt sits higher on touch so the A button doesn't cover it */
body.is-touch #walk-prompt { bottom: 130px; }
