/* public/_share/carnegie-nav.css — shared Carnegie nav styles.
 *
 * 2026-05-31: Consolidated the row of icon-pill nav links into a SINGLE
 * launcher button + monochrome line-icon tile grid. Per-page action
 * buttons still live in the action slot via CarnegieNav.addAction().
 *
 * Carnegie-simplistic: black/white only, no gradients, no decorative
 * color. Active page tile is filled solid black; everything else is
 * 1px outlined.
 */

.carnegie-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  row-gap: 8px;
}

/* The header itself must establish a HIGH stacking context. Tower's sections
 * use z-index up to 9000 (run-tray, kanban modals, sticky bars). Without
 * this rule, the launcher panel (z-index 200 inside the header) gets
 * painted UNDERNEATH Tower's hero text, run-tray button, etc. (Kenneth
 * screenshot 2026-05-31: hero "Paste companies you like" bled through the
 * tile grid.) Use `isolation: isolate` to also create a clean stacking
 * context that prevents Tower's high-z descendants from poking through.
 */
.carnegie-nav-root,
.create-header.carnegie-nav-root {
  position: relative;
  z-index: 10000;
  isolation: isolate;
}

.carnegie-nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

/* Per-page action slot (Connect Gmail / Save / + New page / etc.). */
.carnegie-nav-slot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.carnegie-nav-slot:empty { display: none; }

/* ── Launcher trigger ───────────────────────────────────────────────── */
.carnegie-launcher {
  position: relative;
}
.carnegie-launcher-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--air-surface, #ffffff);
  border: 1px solid var(--air-divider-strong, rgba(11,16,32,0.18));
  color: var(--air-text, #0b1020);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 200ms cubic-bezier(0.32, 0.72, 0, 1),
              background 150ms cubic-bezier(0.32, 0.72, 0, 1);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  font-family: var(--air-font-body, "DM Sans", system-ui, sans-serif);
}
.carnegie-launcher-trigger:hover { background: rgba(11,16,32,0.04); }
.carnegie-launcher-trigger:active { transform: scale(0.94); }
.carnegie-launcher-trigger svg {
  width: 16px;
  height: 16px;
  display: block;
  stroke: currentColor;
  fill: currentColor; /* dots */
}
.carnegie-launcher-trigger.is-pressing { background: rgba(11,16,32,0.06); }
.carnegie-launcher-trigger.is-pressing::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--air-text, #0b1020);
  opacity: 0.35;
  animation: carnegie-press-ring 500ms linear forwards;
}
@keyframes carnegie-press-ring {
  from { transform: scale(1.0); opacity: 0.35; }
  to   { transform: scale(1.18); opacity: 0; }
}

/* ── Launcher panel (expanded grid) ─────────────────────────────────── */
.carnegie-launcher-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(320px, calc(100vw - 24px));
  background: #ffffff;
  border: 1px solid var(--air-divider-strong, rgba(11,16,32,0.18));
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(11,16,32,0.16),
              0 4px 12px rgba(11,16,32,0.08);
  padding: 10px;
  /* z-index well above Tower's highest section z-index (9000). The header
   * itself is z-index:10000 + isolate so this is local — but we bump high
   * inside the local context too as defense in depth. */
  z-index: 10;
  font-family: var(--air-font-body, "DM Sans", system-ui, sans-serif);
  color: var(--air-text, #0b1020);

  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.97);
  transform-origin: top right;
  transition:
    opacity 220ms cubic-bezier(0.32, 0.72, 0, 1),
    transform 260ms cubic-bezier(0.32, 0.72, 0, 1),
    visibility 0s linear 260ms;
}
.carnegie-launcher.is-open .carnegie-launcher-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition:
    opacity 220ms cubic-bezier(0.32, 0.72, 0, 1),
    transform 320ms cubic-bezier(0.32, 0.72, 0, 1),
    visibility 0s linear 0s;
}
.carnegie-launcher-panel-header {
  font-size: 10px;
  font-family: "Fira Code", ui-monospace, monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(11,16,32,0.38);
  padding: 4px 8px 8px;
}

/* Backdrop catches outside-taps and adds a subtle dimming. It lives INSIDE
 * the header's isolation context, so z-index is local. Must sit BELOW the
 * panel (panel is z:10) so taps reach the tiles. The header itself sits
 * at z:10000 in the body stacking context, so even though the backdrop
 * is locally z:1, it still paints above page content below the header. */
.carnegie-launcher-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11,16,32,0.12);
  z-index: 1;
  display: none;
  pointer-events: auto;
}
.carnegie-launcher.is-open .carnegie-launcher-backdrop { display: block; }
.carnegie-launcher-panel { z-index: 10; }

