/* Shrine World UI — cream paper, tinta gelap, satu aksen oranye.
   Token default di :root; theme.js nimpa dengan nilai yang sama (satu sumber). */

@font-face {
  font-family: 'Playfair Display';
  src: url('../../fonts/PlayfairDisplay-VariableFont_wght.ttf') format('truetype');
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: 'Playfair Display';
  src: url('../../fonts/PlayfairDisplay-Italic-VariableFont_wght.ttf') format('truetype');
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}
@font-face { font-family: 'Inter'; src: url('../../fonts/Inter-Regular.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../../fonts/Inter-Medium.otf') format('opentype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../../fonts/Inter-SemiBold.otf') format('opentype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../../fonts/JetBrainsMono-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../../fonts/JetBrainsMono-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../../fonts/JetBrainsMono-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --paper: #F4F1E8;
  --paper-2: #EDE8DC;
  --ink: #23221C;
  --ink-muted: #6B675E;
  --hairline: #D9D3C4;
  --orange: #F54E00;
  --blue: #1D4ED8;
  --blue-muted: #9DB4F0;
  --green: #1E7B34;
  --green-muted: #A8D5B1;
  --red: #C62828;
  --grey: #B8B3A6;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --font-sans: 'Inter', system-ui, sans-serif;

  --hud-h: 64px;
  --hit: 40px;            /* tinggi tombol desktop */
  --panel-w: 360px;
  --radius: 4px;
  --paper-glass: rgba(244, 241, 232, 0.88);
}

/* ---------- Root overlay ---------- */
#ui-root {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;           /* canvas di bawah tetap bisa di-orbit */
  font-family: var(--font-sans);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
#ui-root > * { pointer-events: auto; }
#ui-root *, #ui-root *::before, #ui-root *::after { box-sizing: border-box; }
/* Reset tombol pakai :where biar specificity-nya nol → class di bawah bebas nimpa. */
:where(#ui-root) button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Atom: chip mono (tag gelap kecil) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  white-space: nowrap;
}
.chip--orange { background: var(--orange); border-color: var(--orange); }
.chip--grey   { background: var(--grey);   border-color: var(--grey); color: var(--ink); }
.chip--outline { background: transparent; color: var(--ink); border-color: var(--hairline); }
/* Chip warna pop ruang/karakter (Gen Z office). --pop di-set elemen induk; fallback oranye. */
.chip--pop { background: var(--pop, var(--orange)); border-color: var(--pop, var(--orange)); color: var(--paper); }
.chip[hidden] { display: none; }

/* ---------- Atom: tombol hairline ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--hit);
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--paper);
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--ink); }
.btn.is-on { border-color: var(--orange); color: var(--orange); }
.btn--ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--ink:hover { background: #000; border-color: #000; }

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: var(--hud-h);
  padding: 0 16px;
  background: var(--paper-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.hud__left { display: flex; align-items: center; gap: 12px; }
.hud__title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
}
.hud__stats {
  display: flex;
  justify-content: safe center;   /* 'safe': kalau overflow, mulai dari kiri (center biasa kepotong dua sisi) */
  gap: 0;
  min-width: 0;
  overflow-x: auto;              /* kalau gak muat, geser; jangan numpuk */
  scrollbar-width: none;
}
.hud__stats::-webkit-scrollbar { display: none; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: none;
  padding: 6px 10px;
  border-left: 1px solid var(--hairline);
}
.stat:first-child { border-left: 0; }
.stat__label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
}
.stat__value {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat__value small { font-size: 12px; color: var(--ink-muted); font-weight: 500; }
.stat--alert .stat__value { color: var(--red); }
.hud__right { display: flex; align-items: center; gap: 8px; }
/* Chip jam + cuaca: "19:32 WIB · Hujan ringan 27°". Garis kiri = siang oranye / malam biru; bagian hari di title. */
.hud__clock {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  border-left: 3px solid var(--hairline);
  margin-right: 4px;
}
.hud__clock.is-day { border-left-color: var(--orange); }
.hud__clock.is-night { border-left-color: var(--blue); }
.hud__clock-wx { color: var(--ink-muted); white-space: pre; }
.hud__clock-wx:empty { display: none; }
/* Tombol suara: teks doang, tanpa ikon. is-locked = belum ada gesture (browser nahan autoplay). */
.btn--sound { min-width: 96px; letter-spacing: 0.08em; }
.btn--sound.is-locked { color: var(--ink-muted); border-style: dashed; }
.btn--sound.is-on { border-color: var(--orange); color: var(--orange); }

/* ---------- Toast event: kanan atas, di bawah HUD ---------- */
.toasts {
  position: absolute;
  top: calc(var(--hud-h) + 12px);
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
  z-index: 2;
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  height: 26px;
  padding: 0 10px 0 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper-glass);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--c, var(--orange));
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity .25s ease, transform .25s ease;
}
.toast.is-on { opacity: 1; transform: none; }
.toast__who {
  padding: 1px 6px;
  border-radius: 2px;
  background: var(--c, var(--orange));
  color: var(--paper);
}
.toast__text { overflow: hidden; text-overflow: ellipsis; }
.toast--error { border-left-color: var(--red); }
.toast--error .toast__who { background: var(--red); }
body.panel-open .toasts { right: calc(var(--panel-w) + 32px); }

