/* mega-menu.css — Tools navigation mega menu.
 *
 * Deliberately NOT Tailwind. This site has no build pipeline (no npm,
 * no bundler, no PostCSS) — every other stylesheet is hand-authored CSS
 * against the existing custom-property system in main.css. Introducing
 * Tailwind here would mean either a runtime CDN (no purge, worse
 * Lighthouse score — the opposite of what was asked for) or bolting on
 * a whole new build toolchain to redesign one menu. This file extends
 * the site's own design tokens (--p1, --text-dim, --ease, etc.) instead,
 * so it's a natural evolution of the existing system, not a second
 * styling language living next to it.
 *
 * Loaded on every page via header-chrome.js's HEAD_LINKS — one file,
 * one link, no per-page duplication.
 */

/* ── Container: same trigger/positioning as before, wider + taller to
   fit two panels. Motion upgraded from a plain fade+slide to fade +
   scale + slide, matching the "premium SaaS" opening feel of Linear/
   Vercel-style menus while keeping the exact easing curve (var(--ease))
   already used for every other transition on the site. ── */
.nav-tools-panel.mega {
  width: 760px;
  padding: 0;
  display: grid;
  grid-template-columns: 264px 1fr;
  transform: translateX(-50%) translateY(-8px) scale(.97);
  transform-origin: top center;
  overflow: hidden;
}
/* NOTE: header-chrome.js stamps this element as
   class="nav-tools-panel mega" -- both classes on the SAME element.
   .mega-footer (further below) has always had `grid-column: 1 / -1` --
   a CSS Grid property, meaningless outside a grid container. That is
   the tell that this panel was designed as a 2-column GRID (rail |
   preview, footer spanning both) from the start, not flex. An earlier
   state of this rule had `display: block`, which broke rail/preview
   into stacked blocks; a previous pass "fixed" that to
   `display: flex`, which stopped the stacking but broke the footer's
   spanning instead, since flex has no concept of grid-column. The
   footer then became a cramped THIRD flex sibling, squeezing the
   preview panel down to roughly a third of its intended width --
   which is what caused a wrapped heading colliding with the
   illustration, truncated tool names, and an overlapping highlight
   card, all visible together in one screenshot. Grid is correct here:
   it matches what .mega-footer already assumed, restores the
   preview's real ~470px width, and needs no HTML changes -- grid
   auto-flow places mega-rail and mega-preview in row 1's two columns,
   then mega-footer's own grid-column: 1 / -1 drops it to row 2,
   spanning both. */
.nav-tools-drop:hover .nav-tools-panel.mega,
.nav-tools-drop:focus-within .nav-tools-panel.mega,
.nav-tools-drop.js-open .nav-tools-panel.mega {
  transform: translateX(-50%) translateY(0) scale(1);
}

.mega-rail {
  min-width: 0; padding: 10px;
  border-right: 1px solid rgba(255,255,255,.07);
  display: flex; flex-direction: column; gap: 2px;
}

/* ── Category card ── */
.mega-cat {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 10px;
  text-decoration: none; color: inherit;
  border: 1px solid transparent;
  transition: background 180ms var(--ease), border-color 180ms var(--ease), transform 180ms var(--ease);
  opacity: 0; transform: translateX(-6px);
  animation: megaCatIn 320ms var(--ease) forwards;
}
/* Staggered entrance — each card ~35ms after the last, capped well
   under the "avoid excessive motion" line (5 cards × 35ms = 175ms). */
.mega-cat:nth-child(1) { animation-delay: 20ms; }
.mega-cat:nth-child(2) { animation-delay: 55ms; }
.mega-cat:nth-child(3) { animation-delay: 90ms; }
.mega-cat:nth-child(4) { animation-delay: 125ms; }
.mega-cat:nth-child(5) { animation-delay: 160ms; }
@keyframes megaCatIn { to { opacity: 1; transform: translateX(0); } }

.mega-cat:hover, .mega-cat:focus-visible, .mega-cat.active {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}
.mega-cat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mega-cat-ico {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease);
}
.mega-cat-ico svg { width: 18px; height: 18px; }
.mega-cat:hover .mega-cat-ico, .mega-cat.active .mega-cat-ico {
  transform: rotate(-6deg) scale(1.08);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}