/* ── Tile grid ──────────────────────────────────────────────────────── */
.carnegie-launcher-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.carnegie-launcher-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 14px 6px 12px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--air-text, #0b1020);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
  min-height: 88px;
  transition: background 160ms cubic-bezier(0.32, 0.72, 0, 1),
              transform 160ms cubic-bezier(0.32, 0.72, 0, 1);
  font-family: var(--air-font-body, "DM Sans", system-ui, sans-serif);
}
.carnegie-launcher-tile:hover { background: rgba(11,16,32,0.04); }
.carnegie-launcher-tile:active { transform: scale(0.95); }
.carnegie-launcher-tile.is-current { background: rgba(11,16,32,0.06); }

.carnegie-launcher-tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--air-text, #0b1020);
  background: transparent;
  border: 1px solid var(--air-divider-strong, rgba(11,16,32,0.18));
  box-sizing: border-box;
}
.carnegie-launcher-tile.is-current .carnegie-launcher-tile-icon {
  background: var(--air-text, #0b1020);
  color: var(--air-surface, #ffffff);
  border-color: var(--air-text, #0b1020);
}
.carnegie-launcher-tile-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  stroke: currentColor;
  fill: none;
}

.carnegie-launcher-tile-label {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--air-text, #0b1020);
  font-family: var(--air-font-body, "DM Sans", system-ui, sans-serif);
}
.carnegie-launcher-tile-sub {
  font-size: 10px;
  color: rgba(11,16,32,0.38);
  line-height: 1.2;
  font-family: "Fira Code", ui-monospace, monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.carnegie-launcher-tile-sub:empty { display: none; }

/* ── Stagger entrance ───────────────────────────────────────────────── */
.carnegie-launcher.is-open .carnegie-launcher-tile {
  animation: carnegie-tile-in 380ms cubic-bezier(0.32, 0.72, 0, 1) both;
}
.carnegie-launcher.is-open .carnegie-launcher-tile:nth-child(1) { animation-delay: 30ms; }
.carnegie-launcher.is-open .carnegie-launcher-tile:nth-child(2) { animation-delay: 70ms; }
.carnegie-launcher.is-open .carnegie-launcher-tile:nth-child(3) { animation-delay: 110ms; }
.carnegie-launcher.is-open .carnegie-launcher-tile:nth-child(4) { animation-delay: 150ms; }
.carnegie-launcher.is-open .carnegie-launcher-tile:nth-child(5) { animation-delay: 190ms; }
.carnegie-launcher.is-open .carnegie-launcher-tile:nth-child(6) { animation-delay: 230ms; }
@keyframes carnegie-tile-in {
  from { opacity: 0; transform: scale(0.85) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Desktop hover-to-expand */
@media (hover: hover) and (pointer: fine) {
  .carnegie-launcher:hover .carnegie-launcher-panel,
  .carnegie-launcher:focus-within .carnegie-launcher-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    transition:
      opacity 220ms cubic-bezier(0.32, 0.72, 0, 1),
      transform 320ms cubic-bezier(0.32, 0.72, 0, 1),
      visibility 0s linear 0s;
  }
  .carnegie-launcher:hover .carnegie-launcher-tile,
  .carnegie-launcher:focus-within .carnegie-launcher-tile {
    animation: carnegie-tile-in 380ms cubic-bezier(0.32, 0.72, 0, 1) both;
  }
}

/* ── Narrow-viewport label collapse on the action slot ──────────────────
 * Action-slot buttons (Connect Gmail, Connect LinkedIn, Save, etc.) are
 * already shrunk by their own `.air-btn-sm` class. At ≤480px hide labels
 * tagged with `.carnegie-action-label` so only icons remain — pages can
 * opt in by wrapping the button text in `<span class="carnegie-action-label">`.
 */
@media (max-width: 480px) {
  .carnegie-launcher-panel {
    width: calc(100vw - 24px);
    right: -8px;
    max-width: 360px;
  }
  .carnegie-nav-brand .create-brand-sub { display: none; }
  .carnegie-nav-slot .carnegie-action-label { display: none; }
  .carnegie-nav-slot .air-btn { padding: 0 10px; min-width: 36px; }
  .carnegie-nav-slot .air-btn svg { margin-right: 0; }
}
@media (max-width: 380px) {
  .carnegie-nav-brand .create-brand-name { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .carnegie-launcher-panel,
  .carnegie-launcher-tile,
  .carnegie-launcher-trigger,
  .carnegie-launcher-trigger::before {
    transition: none !important;
    animation: none !important;
  }
}

/* Rule #10 guard: any element inside the launcher with `hidden` must
 * truly hide regardless of base display rules. */
.carnegie-launcher-panel[hidden],
.carnegie-launcher-tile[hidden],
.carnegie-launcher-trigger[hidden] {
  display: none !important;
}
