/* Fonts: Unbounded (headings) and Inter (UI), variable woff2, served by us. Both are OFL. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/unbounded-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/unbounded-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --night: #0B0710;
  --ink: #16101F;
  --line: #2A2135;
  --text: #F5F0FA;
  --muted: #9C8FB0;
  --h0: #3B2BFF;
  --h1: #B517FF;
  --h2: #FF2E88;
  --h3: #FF6A00;
  --h4: #FFD60A;
  --focus: #FFD60A;
  --social: #C23BFF;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Thonburi", sans-serif;
  --font-head: "Unbounded", "Inter", system-ui, "Noto Sans Thai", "Thonburi", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --panel-peek: 168px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--night);
  color: var(--text);
  font: 400 16px/1.45 var(--font-ui);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; }
p { margin: 0; }
a { color: var(--text); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button { font: inherit; color: inherit; cursor: pointer; }
.sub { color: var(--muted); font-size: 0.875rem; }
[hidden] { display: none !important; }

/* Layout: mobile first. The map fills the screen, the panel is a bottom sheet. */
#app { position: fixed; inset: 0; overflow: hidden; }
/* isolation: the markers carry z-index by heat; keep them below the panel and header. */
#map { position: absolute; inset: 0; background: var(--night); isolation: isolate; z-index: 0; }

header.top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 7;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-top) + 8px) 12px 18px;
  background: linear-gradient(var(--night) 35%, rgba(11, 7, 16, 0));
  pointer-events: none;
}
header.top > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-word { font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand-mark { display: block; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.lang { display: flex; gap: 4px; }

.chip, .icon-btn, .pill {
  border: 1px solid var(--line);
  background: var(--ink);
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.8125rem;
  font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--night); border-color: var(--text); }
.icon-btn { width: 36px; padding: 0; font-family: var(--font-head); }
.pill { display: inline-flex; align-items: center; gap: 6px; }
.pill[aria-pressed="true"] { background: var(--h2); color: var(--night); border-color: var(--h2); }
.pill.wide { display: flex; width: 100%; justify-content: center; margin: 8px 0; min-height: 44px; }
.pill.back { margin-bottom: 12px; }
.linklike { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }

.maplibregl-ctrl-top-right { top: calc(var(--safe-top) + 56px); }
/* The attribution sits bottom-left, lifted above the bottom sheet on phones. */
.maplibregl-ctrl-bottom-left { bottom: calc(var(--panel-peek) + 4px); transition: bottom 0.25s ease; z-index: 5; }
#app.sheet-open .maplibregl-ctrl-bottom-left { bottom: calc(min(68dvh, 640px) + 4px); }
.maplibregl-ctrl-attrib { background: rgba(22, 16, 31, 0.85) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--text) !important; }

/* Bottom sheet */
#panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  height: var(--panel-peek);
  background: var(--ink);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column;
  transition: height 0.25s ease;
}
#panel[data-open="true"] { height: min(68dvh, 640px); }
.handle { background: none; border: 0; padding: 10px 0 6px; width: 100%; display: flex; justify-content: center; min-height: 28px; }
.grip { width: 44px; height: 5px; border-radius: 3px; background: var(--muted); }
#panel-body { flex: 1; overflow-y: auto; padding: 0 16px calc(var(--safe-bottom) + 16px); -webkit-overflow-scrolling: touch; }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 10px; }
.list-head .sub { margin-top: 2px; }
.error { background: rgba(255, 46, 136, 0.14); border: 1px solid var(--h2); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }

.venue-list { list-style: none; margin: 0; padding: 0; }
.venue-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  width: 100%; text-align: left;
  background: none; border: 0; border-top: 1px solid var(--line);
  padding: 12px 2px; min-height: 64px;
}
.venue-row:first-child { border-top: 0; }
.row-name { font-weight: 600; overflow-wrap: anywhere; }
.row-meta { grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--muted); font-size: 0.8125rem; }
.row-heat { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 64px; }
.heat-num { font-family: var(--font-head); font-weight: 800; font-size: 1.5rem; line-height: 1; }
.heat-bar { display: block; width: 64px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.heat-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--c, var(--h2)); }
.row-fd { grid-column: 1 / span 2; color: var(--muted); font-size: 0.8125rem; }

.tag {
  display: inline-block; font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.06em;
  border-radius: 6px; padding: 2px 6px; color: var(--muted); border: 1px dashed var(--muted);
  white-space: nowrap;
}
.tag.live { color: var(--night); background: var(--h2); border: 1px solid var(--h2); }
.tag.social { color: var(--night); background: var(--social); border: 1px solid var(--social); }
.tags { display: inline-flex; flex-wrap: nowrap; align-items: center; gap: 4px; flex: 0 0 auto; }

.attrib { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.8125rem; display: grid; gap: 6px; }
.attrib a { color: var(--muted); }

