/* Parkmember — parking-garage signage. Dark concrete, safety yellow,
   oversized numerals. No webfonts, no images, no external anything. */

/* Visually hidden but available to screen readers (live region). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:root {
  --bg: #17181A;
  --surface: #1F2124;
  --surface-2: #26282C;
  --fg: #F2F0EB;
  --muted: rgba(242, 240, 235, 0.55);
  --line: rgba(242, 240, 235, 0.12);
  --accent: #FFC400;
  --accent-ink: #17181A;
  --danger: #FF5A4E;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* press feedback: scale 0.97 (UX.md §1) */
.floor-btn,
.btn-primary,
.btn-ghost,
.btn-install,
.icon-btn,
.update-pill {
  transition: transform 0.08s ease-out;
}
.floor-btn:active,
.btn-primary:active,
.btn-ghost:active,
.btn-install:active {
  transform: scale(0.97);
}
/* The pill is centered with translateX(-50%); keep that while pressing so it
   doesn't jump, and add a subtle scale on top. */
.update-pill:active {
  transform: translateX(-50%) scale(0.97);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ── header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.offline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border-radius: 10px;
}
.icon-btn:active { color: var(--fg); }

/* ── main / views ── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 4px 16px 8px;
  min-height: 0;
}

.view-grid,
.view-parked {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.view-grid[hidden],
.view-parked[hidden] {
  display: none;
}

.grid-hint {
  margin: 4px 2px 12px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

/* floor grid: 3 per row, big equal buttons, fills the viewport without
   scrolling. Rows auto-size to share the available height (auto-flow rows
   with 1fr), so floors 2–11 (4 rows; last row has one button) all fit. */
.floor-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 10px;
  min-height: 0;
}

.floor-btn {
  min-height: 64px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: clamp(2rem, 9vh, 4.6rem);
  font-weight: 900;
  line-height: 1;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* Re-choosing: the floor the car is currently on, so the user sees it. */
.floor-btn.current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
  color: var(--accent);
}

/* ── parked state: giant numeral ── */
.view-parked {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  animation: parked-in 0.22s ease-out;
}

@keyframes parked-in {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1); }
}

.parked-label {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.parked-floor {
  font-size: min(40vh, 56vw);
  font-weight: 900;
  line-height: 0.95;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 60px rgba(255, 196, 0, 0.18);
}

.parked-time {
  min-height: 44px;
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 600;
  /* Affordance that it's tappable (toggles relative/absolute time). */
  text-decoration: underline dotted;
  text-decoration-color: var(--line);
  text-underline-offset: 5px;
}
.parked-time:active { color: var(--fg); }

.parked-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  width: 100%;
}

.btn-primary {
  min-height: 64px;
  min-width: min(320px, 86%);
  padding: 0 28px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius);
  font-size: 1.25rem;
  font-weight: 800;
}

.btn-ghost {
  min-height: 48px;
  padding: 0 20px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ── footer ── */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px calc(10px + var(--safe-bottom));
  color: var(--muted);
}

