/* App-mode shell shared by the viewer, MCR, admin and login pages.
 *
 * The page itself never scrolls or rubber-bands: <html>/<body> are pinned to
 * the visible screen and only .app-scroll (inside it) scrolls. That is what
 * stops the whole screen "sliding about" on a phone. Pages define their own
 * colours with CSS variables (--bg, --panel, --text, --muted, --border,
 * --primary, --primary-text) before this file's rules apply.
 */

/* ---- colour themes. Dark is the default; pages may override either palette
   (e.g. the admin page puts the club's branding colours into the light one). ---- */
:root, html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14;
  --panel: #12151c;
  --text: #f5f7fa;
  --muted: #9aa7bd;
  --border: #252c3b;
  --primary: #3b82c4;
  --primary-text: #ffffff;
  --error: #ff6b6b;
  --ok: #6fcf97;
  --warn: #e0b23f;
  --bad: #e05a4a;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f4f6fa;
  --text: #101828;
  --muted: #5b6474;
  --border: #d5dbe6;
  --primary: #1f6fb2;
  --primary-text: #ffffff;
  --error: #c0392b;
  --ok: #12864f;
  --warn: #9a6200;
  --bad: #c0262b;
}

html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}
body {
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }

/* Normal text can still be selected, but buttons and chrome can't. */
button, .menu-btn, .tab-btn, header { user-select: none; -webkit-user-select: none; }

.app-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ---- header + menu ---- */
.app-header {
  flex: 0 0 auto;
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.app-header img.logo { width: 28px; height: 28px; object-fit: contain; flex: 0 0 auto; }
.app-header h1 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.menu-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.menu-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 10px;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.app-header.menu-open .menu-panel { display: block; }
.menu-panel a, .menu-panel button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: rgba(127, 127, 127, 0.16); }
.menu-panel .menu-user { padding: 8px 14px 4px; font-size: 12px; color: var(--muted); word-break: break-all; }
.menu-panel hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu-backdrop { display: none; position: fixed; inset: 0; z-index: 35; background: transparent; }
.app-header.menu-open ~ .menu-backdrop { display: block; }

/* On wide screens the menu is just a row of links in the header. */
@media (min-width: 900px) {
  .menu-btn, .menu-backdrop { display: none !important; }
  .menu-panel {
    display: flex !important;
    position: static;
    min-width: 0;
    padding: 0;
    gap: 2px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .menu-panel a, .menu-panel button { width: auto; min-height: 36px; padding: 0 12px; font-size: 13px; color: var(--muted); }
  .menu-panel a:hover, .menu-panel button:hover { color: var(--text); }
  .menu-panel .menu-user, .menu-panel hr { display: none; }
}

/* ---- touch-friendly form controls on phones ---- */
@media (max-width: 700px) {
  input, select, textarea { font-size: 16px !important; } /* stops iOS zooming in on focus */
  button, .btn { min-height: 40px; }
}

/* ---- pull-to-refresh indicator ---- */
.ptr {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 8px);
  z-index: 90;
  width: 44px;
  height: 44px;
  margin: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translate(-50%, -60px);
  pointer-events: none;
}
.ptr svg { width: 24px; height: 24px; fill: currentColor; }
.ptr.settling { transition: opacity 0.2s ease, transform 0.2s ease; }
.ptr.ready { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.ptr.loading svg { animation: ptr-spin 0.8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
