/* Banrai Hotel — guest chat.
 *
 * Visual language borrowed from the in-room guide (guide_v1): warm minimalism —
 * washi neutrals, one precious crimson, type and space carrying the hierarchy
 * instead of boxes. Tokens are copied rather than imported: this page is served
 * from public/ alone and makes no external request of any kind, so the Noto
 * webfonts the guide loads from Google are replaced with the language-native
 * system stacks every guest phone already has.
 */

:root {
  --brand: #c0252b;
  --brand-dark: #8a1b20;
  --brand-soft: rgba(192, 37, 43, 0.08);
  --brand-soft-2: rgba(192, 37, 43, 0.15);
  --brand-line: rgba(192, 37, 43, 0.22);
  --gold: #c19a4b;
  --gold-ink: #8a6a24;
  --gold-soft: rgba(193, 154, 75, 0.12);
  --gold-line: rgba(193, 154, 75, 0.32);
  --ink: #1a1612;
  --ink-2: #4a443d;
  --ink-3: #8a8278;
  --bg: #ffffff;
  --bg-soft: #faf7f2;
  --bg-card: #f5efe6;
  --rule: #ece6db;
  --rule-strong: #ddd4c4;

  --serif-jp: 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif JP', serif;
  --sans-jp: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Noto Sans JP', sans-serif;
  --sans-en: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --sans-zh: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --sans-ko: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;

  --shadow-card: 0 4px 16px rgba(26, 22, 18, 0.08);
  --shadow-elev: 0 6px 28px rgba(26, 22, 18, 0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --top-h: 56px;

  --text-xs: 0.7rem;
  --text-sm: 0.88rem;
  --text-base: 0.96rem;
  --text-md: 1.13rem;
  --text-lg: 1.33rem;

  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: var(--sans-jp);
  color: var(--ink);
  background: #e8e3db;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.65;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}
html[lang="en"] body { font-family: var(--sans-en); }
html[lang="zh"] body { font-family: var(--sans-zh); }
html[lang="ko"] body { font-family: var(--sans-ko); }

html, body { height: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------------- shell --- */

.phone {
  max-width: 440px;
  margin: 0 auto;
  height: 100%;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
}
@media (max-width: 440px) {
  .phone { box-shadow: none; }
  html, body { background: var(--bg); }
}

.topbar {
  flex: none;
  height: var(--top-h);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  padding-top: env(safe-area-inset-top);
  height: calc(var(--top-h) + env(safe-area-inset-top));
}

.brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.brand-mark {
  font-family: var(--serif-jp);
  font-weight: 700;
  font-size: 22px;
  color: var(--brand);
  letter-spacing: 0.04em;
  line-height: 1;
}
.brand-text { min-width: 0; }
.brand-en {
  font-family: var(--sans-en);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.25;
  color: var(--ink);
}
.brand-loc {
  font-family: var(--sans-en);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  line-height: 1.25;
}

.room-chip {
  font-family: var(--sans-en);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  background: var(--bg-card);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
  flex: none;
}

.lang-switch {
  display: flex;
  background: var(--bg-card);
  border-radius: 999px;
  padding: 3px;
  flex: none;
}
.lang-switch button {
  font-family: var(--sans-en);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--ink-3);
  min-width: 26px;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}
.lang-switch button[aria-pressed="true"] { background: var(--brand); color: #fff; }

/* --------------------------------------------------------------- thread --- */

.thread {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-lg) var(--space-md) var(--space-md);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.intro { padding: var(--space-2xs) var(--space-2xs) 0; }
.intro-eyebrow {
  font-family: var(--sans-en);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-xs);
}
.intro-eyebrow::before {
  content: '';
  width: 18px;
  height: 1px;
  background: var(--brand);
  opacity: 0.5;
}
.intro-title {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.01em;
  text-wrap: balance;
}
.intro-body {
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--ink-2);
  text-wrap: pretty;
}

.quick { margin-top: var(--space-lg); }
.quick-title {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
}
.quick-grid { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.quick-chip {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 9px 14px;
  line-height: 1.3;
  transition: transform 0.16s var(--ease-out-quint), border-color 0.16s, background 0.16s;
}
.quick-chip:hover { border-color: var(--brand-line); }
.quick-chip:active { transform: scale(0.97); background: var(--brand-soft); }

/* ------------------------------------------------------------- messages --- */

.msg { display: flex; flex-direction: column; max-width: 86%; animation: msgIn 0.34s var(--ease-out-quint) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.msg-guest { align-self: flex-end; align-items: flex-end; }
.msg-hotel { align-self: flex-start; align-items: flex-start; }

.bubble {
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-base);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-guest .bubble {
  background: var(--bg-card);
  color: var(--ink);
  border-bottom-right-radius: var(--radius-sm);
}
.msg-hotel .bubble {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-bottom-left-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}

.msg-hotel.is-official .bubble { border-color: var(--brand-line); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.badge svg { width: 12px; height: 12px; flex: none; }
.badge-official { color: var(--brand-dark); background: var(--brand-soft); }

.staff-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gold-ink);
  line-height: 1.5;
}
.staff-note svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }

/* The room line, when we have no room: a continuation of the hand-off note,
   quieter than it, and nothing to act on. Both stretch, so the note and the
   line under it share one edge instead of ending at two different widths. */
.has-room-hint .staff-note { border-radius: var(--radius-sm) var(--radius-sm) 0 0; align-self: stretch; }
.staff-note-hint {
  align-self: stretch;
  padding: 8px 12px 9px;
  border: 1px solid var(--gold-line);
  border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--bg-soft);
  font-size: var(--text-xs);
  color: var(--ink-2);
  line-height: 1.6;
}

