/* ============================================================
   Analytics Hub · global UX layer styles (palette / hamburger /
   recent / ribbon / skip-link)
   Inherits tokens from styles.css (--bg, --text, --accent, etc.)
   ============================================================ */

/* ----------------------------------------------------- External-link arrow */
/* Adds ↗ via ::after to anchors tagged with .ah-ext by palette.js. */
.ah-ext::after {
  content: " \2197"; /* ↗ */
  display: inline-block;
  margin-left: 2px;
  color: var(--text-muted);
  font-size: .82em;
  font-weight: 400;
  text-decoration: none;
  vertical-align: baseline;
}
a.ah-ext:hover::after { color: var(--accent); }

/* ----------------------------------------------------- Nudges (pulse + toast) */
/* Halo applied to a target element. Removed on click or timeout. */
@keyframes ah-nudge-pulse {
  0%   { box-shadow: 0 0 0 0   color-mix(in srgb, var(--accent) 55%, transparent); }
  70%  { box-shadow: 0 0 0 14px color-mix(in srgb, var(--accent)  0%, transparent); }
  100% { box-shadow: 0 0 0 0   color-mix(in srgb, var(--accent)  0%, transparent); }
}
.ah-nudge-pulse {
  position: relative;
  border-radius: 8px;
  animation: ah-nudge-pulse 1.8s ease-out infinite;
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}
.ah-nudge-pulse--static { animation: none; }

/* Toast (corner chip variant) */
.ah-nudge-toast {
  position: fixed;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .65rem .55rem .85rem;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 999px;
  box-shadow: 0 6px 20px -8px color-mix(in srgb, var(--accent) 35%, transparent);
  font-size: .85rem;
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto;
}
.ah-nudge-toast.is-shown { opacity: 1; transform: translateY(0); }
.ah-nudge-toast--top-right    { top: 84px;     right: 18px; }
.ah-nudge-toast--bottom-right { bottom: 18px;  right: 18px; }
.ah-nudge-toast__close {
  appearance: none; border: 0; background: transparent;
  font-size: 1.05rem; line-height: 1; color: var(--text-muted);
  cursor: pointer; padding: 2px 6px; border-radius: 50%;
}
.ah-nudge-toast__close:hover { color: var(--text); background: var(--bg-alt); }

/* Recently Viewed empty state */
.ah-recent--empty {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--border));
}
.ah-recent--empty .ah-recent__label {
  color: var(--text-soft);
  font-style: italic;
}

/* ----------------------------------------------------- skip link */
.ah-skip {
  position: absolute; top: -100px; left: 12px;
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px;
  font-weight: 600; font-size: 14px;
  z-index: 100; text-decoration: none;
  transition: top .15s ease;
}
.ah-skip:focus { top: 12px; outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----------------------------------------------------- ribbon */
.ah-ribbon {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 14%, transparent), color-mix(in srgb, var(--accent-2) 10%, transparent));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  font-size: 13px;
}
.ah-ribbon[hidden] { display: none; }
.ah-ribbon__inner {
  max-width: 1200px; margin: 0 auto; padding: 8px 24px;
  display: flex; align-items: center; gap: 10px;
}
.ah-ribbon__tag {
  background: var(--accent); color: #fff;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.ah-ribbon__msg {
  color: var(--text); font-weight: 600;
  text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 60ch;
}
.ah-ribbon__msg:hover { text-decoration: underline; }
.ah-ribbon__meta { color: var(--text-muted); font-size: 12px; }
.ah-ribbon__close {
  margin-left: auto; background: transparent; border: 0;
  color: var(--text-soft); cursor: pointer; font-size: 18px;
  padding: 0 4px; line-height: 1;
}
.ah-ribbon__close:hover { color: var(--text); }

/* ----------------------------------------------------- palette trigger pill */
.ah-palette-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-soft); cursor: pointer;
  padding: 6px 10px 6px 12px; border-radius: 999px;
  font: inherit; font-size: 13px;
  transition: background .15s, color .15s, border-color .15s;
}
.ah-palette-trigger:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.ah-palette-trigger kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: var(--font);
  color: var(--text-muted);
}

