/* "Full-moon night on the Chao Phraya": deep-navy glass panels with a fine gold hairline, Thai serif display type,
   candle-gold accent. Layout: brand top-left, clock top-right, stats card under the brand, Thai MOOC card
   bottom-left, a floating dock bottom-centre with the main action in the middle. Single dark theme by design
   (the scene is always night-lit). */
:root {
  color-scheme: dark;
  --bg: #070d1f;
  --ink: #f4efe3;
  --ink-soft: #b9c0d2;
  --ink-faint: #8a93aa;
  --glass: linear-gradient(160deg, rgba(22, 32, 66, 0.78), rgba(9, 15, 36, 0.72));
  --glass-solid: #111a36;
  --hair: rgba(243, 197, 107, 0.26);
  --line: rgba(255, 255, 255, 0.12);
  --gold: #f3c56b;
  --gold-2: #ffdf9b;
  --gold-deep: #c8902e;
  --gold-ink: #1d1404;
  --live: #4ee38a;
  --danger: #ff9b8a;
  --font-display: "Noto Serif Thai", "Noto Serif", Georgia, serif;
  --font-body: "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --r-card: 12px;   /* one corner radius for every card, panel and bar */
  --r-btn: 8px;     /* buttons inside them */
  --r-lg: var(--r-card);
  --r-md: var(--r-card);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); overflow: hidden; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
[hidden] { display: none !important; }
svg { width: 1em; height: 1em; flex: none; }

.glass {
  background: var(--glass); border: 1px solid var(--hair); border-radius: var(--r-lg);
  box-shadow: var(--shadow); backdrop-filter: blur(12px) saturate(1.2); -webkit-backdrop-filter: blur(12px) saturate(1.2);
}

button {
  font: 600 14px/1 var(--font-body); color: var(--ink); cursor: pointer;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: var(--r-btn);
  padding: 10px 15px; min-height: 40px; transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
button:hover { border-color: var(--gold); background: rgba(243, 197, 107, 0.1); }
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
button:disabled { opacity: 0.55; cursor: default; }
.primary, button.primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, var(--gold-deep)); color: var(--gold-ink); border-color: var(--gold-2);
  box-shadow: 0 0 28px rgba(243, 197, 107, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ---------- top: brand + clock ---------- */
.hud-top { position: fixed; top: 14px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none; z-index: 2; }
.hud-top > .clock { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7); }
.brand-mark {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: var(--gold-2);
  background: radial-gradient(circle at 50% 40%, rgba(243, 197, 107, 0.28), rgba(243, 197, 107, 0.04) 70%); border: 1px solid var(--hair);
  box-shadow: 0 0 24px rgba(243, 197, 107, 0.25);
}
.brand-mark svg { width: 30px; height: 30px; }
h1 { font-family: var(--font-display); font-size: clamp(21px, 2.8vw, 30px); margin: 0; line-height: 1.2; letter-spacing: 0.01em;
  background: linear-gradient(180deg, #fff6df, var(--gold) 120%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.85)); }   /* stays readable over the moon */
.brand-sub { margin: 3px 0 0; font-size: 13px; color: var(--ink-soft); }

.clock { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: var(--r-card); }
.clock-icon { width: 16px; height: 16px; color: var(--gold-2); }
.clock-label { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 15px; }
.clock input { width: clamp(90px, 16vw, 190px); accent-color: var(--gold); }
.clock button { min-height: 32px; padding: 7px 12px; font-size: 13px; }

/* ---------- stats card ---------- */
.stats { position: fixed; top: 84px; left: 16px; z-index: 1; padding: 14px 16px 12px; display: grid; gap: 10px; width: 236px; box-sizing: border-box; }
.stat { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.stat + .stat { border-top: 1px solid var(--line); padding-top: 9px; }
.stat-label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-soft); }
.stat-label svg { width: 15px; height: 15px; color: var(--gold); }
.stat-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-num b { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--ink); }
.stat-num small { font-size: 12px; color: var(--ink-faint); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-faint); display: inline-block; }
.live-dot.on { background: var(--live); box-shadow: 0 0 0 0 rgba(78, 227, 138, 0.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(78, 227, 138, 0.55); } 70% { box-shadow: 0 0 0 8px rgba(78, 227, 138, 0); } 100% { box-shadow: 0 0 0 0 rgba(78, 227, 138, 0); } }
.stat-note { margin: 0; font-size: 12px; color: var(--ink-faint); line-height: 1.4; }
.stat-note:empty { display: none; }

