/* File: css/base.css
 * Owner: Person B (Saurav)
 * AI-assisted (update): Claude, 2026-11-15 - responsive pass: compact collapsible header, dvh units, safe-area insets, 16px form fields, 44px tap targets. Reviewed by a human: YES, Person C (Yochan).
 * AI-assisted: YES — Gemini, 2026-11-15. Reviewed by a human: YES, Person C (Yochan).
 * Sources used: none
 */
* {
  box-sizing: border-box;
}

img {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  /* env() keeps the header clear of a phone notch in landscape; it is 0 elsewhere */
  padding: calc(8px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 8px max(14px, env(safe-area-inset-left, 0px));
  background: #0d2640f2;
  border-bottom: 1px solid var(--line);
}

/* Desktop: the tools wrapper is invisible to layout, so the buttons sit in the header row as before.
   Small screens turn it into a collapsible panel (see the max-width: 1180px block below). */
#hdr-tools {
  display: contents;
}

#hdr-more {
  display: none;
}

.home-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
}

.home-link h1 {
  margin: 0 10px 0 0;
}

.home-link:hover h1 {
  opacity: 0.85;
}

h1 {
  margin: 0 10px 0 0;
  font: 700 24px system-ui, sans-serif;
  letter-spacing: 2px;
  color: var(--accent);
}

h2 {
  margin: 4px 0 8px;
  font-size: 1.35rem;
}

h3 {
  margin: 14px 0 6px;
  font-size: 1.05rem;
  color: var(--accent);
}

button,
select,
input[type="text"],
textarea {
  min-height: 44px;
  padding: 8px 14px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid #3c78b5;
  border-radius: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

button {
  background: var(--line);
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #3570ab;
  border-color: #63a4e6;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Integrated Audio Mute Button + Volume Slider */
.audio-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 10px 0 0;
  background: #102a46;
  border: 1px solid #3c78b5;
  border-radius: 6px;
}

.audio-control #mute {
  border: 0;
  border-right: 1px solid #295c8f;
  border-radius: 5px 0 0 5px;
  min-height: 44px;
}

.audio-control input[type="range"] {
  width: 78px;
  height: 28px;
  padding: 0;
  min-height: 0;
  margin: 0;
  accent-color: var(--ok);
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  touch-action: pan-y;
}

.audio-control.is-muted input[type="range"] {
  accent-color: var(--muted);
  opacity: 0.6;
}

.team-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 8px;
  cursor: pointer;
}

.team-toggle input {
  width: 20px;
  height: 20px;
}

#nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 auto;
}

#nav button {
  background: transparent;
}

#nav button.on {
  background: var(--accent);
  color: #0b2038;
  font-weight: 700;
}

#nav button.done {
  border-color: var(--ok);
}

#app {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow: auto;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) 14px max(16px, env(safe-area-inset-left, 0px));
}

/* overflow-x: clip does not create a scroll container, so position: sticky inside #app still works */
@supports (overflow: clip) {
  #app {
    overflow-x: clip;
    overflow-y: visible;
  }
}

/* Text fields stay at 16px or larger: iOS Safari zooms the page in when a smaller field is focused */
select,
input[type="text"],
textarea {
  font-size: 1rem;
}

.st {
  display: none;
}

.st.on {
  display: block;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.lock {
  opacity: 0.35;
  pointer-events: none;
}

[hidden] {
  display: none !important;
}

#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
  opacity: 0.92;
  transform: translateZ(0);
  will-change: transform;
}

/* Laptops (1181-1500px): tighten the header so every control fits on one row */
@media (min-width: 1181px) and (max-width: 1500px) {
  header {
    gap: 6px;
  }
  h1,
  .home-link h1 {
    margin-right: 4px;
    font-size: 22px;
    letter-spacing: 1.5px;
  }
  header button {
    padding: 8px 10px;
  }
  .audio-control input[type="range"] {
    width: 64px;
  }
}

/* Tablets and phones: stage buttons stay visible, everything else folds into the "More" panel */
@media (max-width: 1180px) {
  #hdr-more {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    font-weight: 600;
  }

  #hdr-more::after {
    content: "\25BE";
    font-size: 0.85em;
    transition: transform 0.15s ease;
  }

  header.tools-open #hdr-more {
    background: var(--accent);
    border-color: var(--accent);
    color: #0b2038;
  }

  header.tools-open #hdr-more::after {
    transform: rotate(180deg);
  }

  #hdr-tools {
    display: none;
    order: 10;
    flex: 1 1 100%;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    padding-top: 6px;
    border-top: 1px solid #295c8f77;
  }

  header.tools-open #hdr-tools {
    display: grid;
  }

  #hdr-tools #car,
  #hdr-tools .audio-control {
    grid-column: 1 / -1;
  }

  #hdr-tools .audio-control {
    display: flex;
  }

  #hdr-tools .audio-control input[type="range"] {
    flex: 1;
    width: auto;
  }
}

@media (max-width: 640px) {
  header {
    gap: 6px;
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    padding-bottom: 6px;
  }

  h1,
  .home-link h1 {
    margin-right: 0;
    font-size: 22px;
  }

  /* Row 1: logo, (flight Menu), More.  Row 2: the four stage buttons share the full width. */
  #nav {
    order: 5;
    flex: 1 1 100%;
    gap: 4px;
    margin: 0;
  }

  #nav button {
    flex: 1;
    padding: 6px 4px;
  }

  button {
    padding: 6px 10px;
    font-size: 0.95rem;
  }

  #app {
    padding-top: 10px;
    padding-bottom: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}