/*
 * The header: the FLYABOO wordmark on a plain bar (the full artwork is on the sign-in page). It is taller than
 * the original 55px text header, so page heights that were calculated against 55px subtract --header-extra too.
 */
:root {
  --header-height: clamp(68px, 5.5vw, 88px);
  --header-extra: calc(var(--header-height) - 55px);
}

#header {
  position: relative;
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 clamp(12px, 3vw, 40px);
  border-bottom: 2px solid var(--c-amber);
  background: var(--c-grey-0a0a0a);
  z-index: 2000;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  height: 100%;
  /* Gives way to the live counts rather than sitting under them: Junior Mode's labels ("FLYING NOW", "JET TYPES") are
     longer than the grown-ups' and used to run over the wordmark on a phone. */
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
}

.brand-wordmark {
  height: 64%;
  width: auto;
  max-width: 100%;
  overflow: visible;
}

#title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#menu-btn {
  cursor: pointer;
  width: 40px;
  display: flex;
  justify-content: flex-end;
  margin-left: auto;
  background: none;
  border: 0;
  padding: 0;
  color: var(--c-amber);
}

#tab-bar {
  display: flex;
  background: var(--c-black);
  border-bottom: 2px solid var(--c-amber);
  flex-shrink: 0;
}

/* Links standing in for the original <button>s, so they carry the UA button font size explicitly. */
.tab-btn {
  flex: 1;
  display: block;
  background: var(--c-black);
  color: var(--c-grey-555);
  border: none;
  border-right: 1px solid var(--c-grey-111);
  padding: 12px;
  font-family: inherit;
  font-size: 13.3333px;
  font-weight: bold;
  line-height: normal;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--c-amber);
  background: var(--c-grey-111);
  text-shadow: 0 0 8px var(--c-amber);
}

#stats-panel {
  height: 80px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 5px;
  background: var(--c-grey-0a0a0a);
  border-bottom: 1px solid var(--c-grey-222);
  flex-shrink: 0;
}

.stat-card {
  background: var(--c-black);
  border: 1px solid var(--c-grey-111);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stat-val {
  color: var(--c-yellow);
  font-size: 1.8rem;
  font-weight: bold;
}

.stat-label {
  color: var(--c-cyan);
  font-size: 0.6rem;
  text-transform: uppercase;
}

/* In the top bar the counts are a compact row beside the wordmark instead of a band of their own. */
#header #stats-panel {
  height: auto;
  display: flex;
  flex: 0 0 auto;
  gap: clamp(8px, 2vw, 22px);
  margin-left: auto;
  padding: 0;
  background: none;
  border: 0;
}

#header .stat-card {
  flex-direction: row;
  align-items: baseline;
  gap: 5px;
  padding: 0;
  background: none;
  border: 0;
}

#header .stat-val {
  font-size: 1.45rem;
  line-height: 1;
}

#header .stat-label {
  font-size: 0.62rem;
}

#header #menu-btn {
  margin-left: clamp(10px, 3vw, 24px);
}

/* Background, stacking and opacity reflect the overrides in the original index.html <head>. */
#side-nav {
  position: fixed;
  top: 0;
  right: calc(-1 * min(300px, 88vw));
  width: min(300px, 88vw);
  height: 100%;
  background: var(--c-grey-111);
  border-left: 2px solid var(--c-amber);
  transition: 0.4s;
  z-index: 3000;
  /* A column: the NAV / ATC / CONFIG tabs stay at the top and only the tab's content below them scrolls. */
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  overflow: hidden;
  opacity: 1;
  pointer-events: auto;
}

#side-nav > [data-tab] {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#side-nav > [data-tab][hidden] {
  display: none;
}

#side-nav.open {
  right: 0;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  z-index: 2500;
}

.overlay.open {
  display: block;
}

.sidenav-tabs {
  display: flex;
  flex: none;
  border-bottom: 1.5px solid var(--c-grey-222);
  background: var(--c-grey-080808);
  z-index: 100;
}

.sidenav-tab-btn {
  flex: 1;
  background: var(--c-grey-050505);
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--c-grey-888);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: bold;
  padding: 12px 0;
  cursor: pointer;
  transition: all 0.25s ease;
  outline: none;
  text-align: center;
}

.sidenav-tab-btn:hover {
  color: var(--c-white);
  background: var(--c-grey-111);
}

.sidenav-tab-btn.active {
  color: var(--c-amber);
  border-bottom: 2px solid var(--c-amber);
  background: var(--c-grey-111);
  text-shadow: 0 0 8px rgba(255, 176, 0, 0.45);
}

.sidenav-panel {
  padding: 15px;
}

.sidenav-heading {
  font-size: 0.65rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 6px;
}

.sidenav-note {
  color: var(--c-grey-666);
  font-size: 0.65rem;
  margin: 8px 0 0;
}

.operator-box {
  padding: 15px;
  border-bottom: 1px solid var(--c-grey-222);
  background: var(--c-grey-111);
}

.operator-label {
  color: var(--c-amber);
  font-size: 0.7rem;
  font-weight: bold;
  display: block;
  margin-bottom: 8px;
}

