/* ==========================================================================
   LearnSQL shared components. Loaded after site.css on every page.

   Every visual here is built from site.css tokens (--surface, --line, --accent, --accent-soft, --ink, --body,
   --muted, --faint, --ok, --warn, --danger, --accent2, --radius, --fs-*). Nothing is hardcoded except the
   accent-ink fallback. Names follow one rule: c-<block>, c-<block>--<modifier>, c-<block>__<part>, and the
   state classes is-on (a chip that is pressed) and is-off.

   Components
     .c-section-head  + .c-ico              heading with an icon: h2 (or h3) and a paragraph
     .c-card          + --link, --hover, --accent, --compact   panel; --link is an <a> card; --hover lifts a card that holds its own links
                      + __meta, __foot      chips and badges row; footer link pinned to the bottom
     .c-grid          + --sm, --lg, --2/3/4 responsive grid of cards (min column width by modifier)
     .c-chips         + .c-chip, .is-on     filter chips (buttons with aria-pressed too) or tags (--static)
     .c-badge         + --beginner, --intermediate, --advanced, --accent, --neutral   level badges
     .c-lang          + --sql, --dax, --m   language tags: SQL, DAX, Power Query M
     .c-kpis          + .c-kpi              KPI tiles: <b> value, <span> label, <small> note
     .c-callout       + --tip, --note, --warn, --ok, --danger    callouts with optional h4
     .c-stack, .c-row                       vertical and wrapping horizontal spacing
   Header mega-menu (the nav styles at the end of this file): .hn, .hn-pop.hn-mega, .hn-col, .hn-list, .hn-foot
   Command palette (ux.css, block "palette"): .pal-*

   See docs/components.md for the markup of each one.
   ========================================================================== */

/* ---- Section heading with an icon ------------------------------------------------------------ */
.c-section-head { display: flex; gap: 14px; align-items: flex-start; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.c-section-head h2 { margin: 0; font-size: 1.3rem; }
.c-section-head h3 { margin: 0; font-size: 1.1rem; }
.c-section-head p { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-sm); max-width: 76ch; }
.c-ico { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); }
.c-ico svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Card ------------------------------------------------------------------------------------ */
.c-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 18px 20px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none;
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s; }
.c-card h3 { margin: 0; font-size: var(--fs-base); line-height: 1.3; }
.c-card p { margin: 0; color: var(--muted); font-size: var(--fs-sm); line-height: 1.5; }
.c-card__meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.c-card__foot { margin-top: auto; padding-top: 6px; color: var(--accent); font-weight: 600; font-size: var(--fs-sm); }
.c-card--link:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; color: var(--ink); }
.c-card--link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.c-card--link:hover .c-card__foot { text-decoration: underline; }
.c-card--accent { border-left: 3px solid var(--accent); }
.c-card--hover:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.c-card--compact { padding: 12px 14px; gap: 6px; }
.c-card[hidden] { display: none; }

/* ---- Grid of cards -------------------------------------------------------------------------- */
.c-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(var(--c-min, 260px), 1fr)); margin: 0; }
.c-grid--sm { --c-min: 200px; }
.c-grid--lg { --c-min: 340px; }
.c-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.c-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.c-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .c-grid--3, .c-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .c-grid--2, .c-grid--3, .c-grid--4 { grid-template-columns: minmax(0, 1fr); } }

/* ---- Chips: filter buttons and static tags -------------------------------------------------- */
.c-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.c-chip { display: inline-flex; align-items: center; gap: 6px; font: 600 var(--fs-sm) var(--font-body, system-ui); line-height: 1.2;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--body);
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.c-chip:hover { border-color: var(--accent); color: var(--ink); text-decoration: none; }
.c-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.c-chip.is-on, .c-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #fff); }
.c-chip small, .c-chip__n { opacity: .75; font-size: .78em; font-weight: 600; }
.c-chip--static { cursor: default; padding: 4px 10px; font-size: var(--fs-xs); color: var(--muted); background: var(--bg-sunken, var(--surface)); border-color: transparent; }
.c-chip--static:hover { border-color: transparent; color: var(--muted); }

/* ---- Level badges (Beginner, Intermediate, Advanced) ---------------------------------------- */
.c-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: var(--fs-2xs);
  font-weight: 700; letter-spacing: .02em; line-height: 1.5; background: var(--bg-sunken, var(--surface)); color: var(--body); border: 1px solid transparent; }