.mega-cat-body { flex: 1; min-width: 0; }
.mega-cat-top {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--fd); font-weight: 600; font-size: 13.5px; color: var(--text);
}
.mega-cat-count {
  font-family: var(--fb); font-size: 10.5px; font-weight: 600;
  color: var(--text-faint); background: rgba(255,255,255,.06);
  padding: 1px 6px; border-radius: 100px;
}
.mega-cat-desc {
  display: block; font-size: 11.5px; color: var(--text-dim);
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mega-cat-arrow {
  width: 14px; height: 14px; color: var(--text-faint); flex-shrink: 0;
  transition: transform 200ms var(--ease), color 200ms var(--ease);
}
.mega-cat:hover .mega-cat-arrow, .mega-cat.active .mega-cat-arrow {
  transform: translateX(3px); color: var(--accent);
}

/* ── Featured tabs (Popular / AI-Powered) — real, honest data only.
   See header-chrome.js for why "New"/"Trending" aren't here. ── */
.mega-tabs {
  display: flex; gap: 4px; margin-top: 8px; padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.mega-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 8px; border-radius: 8px; border: none; cursor: pointer;
  background: transparent; color: var(--text-dim);
  font-family: var(--fb); font-size: 12px; font-weight: 600;
  transition: background 160ms var(--ease), color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.mega-tab span { font-size: 12px; }
.mega-tab:hover { background: rgba(255,255,255,.05); color: var(--text); }
.mega-tab.active {
  background: rgba(34,211,238,.14); color: var(--p1);
  box-shadow: inset 0 0 0 1px rgba(34,211,238,.25);
}
.mega-tab:focus-visible { outline: 2px solid var(--p1); outline-offset: 2px; }

/* ── Preview panel (right) ── */
.mega-preview {
  flex: 1; padding: 20px 22px; display: flex; flex-direction: column; min-width: 0;
}
/* Compressed ~35% vs the previous pass (margin-bottom 16\u219210, gap
   12\u21938, min-height 60\u219240) \u2014 the illustration sits right next to
   the title now instead of floating in dead space above it. */
.mega-preview-head {
  display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px;
  position: relative; min-height: 40px;
}
/* Soft glow blob behind the icon — the same radial-glow technique the
   homepage hero already uses (--accent set inline per category/tab). */
.mega-preview-head::before {
  content: ''; position: absolute; top: -14px; left: -14px; width: 96px; height: 96px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%);
  pointer-events: none; z-index: 0;
}
.mega-preview-ico {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0; position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
}
.mega-preview-ico svg { width: 21px; height: 21px; }
.mega-preview-head h3 {
  font-family: var(--fd); font-size: 16px; font-weight: 700; color: var(--text);
  position: relative; z-index: 1; display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
}
/* "21 Tools" next to the title \u2014 quieter than the heading itself but
   still legible; the count that used to open the paragraph below now
   lives inline here instead, one less line to read before the desc. */
.mega-preview-count {
  font-family: var(--fb); font-size: 11px; font-weight: 600; color: var(--text-faint);
  background: rgba(255,255,255,.05); padding: 2px 7px; border-radius: 99px;
}
.mega-preview-head > div { max-width: 230px; min-width: 0; }
.mega-preview-head p { font-size: 12px; color: var(--text-dim); margin-top: 2px; line-height: 1.45; position: relative; z-index: 1; }

/* Per-category animated illustration \u2014 pulled in closer to the head
   (was top:-6px/right:-4px/148\u00d792) so it reads as part of the same
   compact block instead of a separate floating element. */
.mega-illo-wrap {
  position: absolute; top: -2px; right: 0; width: 120px; height: 74px;
  z-index: 0; pointer-events: none; opacity: .9;
}
.mega-illo { width: 100%; height: 100%; overflow: visible; }

@media (prefers-reduced-motion: no-preference) {
  .illo-float { animation: illoFloat 3.6s ease-in-out infinite; }
  .illo-d1 { animation-delay: 0ms; }
  .illo-d2 { animation-delay: .5s; }
  .illo-d3 { animation-delay: 1s; }
  @keyframes illoFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

  .illo-sparkle { transform-origin: center; animation: illoTwinkle 2.2s ease-in-out infinite; }
  .illo-sp2 { animation-delay: 1.1s; }
  @keyframes illoTwinkle { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.05); } }

  .illo-cursor { animation: illoBlink 1.1s step-end infinite; }
  @keyframes illoBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

  .illo-heart { transform-origin: center; animation: illoPulse 2.6s ease-in-out infinite; }
  @keyframes illoPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

  .illo-bar { transform-origin: bottom; animation: illoGrow 2.8s ease-in-out infinite; }
  .illo-b1 { animation-delay: 0ms; } .illo-b2 { animation-delay: .3s; } .illo-b3 { animation-delay: .6s; }
  @keyframes illoGrow { 0%, 100% { transform: scaleY(.82); } 50% { transform: scaleY(1); } }

  .illo-arrow { animation: illoSlide 1.8s ease-in-out infinite; }
  @keyframes illoSlide { 0%, 100% { transform: translateX(0); opacity: .6; } 50% { transform: translateX(4px); opacity: .9; } }
}
/* No @media query needed for reduced-motion beyond the block above:
   with it absent, every .illo-* element simply keeps its static SVG
   transform/opacity \u2014 there is no default animation to turn off. */