/* ---------- Thai MOOC card ---------- */
.promo { position: fixed; left: 16px; bottom: calc(18px + var(--safe-b)); z-index: 1; width: 276px; box-sizing: border-box; padding: 16px 18px 18px; overflow: hidden; }
.promo::before { content: ""; position: absolute; right: -40px; top: -40px; width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 238, 200, 0.35), rgba(255, 238, 200, 0) 70%); pointer-events: none; }
.promo-kicker { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.promo h2 { font-family: var(--font-display); font-size: 19px; line-height: 1.4; margin: 6px 0 6px; font-weight: 600; }
.promo h2 span { color: var(--gold-2); }
.promo-text { margin: 0 0 12px; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.promo-cta { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; font-size: 14px; color: var(--gold-ink);
  padding: 10px 16px; border-radius: var(--r-btn); background: linear-gradient(180deg, var(--gold-2), var(--gold) 60%, var(--gold-deep)); box-shadow: 0 4px 18px rgba(243, 197, 107, 0.35); }
.promo-cta:hover { filter: brightness(1.06); }
.promo-close { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; min-height: 30px; padding: 0; font-size: 17px; line-height: 1; background: transparent; border-color: transparent; color: var(--ink-faint); }

/* ---------- dock ---------- */
.dock { position: fixed; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.dock-bar { display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: var(--r-card); }
.dock-btn { display: inline-flex; align-items: center; gap: 7px; background: transparent; border-color: transparent; padding: 10px 14px; }
.dock-btn svg { width: 18px; height: 18px; color: var(--gold-2); }
.dock-btn[aria-pressed="true"] svg { color: var(--gold-ink); }
.dock-main { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; padding: 12px 22px; min-height: 48px; margin: 0 4px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, var(--gold-deep)); color: var(--gold-ink); border-color: var(--gold-2);
  box-shadow: 0 0 28px rgba(243, 197, 107, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.dock-main svg { width: 22px; height: 22px; }
.dock-main:hover { background: linear-gradient(180deg, #fff0c4, var(--gold-2) 55%, var(--gold)); }
.views { padding: 12px; width: min(420px, calc(100vw - 24px)); box-sizing: border-box; }
.views-title { margin: 0 0 8px 4px; font-size: 12px; color: var(--ink-faint); letter-spacing: 0.06em; }
.views-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.views-grid button { font-size: 13px; padding: 9px 8px; min-height: 38px; border-radius: var(--r-btn); }

/* ---------- walk mode ---------- */
.walk-hud { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.walk-hud > * { pointer-events: auto; }
.walk-hint { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); margin: 0; font-size: 13px; color: var(--ink-soft); background: var(--glass-solid); border: 1px solid var(--hair); padding: 7px 14px; border-radius: var(--r-card); white-space: nowrap; pointer-events: none !important; }
.kb { font-weight: 600; }
.touch { display: none; }
@media (pointer: coarse) { .kb { display: none; } .touch { display: inline; } }
.stick { position: fixed; left: 24px; bottom: calc(100px + var(--safe-b)); width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--hair); touch-action: none; display: none; }
@media (pointer: coarse) { .stick { display: block; } }
.knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(243, 197, 107, 0.75); }
#btn-walk-exit { position: fixed; right: 16px; bottom: calc(100px + var(--safe-b)); background: var(--glass-solid); border-color: var(--hair); }
body.walking .stats, body.walking .promo { display: none; }

/* ---------- labels, cards, dialog, toast ---------- */
.own-label { position: fixed; left: 0; top: 0; transform: translate(-50%, -100%); font-size: 12px; font-weight: 600; color: var(--gold-ink); background: var(--gold); padding: 4px 10px; border-radius: 999px; pointer-events: none; white-space: nowrap; box-shadow: 0 0 16px rgba(243, 197, 107, 0.5); }
.own-label::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--gold); }

.card { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); width: min(360px, calc(100vw - 32px)); box-sizing: border-box; z-index: 3;
  background: var(--glass-solid); border: 1px solid var(--hair); border-radius: var(--r-lg); padding: 16px 44px 16px 18px; box-shadow: var(--shadow); }
.card p { margin: 0; }
.card-kind { font-size: 12px; color: var(--gold); font-weight: 600; letter-spacing: 0.04em; }
.card-name { font-weight: 600; margin-top: 4px !important; }
.card-wish { margin-top: 6px !important; font-family: var(--font-display); font-size: 17px; line-height: 1.55; overflow-wrap: anywhere; }
.card-close { position: absolute; top: 8px; right: 8px; min-height: 30px; width: 30px; padding: 0; font-size: 18px; background: transparent; border-color: transparent; }

dialog { border: 1px solid var(--hair); border-radius: var(--r-card); background: var(--glass-solid); color: var(--ink); padding: 0; width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(3, 6, 16, 0.62); backdrop-filter: blur(3px); }
form { padding: 20px 20px 18px; display: flex; flex-direction: column; gap: 6px; }
h2 { font-family: var(--font-display); margin: 0 0 6px; font-size: 22px; }
fieldset { border: 0; padding: 0; margin: 0 0 6px; }
legend, label { font-size: 14px; color: var(--ink-soft); padding: 0; margin-top: 4px; }
.design-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 6px; }
.design { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); font-size: 12px; text-align: center; line-height: 1.3; cursor: pointer; color: var(--ink); position: relative; }
.design:has(input:checked) { border-color: var(--gold); background: rgba(243, 197, 107, 0.14); box-shadow: 0 0 18px rgba(243, 197, 107, 0.2); }
.design:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
.design input { position: absolute; opacity: 0; pointer-events: none; }
.design canvas { width: 56px; height: 44px; }
input[type="text"], input:not([type]), textarea { font: 16px/1.5 var(--font-body); color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: none; }
.hint { margin: 2px 0 0; font-size: 12px; color: var(--ink-faint); }
.form-err { margin: 4px 0 0; color: var(--danger); font-size: 14px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.toast { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 4; background: var(--glass-solid); border: 1px solid var(--hair); padding: 10px 18px; border-radius: var(--r-card); font-size: 14px; max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--shadow); }
.err { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--bg); z-index: 9; }

