/* Small extras on top of Tailwind (palette lives in base.html tailwind.config). */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C2CDD2; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #147A8A; }

@keyframes speakingRing {
  0% { box-shadow: 0 0 0 0 rgba(20, 122, 138, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(20, 122, 138, 0); }
  100% { box-shadow: 0 0 0 0 rgba(20, 122, 138, 0); }
}
.speaking-pulse { animation: speakingRing 1.8s infinite; }

@keyframes floatUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: floatUp 0.22s ease-out forwards; }

/* Room chat wallpaper: soft tint with a faint dot pattern, WhatsApp-like but on-brand. */
.chat-wallpaper {
  background-color: #EEF4F5;
  background-image: radial-gradient(rgba(20, 122, 138, 0.07) 1px, transparent 1px);
  background-size: 18px 18px;
}

/* Privacy / terms page text */
.legal h2 { font-family: Lora, Georgia, serif; font-size: 1.15rem; font-weight: 600; color: #051A24; margin: 1.75rem 0 0.5rem; }
.legal p { margin: 0.6rem 0; }
.legal ul { list-style: disc; padding-left: 1.25rem; margin: 0.5rem 0; }
.legal li { margin: 0.3rem 0; }
.legal a { color: #0E5B68; text-decoration: underline; }

/* Room countdown: amber pulse once time is up. */
.room-timer.timer-done { background-color: #F59E0B; color: #051A24; animation: timer-pulse 1s ease-in-out infinite; }
.room-timer.timer-done svg { color: #051A24; }
@keyframes timer-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .room-timer.timer-done { animation: none; } }

/* Smooth in-page jumps (landing page "Sign in" / section links). */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* App navigation offsets: room for the fixed sidebar (desktop) or bottom tab bar (smaller screens). */
:root { --app-bottombar: calc(3.75rem + env(safe-area-inset-bottom)); }
@media (min-width: 1024px) {
  body:has(#app-sidebar) { padding-left: 18rem; }
}
@media (max-width: 1023.98px) {
  body:has(#app-bottombar) { padding-bottom: var(--app-bottombar); }
  /* Full-height pages (Messages) must stop above the tab bar, not under it. */
  body:has(#app-bottombar) .app-fill { height: calc(100dvh - var(--app-bottombar)) !important; }
  body:has(#app-bottombar) #toast-stack { bottom: calc(var(--app-bottombar) + 0.75rem); }
}
.legal h3 { font-size: 1rem; font-weight: 600; color: #051A24; margin: 1.25rem 0 0.4rem; }
.legal strong { color: #051A24; font-weight: 600; }

/* Feel like an app on phones: no double-tap zoom on buttons, and no auto-zoom when typing
   (iOS zooms into any field with text smaller than 16px). Pinch-zoom still works. */
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
@media (max-width: 640px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { font-size: 16px !important; }
}
/* Game areas: taps go to the game, never to scrolling or zooming the page. */
#arcade-stage { touch-action: none; -webkit-user-select: none; user-select: none; }

/* Modern dropdowns everywhere: custom chevron, soft hover, clear focus ring (native menus stay
   accessible and keyboard/touch friendly). */
:root { accent-color: #147A8A; }
select:not([multiple]),
.pj-select-button {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23147A8A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 1rem;
  padding-right: 2.6rem !important;
  cursor: pointer;
  font-weight: 600;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
select:not([multiple]):hover,
.pj-select-button:hover { border-color: rgba(20, 122, 138, 0.45); background-color: #fff; }
select:not([multiple]):focus,
select:not([multiple]):focus-visible,
.pj-select-button:focus-visible,
.pj-select-button[aria-expanded="true"] { outline: none; border-color: #147A8A; box-shadow: 0 0 0 4px rgba(20, 122, 138, 0.15); background-color: #fff; }
select option { color: #051A24; background: #fff; font-weight: 500; }

/* ---- Arcade: full-screen game mode (automatic on phones, ⛶ button on computers) ---- */
body.arcade-full { overflow: hidden; overscroll-behavior: none; }
.arcade-full-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 61; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; height: calc(48px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0;
  background: #051A24; color: #fff; border-bottom: 1px solid #0b3c47;
}
#arcade-stage.arcade-full-stage {
  position: fixed !important; z-index: 60; left: 0; right: 0; height: auto !important; border-radius: 0;
  top: calc(48px + env(safe-area-inset-top)); bottom: env(safe-area-inset-bottom);
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
body.arcade-full::after { content: ""; position: fixed; inset: 0; background: #051A24; z-index: 59; }

/* Try-Maya box: the hidden attribute wins over the flex layout */
[data-trial-form][hidden] { display: none; }

/* Room chat on phones: folded down to its header bar so the people in the room stay visible */
@media (max-width: 1023px) {
  #room-chat[data-collapsed] { height: auto; }
  #room-chat[data-collapsed] > :not(.room-chat-head):not([data-chat-resize]) { display: none; }
  #room-chat[data-collapsed] .room-chat-head { border-bottom: 0; }
  #room-chat[data-collapsed] [data-chat-chevron] { transform: rotate(180deg); }
}

/* ---------- Rooms: Google Meet-style tiles (app.js layoutTiles sets --tile-w / --tile-h) ---------- */
.room-grid { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 10px; min-height: 100%; }
.room-tile { width: var(--tile-w, 150px); height: var(--tile-h, 125px); }
.room-tile .tile-avatar {
  width: clamp(40px, calc(var(--tile-h, 125px) * 0.5), 140px);
  height: clamp(40px, calc(var(--tile-h, 125px) * 0.5), 140px);
  font-size: clamp(14px, calc(var(--tile-h, 125px) * 0.17), 44px);
}
.room-control {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 3rem; min-width: 3rem; padding: 0 1.1rem; border-radius: 9999px;
  font-size: 0.8125rem; font-weight: 600; transition: background-color 0.15s, transform 0.1s;
}
.room-control:active { transform: scale(0.94); }
@media (max-width: 430px) {
  .room-control { padding: 0; width: 3rem; }
  .room-control-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.sheet-panel { animation: sheet-up 0.22s ease-out; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
#room-frame[hidden] { display: none; }

/* Pages shown inside the room's panel: no app navigation (the panel has its own Back to room bar). */
.in-frame #app-sidebar, .in-frame #app-bottombar, .in-frame .app-header, .in-frame #practice-now { display: none !important; }
.in-frame body { padding-left: 0 !important; padding-bottom: 0 !important; }
.in-frame .app-fill { height: 100dvh !important; }

/* ---------- Chat gestures (app.js): swipe a message right to reply, long-press for its menu ---------- */
#ar-chat-messages, #dm-messages { overflow-x: hidden; }
.chat-row { position: relative; }
.chat-swipe-icon {
  position: absolute; left: -30px; top: 50%; margin-top: -13px; width: 26px; height: 26px; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  background: rgb(255 255 255 / 0.9); color: #0F5F6B; box-shadow: 0 1px 3px rgb(5 26 36 / 0.15); opacity: 0;
}
.chat-row.swiping { transition: none; }
.chat-row.swipe-back { transition: transform 0.2s ease-out; }
.chat-flash > div:not(.chat-swipe-icon) { animation: chat-flash 1.4s ease-out; border-radius: 1rem; }
@keyframes chat-flash { 0%, 40% { background: rgb(197 232 236 / 0.9); } 100% { background: transparent; } }
@media (hover: none) {
  /* Long-press opens the message menu (with Copy), so don't select text or show the browser's menu. */
  .chat-row { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}

/* ---------- Feel like an app on phones ---------- */
html { -webkit-tap-highlight-color: transparent; }
body { touch-action: manipulation; }  /* no double-tap zoom delay */
@media (max-width: 640px) {
  /* 16px text boxes: phones (iPhone especially) zoom the page in when you tap smaller ones. The line height grows
     with it, or the small boxes' 16px line cuts off the bottom of letters like g and y. */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea {
    font-size: 16px !important; line-height: 1.5 !important;
  }
}
/* Text too long for its box ends in "…" instead of being cut mid-letter. */
input, input::placeholder { text-overflow: ellipsis; }

/* Phone density inside the app: desktop-sized padding and corners made cards and buttons look oversized. */
@media (max-width: 639.98px) {
  body:has(#app-bottombar) :is(.p-8, .p-10) { padding: 1.25rem; }
  body:has(#app-bottombar) :is(.p-6, .p-7) { padding: 1rem; }
  body:has(#app-bottombar) .rounded-3xl { border-radius: 1.25rem; }
  body:has(#app-bottombar) .py-5 { padding-top: 1rem; padding-bottom: 1rem; }
  body:has(#app-bottombar) .py-4 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
  body:has(#app-bottombar) .py-3\.5 { padding-top: 0.7rem; padding-bottom: 0.7rem; }
  /* Rows of filter chips scroll sideways like an app, without a scrollbar. */
  .chip-row { scrollbar-width: none; }
  .chip-row::-webkit-scrollbar { display: none; }
}

/* Installed app (home-screen icon): no browser-style page bounce or text selection on app chrome. */
@media (display-mode: standalone) {
  html, body { overscroll-behavior-y: none; }
  header, #app-bottombar { -webkit-user-select: none; user-select: none; }
}
@media (hover: none) {
  button:active, summary:active { scale: 0.97; }  /* "scale" adds to any transform the element already has */
  nav, button, summary, label { -webkit-user-select: none; user-select: none; }
}
/* Rooms: scrolling the people or the chat never pulls the whole page (no accidental refresh that drops the call). */
html:has(#room-live) { overscroll-behavior-y: none; }
#ar-chat-messages, #dm-messages, [data-stage] { overscroll-behavior: contain; }

/* A thin loading bar at the top while the next page loads. */
#nav-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 100; pointer-events: none;
  background: linear-gradient(90deg, #147A8A, #C5E8EC); opacity: 0; transition: width 0.3s ease-out, opacity 0.3s;
}
#nav-progress.loading { width: 75%; opacity: 1; transition: width 4s cubic-bezier(0.1, 0.7, 0.2, 1), opacity 0.1s; }
#nav-progress.done { width: 100%; opacity: 0; transition: width 0.2s ease-out, opacity 0.3s 0.15s; }

/* Page changes cross-fade (browsers that support view transitions). */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.18s; }
@media (prefers-reduced-motion: reduce) { ::view-transition-old(root), ::view-transition-new(root) { animation: none; } }

/* "Install the app" card (Android): sits above the bottom tab bar. */
#install-card { position: fixed; left: 0.75rem; right: 0.75rem; bottom: calc(var(--app-bottombar, 0px) + 0.75rem); z-index: 60; }
