/* Navigation rail and bottom tab bar. Every #tabs / .desktop-brand rule lives
   here, in cascade order, so the nav has one source of truth. Loaded after
   theme.css. */

.desktop-brand {
  display: none;
}
#tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  justify-items: center;
  min-height: 76px;
  background: var(--paper);
  border-top: 1px solid var(--line-2);
}
#tabs button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  border-radius: 13px;
  font-weight: 800;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-2);
  transition:
    background 0.15s var(--ease),
    border-color 0.15s var(--ease);
}
body.onquiz #journeyHeader,
body.onquiz #tabs {
  display: none;
}
#tabs button.on {
  color: var(--brand-ink);
  background: transparent;
  border-color: transparent;
}
#tabs .tab-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 2px solid transparent;
  border-radius: 13px;
  transform: none;
  transition:
    background 0.16s ease,
    border-color 0.16s ease;
}
#tabs button.on .tab-icon {
  border-color: var(--brand-line);
  background: var(--brand-soft);
}
#tabs .tab-art {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center;
  transition: transform 0.13s ease-out;
}
#tabs button:active .tab-icon {
  transform: none;
}

/* 720-959px: a 540px bar centred over full-bleed content. Sitting flush to the
   bottom edge with square corners, it read as a full-width bar that had failed
   to size itself — scrolling rows were visible on both sides of it at the same
   height ("Governme" to the left, "0/5 le" to the right). Lifting it off the
   edge and rounding it makes it plainly a floating bar that content passes
   behind, which is what it always was. */
@media (min-width: 720px) {
  #tabs {
    left: 50%;
    right: auto;
    width: 540px;
    transform: translateX(-50%);
    bottom: 14px;
    border: 1px solid var(--line-2);
    border-radius: 20px;
  }
}

@media (max-width: 959px) {
  #tabs {
    min-height: 72px;
    padding: 8px 12px calc(8px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  }
  /* Icons only in the bottom bar; each button retains its accessible name. */
  #tabs button {
    min-width: 0;
    height: 54px;
    padding: 0;
    gap: 0;
    border: 0;
    font-size: 0;
    line-height: 0;
    white-space: nowrap;
  }
  #tabs [data-tab="learn"] .tab-art {
    width: 39px;
    height: 39px;
  }
  #tabs [data-tab="mocks"] .tab-art,
  #tabs [data-tab="progress"] .tab-art,
  #tabs [data-tab="unlock"] .tab-art {
    width: 38px;
    height: 38px;
  }
  /* Phone press: the icon squashes under the finger (class set by bindTabPress in app/main.js) and springs back on release. */
  #tabs button.is-pressed .tab-art {
    transform: scale(0.95);
    transition: transform 0.08s ease;
  }
}

@media (min-width: 960px) {
  #tabs {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: var(--desktop-rail);
    padding: 30px 18px 24px 18px;
    border-radius: 0;
    transform: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .desktop-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 2px;
    padding: 4px 0 0;
    border-bottom: 1px solid rgb(255 255 255 / 16%);
    color: #fff;
    text-decoration: none;
  }
  /* The rail wordmark is live text in the bundled Fredoka Bold, the face of the
     brand artwork, so it stays crisp at any size. The anchor carries the accessible name. */
  .desktop-brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
  }
  .desktop-wordmark {
    font:
      700 31px/1 Fredoka,
      Nunito,
      system-ui,
      sans-serif;
    letter-spacing: -0.4px;
    color: #1cb0f6;
    white-space: nowrap;
  }
  #tabs button {
    min-height: 58px;
    padding: 3px 14px 3px 8px;
    gap: 9px;
    font-size: 13px;
    line-height: 1.2;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    flex-direction: row;
    justify-content: flex-start;
    border: 2px solid transparent;
    border-radius: 16px;
    transition:
      background 0.16s ease,
      border-color 0.16s ease;
  }
  #tabs button.on {
    background: var(--brand-soft);
    border-color: var(--brand-line);
    color: var(--brand-ink);
  }
  #tabs button:not(.on):hover,
  #tabs button:not(.on):focus-visible {
    background: var(--panel-2);
    border-color: transparent;
  }
  #tabs button.on .tab-icon {
    border-color: transparent;
    background: transparent;
  }
  #tabs [data-tab="learn"] .tab-art {
    width: 38px;
    height: 38px;
  }
  #tabs [data-tab="mocks"] .tab-art,
  #tabs [data-tab="progress"] .tab-art {
    width: 36px;
    height: 36px;
  }
  body.onquiz #tabs {
    display: flex;
  }
}

@media (prefers-reduced-motion: reduce) {
  #tabs .tab-icon,
  #tabs .tab-art {
    transition: none;
  }
}
