/* Cross-platform refinements.
   Everything here is additive: font fallbacks for Windows/Android and touch or
   safe-area behaviour that desktop browsers ignore, so the Mac original still
   renders pixel-for-pixel the same. */

:root {
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Noto Sans SC", Roboto, sans-serif;
  --serif: LocalSong, "Songti SC", "Noto Serif CJK SC", "STSong", "SimSun", "Songti TC",
    "Source Han Serif SC", "Noto Serif SC", "Times New Roman", serif;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* A double tap must not zoom the stage; scrolling and pinch-zoom stay enabled. */
.theatre,
.topbar,
.footer,
.drawer,
.research-topbar,
.research-pagination,
.shadow-atmosphere-controls {
  touch-action: manipulation;
}

.stage-topline,
.stage-heading,
.finger-dock,
.camera-preview,
.vertical-note,
.frame-corner,
.library-trigger,
.settings-trigger,
.status-chip,
.stage-actions {
  -webkit-user-select: none;
  user-select: none;
}

/* Notches and rounded corners: keep the chrome inside the safe area. */
@supports (padding: env(safe-area-inset-top)) {
  .topbar,
  .research-topbar {
    padding-left: max(4%, env(safe-area-inset-left));
    padding-right: max(4%, env(safe-area-inset-right));
  }
  .frame-corner.top-left { top: max(24px, env(safe-area-inset-top)); }
  .frame-corner.top-right { top: max(24px, env(safe-area-inset-top)); }
  .frame-corner.bottom-left { bottom: max(24px, env(safe-area-inset-bottom)); }
  .frame-corner.bottom-right { bottom: max(24px, env(safe-area-inset-bottom)); }
  .footer { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .drawer { padding-bottom: env(safe-area-inset-bottom); }
  .toast { bottom: calc(120px + env(safe-area-inset-bottom)); }
}

/* Phones: a performance fills the screen instead of leaving a scrollable page.
   The shell becomes exactly one viewport tall and the framed theatre flexes into
   whatever height is left, so the frame margins and border are always honoured. */
@media (max-width: 650px), (max-height: 550px) and (orientation: landscape) {
  .app-shell.performing {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .app-shell.performing .theatre {
    flex: 1 1 auto;
    min-height: 0;
  }
  .app-shell.performing .footer {
    display: none;
  }
}

/* Very short screens: give the sheet back the space the frame would take. */
@media (max-height: 620px) {
  .app-shell.performing .theatre {
    margin-top: 8px;
    margin-bottom: 8px;
    border-width: 12px;
  }
}

/* Installed to the home screen: the status bar sits above the top bar. */
@media (display-mode: standalone) {
  .topbar,
  .research-topbar {
    padding-top: env(safe-area-inset-top);
  }
}

/* Some mobile browsers refuse to decode frames for a 1×1 video element; two
   pixels are still invisible but keep the camera pipeline alive. */
#camera {
  width: 2px;
  height: 2px;
  left: 0;
  bottom: 0;
}

/* Only shown when JavaScript is disabled; the site never renders it otherwise. */
.noscript-note {
  padding: 28px;
  font-family: var(--sans);
  line-height: 1.9;
  color: #f2e8d5;
  background: #37271f;
}

/* Coarse pointers cannot hover, so emphasise the press state that replaces it. */
@media (hover: none) {
  .primary-button:active {
    background: #723023;
    transform: translateY(1px);
  }
  .icon-button:active,
  .light-button:active,
  .library-trigger:active,
  .settings-trigger:active {
    background: #ecd9b4cc;
  }
}

/* The finger is the lamp on touch screens; no cursor replica is needed. */
@media (pointer: coarse) {
  .shadow-lamp-cursor {
    display: none !important;
  }
  .shadow-light-note {
    display: none;
  }
}
