@font-face { font-family: "BVP"; src: url("../assets/fonts/BeVietnamPro-Medium.ttf"); font-weight: 500; }
@font-face { font-family: "BVP"; src: url("../assets/fonts/BeVietnamPro-SemiBold.ttf"); font-weight: 600; }
@font-face { font-family: "BVP"; src: url("../assets/fonts/BeVietnamPro-ExtraBold.ttf"); font-weight: 800; }

/* Colours: every colour of the visit's interface is here (the minimap in ui.js reads --accent and --map-*).
   Triplets ("r g b") are used as rgb(var(--x) / alpha).
   Default: blue + white (owner's client 04/12: young people's organisation, "ưu tiên xanh dương + trắng cho sáng sủa").
   Blue = the company logo's #0260b0. */
:root {
  --bg: #eaf3fd;                 /* behind the 3D */
  --ink: #0b2545;                /* text */
  --ink-soft: #2c4f7c;           /* subtitle */
  --accent: 2 96 176;            /* titles, borders, selected card, minimap rooms */
  --bar-from: #5bb4ff;           /* loading bar gradient start (ends at --accent) */
  --btn-hi: #2d9bf0;             /* main button gradient, top */
  --btn-lo: #0260b0;             /* main button gradient, bottom */
  --on-accent: #ffffff;          /* text on the main button */
  --btn-shadow: 0 8px 24px rgba(2,96,176,.3);
  --glass: 255 255 255;          /* see-through panels over the 3D (place, tools, menu, minimap, hint) */
  --card: #ffffff;               /* help window */
  --chip: #ffffff;               /* character cards */
  --track: rgba(2,96,176,.12);   /* loading bar track */
  /* loading screen: white in the middle, sky blue at the edges (owner 04/12: "màu xanh bầu trời ... sky blue",
     no clouds, "đậm hơn xíu") */
  --load-bg: radial-gradient(ellipse 65% 60% at 50% 45%, #ffffff 0%, #ecf8fe 20%, #b0e0f6 46%, #6cc0ea 72%, #44a7dd 100%);
  --load-glow: radial-gradient(closest-side, rgba(255,255,255,.95), rgba(255,255,255,.55) 45%, rgba(255,255,255,0)); /* breathes */
  --title-glow: 0 2px 14px rgba(2,96,176,.18);
  --logo-shadow: drop-shadow(0 6px 16px rgba(2,60,120,.25));
  --overlay: rgba(6,26,52,.82);  /* behind a window or an enlarged photo */
  --on-overlay: #ffffff;         /* photo caption, lightbox buttons */
  --on-overlay-line: #ffffff;
  --panel-solid: rgba(255,255,255,.96); /* photo edit panel */
  --field: #f3f7fc;
  --field-line: #b9cde6;
  --field-btn: #eaf2fc;
  --map-case: 2 96 176;          /* minimap: display cases, the banner */
  --map-me: 255 136 0;           /* minimap: the visitor and the view cone (orange: the carpets are already red) */
  --map-floor: 255 255 255;      /* minimap: the rooms' floors, the sidewalk */
  --map-wall: 120 170 222;       /* minimap: walls, the kerb */
  --map-carpet: 226 76 76;       /* minimap: the red runners */
  --map-green: 92 172 96;        /* minimap: hedges, pots */
  --map-paving: 236 231 221;     /* minimap: the forecourt */
  --map-road: 150 162 178;       /* minimap: the street */
  --map-gold: 232 178 64;        /* minimap: the statues, the emblem */
  --map-ring: 255 255 255;       /* minimap: the rim round the visitor's dot and the statues */
  --map-shade: 11 37 69;         /* minimap: the visitor dot's shadow */
  --map-label: 44 79 124;        /* minimap: "Lối vào" */
  --map-card: 0 0 0 / .14;       /* minimap: the card's shadow (rgb triplet / alpha) */
}

/* The first look, gold on dark brown: ?theme=vang */
:root[data-theme="vang"] {
  --bg: #0b0b0d;
  --ink: #f4ead8;
  --ink-soft: #e9dcc4;
  --accent: 242 198 109;
  --bar-from: #b8862e;
  --btn-hi: #f6d48a;
  --btn-lo: #d4a24a;
  --on-accent: #1a1206;
  --btn-shadow: 0 8px 24px rgba(212,162,74,.35);
  --glass: 15 10 6;
  --card: #1b140d;
  --chip: rgba(255,255,255,.05);
  --track: rgba(255,255,255,.12);
  --load-bg: radial-gradient(ellipse at center, #2a1a0c 0%, #0b0806 70%);
  --load-glow: none;
  --title-glow: 0 2px 10px rgba(242,198,109,.35);
  --logo-shadow: drop-shadow(0 6px 18px rgba(0,0,0,.5));
  --overlay: rgba(0,0,0,.72);
  --on-overlay: #f4ead8;
  --on-overlay-line: #f2c66d;
  --panel-solid: rgba(20,14,8,.95);
  --field: #0e0a06;
  --field-line: #5a4630;
  --field-btn: #2a1d10;
  --map-case: 255 255 255;
  --map-me: 255 222 138;
  --map-floor: 60 44 28;
  --map-wall: 242 198 109;
  --map-carpet: 200 60 50;
  --map-green: 110 160 90;
  --map-paving: 40 30 20;
  --map-road: 90 80 70;
  --map-gold: 242 198 109;
  --map-ring: 255 240 210;
  --map-shade: 0 0 0;
  --map-label: 242 198 109;
  --map-card: 0 0 0 / .4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: "BVP", system-ui, sans-serif; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button { font: inherit; cursor: pointer; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--load-bg); z-index: 20; transition: opacity .6s; overflow: hidden; }
#loading.done { opacity: 0; pointer-events: none; }
/* the slow motion behind the card: only transform / opacity (cheap while the 3D loads), paused once the visit starts */
#loading::before { content: ""; position: absolute; pointer-events: none; left: 50%; top: 45%; width: 120vmin; height: 120vmin; margin: -60vmin 0 0 -60vmin; background: var(--load-glow); animation: load-breathe 7s ease-in-out infinite alternate; }
#loading.done::before { animation-play-state: paused; }
@keyframes load-breathe { from { transform: scale(.9); opacity: .75; } to { transform: scale(1.1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #loading::before { animation: none; } }
.load-card { position: relative; z-index: 1; text-align: center; width: min(420px, 86vw); }
#load-logo { width: 110px; height: 110px; object-fit: contain; filter: var(--logo-shadow); }
.load-title { margin-top: 14px; font-weight: 800; letter-spacing: .12em; font-size: 26px; color: rgb(var(--accent)); text-shadow: var(--title-glow); }
.load-sub { font-weight: 600; letter-spacing: .08em; font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
.load-bar { margin: 26px auto 10px; height: 4px; background: var(--track); border-radius: 2px; overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--bar-from), rgb(var(--accent))); transition: width .25s; }
#load-text { font-size: 13px; opacity: .8; min-height: 18px; }
#char-pick { margin-top: 20px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
#char-pick .cp-title { width: 100%; font-size: 13px; opacity: .85; }
#char-pick button { width: 118px; padding: 8px 8px 10px; border-radius: 14px; border: 2px solid rgb(var(--accent) / .25); background: var(--chip); color: var(--ink); font-weight: 600; }
#char-pick button.on { border-color: rgb(var(--accent)); background: rgb(var(--accent) / .16); }
#char-pick img { display: block; width: 100%; height: 120px; object-fit: contain; }   /* transparent portraits (tools/portrait_alpha.py) */
#char-pick span { display: block; margin-top: 15px; }
#enter { margin-top: 18px; padding: 12px 28px; border-radius: 999px; border: 1px solid rgb(var(--accent)); color: var(--on-accent); background: linear-gradient(180deg, var(--btn-hi), var(--btn-lo)); font-weight: 800; letter-spacing: .04em; box-shadow: var(--btn-shadow); }
#enter.wait { opacity: .6; }   /* still loading: a tap now enters as soon as it is ready */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
#place { position: absolute; left: 14px; top: 12px; padding: 8px 14px; border-radius: 12px; background: rgb(var(--glass) / .55); backdrop-filter: blur(8px); font-size: 13px; line-height: 1.35; max-width: 60vw; }
#place b { display: block; color: rgb(var(--accent)); font-weight: 800; letter-spacing: .05em; font-size: 12px; text-transform: uppercase; }
#tools { position: absolute; right: 12px; top: 12px; display: flex; gap: 8px; }
#tools button { min-width: 40px; height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid rgb(var(--accent) / .35); color: var(--ink); background: rgb(var(--glass) / .55); backdrop-filter: blur(8px); font-weight: 600; }
#tools button:hover { border-color: rgb(var(--accent)); }
#tour-menu { position: absolute; right: 12px; top: 60px; width: 250px; max-height: 70vh; overflow: auto; border-radius: 14px; background: rgb(var(--glass) / .82); backdrop-filter: blur(10px); padding: 6px; border: 1px solid rgb(var(--accent) / .25); }
#tour-menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-size: 14px; }
#tour-menu button:hover { background: rgb(var(--accent) / .15); }
#minimap { position: absolute; right: 12px; bottom: 12px; width: 220px; height: 190px; border-radius: 22px; background: rgb(var(--glass) / .72); backdrop-filter: blur(10px); border: 2px solid rgb(var(--glass) / .9); box-shadow: 0 8px 22px rgb(var(--map-card)); cursor: pointer; transition: transform .2s ease; transform-origin: 100% 100%; }
#minimap:hover { transform: scale(1.04); }
#hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 8px 14px; border-radius: 999px; background: rgb(var(--glass) / .6); font-size: 13px; opacity: 0; transition: opacity .4s; pointer-events: none; white-space: nowrap; }
#hint.on { opacity: 1; }
#tip { position: absolute; padding: 6px 10px; border-radius: 8px; background: rgb(var(--glass) / .85); font-size: 12px; max-width: 280px; pointer-events: none; transform: translate(14px, 14px); }
#joy { position: absolute; left: 22px; bottom: 26px; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgb(var(--accent) / .45); background: rgb(var(--glass) / .25); touch-action: none; }
#joy i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgb(var(--accent) / .55); }

.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--overlay); }
.modal[hidden] { display: none; }
.modal-card { background: var(--card); border: 1px solid rgb(var(--accent) / .3); border-radius: 16px; padding: 20px 22px; width: min(520px, 92vw); }
.modal-card h3 { margin: 0 0 10px; color: rgb(var(--accent)); }
.modal-card ul { padding-left: 18px; line-height: 1.6; }
.modal .close, .lb-actions button { padding: 9px 18px; border-radius: 999px; border: 1px solid rgb(var(--accent)); background: transparent; color: var(--ink); font-weight: 600; }
#lightbox .lb-actions button { color: var(--on-overlay); border-color: var(--on-overlay-line); }
.lb-card { max-width: 94vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
#lb-img, #lb-video { max-width: 94vw; max-height: 76vh; border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.6); background: #000; }
#lb-cap { max-width: 860px; text-align: center; font-size: 15px; line-height: 1.45; color: var(--on-overlay); }
.lb-actions { display: flex; gap: 10px; }
#lb-video-btn { background: linear-gradient(180deg, var(--btn-hi), var(--btn-lo)) !important; color: var(--on-accent) !important; }

#edit-panel { position: fixed; left: 14px; bottom: 14px; z-index: 25; width: 320px; background: var(--panel-solid); border: 1px solid rgb(var(--accent)); border-radius: 14px; padding: 14px; font-size: 13px; }
#edit-panel img { width: 100%; max-height: 160px; object-fit: contain; background: #000; border-radius: 8px; }
#edit-panel textarea { width: 100%; min-height: 54px; margin-top: 8px; background: var(--field); color: var(--ink); border: 1px solid var(--field-line); border-radius: 8px; padding: 6px; font: inherit; }
#edit-panel .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
#edit-panel button { padding: 7px 12px; border-radius: 8px; border: 1px solid rgb(var(--accent)); background: var(--field-btn); color: var(--ink); }

@media (max-width: 640px) {
  #place { font-size: 12px; max-width: calc(100vw - 210px); padding: 6px 10px; top: max(10px, env(safe-area-inset-top)); }
  #place b { display: none; }
  #tools { gap: 6px; right: 8px; top: max(10px, env(safe-area-inset-top)); }
  #tools button { height: 36px; min-width: 36px; padding: 0 9px; font-size: 13px; }
  #tour-menu { right: 8px; top: 54px; width: min(250px, calc(100vw - 16px)); }
  #minimap { width: 118px; height: 102px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); }
  #joy { left: 16px; bottom: max(20px, env(safe-area-inset-bottom)); }
}
