/* ============================================================
   shell-header.css — App Shell Header (index.html)
   ─────────────────────────────────────────
   PURPOSE : Brand, primary navigation, page actions and the
             sub-navigation band (html-templates/components/).
   NOTE    : Builds on .brand from css/shared/layout-app.css, and
             neutralises the older per-control margins that assumed
             the controls sat directly in .brand.
   ============================================================ */

/* ── Bar: brand | primary nav | actions ───────────────────────── */
.shell-header .shell-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand nav actions";
  align-items: center;
  column-gap: 28px;
}

.shell-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: 10px;
}

.shell-brand .brand-text {
  flex: 0 1 auto;
}

/* ── Primary navigation ───────────────────────────────────────── */
.shell-nav {
  grid-area: nav;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.shell-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.shell-nav__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.shell-nav__link:hover {
  color: var(--text);
  background: var(--surface-sunken);
}

.shell-nav__link[aria-current] {
  color: var(--accent-strong);
  background: var(--accent-tint);
}

/* ── Page actions ─────────────────────────────────────────────── */
.shell-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* The controls used to position themselves inside .brand with auto
   margins (some !important, in RTL); the grid positions them now. */
.shell-actions > * {
  margin: 0 !important;
}

/* ── Sub-navigation band ──────────────────────────────────────── */
.shell-subnav {
  display: flex;
  justify-content: center;
  height: 46px;
  padding: 0 24px;
  background: var(--shell-band);
  border-bottom: 1px solid var(--border);
}

.shell-subnav[hidden],
.shell-subnav__list[hidden] {
  display: none;
}

.shell-subnav__list {
  display: flex;
  align-items: stretch;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.shell-subnav__list::-webkit-scrollbar {
  display: none;
}

.shell-subnav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--shell-band-text-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.shell-subnav__link:hover {
  color: var(--shell-band-text);
  background: var(--shell-band-hover);
}

.shell-subnav__link[aria-current="page"] {
  color: var(--shell-band-text);
  font-weight: 600;
}

.shell-subnav__link[aria-current="page"]::after {
  content: "";
  position: absolute;
  inset-inline: 12px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--shell-band-indicator);
}

.shell-subnav__link.badge-soon-link {
  padding-inline-end: 38px; /* Give more space to fit badge */
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none; /* Disables click and hover on the link itself */
}

/* Because pointer-events: none disables hover, we don't need a hover state override */

.shell-subnav__link.badge-soon-link::after {
  /* No content here, aria-current="page" uses ::after */
}

.shell-subnav__link.badge-soon-link::before {
  content: attr(data-badge);
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-end: 8px; /* relative to padding-inline-end */
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--mark-catch, #FEB536);
  color: var(--mark-disc, #043E3D);
  text-transform: uppercase;
  letter-spacing: 0.2px;
  box-shadow: 0 1px 3px rgba(254, 181, 54, 0.4), 0 1px 2px rgba(0,0,0,0.1);
  border: 1px solid rgba(254, 181, 54, 0.6);
  pointer-events: none; /* Let clicks pass through */
  z-index: 1;
}

/* RTL adjustment for letter spacing */
html[dir="rtl"] .shell-subnav__link.badge-soon-link::before {
  letter-spacing: normal;
  font-family: 'IBM Plex Sans Arabic', 'Tajawal', 'Inter', system-ui, sans-serif;
}

/* ── Focus ────────────────────────────────────────────────────── */
.shell-brand:focus-visible,
.shell-nav__link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.shell-subnav__link:focus-visible {
  outline: 2px solid var(--shell-band-indicator);
  outline-offset: -4px;
}

/* ── Arabic ───────────────────────────────────────────────────── */
html[dir="rtl"] .shell-nav__link,
html[dir="rtl"] .shell-subnav__link {
  font-family: 'IBM Plex Sans Arabic', 'Tajawal', 'Inter', system-ui, sans-serif;
  letter-spacing: normal;
}

/* ── Responsive ───────────────────────────────────────────────── */

/* When one row gets crowded, the primary nav moves under the brand.
   The exam view needs this sooner because it adds the hand-tracking button.
   The two blocks below are the same layout at two widths
   (html[data-boot-route] covers first paint, before the router runs). */
@media (max-width: 1120px) {
  html[data-boot-route="exam"] .shell-header .shell-bar,
  body[data-active-route="exam"] .shell-header .shell-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "nav   nav";
    row-gap: 4px;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 10px 20px 6px;
  }
}

@media (max-width: 960px) {
  .shell-header .shell-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "nav   nav";
    row-gap: 4px;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 10px 20px 6px;
  }
}

@media (max-width: 640px) {
  .shell-header .shell-bar {
    padding: 8px 12px 6px;
    column-gap: 12px;
  }

  .shell-brand .brand-text p {
    display: none;
  }

  .shell-actions {
    gap: 8px;
  }

  /* Phone tab bar: four equal columns, icon above label, never scrolls. */
  .shell-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
    overflow: visible;
  }

  .shell-nav__link {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    height: 50px;
    padding: 0 4px;
    font-size: 0.74rem;
  }

  /* Icon-only hand-tracking button. ht-nav-dropdown.css removes the label
     with display:none; keep it for screen readers instead. */
  .shell-actions .ht-top-btn > span {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .shell-subnav {
    justify-content: flex-start;
    padding: 0 8px;
  }

  .shell-subnav__link {
    padding: 0 12px;
    font-size: 0.84rem;
  }

  .shell-subnav__link.badge-soon-link {
    padding-inline-end: 32px;
  }
  
  .shell-subnav__link.badge-soon-link::before {
    inset-inline-end: 6px;
    font-size: 0.55rem;
    padding: 2px 4px;
  }
}