.footer-link {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.footer-link:active { color: var(--fg); }
.footer-sep { opacity: 0.5; }

/* ── history slide-over ── */
.panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(420px, 100%);
  background: var(--bg);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: calc(8px + var(--safe-top)) 16px calc(12px + var(--safe-bottom));
  z-index: 30;
}
.panel[hidden] { display: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h2 {
  margin: 8px 0;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.history-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}

.h-floor {
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--accent);
  min-width: 2.2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.h-date { flex: 1; font-weight: 600; }
.h-dur { color: var(--muted); font-variant-numeric: tabular-nums; }

.empty {
  color: var(--muted);
  text-align: center;
  margin-top: 40px;
}

.history-clear {
  margin-top: 12px;
  align-self: center;
  color: var(--muted);
}
.history-clear[hidden] { display: none; }
.history-clear:disabled { opacity: 0.4; }
.history-clear.armed {
  color: var(--danger);
  text-decoration-color: var(--danger);
  font-weight: 800;
}

/* ── full-screen deep-link confirmation ── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  animation: confirm-pop 0.18s ease-out;
}
.confirm-overlay[hidden] { display: none; }

.confirm-text {
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: 900;
  color: var(--accent);
  text-align: center;
  padding: 0 24px;
}

@keyframes confirm-pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* ── install banner (slim, above safe area) ── */
.install-banner {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(10px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  z-index: 40;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
.install-banner[hidden] { display: none; }

.banner-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
.banner-text {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.25;
}
.btn-install {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 44px;
}
.banner-dismiss { min-width: 36px; }

/* ── bottom sheets (iOS instructions, privacy) ── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.sheet-backdrop[hidden] { display: none; }

.sheet {
  width: min(560px, 100%);
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 20px 22px calc(20px + var(--safe-bottom));
  border-top: 2px solid var(--accent);
}
.sheet h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
}
.sheet .btn-primary {
  width: 100%;
  margin-top: 16px;
  min-width: 0;
}

.ios-steps {
  margin: 8px 0;
  padding-left: 22px;
  line-height: 1.7;
}

.note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.privacy-copy {
  line-height: 1.6;
  user-select: text;
  -webkit-user-select: text;
}

/* ── admin sheet ── */
.admin-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.admin-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--fg);
  font-size: 1.1rem;
  padding: 12px 14px;
  min-height: 48px;
}
.admin-input:focus {
  outline: none;
  border-color: var(--accent);
}
.admin-error {
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
  margin: 10px 0 0;
}
#admin-login .btn-primary { width: 100%; margin-top: 14px; min-width: 0; }
#admin-close { width: 100%; margin-top: 12px; }

.admin-stat {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.admin-stat-num {
  font-size: 2.6rem;
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}
.admin-stat-label {
  color: var(--muted);
  font-weight: 600;
}

/* ── feedback sheet ── */
.feedback-text {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  padding: 12px 14px;
  resize: vertical;
  min-height: 120px;
  user-select: text;
  -webkit-user-select: text;
}
.feedback-text:focus {
  outline: none;
  border-color: var(--accent);
}
.feedback-meta {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
.feedback-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.feedback-turnstile {
  margin: 12px 0 4px;
  min-height: 0;
}
#feedback-form .btn-primary { width: 100%; margin-top: 12px; min-width: 0; }
#feedback-close { width: 100%; margin-top: 12px; }

/* ── toast & update pill ── */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(84px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 999px;
  padding: 10px 12px 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 70;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  max-width: 90vw;
  text-align: center;
}
.toast[hidden] { display: none; }

.toast-action {
  flex-shrink: 0;
  color: var(--accent);
  font-weight: 800;
  font-size: 0.9rem;
  padding: 4px 12px;
  border-radius: 999px;
  min-height: 32px;
  background: rgba(255, 196, 0, 0.12);
}
.toast-action:active { transform: scale(0.95); }

.update-pill {
  position: fixed;
  top: calc(10px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 800;
  z-index: 70;
}
.update-pill[hidden] { display: none; }

/* In-progress state: muted, non-pressable, with a spinner so it's obvious
   the tap registered and work is happening. */
.update-pill.is-updating {
  background: var(--surface-2);
  color: var(--fg);
  cursor: default;
}
.update-pill.is-updating::before {
  content: "";
  width: 13px;
  height: 13px;
  border: 2px solid rgba(242, 240, 235, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
/* The updating pill must not react to press (it's disabled). */
.update-pill.is-updating:active { transform: translateX(-50%); }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast-dismiss {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 28px;
  min-height: 28px;
  border-radius: 999px;
}
.toast-dismiss:active { color: var(--fg); }

/* ── shortcuts setup page ── */
.setup-page {
  display: block;
  padding: calc(12px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
  max-width: 640px;
  margin: 0 auto;
  user-select: text;
  -webkit-user-select: text;
  min-height: auto;
}

.setup-page h1 {
  font-size: 1.4rem;
  margin: 12px 0 4px;
}
.setup-page h2 {
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 28px 0 8px;
}
.setup-page p,
.setup-page li {
  line-height: 1.6;
  color: var(--fg);
}
.setup-page .back-link {
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
  width: 100%;
  text-align: left;
}
.url-row .url-label {
  font-weight: 800;
  white-space: nowrap;
}
.url-row .url-value {
  flex: 1;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.url-row .copy-hint {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.warn {
  border-left: 3px solid var(--danger);
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 0 10px 10px 0;
  color: var(--muted);
  font-size: 0.9rem;
}