/* ---------- Dock kiri bawah: legend + daftar ruang ---------- */
.dock {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(560px, calc(100vw - var(--panel-w) - 48px));
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 8px 12px;
  background: var(--paper-glass);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c, var(--grey));
  flex: none;
}
.rooms { display: flex; flex-wrap: wrap; gap: 6px; }
.room-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper-glass);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--c, var(--hairline));
  border-radius: 2px;
  transition: border-color .15s;
}
.room-chip:hover, .room-chip.is-active { border-color: var(--ink); border-left-color: var(--c, var(--ink)); }
.room-chip.is-active { background: var(--ink); color: var(--paper); }

/* ---------- Panel kanan ---------- */
.panel {
  position: absolute;
  top: calc(var(--hud-h) + 16px);
  right: 16px;
  bottom: 16px;
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  transition: transform .25s ease, opacity .2s ease, border-color .2s;
  box-shadow: 0 1px 0 rgba(35, 34, 28, 0.04);
}
.panel.is-open { transform: none; opacity: 1; }
/* Outline panel = warna pop ruang/karakter (fallback oranye); error tetap merah. */
.panel.is-open { border-color: var(--pop, var(--orange)); box-shadow: 0 1px 0 rgba(35, 34, 28, 0.04), inset 0 3px 0 var(--pop, var(--orange)); }
.panel[data-status="error"]   { border-color: var(--red); }
.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 0;
}
.panel__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.panel__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 2px; }
.panel__realname { height: 24px; }
.panel__bio {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.panel__bio[hidden] { display: none; }
/* Catchphrase: speech bubble, pop color, ekor kiri bawah */
.speech {
  position: relative;
  margin: 14px 0 0;
  padding: 10px 14px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15px;
  line-height: 1.35;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--pop, var(--orange));
  border-radius: 14px 14px 14px 3px;
}
.speech::before {
  content: '';
  position: absolute;
  left: -1.5px; bottom: -9px;
  width: 10px; height: 10px;
  background: var(--paper);
  border-left: 1.5px solid var(--pop, var(--orange));
  border-bottom: 1.5px solid var(--pop, var(--orange));
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.speech::after { content: '— ' attr(data-by); display: none; }
.speech[hidden] { display: none; }
.habits { display: flex; flex-wrap: wrap; gap: 4px; }
.habits[hidden], .section-title[hidden] { display: none; }
.habit {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: color-mix(in srgb, var(--pop, var(--orange)) 14%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--pop, var(--orange)) 45%, var(--hairline));
  border-radius: 10px;
  white-space: nowrap;
}
.panel__close {
  width: var(--hit); height: var(--hit);
  margin: -8px -8px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--ink-muted);
  border-radius: var(--radius);
}
.panel__close:hover { color: var(--ink); background: var(--paper-2); }
.panel__body { flex: 1; overflow-y: auto; padding: 0 16px 16px; }
.panel__name {
  margin: 10px 0 8px;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 24px;
  padding: 0 10px 0 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  border: 1px solid var(--c, var(--hairline));
  border-radius: 12px;
}
.pill .dot { background: var(--c, var(--grey)); }
.bubble {
  margin: 14px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper-2);
  border-left: 2px solid var(--ink);
}
.bubble:empty { display: none; }
.facts {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--hairline);
}
.facts li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}
.facts dt, .facts__k {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-top: 2px;
}
.facts__v { font-size: 13px; font-weight: 500; }
.facts__v.is-null { color: var(--grey); }
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--hairline); }
.jobs { margin: 0; padding: 0; list-style: none; }
.job {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}
.job:last-child { border-bottom: 0; }
.job__name { font-size: 13px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job__sched {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jobs__empty { font-size: 12px; color: var(--ink-muted); padding: 6px 0; }

/* ---------- Responsive ---------- */
/* HUD dua baris (counter jadi baris geser) sudah dari 1100px biar iPad landscape gak perlu scroll. */
@media (max-width: 1100px) {
  :root { --hud-h: 110px; }   /* HUD dua baris → panel mulai di bawahnya */
  .hud {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0 12px;
    padding: 10px 16px 0;
    min-height: 0;
  }
  .hud__left { grid-row: 1; grid-column: 1; }
  .hud__right { grid-row: 1; grid-column: 2; }
  .hud__stats {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin: 8px -16px 0;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
  }
  .hud__clock { margin-right: 0; }
  .hud__clock-wx { display: none; }   /* layar sempit: jam aja, cuaca ikut di title */
  .toasts { top: calc(var(--hud-h) + 8px); }
}
@media (max-width: 900px) {
  :root { --hit: 44px; --panel-w: 100vw; }
  .btn { padding: 0 12px; }
  .dock { max-width: calc(100vw - 32px); }
  .rooms { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .rooms::-webkit-scrollbar { display: none; }
  .room-chip { flex: none; min-height: 44px; }
  /* Panel jadi bottom sheet */
  .panel {
    top: auto;
    left: 0; right: 0; bottom: 0;
    width: auto;
    max-height: 58vh;
    border-radius: 8px 8px 0 0;
    border-bottom: 0;
    transform: translateY(105%);
  }
  .panel.is-open { transform: none; }
  body.panel-open .dock { display: none; }
  body.panel-open .toasts { right: 16px; }
}
@media (max-width: 560px) {
  .hud__title { font-size: 18px; }
  .hud__clock { display: none; }
  .btn { padding: 0 10px; font-size: 10px; }
}
@media (pointer: coarse) { :root { --hit: 44px; } .room-chip { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { .panel, .toast { transition: none; } }

/* 6 Okt: HUD padat di laptop 1440 (chip cuaca + suara nambah) -> tile stat dirapetin dulu sebelum scroll */
@media (max-width: 1680px) {
  .stat { padding: 5px 7px; }
  .stat__label { font-size: 8.5px; letter-spacing: 0.04em; }
  .stat__value { font-size: 17px; }
}

/* ---------- C4: Story 9:16 (body.story) — HUD, dock, toast, panel disembunyikan; dunia + caption doang.
   Zona aman IG Story (250 px atas / 340 px bawah) diurus tour.css. Rules potret/story aja di sini. ---------- */
body.story .hud, body.story .toasts, body.story .dock, body.story .panel { display: none !important; }
body.story #ui-root { pointer-events: none; }
