/* Shared public app shell: one compact task bar and native disclosures. Loaded after
   bootstrap-theme.css, which owns the Bootstrap component theme. This file composes the
   real Bootstrap `.nav`/`.nav-link`, `.btn` and `.input-group` classes for the masthead;
   it does not draw a second native control layer. */

.ui-icon { flex: none; vertical-align: middle; }

/* Site header ------------------------------------------------------------- */
.site-header {
  position: relative;
  background: var(--surface);
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid var(--rule);
}
.masthead {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand nav utilities";
  align-items: center;
  column-gap: clamp(12px, 2vw, 28px);
  padding-block: 6px;
}
.brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { color: var(--ink); }
.brand-icon { display: block; width: 28px; height: 28px; flex: none; }
.brand-name {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
}

/* Primary destinations: one responsive nav, no duplicated desktop/mobile copies. */
.site-nav {
  grid-area: nav;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 2px;
  min-width: 0;
}
.site-nav .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.15;
  white-space: nowrap;
  transition: color var(--motion) ease, background-color var(--motion) ease,
              box-shadow var(--motion) ease;
}
.site-nav .nav-link:hover { color: var(--accent); background: var(--accent-soft); }
.site-nav .nav-link[aria-current] {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
  box-shadow: inset 0 -3px 0 var(--accent);
}
/* Bootstrap's `.nav-link:focus-visible` sets `outline: 0` at a higher specificity than
   the shared focus rule. Restore the solid public focus outline at the shell boundary. */
.site-nav .nav-link:focus-visible,
.app-panel-link:focus-visible,
.app-disclosure-toggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: none;
}
.app-nav-label-narrow { display: none; }

/* Utility disclosures. Desktop opens a native panel below its trigger; the mobile
   layout turns the same details into a full-width row in normal flow. */
.app-utilities {
  grid-area: utilities;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}
.app-disclosure { position: relative; min-width: 0; line-height: 1.2; }
.app-disclosure-toggle {
  gap: 6px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.app-disclosure[data-state] > .app-disclosure-toggle { color: var(--accent); border-color: var(--accent); }
.app-disclosure > summary { list-style: none; cursor: pointer; }
.app-disclosure > summary::-webkit-details-marker { display: none; }
.app-disclosure > summary .ui-icon { flex: none; width: 1.05em; height: 1.05em; }
.app-disclosure-label { overflow-wrap: normal; }
.app-disclosure-marker { display: inline-flex; flex: none; transition: transform var(--motion) ease; }
.app-disclosure > summary .app-disclosure-marker .ui-icon { width: 0.8em; height: 0.8em; }
.app-disclosure[open] .app-disclosure-marker { transform: rotate(180deg); }

.app-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  width: min(16rem, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid var(--rule-strong);
  border-top: 3px solid var(--accent);
  border-radius: 0 0 8px 8px;
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(26, 26, 26, 0.14);
}
.app-search-panel { width: min(15rem, calc(100vw - 32px)); }
.app-more-panel { display: grid; grid-template-columns: 1fr; gap: 10px; }
.app-panel-title {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.app-panel-list { margin: 0; padding: 0; list-style: none; }
.app-panel-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 4px 8px;
  border-radius: 5px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.2;
  white-space: nowrap;
}
.app-panel-link:hover { color: var(--accent); background: var(--accent-soft); }
.app-panel-link[aria-current] { color: var(--accent); font-weight: 600; }
.app-disclosure:not([open]) > .app-panel { display: none; }

/* Search is one native input group inside the disclosure: no second term field. */
.search { display: block; width: 100%; min-width: 0; margin: 0; }
.app-search .form-control {
  min-height: 44px;
  padding: 8px 10px;
  font-size: 0.9rem;
}
.app-search .btn {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 0.85rem;
}

@media (max-width: 1120px) {
  /* Between the one-row desktop bar and the phone stack, the brand and utilities
     share the first row while the full-label task rail takes its own. The three
     links keep their reviewed label widths instead of overrunning the utilities. */
  .masthead {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand utilities" "nav nav";
    row-gap: 4px;
    padding-block: 5px;
  }
}

/* Narrow app bar ---------------------------------------------------------- */
@media (max-width: 900px) {
  .masthead {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "brand" "nav" "utilities";
    row-gap: 3px;
    padding-block: 2px;
  }
  .brand { justify-self: start; min-height: 48px; max-width: calc(100% - 96px); }
  .brand-name { font-size: 1.25rem; }
  .site-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px;
  }
  .site-nav .nav-link {
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-height: 48px;
    padding: 3px 2px;
    text-align: center;
    white-space: normal;
    line-height: 1.0;
  }
  .site-nav .nav-link .ui-icon { width: 18px; height: 18px; }
  .app-nav-label { display: block; }
  .app-nav-label-wide { display: none; }
  .app-nav-label-narrow { display: inline; }
  .app-utilities {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px;
    padding-top: 0;
  }
  .app-disclosure-toggle {
    gap: 3px;
    min-height: 44px;
    padding: 7px 8px;
  }
  .app-disclosure > summary .ui-icon { width: 0.8em; height: 0.8em; }
  .app-disclosure > summary .app-disclosure-marker .ui-icon {
    width: 0.5em;
    height: 0.5em;
  }
  .app-more { position: static; width: 100%; }
  .app-more > summary { position: absolute; top: 6px; right: 20px; }
  .app-disclosure[open] { flex: 1 1 100%; }
  .app-panel {
    position: static;
    width: auto;
    margin-top: 6px;
    padding: 8px;
    border-radius: 7px;
    box-shadow: none;
  }
  .app-search-panel { width: auto; }
  .app-more-panel { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .brand-icon { width: 26px; height: 26px; }
  .app-more > summary { right: 16px; }
  .app-search .form-control,
  .app-search .btn {
    flex: 1 1 100%;
    width: 100%;
  }
  /* Bootstrap's multiple :not selectors outrank ordinary theme classes. The
     stacked-only exception restores all outer corners, not the joined row. */
  .app-search > .input-group > .form-control:not(:last-child) {
    border-radius: 7px 7px 0 0 !important;
  }
  .app-search > .input-group > .btn:not(:first-child) {
    margin-top: -1px;
    margin-left: 0 !important;
    border-radius: 0 0 7px 7px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-nav .nav-link, .app-disclosure-toggle, .app-disclosure-marker {
    transition: none !important;
    animation: none !important;
  }
  .app-disclosure[open] .app-disclosure-marker { transform: none; }
}

@media print {
  .site-header, .search, .app-panel { display: none !important; }
}