.c-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.c-badge--beginner { background: var(--ok-soft); color: var(--ok); }
.c-badge--intermediate { background: var(--warn-soft); color: var(--warn); }
.c-badge--advanced { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.c-badge--accent { background: var(--accent-soft); color: var(--accent); }
.c-badge--neutral { background: var(--bg-sunken, var(--surface)); color: var(--muted); }

/* ---- Language tags: SQL, DAX, Power Query M ------------------------------------------------- */
.c-lang { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 6px; font: 700 var(--fs-2xs) var(--mono, monospace);
  letter-spacing: .02em; background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.c-lang--sql { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.c-lang--dax { background: color-mix(in srgb, var(--accent2) 14%, var(--surface)); color: color-mix(in srgb, var(--accent2) 55%, var(--ink)); border-color: color-mix(in srgb, var(--accent2) 40%, transparent); }
.c-lang--m { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }

/* ---- KPI tiles ------------------------------------------------------------------------------- */
.c-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 0 0 20px; }
.c-kpi { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 12px 16px; border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 10px; background: var(--surface); }
.c-kpi b { font-size: 1.55rem; line-height: 1.15; letter-spacing: -.01em; color: var(--ink); }
.c-kpi span { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.c-kpi small { font-size: var(--fs-xs); color: var(--muted); }
.c-kpis:empty { display: none; }

/* ---- Callouts -------------------------------------------------------------------------------- */
.c-callout { --c-tone: var(--accent); --c-tone-bg: var(--accent-soft); margin: 18px 0; padding: 14px 18px; border: 1px solid var(--line);
  border-left: 4px solid var(--c-tone); border-radius: 10px; background: var(--c-tone-bg); }
.c-callout h4 { margin: 0 0 4px; font-size: 1rem; }
.c-callout p { margin: 0; color: var(--body); font-size: .94rem; line-height: 1.55; }
.c-callout p + p { margin-top: 6px; }
.c-callout--tip, .c-callout--note { --c-tone: var(--accent); --c-tone-bg: var(--accent-soft); }
.c-callout--warn { --c-tone: var(--warn); --c-tone-bg: var(--warn-soft); }
.c-callout--ok { --c-tone: var(--ok); --c-tone-bg: var(--ok-soft); }
.c-callout--danger { --c-tone: var(--danger); --c-tone-bg: color-mix(in srgb, var(--danger) 12%, var(--surface)); }

/* ---- Spacing helpers ------------------------------------------------------------------------- */
.c-stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.c-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }

/* ==========================================================================
   ---- nav: header mega-menu (replaces the single-column dropdowns) ----
   Desktop (wider than 1100px): each group opens a panel that spans the header container, with one column per
   track or topic. The panel is positioned against the header (.wrap), so it is centred and never runs off the screen.
   Phone and narrow screens: the header's burger menu holds an accordion, one group open at a time, and the columns
   stack in order.
   ========================================================================== */
@media (min-width: 1101px) {
  .hn { position: static; }
  .hn .hn-pop.hn-mega {
    display: none; position: absolute; top: calc(100% + 6px); left: 50%; right: auto; transform: translateX(-50%);
    width: min(var(--container), calc(100vw - 32px)); min-width: 0; max-height: min(78vh, 720px); overflow: auto;
    padding: 18px 22px 12px; box-sizing: border-box; border-radius: 16px; text-align: left;
    grid-template-columns: repeat(var(--hn-cols, 3), minmax(0, 1fr)); gap: 6px 28px; align-items: start;
  }
  .hn.open .hn-pop.hn-mega { display: grid; }
  .hn-mega .hn-foot { grid-column: 1 / -1; }
}
.hn-col { min-width: 0; }
.hn-col-h { margin: 0 0 6px; padding: 0 10px; font: 700 .7rem/1.3 var(--font-body, system-ui); letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.hn-col-h a { color: inherit; text-decoration: none; border-radius: 6px; }
.hn-col-h a:hover { color: var(--accent); }
.hn-col-h a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.hn-list a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: .92rem; line-height: 1.35; }
.hn-list a:hover, .hn-list a:focus-visible { background: var(--accent-soft); outline: none; }
.hn-list a[aria-current="page"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.hn-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.hn-foot a { display: inline-block; padding: 4px 10px; color: var(--accent); font-weight: 600; font-size: .9rem; text-decoration: none; border-radius: 8px; }
.hn-foot a:hover, .hn-foot a:focus-visible { background: var(--accent-soft); outline: none; }

@media (max-width: 1100px) {
  .hn .hn-pop.hn-mega, .hn.open .hn-pop.hn-mega { display: none; }
  .hn.open .hn-pop.hn-mega { display: block; position: static; transform: none; width: auto; max-height: 62vh; overflow: auto;
    padding: 2px 0 10px 6px; border: 0; box-shadow: none; background: transparent; }
  .hn-col { margin-top: 8px; }
  .hn-col-h { padding: 4px 8px; font-size: .74rem; }
  .hn-list a { padding: 10px 10px; font-size: 16px; }
  .hn-foot { margin-top: 4px; }
  .hn-foot a { padding: 10px 10px; font-size: 16px; }
}