/* Venue view */
#venue-view > * + * { margin-top: 8px; }
#v-name { font-size: 1.4rem; overflow-wrap: anywhere; }
.heat-row { display: flex; align-items: center; gap: 12px; margin-top: 12px !important; }
.heat-row .heat-num { font-size: 2.4rem; }
.heat-row .heat-bar { flex: 1; height: 8px; }
.note { font-size: 0.875rem; color: var(--text); background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.vote { margin-top: 16px !important; }
.vote-q { font-weight: 600; margin-bottom: 8px; }
.vote-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--night); font-weight: 700; font-size: 1rem; padding: 0 12px; }
.btn.fire { background: var(--h3); color: var(--night); border-color: var(--h3); }
.btn.dead { background: var(--night); color: var(--text); border-color: var(--muted); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px !important; }
.links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--night); font-weight: 600; font-size: 0.875rem; text-decoration: none; }

/* Social strip in the venue sheet */
.social-box { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: rgba(194, 59, 255, 0.07); }
.social-box h3 { font-family: var(--font-head); font-size: 0.95rem; }
.social-box .sub { margin-top: 2px; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.thumb { position: relative; flex: 0 0 72px; width: 72px; height: 72px; border-radius: 12px; overflow: hidden; background: var(--line); scroll-snap-align: start; }
.thumb img { display: block; width: 72px; height: 72px; object-fit: cover; }
.thumb .play { position: absolute; right: 4px; bottom: 4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: rgba(11, 7, 16, 0.85); color: var(--text); font-size: 0.6875rem; line-height: 20px; text-align: center; }

/* Toast */
.toast {
  position: absolute; left: 50%; top: calc(var(--safe-top) + 60px); transform: translate(-50%, -8px); z-index: 9;
  max-width: min(92vw, 420px); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--night); font-weight: 600; font-size: 0.9rem; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--h2); }

/* About dialog */
dialog { border: 1px solid var(--line); border-radius: 20px; background: var(--ink); color: var(--text); padding: 0; max-width: min(92vw, 480px); }
dialog::backdrop { background: rgba(11, 7, 16, 0.8); }
.about-card { padding: 20px; display: grid; gap: 12px; }
.about-card .btn { justify-self: start; min-width: 120px; }

/* Map markers: a button wrapper (focusable, labelled) around the dot. */
.marker { width: 0; height: 0; }
.dot {
  --s: 18px;
  position: absolute; left: 0; top: 0;
  width: calc(var(--s) + 20px); height: calc(var(--s) + 20px);
  margin: calc((var(--s) + 20px) / -2) 0 0 calc((var(--s) + 20px) / -2);
  padding: 0; border: 0; background: none; border-radius: 50%;
  display: grid; place-items: center;
}
.dot .core {
  display: block; width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--c, var(--h0));
  border: 2px solid var(--night);
  box-shadow: 0 0 12px var(--c, var(--h0));
  transition: width 0.3s ease, height 0.3s ease, background 0.3s ease;
}
.dot.forecast .core { opacity: 0.55; box-shadow: none; }
.dot.forecast::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  border: 1.5px dashed var(--c, var(--h0)); opacity: 0.8; pointer-events: none;
}
.dot.live::before {
  content: ""; position: absolute; inset: 10px; border-radius: 50%;
  background: var(--c, var(--h2)); opacity: 0; pointer-events: none;
  animation: pulse 2.4s ease-out infinite;
}
.dot.social .core { box-shadow: 0 0 10px var(--social); }
.dot.social::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; border: 1.5px solid var(--social); opacity: 0.9; pointer-events: none; }
.dot.selected .core { border-color: var(--text); }
.dot.selected::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; border: 2px solid var(--text); pointer-events: none; opacity: 1; }
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(2.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .dot.live::before { animation: none; opacity: 0.25; }
  #panel, .toast, .dot .core { transition: none; }
}
.user-dot { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--h0); box-shadow: 0 0 0 6px rgba(59, 43, 255, 0.3); }

/* Desktop: side list plus map. */
@media (min-width: 900px) {
  #app { display: grid; grid-template-columns: 400px 1fr; grid-template-rows: auto 1fr; }
  header.top { position: relative; grid-column: 1; grid-row: 1; background: var(--night); border-bottom: 1px solid var(--line); padding-bottom: 10px; pointer-events: auto; }
  #map { position: relative; grid-column: 2; grid-row: 1 / span 2; }
  #panel { position: relative; grid-column: 1; grid-row: 2; height: auto !important; border-radius: 0; border-top: 0; box-shadow: none; min-height: 0; }
  .handle { display: none; }
  #panel-body { padding-top: 16px; }
  .maplibregl-ctrl-top-right { top: 12px; }
  .maplibregl-ctrl-bottom-left, #app.sheet-open .maplibregl-ctrl-bottom-left { bottom: 0; }
  .toast { left: calc(400px + (100% - 400px) / 2); top: 16px; }
}