/* ----------------------------------------------------- palette modal */
.ah-palette[hidden] { display: none; }
.ah-palette {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.ah-palette__backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 20, 40, .35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.ah-palette__box {
  position: relative;
  width: min(640px, 92vw);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.ah-palette__input {
  width: 100%; box-sizing: border-box;
  padding: 16px 20px;
  font: inherit; font-size: 16px;
  background: transparent; color: var(--text);
  border: 0; border-bottom: 1px solid var(--border);
  outline: none;
}
.ah-palette__results {
  list-style: none; margin: 0; padding: 6px 0;
  max-height: 50vh; overflow-y: auto;
}
.ah-palette__item {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  align-items: center; gap: 12px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.ah-palette__item.is-active,
.ah-palette__item:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.ah-palette__kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
  text-align: center;
  background: var(--surface-2); color: var(--text-soft);
}
.ah-palette__kind--report { background: color-mix(in srgb, var(--accent-2) 22%, transparent); color: var(--accent-2); }
.ah-palette__kind--page   { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.ah-palette__title { font-weight: 600; }
.ah-palette__ext { font-size: 11px; color: var(--text-muted); }
.ah-palette__hint { color: var(--text-muted); font-size: 12px; text-align: right; }
.ah-palette__empty {
  list-style: none; padding: 24px; text-align: center;
  color: var(--text-muted); font-size: 14px;
}
.ah-palette__footer {
  display: flex; gap: 14px; justify-content: center;
  padding: 8px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 11px; color: var(--text-muted);
}
.ah-palette__footer kbd {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 5px;
  font-family: var(--font); font-size: 10px; margin-right: 3px;
}

/* ----------------------------------------------------- Star CTA */
.ah-star {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text) !important;
  padding: 4px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.ah-star:hover {
  background: linear-gradient(135deg, #f9c513, #e3008c);
  color: #fff !important;
  border-color: transparent;
  text-decoration: none;
}
.ah-star__icon { color: #f9c513; font-size: 14px; }
.ah-star:hover .ah-star__icon { color: #fff; }
.ah-star__count {
  background: var(--bg); color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px; font-weight: 700;
  min-width: 24px; text-align: center;
}
.ah-star:hover .ah-star__count {
  background: rgba(255,255,255,.2);
  border-color: rgba(255,255,255,.3);
  color: #fff;
}

/* ----------------------------------------------------- hamburger (hidden by default) */
.ah-hamburger {
  display: none;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); cursor: pointer;
  width: 36px; height: 36px;
  border-radius: 8px; margin-left: auto;
  font-size: 18px; line-height: 1;
  align-items: center; justify-content: center;
}

/* ----------------------------------------------------- recently viewed rail */
.ah-recent[hidden] { display: none; }
.ah-recent {
  max-width: 1200px; margin: 0 auto;
  padding: 16px 24px 8px;
}
.ah-recent__label {
  margin: 0 0 8px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); font-weight: 700;
}
.ah-recent__row { display: flex; flex-wrap: wrap; gap: 8px; }
.ah-recent__chip {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px;
}
.ah-recent__chip:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  text-decoration: none;
}

/* ----------------------------------------------------- mobile breakpoint */
@media (max-width: 760px) {
  .ah-palette-trigger span { display: none; } /* keep just icon + kbd */
  .ah-palette-trigger kbd  { display: none; }
  .ah-star__label { display: none; }

  .ah-hamburger { display: inline-flex; }

  .site-header .wrap {
    flex-wrap: wrap;
    height: auto;
    padding-top: 10px; padding-bottom: 10px;
  }

  .primary-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 10px;
  }
  .primary-nav.is-open { display: flex; }
  .primary-nav a {
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
  }
  .primary-nav a:last-child { border-bottom: 0; }
  .primary-nav a:not(.nav-cta)::after { display: none; }
  .nav-cta { text-align: center; }

  /* Recent chips: full-width row, horizontal scroll */
  .ah-recent__row { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .ah-recent__chip { white-space: nowrap; }
}

/* ----------------------------------------------------- print: hide chrome */
@media print {
  .ah-ribbon, .ah-palette, .ah-palette-trigger, .ah-hamburger, .ah-skip { display: none !important; }
}