/* ---------- narrow screens ---------- */
@media (max-width: 1100px) {
  .promo { bottom: calc(92px + var(--safe-b)); }      /* above the dock, which reaches it on medium widths */
  body.views-open .promo { display: none; }           /* the view menu needs that space */
}
@media (max-width: 820px) {
  .promo { width: 250px; }
}
@media (max-width: 640px) {
  .hud-top { flex-direction: column; gap: 10px; top: 10px; left: 12px; right: 12px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand-mark svg { width: 24px; height: 24px; }
  .brand-sub { display: none; }                       /* keeps the header to one line above the clock */
  .clock { align-self: stretch; }
  .clock input { flex: 1; width: auto; }
  /* stats become one slim row under the clock */
  .stats { top: 122px; left: 12px; right: 12px; width: auto; grid-template-columns: repeat(3, 1fr); gap: 0; padding: 8px 6px; border-radius: var(--r-md); }
  .stat { flex-direction: column; align-items: center; gap: 2px; text-align: center; }
  .stat + .stat { border-top: 0; padding-top: 0; border-left: 1px solid var(--line); }
  .stat-label { font-size: 11px; gap: 5px; }
  .stat-num b { font-size: 19px; }
  .stat-note { grid-column: 1 / -1; text-align: center; margin-top: 4px; }
  /* the Thai MOOC card becomes a slim banner above the dock */
  .promo { left: 12px; right: 12px; width: auto; bottom: calc(86px + var(--safe-b)); padding: 10px 40px 10px 14px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; border-radius: var(--r-md); }
  .promo::before, .promo-text { display: none; }
  .promo-kicker { grid-column: 1; }
  .promo h2 { grid-column: 1; font-size: 14px; margin: 0; }
  .promo h2 br { display: none; }
  .promo h2 span::before { content: " · "; color: var(--ink-faint); }
  .promo-cta { grid-column: 2; grid-row: 1 / span 2; padding: 8px 12px; font-size: 13px; }
  .dock { left: 12px; right: 12px; transform: none; }
  .dock-bar { width: 100%; justify-content: space-between; box-sizing: border-box; }
  .dock-btn { flex-direction: column; gap: 3px; padding: 6px 6px; font-size: 11px; min-height: 46px; }
  .dock-btn svg { width: 20px; height: 20px; }
  .dock-main { padding: 10px 16px; font-size: 15px; margin: 0; }
  .card { bottom: calc(150px + var(--safe-b)); }
  .walk-hint { top: 170px; }
}
@media (prefers-reduced-motion: reduce) { .live-dot.on { animation: none; } button { transition: none; } }