/* The way back to a roomless guest: the hint keeps its sentence and gains one
   input and one quiet send. Same washi quietness — nothing here shouts. */
.contact-lead { margin: 0 0 7px; }
.contact-form { display: flex; flex-wrap: wrap; gap: 6px; }
.contact-input {
  flex: 1 1 150px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--text-sm);
  font-family: inherit;
}
.contact-input:focus { outline: none; border-color: var(--gold); }
.contact-input:disabled { opacity: 0.6; }
.contact-send {
  padding: 7px 14px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--gold-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.contact-send:disabled { opacity: 0.6; cursor: default; }
.contact-nudge { flex-basis: 100%; margin: 0; color: var(--brand-dark); }
.contact-nudge:empty { display: none; }
.contact-done { margin: 0; color: var(--gold-ink); font-weight: 600; }

.msg-note .bubble {
  background: var(--bg-card);
  border: 1px dashed var(--rule-strong);
  box-shadow: none;
  color: var(--ink-2);
  font-size: var(--text-sm);
}

/* Typing indicator — mandatory, not decoration: the engine's p50 is over five
   seconds and a silent page reads as a broken one. */
.typing { display: flex; gap: 5px; padding: 15px var(--space-md); }
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3);
  animation: typingPulse 1.25s var(--ease-out-expo) infinite;
}
.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes typingPulse {
  0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
  30% { opacity: 0.9; transform: translateY(-3px); }
}

/* ------------------------------------------------------------- composer --- */

.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--rule);
}
.composer-input {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* iOS zooms anything smaller on focus */
  line-height: 1.5;
  background: var(--bg-soft);
  border: 1px solid var(--rule-strong);
  border-radius: 22px;
  padding: 10px 16px;
  transition: border-color 0.16s;
}
.composer-input::placeholder { color: var(--ink-3); }
.composer-input:focus { outline: none; border-color: var(--brand-line); background: var(--bg); }
.send-btn {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.16s var(--ease-out-quint), background 0.16s, opacity 0.16s;
}
.send-btn:active { transform: scale(0.94); background: var(--brand-dark); }
.send-btn[disabled] { opacity: 0.4; cursor: default; }
.send-btn svg { width: 20px; height: 20px; }

/* ----------------------------------------------------------------- gate --- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(26, 22, 18, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  animation: gateIn 0.3s var(--ease-out-quint) both;
}
@keyframes gateIn { from { opacity: 0; } to { opacity: 1; } }

.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg);
  border-radius: 18px;
  box-shadow: var(--shadow-elev);
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  text-align: center;
  animation: gateCardIn 0.42s var(--ease-out-expo) both;
}
@keyframes gateCardIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

.gate-mark {
  font-family: var(--serif-jp);
  font-weight: 700;
  font-size: 34px;
  color: var(--brand);
  letter-spacing: 0.08em;
  line-height: 1;
}
.gate-brand-en {
  font-family: var(--sans-en);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  margin-top: 8px;
}
.gate-welcome {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 12px;
  margin-top: var(--space-lg);
  font-size: var(--text-sm);
  color: var(--ink-3);
}
.gate-rule { width: 34px; height: 1px; background: var(--rule-strong); margin: var(--space-md) auto; }
.gate-title { font-size: var(--text-md); font-weight: 600; line-height: 1.5; text-wrap: balance; }
.gate-hint { margin-top: 6px; font-size: var(--text-sm); color: var(--ink-3); }

.gate-input {
  width: 100%;
  margin-top: var(--space-md);
  font-family: var(--sans-en);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-align: center;
  text-indent: 0.32em; /* keeps the tracked digits optically centred */
  padding: 12px 0;
  background: var(--bg-soft);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  transition: border-color 0.16s, background 0.16s;
}
.gate-input:focus { outline: none; border-color: var(--brand); background: var(--bg); }
.gate-input::placeholder { color: var(--rule-strong); }

.gate-error {
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--brand-dark);
  min-height: 1.4em;
}

.gate-start {
  width: 100%;
  margin-top: var(--space-sm);
  background: var(--brand);
  color: #fff;
  font-size: var(--text-base);
  font-weight: 600;
  border-radius: var(--radius);
  padding: 14px;
  letter-spacing: 0.02em;
  transition: transform 0.16s var(--ease-out-quint), background 0.16s;
}
.gate-start:active { transform: scale(0.98); background: var(--brand-dark); }

/* The quieter of the two actions: plainly visible and plainly secondary. It is
   text, not a second red button — a guest with a room number should not have to
   choose between two equal-looking buttons. */
.gate-skip {
  display: block;
  width: 100%;
  margin-top: var(--space-sm);
  padding: 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-2);
  background: none;
  border-radius: var(--radius-sm);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--ink-3); /* it has to read as tappable, not as a caption */
  transition: color 0.15s, background 0.15s;
}
.gate-skip:hover { color: var(--ink); background: var(--bg-soft); }
.gate-skip:active { background: var(--bg-card); }

.gate-langs { display: flex; justify-content: center; gap: var(--space-2xs); margin-top: var(--space-lg); }
.gate-langs button {
  font-size: var(--text-sm);
  color: var(--ink-3);
  padding: 6px 10px;
  border-radius: 999px;
  transition: color 0.15s, background 0.15s;
}
.gate-langs button[aria-pressed="true"] { color: var(--brand-dark); background: var(--brand-soft); font-weight: 600; }

.gate-foot {
  margin-top: var(--space-lg);
  font-family: var(--sans-en);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.gate-foot b { color: var(--ink-2); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
