/* =====================================================================
   PIRT Theme — Admin local-tasks tabs + admin-toolbar offset
   Per TASK-R3-001 + TASK-R4-016 (header was covering admin toolbar).
   ===================================================================== */

/* ---- Push the fixed `.nav` down so the Drupal admin toolbar isn't covered.
   Drupal core sets --drupal-displace-offset-top when the toolbar / its
   trays are open. Falling back to body class checks for admin_toolbar
   contrib + claro defaults. */
.nav {
  top: var(--drupal-displace-offset-top, 0) !important;
  /* sit BELOW the admin toolbar (toolbar uses 502 / 1259) */
  z-index: 499;
}
/* When admin toolbar JS hasn't yet computed the displace offset, use
   conservative class-based fallbacks so the nav doesn't flash on top of
   the toolbar during first paint. */
body.toolbar-fixed .nav { top: 39px !important; }
body.toolbar-fixed.toolbar-horizontal.toolbar-tray-open .nav { top: 79px !important; }
body.toolbar-vertical.toolbar-tray-open .nav { left: 240px; }

/* Skin layer uses `position: sticky` for the nav — same fix applies. */
body.skin .nav {
  top: var(--drupal-displace-offset-top, 0) !important;
  z-index: 499 !important;
}
body.skin.toolbar-fixed .nav { top: 39px !important; }
body.skin.toolbar-fixed.toolbar-horizontal.toolbar-tray-open .nav { top: 79px !important; }

/* =====================================================================
   Local-tasks tabs — View / Edit / Delete / Revisions / Translate

   Drupal core (stable9 base) renders the `local_tasks_block` plugin as
   `<ul class="tabs primary">…</ul>` (+ `tabs secondary` if present).
   The block is placed in region `highlighted` and `page.html.twig`
   wraps that region with `<div class="container highlighted">`.

   Visibility is server-side gated to admin/editor/reviewer roles only
   (see ISSUE-0078, block.block.pirt_local_tasks.yml). Anonymous users
   never receive this markup.
   ===================================================================== */

/* Region wrapper — the JS behavior moves this directly below entity heroes. */
.container.highlighted {
  padding: 0 24px;
  margin-top: 18px;
  margin-bottom: 24px;
}

.container.highlighted:empty {
  display: none;
}

.container.highlighted.pirt-tabs-after-hero {
  margin-top: 18px;
  margin-bottom: 28px;
}

/* Hide accessibility-only headings Drupal injects above the bar */
.container.highlighted h2.visually-hidden,
nav.tabs-wrapper > h2.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* === Primary tab bar (pill row) === */
ul.tabs.primary,
ul.tabs--primary,
nav.tabs-wrapper--primary > ul {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--sp-surface, #fff);
  border: 1px solid var(--sp-line, #d9e2ec);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 34, 66, 0.06);
  font-size: 13px;
  line-height: 1.4;
}

ul.tabs.primary > li,
ul.tabs--primary > li {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Defeat any global ::before bullets the skin attaches to <li> elements */
ul.tabs.primary > li::before,
ul.tabs--primary > li::before {
  content: none;
}

/* Tab links — neutral resting state, teal hover, white-on-teal active */
ul.tabs.primary > li > a,
ul.tabs--primary > li > a {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 6px;
  color: var(--sp-text, #002242);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background-color 150ms ease, color 150ms ease;
}

ul.tabs.primary > li > a:hover,
ul.tabs--primary > li > a:hover {
  background: rgba(1, 128, 129, 0.09);
  color: var(--sp-primary, #018081);
}

ul.tabs.primary > li > a:focus-visible,
ul.tabs--primary > li > a:focus-visible {
  outline: 2px solid var(--sp-primary, #018081);
  outline-offset: 2px;
}

/* Active tab — filled teal pill (Drupal applies `.is-active` to the <a>
   on canonical entity pages and to the <li> on entity-edit forms;
   handle both shapes). */
ul.tabs.primary > li.is-active > a,
ul.tabs.primary > li > a.is-active,
ul.tabs--primary > li.is-active > a,
ul.tabs--primary > li > a.is-active {
  background: var(--sp-primary, #018081);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(1, 128, 129, 0.28);
}

ul.tabs.primary > li.is-active > a:hover,
ul.tabs.primary > li > a.is-active:hover,
ul.tabs--primary > li.is-active > a:hover,
ul.tabs--primary > li > a.is-active:hover {
  background: var(--sp-primary-d, #016566);
  color: #fff;
}

/* === Secondary tabs (Translate overview, Content moderation states) === */
ul.tabs.secondary,
ul.tabs--secondary {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 12px;
}

ul.tabs.secondary > li,
ul.tabs--secondary > li {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.tabs.secondary > li::before,
ul.tabs--secondary > li::before {
  content: none;
}

ul.tabs.secondary > li > a,
ul.tabs--secondary > li > a {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 4px;
  color: var(--sp-muted, #5b6b7c);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

ul.tabs.secondary > li > a:hover,
ul.tabs.secondary > li.is-active > a,
ul.tabs.secondary > li > a.is-active,
ul.tabs--secondary > li > a:hover,
ul.tabs--secondary > li.is-active > a,
ul.tabs--secondary > li > a.is-active {
  background: rgba(1, 128, 129, 0.08);
  color: var(--sp-primary, #018081);
  border-color: rgba(1, 128, 129, 0.18);
}