/* ── Hero featured card: the first tool in each category's popular[]
   list gets real visual weight instead of sitting flush with the
   other three. No star rating here \u2014 this site has no review data,
   and a fabricated "\u2605\u2605\u2605\u2605\u2605" would be exactly the kind of invented
   number the honesty notes elsewhere in this codebase warn against.
   The hierarchy comes from size, an elevated background and a real
   CTA instead. ── */
.mega-tool-hero-wrap { position: relative; z-index: 1; margin-bottom: 10px; }
.mega-tool-hero {
  display: flex; flex-direction: column; gap: 8px; padding: 13px 14px; border-radius: 12px;
  text-decoration: none; color: inherit;
  background: linear-gradient(165deg, color-mix(in srgb, var(--accent) 12%, transparent), rgba(255,255,255,.03));
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  transition: border-color 160ms var(--ease), transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.mega-tool-hero:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 35%, transparent);
}
.mega-tool-hero-label {
  font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent);
}
.mega-tool-hero-row { display: flex; align-items: center; gap: 10px; }
.mega-tool-hero-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mega-tool-hero-name { font-family: var(--fd); font-size: 14.5px; font-weight: 700; color: var(--text); }
.mega-tool-hero-blurb { font-size: 12px; color: var(--text-dim); line-height: 1.4; }
.mega-tool-hero-cta {
  display: inline-flex; align-items: center; gap: 5px; align-self: flex-start;
  font-size: 12px; font-weight: 600; color: var(--accent);
  padding: 5px 10px; border-radius: 99px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.mega-tool-hero-cta svg { width: 12px; height: 12px; transition: transform 200ms var(--ease); }
.mega-tool-hero:hover .mega-tool-hero-cta svg { transform: translateX(2px); }

/* Secondary tools: single column now that the hero card carries the
   primary visual weight \u2014 three compact rows read cleaner than an
   uneven 2-column grid with an odd number of items. */
.mega-preview-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; position: relative; z-index: 1; }
.mega-tool {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px;
  color: var(--text-dim); text-decoration: none;
  background: rgba(255,255,255,.03); border: 1px solid transparent;
  transition: background 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease), transform 150ms var(--ease);
}
.mega-tool:hover { background: rgba(255,255,255,.06); color: var(--text); border-color: rgba(255,255,255,.08); transform: translateX(2px); }
.mega-tool.starred .mega-tool-name { color: var(--text); font-weight: 600; }
.mega-tool-mark {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; line-height: 1;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.mega-tool.starred .mega-tool-mark { color: #fbbf24; background: rgba(251,191,36,.14); }
/* Real per-tool preview thumbnail \u2014 replaces the generic \u2605/\u2713 mark
   when CAT_META supplies one (data.js's `thumbs` map). SVG only, no
   images, sized to sit inline with a text row at no performance cost. */
.mega-tool-thumb {
  flex-shrink: 0; width: 30px; height: 22px; border-radius: 5px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.04); color: var(--accent);
}
.mega-tool-thumb svg { width: 26px; height: 18px; }
.mega-tool-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.mega-tool-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mega-tool-blurb { font-size: 11px; color: var(--text-faint); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Highlight card: "Recently Added" (self-expiring, see data.js) or
   "Editor's Pick" \u2014 the only two framings used, both claims this site
   can actually back up (see the honesty note in data.js's CAT_META).
   NEW gets a touch more presence (soft glow + a slow pulse on the
   sparkle) since it's flagging something genuinely just-shipped;
   Editor's Pick stays calmer \u2014 it's curation, not news. ── */
.mega-highlight {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
  padding: 10px 12px; border-radius: 11px; text-decoration: none;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  transition: background 150ms var(--ease), border-color 150ms var(--ease), box-shadow 150ms var(--ease);
  position: relative; z-index: 1;
}
.mega-highlight:hover { background: color-mix(in srgb, var(--accent) 13%, transparent); }
.mega-highlight-new {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent), 0 0 20px -8px color-mix(in srgb, var(--accent) 55%, transparent);
}
.mega-hl-sparkle { font-size: 15px; flex-shrink: 0; }
.mega-hl-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.mega-hl-badge { font-size: 10px; font-weight: 700; letter-spacing: .05em; color: var(--accent); }
.mega-highlight-new .mega-hl-badge { text-transform: uppercase; }
.mega-hl-name { font-size: 13px; font-weight: 600; color: var(--text); }
.mega-hl-cta {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  font-size: 11.5px; font-weight: 600; color: var(--accent);
}
.mega-hl-cta svg { width: 12px; height: 12px; transition: transform 200ms var(--ease); }
.mega-highlight:hover .mega-hl-cta svg { transform: translateX(2px); }

@media (prefers-reduced-motion: no-preference) {
  .mega-highlight-new .mega-hl-sparkle { animation: hlPulse 2.4s ease-in-out infinite; }
  @keyframes hlPulse { 0%, 100% { opacity: .7; transform: scale(1); } 50% { opacity: 1; transform: scale(1.15); } }
}

.mega-explore {
  display: inline-flex; align-items: center; gap: 6px; margin-top: auto;
  font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none;
  padding: 8px 0; position: relative; z-index: 1;
}
.mega-explore svg { width: 13px; height: 13px; transition: transform 200ms var(--ease); }
.mega-explore:hover svg { transform: translateX(3px); }

/* Cross-fade + settle when the preview content swaps (category or tab
   change) \u2014 handled by mega-menu.js toggling this class briefly, not
   a hard cut. 200ms sits in the requested 180-250ms window; the small
   blur is intentionally subtle (2px) \u2014 enough to read as a soft
   fade rather than a snap, cheap enough not to jank on a small panel. */
.mega-preview.swapping { animation: megaSwap 200ms var(--ease); }
@keyframes megaSwap {
  0%   { opacity: .3; transform: translateY(3px); filter: blur(2px); }
  100% { opacity: 1;  transform: translateY(0);    filter: blur(0); }
}

/* ── AI prompt bar — honest framing: this submits to the REAL tool
   search (the existing /?q= handler), phrased as a task rather than
   a keyword search. Not a chat, not a fake assistant. ── */
.mega-footer {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 12px 16px; grid-column: 1 / -1;
}
.mega-ai-prompt {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: 8px 10px;
  transition: border-color 180ms var(--ease), background 180ms var(--ease);
}
.mega-ai-prompt:focus-within {
  border-color: rgba(244,114,182,.4);
  background: rgba(244,114,182,.05);
}
.mega-ai-ico { width: 15px; height: 15px; color: #f472b6; flex-shrink: 0; }
.mega-ai-input {
  flex: 1; background: none; border: none; outline: none;
  font-family: var(--fb); font-size: 12.5px; color: var(--text);
}
.mega-ai-input::placeholder { color: var(--text-faint); }
.mega-ai-go {
  width: 24px; height: 24px; border-radius: 7px; border: none; cursor: pointer; flex-shrink: 0;
  background: rgba(255,255,255,.06); color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.mega-ai-go svg { width: 13px; height: 13px; }
.mega-ai-prompt:focus-within .mega-ai-go { background: #f472b6; color: #1a0a14; }
.mega-ai-go:focus-visible { outline: 2px solid #f472b6; outline-offset: 2px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   Desktop/laptop (≥1024px): full two-panel mega menu, as above.
   Tablet (768–1023px): the two-panel hover model doesn't translate to
   a touch device with no hover state — collapses to a single column
   of full category cards (still premium, no dead hover-only content).
   Mobile (<768px): the existing flat mobile-menu drawer already handles
   small screens well (confirmed working, touch-optimized) — left as
   the deliberate choice rather than force-fitting a hover mega menu
   onto a phone. This matches how Linear/Vercel/Stripe themselves
   simplify mega menus below tablet width, not a shortcut.
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  .nav-tools-panel.mega { width: 320px; }
  .mega-rail { grid-column: 1 / -1; width: 100%; border-right: none; border-bottom: 1px solid rgba(255,255,255,.07); }
  .mega-preview { display: none; } /* no hover target on touch — rail links go straight to category pages */
  .mega-cat-desc { display: none; }
}
/* Below 767px, .nav-links (the parent of .nav-tools-drop) is hidden
   by main.css's mobile breakpoint — that alone takes this panel out
   of the visible/focusable tree for true mobile, so no separate
   force-hide rule is needed here. Removing that old rule is what
   makes the 768-1024px tablet range able to show this panel at all
   (it previously force-hid everything below 900px, leaving no way
   to open the menu on an 800px-wide tablet no matter the trigger). */

/* ═══════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .nav-tools-panel.mega,
  .nav-tools-panel.mega .mega-cat,
  .mega-cat-ico, .mega-cat-arrow, .mega-explore svg, .mega-preview.swapping,
  .mega-tool, .mega-tool-hero, .mega-tool-hero-cta svg, .mega-highlight, .mega-hl-cta svg {
    animation: none !important; transition-duration: 1ms !important;
  }
  .mega-cat { opacity: 1; transform: none; }
  .mega-tool:hover { transform: none; }
  .mega-tool-hero:hover, .mega-highlight:hover { transform: none; box-shadow: none; }
  .nav-tools-drop:hover .nav-tools-panel.mega,
  .nav-tools-drop:focus-within .nav-tools-panel.mega,
  .nav-tools-drop.js-open .nav-tools-panel.mega { transform: translateX(-50%) translateY(0) scale(1); }
}
