/* ===========================================================
   DESIGN TOKENS
=========================================================== */
:root {
  --ink:          #0C1720;
  --ink-soft:     #132330;
  --ink-softer:   #1B2E3C;
  --brass:        #C9A66B;
  --brass-light:  #E3C892;
  --brass-dim:    rgba(201, 166, 107, 0.35);
  --ivory:        #F4EFE4;
  --ivory-dim:    rgba(244, 239, 228, 0.62);
  --ivory-faint:  rgba(244, 239, 228, 0.38);
  --line:         rgba(244, 239, 228, 0.12);
  --sage:         #8CA394;

  --font-display: 'Fraunces', serif;
  --font-body:    'Inter', -apple-system, sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
}

button, input {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--brass-light);
  outline-offset: 3px;
}

/* subtle ambient grain so the deep navy doesn't look flat */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 1;
}

.screen {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  width: 100%;
}

.screen[hidden],
.typing-row[hidden] {
  display: none;
}

/* ===========================================================
   SCHERMATA 1 — ACCESSO
=========================================================== */
.screen--entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 24px calc(56px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(201,166,107,0.10), transparent 60%),
    var(--ink);
}

.entry-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.plaque-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.plaque-mark__line {
  width: 24px;
  height: 1px;
  background: var(--brass-dim);
}

.plaque-mark__label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass-light);
}

.entry-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(30px, 8vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  color: var(--ivory);
}

.entry-copy {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ivory-dim);
  margin: 0 0 36px;
  max-width: 300px;
}

.room-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.room-form__label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ivory-faint);
  margin-bottom: 14px;
}

.room-form__field {
  position: relative;
  width: 100%;
  max-width: 220px;
  margin-bottom: 8px;
}

#room-input {
  width: 100%;
  background: transparent;
  border: none;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 56px;
  letter-spacing: 0.08em;
  padding: 8px 4px 16px;
  color: var(--ivory);
}

#room-input::placeholder { color: var(--ivory-faint); }

.room-form__underline {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brass), transparent);
  transform: scaleX(0.4);
  opacity: 0.5;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

#room-input:focus ~ .room-form__underline {
  transform: scaleX(1);
  opacity: 1;
}

.room-form__error {
  font-size: 13px;
  color: #E29B8C;
  margin: 4px 0 0;
}

.btn-primary {
  margin-top: 28px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 28px;
  border-radius: 999px;
  background: var(--brass);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 24px rgba(201,166,107,0.18);
}

.btn-primary:hover { background: var(--brass-light); }
.btn-primary:active { transform: scale(0.97); }

.btn-primary svg { transition: transform 0.15s ease; }
.btn-primary:hover svg { transform: translateX(2px); }

.entry-footnote {
  margin-top: 28px;
  font-size: 13px;
  color: var(--ivory-faint);
  text-align: center;
}

/* shake feedback on invalid room number */
.room-form__field.is-invalid #room-input {
  animation: shake 0.32s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ===========================================================
   SCHERMATA 2 — CHAT
=========================================================== */
.screen--chat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-soft);
  flex-shrink: 0;
}

.chat-header__plaque {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--brass-dim);
  background: linear-gradient(160deg, rgba(201,166,107,0.14), transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header__digits {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--brass-light);
}

.chat-header__meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.chat-header__title {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--ivory);
}

.chat-header__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ivory-faint);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ivory-faint);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.status-dot.is-online {
  background: var(--sage);
  box-shadow: 0 0 0 3px rgba(140,163,148,0.18);
}

.chat-header__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ivory-faint);
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.chat-header__close:hover {
  background: var(--ink-softer);
  color: var(--ivory);
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thread-daymark {
  text-align: center;
  margin: 4px 0 14px;
}
.thread-daymark span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ivory-faint);
}

.msg {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  line-height: 1.45;
  animation: rise 0.25s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg--guest {
  align-self: flex-end;
  background: var(--brass);
  color: var(--ink);
  border-bottom-right-radius: 4px;
}

.msg--staff {
  align-self: flex-start;
  background: var(--ink-softer);
  color: var(--ivory);
  border-bottom-left-radius: 4px;
}

.msg--system {
  align-self: center;
  background: transparent;
  color: var(--ivory-faint);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 4px 10px;
}

.msg__time {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  margin-top: 5px;
  opacity: 0.55;
}

.typing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px 10px;
  color: var(--ivory-faint);
  font-size: 12.5px;
  flex-shrink: 0;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}
.typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brass-light);
  animation: bounce 1.1s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.chat-inputbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--ink-soft);
  flex-shrink: 0;
}

#message-input {
  flex: 1;
  background: var(--ink-softer);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 14.5px;
  color: var(--ivory);
  transition: border-color 0.2s ease;
}
#message-input::placeholder { color: var(--ivory-faint); }
#message-input:focus { border-color: var(--brass-dim); }

.chat-inputbar__send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brass);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}
.chat-inputbar__send:hover { background: var(--brass-light); }
.chat-inputbar__send:active { transform: scale(0.93); }

/* ===========================================================
   RESPONSIVE
=========================================================== */
@media (min-width: 560px) {
  .screen--chat { max-width: 480px; margin: 0 auto; border-inline: 1px solid var(--line); }
}

/* ===========================================================
   REDUCED MOTION
=========================================================== */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