.operator-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.operator-icon {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  border: 2px solid var(--operator-color);
  background: var(--c-black);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.operator-icon span {
  font-size: 24px;
  line-height: 1;
}

/* Stands in for the original operator <select>, which used the UA select font. */
.operator-name {
  flex-grow: 1;
  height: 40px;
  display: flex;
  align-items: center;
  background: var(--c-black);
  color: var(--c-cyan-bright);
  border: 1px solid var(--c-cyan);
  padding: 5px;
  font-family: monospace;
  font-size: 13.3333px;
}

.nav-item {
  display: block;
  padding: 15px 25px;
  border-bottom: 1px solid var(--c-grey-222);
  cursor: pointer;
  font-weight: bold;
  text-transform: uppercase;
  text-decoration: none;
}

/* The pages, in folding groups. */
.nav-group {
  border-bottom: 1px solid var(--c-grey-222);
}

.nav-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  background: var(--c-grey-0a0a0a);
  color: var(--c-amber);
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.nav-group-title::-webkit-details-marker {
  display: none;
}

.nav-group-title::after {
  content: "▸";
  margin-left: 4px;
  transition: transform 0.2s;
}

.nav-group[open] > .nav-group-title::after {
  transform: rotate(90deg);
}

.nav-group-count {
  margin-left: auto;
  color: var(--c-grey-666);
  font-size: 0.65rem;
}

.nav-group .nav-item {
  padding: 11px 20px 11px 30px;
  font-size: 0.85rem;
}

.nav-item--current {
  background: var(--c-grey-222);
  box-shadow: inset 4px 0 0 currentColor;
}

.nav-signout {
  margin: 0;
}

.nav-item-button {
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--c-grey-222);
  color: var(--c-grey-666);
  font-family: inherit;
  font-size: 1rem;
  text-align: left;
}

#footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 25px;
  background: var(--c-grey-050505);
  border-top: 1px solid var(--c-grey-222);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  z-index: 5000;
}

.footer-status {
  display: flex;
  gap: 10px;
  align-items: center;
}

#sync-time {
  color: var(--c-amber);
  font-size: 0.75rem;
  font-weight: bold;
}

#sync-text {
  color: var(--c-green);
  font-size: 0.75rem;
}

.fullscreen-btn {
  background: none;
  border: 1px solid var(--c-grey-333);
  color: var(--c-grey-555);
  font-family: inherit;
  font-size: 0.6rem;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
}

#notify {
  position: fixed;
  right: 12px;
  bottom: 40px;
  background: var(--c-grey-111);
  color: var(--c-white);
  padding: 8px 12px;
  border: 1px solid var(--c-grey-333);
  border-left: 4px solid var(--c-amber);
  border-radius: 4px;
  display: none;
  z-index: 6000;
  font-weight: bold;
}

@media (max-width: 768px) {
  :root {
    --header-height: 64px;
  }

  .brand-wordmark {
    height: 62%;
  }

  #header #stats-panel {
    gap: 10px;
  }

  #header .stat-val {
    font-size: 0.95rem;
  }

  #header .stat-label {
    font-size: 0.45rem;
  }

  /* On phones the live counts only show on BOARD, MAP and STATS, leaving the other pages more room. */
  #stats-panel.stats-panel--secondary {
    display: none;
  }

  #footer {
    padding-left: max(18px, env(safe-area-inset-left, 18px));
    padding-right: max(18px, env(safe-area-inset-right, 18px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(25px + env(safe-area-inset-bottom, 0px));
  }
}

/* Narrow phones: the label tucks under its number, so three counts still fit beside the wordmark. */
@media (max-width: 430px) {
  #header .stat-card {
    flex-direction: column;
    align-items: center;
    gap: 0;
  }

  #header .stat-val {
    font-size: 0.85rem;
  }

  #header .stat-label {
    font-size: 0.4rem;
  }

  #header #stats-panel {
    gap: 8px;
  }
}

/* The one search box, over the page. */
#site-search {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10vh 16px 16px;
  background: rgba(0, 0, 0, 0.72);
}

#site-search[hidden] {
  display: none;
}

.site-search-sheet {
  width: min(560px, 100%);
  max-height: 76vh;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--c-amber);
  border-radius: 6px;
  background: var(--c-grey-0a0a0a);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.site-search-row {
  display: flex;
  gap: 8px;
}

.site-search-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--c-grey-333);
  border-radius: 4px;
  background: var(--c-black);
  color: var(--c-white);
  font-family: var(--font-mono);
  font-size: 1rem;
}

.site-search-hint {
  margin: 8px 2px;
  color: var(--c-grey-aaa);
  font-size: 0.78rem;
}

.site-search-results {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-search-results a {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 6px;
  border-bottom: 1px solid var(--c-grey-222);
  color: var(--c-white);
  text-decoration: none;
}

.site-search-results a:hover {
  background: var(--c-grey-111);
}

.site-search-icon {
  font-size: 1.1rem;
}

.site-search-sub {
  display: block;
  color: var(--c-grey-aaa);
  font-size: 0.75rem;
}

#header #search-btn {
  margin-left: clamp(6px, 2vw, 14px);
  background: none;
  border: 0;
  color: var(--c-cyan);
  cursor: pointer;
  padding: 4px;
}
