/* ============================================================
   MARKAROO — global navigation (Tier 1) + product sub-nav (Tier 2)
   ------------------------------------------------------------
   Self-contained ON PURPOSE. The site runs two unrelated
   stylesheets — site-assets/css/global.css (home, grading,
   learning, pricing, ambassador) and help/help.css (help, privacy,
   terms, data-security) — and they share no custom properties.
   So this file owns its own --mk-* tokens, keyed off [data-theme],
   and can be dropped onto any page without inheriting or
   disturbing that page's own styles.

   Every selector is prefixed .mk- to avoid colliding with the
   legacy .navbar rules that still live in global.css.

   Dark themes come from two scripts: mode.js sets
   institutional / institutional-dark; theme.js sets the student
   themes (dark, violet-night, midnight are the dark ones).
   ============================================================ */

:root,
[data-theme="institutional"] {
  --mk-canvas:        #FAFAF7;
  --mk-surface:       #ffffff;
  --mk-surface-2:     #EEF0F6;
  --mk-heading:       #000F47;
  --mk-text:          #2E3856;
  --mk-muted:         #586380;
  --mk-rule:          rgba(163,145,97,.24);
  --mk-primary:       #a39161;
  --mk-primary-hover: #b5a474;
  --mk-primary-soft:  rgba(163,145,97,.10);
  --mk-on-primary:    #ffffff;
  --mk-glass:         rgba(250,250,247,.82);
  --mk-grading-tint:  rgba(163,145,97,.10);
  --mk-learning-tint: rgba(0,15,71,.06);
  --mk-panel-shadow:  0 4px 16px rgba(0,15,71,.07), 0 18px 50px rgba(0,15,71,.10);
}

/* The Learning app's theme picker (bloom/sage/violet-night/midnight, plus its
   own light/dark) used to tint the whole page — hero, cards, buttons — but
   the shared nav bar ignored it and stayed the site's default gold no matter
   which theme was picked. These blocks mirror global.css's own per-theme
   --color-* values so the nav (heading, links, logo, CTA) shifts with the
   rest of the page instead of sitting fixed on top of it. */
[data-theme="light"],
[data-theme="bloom"] {
  --mk-canvas:        #fef7ff;
  --mk-surface:       #ffffff;
  --mk-surface-2:     #f4eaff;
  --mk-heading:       #201635;
  --mk-text:          #463f54;
  --mk-muted:         #6b6478;
  --mk-rule:          rgba(118,64,196,.24);
  --mk-primary:       #7640c4;
  --mk-primary-hover: #6735b2;
  --mk-primary-soft:  rgba(118,64,196,.08);
  --mk-on-primary:    #ffffff;
  --mk-glass:         rgba(254,247,255,.82);
  --mk-grading-tint:  rgba(163,145,97,.10);
  --mk-learning-tint: rgba(0,15,71,.06);
  --mk-panel-shadow:  0 4px 16px rgba(45,10,90,.07), 0 18px 50px rgba(45,10,90,.10);
}

[data-theme="sage"] {
  --mk-canvas:        #f6faf5;
  --mk-surface:       #ffffff;
  --mk-surface-2:     #e1ece4;
  --mk-heading:       #1c332a;
  --mk-text:          #44594f;
  --mk-muted:         #4f675c;
  --mk-rule:          rgba(63,111,90,.24);
  --mk-primary:       #3f6f5a;
  --mk-primary-hover: #2f5545;
  --mk-primary-soft:  rgba(63,111,90,.08);
  --mk-on-primary:    #ffffff;
  --mk-glass:         rgba(246,250,245,.82);
  --mk-grading-tint:  rgba(163,145,97,.10);
  --mk-learning-tint: rgba(0,15,71,.06);
  --mk-panel-shadow:  0 4px 16px rgba(20,40,30,.07), 0 18px 50px rgba(20,40,30,.10);
}

[data-theme="institutional-dark"] {
  --mk-canvas:        #08081A;
  --mk-surface:       #14142B;
  --mk-surface-2:     #1C1C38;
  --mk-heading:       #EDEFF7;
  --mk-text:          #D4D8E4;
  --mk-muted:         #9AA3C7;
  --mk-rule:          rgba(255,255,255,.13);
  --mk-primary:       #cbb888;
  --mk-primary-hover: #ddcaa0;
  --mk-primary-soft:  rgba(203,184,136,.16);
  --mk-on-primary:    #08081A;
  --mk-glass:         rgba(8,8,26,.82);
  --mk-grading-tint:  rgba(203,184,136,.14);
  --mk-learning-tint: rgba(255,255,255,.07);
  --mk-panel-shadow:  0 8px 24px rgba(0,0,0,.5), 0 20px 60px rgba(0,0,0,.55);
}

[data-theme="dark"],
[data-theme="violet-night"] {
  --mk-canvas:        #14102a;
  --mk-surface:       #1b1536;
  --mk-surface-2:     #241c45;
  --mk-heading:       #f5f0ff;
  --mk-text:          #d6cfec;
  --mk-muted:         #a79fc4;
  --mk-rule:          rgba(255,255,255,.13);
  --mk-primary:       #b794f6;
  --mk-primary-hover: #c9b1fb;
  --mk-primary-soft:  rgba(183,148,246,.16);
  --mk-on-primary:    #14102a;
  --mk-glass:         rgba(20,16,42,.82);
  --mk-grading-tint:  rgba(203,184,136,.14);
  --mk-learning-tint: rgba(255,255,255,.07);
  --mk-panel-shadow:  0 8px 24px rgba(0,0,0,.5), 0 20px 60px rgba(0,0,0,.55);
}

[data-theme="midnight"] {
  --mk-canvas:        #07111f;
  --mk-surface:       #111827;
  --mk-surface-2:     #1f2a3d;
  --mk-heading:       #f8fafc;
  --mk-text:          #cbd5e1;
  --mk-muted:         #93a3bb;
  --mk-rule:          rgba(255,255,255,.13);
  --mk-primary:       #93c5fd;
  --mk-primary-hover: #bfdbfe;
  --mk-primary-soft:  rgba(37,99,235,.18);
  --mk-on-primary:    #07111f;
  --mk-glass:         rgba(7,17,31,.82);
  --mk-grading-tint:  rgba(203,184,136,.14);
  --mk-learning-tint: rgba(255,255,255,.07);
  --mk-panel-shadow:  0 8px 24px rgba(0,0,0,.5), 0 20px 60px rgba(0,0,0,.55);
}

/* Anchor targets must clear the sticky bar(s). The old navbar never set
   this, so #section links have always landed slightly underneath it;
   Tier 2 makes that worse, so it is fixed here for both tiers. */
html { scroll-padding-top: 86px; }
html:has(.mk-subnav) { scroll-padding-top: 132px; }
@media (max-width: 940px) {
  html { scroll-padding-top: 78px; }
  html:has(.mk-subnav) { scroll-padding-top: 124px; }
}

/* ─── Tier 1 bar ───────────────────────────────────────────── */
.mk-nav {
  position: sticky; top: 0; z-index: 600;
  background: var(--mk-glass);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
          backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--mk-rule);
  font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
}
/* Opaque fallback where backdrop-filter is unsupported. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .mk-nav { background: var(--mk-canvas); }
}
.mk-nav *, .mk-nav *::before, .mk-nav *::after { box-sizing: border-box; }

/* Three zones, three anchors: identity left, navigation centre, action right.
   A 1fr/auto/1fr grid — NOT flex + margin-auto — because the right cluster
   (theme + Sign in + CTA) is far wider than the logo, so a flex "centre" would
   sit visibly off-centre and would drift again whenever a label changes length
   (Pricing already swaps to #pricing on the product pages). The grid pins the
   links to the true centre of the bar regardless of what flanks them. */
.mk-nav-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px;
  height: 70px; display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 24px;
}

/* justify-self on each zone: grid items default to `stretch`, which would blow
   the logo anchor out to the full width of its 1fr column. */
.mk-logo {
  justify-self: start;
  display: flex; align-items: center; gap: 9px; text-decoration: none; flex: none;
}
.mk-logo-mark {
  /* 46x32 is the pre-rebuild size. The mark is wider than it is tall, so a
     square box made `contain` shrink it to fit the height.
     A CSS mask, not a background-image: the source SVG's own colours (a
     three-tone blue) are not brand colours and are never shown as-is, per
     Marketing/Markaroo-Brand-Guidelines.md. Masking keeps only the
     silhouette and fills it with --mk-primary, which already resolves to
     the brand-correct gold (#a39161 light / #cbb888 dark) on every page. */
  width: 46px; height: 32px; flex: none;
  background-color: var(--mk-primary);
  -webkit-mask: url('/markaroo-logo-transparent.svg') left center/contain no-repeat;
          mask: url('/markaroo-logo-transparent.svg') left center/contain no-repeat;
}
.mk-logo-word {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 22px; font-weight: 600; color: var(--mk-heading); letter-spacing: .01em;
}

.mk-links { justify-self: center; display: flex; align-items: center; gap: 4px; }
.mk-item { position: relative; }

.mk-link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 9px 13px; border-radius: 8px;
  font: 500 14.5px/1 'Geist', ui-sans-serif, system-ui, sans-serif;
  color: var(--mk-muted); text-decoration: none;
  border: 0; background: none; cursor: pointer;
  transition: color .16s, background .16s;
}
.mk-link:hover, .mk-link:focus-visible { color: var(--mk-heading); background: var(--mk-primary-soft); }
.mk-link[aria-current="page"] { color: var(--mk-heading); font-weight: 600; }

.mk-chev {
  width: 9px; height: 9px; flex: none;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg) translate(-1px,-1px);
  transition: transform .2s;
}
.mk-item.is-open .mk-link { color: var(--mk-heading); background: var(--mk-primary-soft); }
.mk-item.is-open .mk-chev { transform: rotate(-135deg) translate(-2px,-2px); }

.mk-right { justify-self: end; display: flex; align-items: center; gap: 6px; }

/* The theme control is a utility, not navigation. A hairline keeps it from
   reading as the first of three equal-weight items on the right. */
.mk-right .mk-theme-slot { position: relative; padding-right: 9px; margin-right: 3px; }
.mk-right .mk-theme-slot::after {
  content: ''; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 1px; height: 18px; background: var(--mk-rule);
}

/* Sign in is secondary: quiet text, and it hands the only filled shape on the
   bar to the CTA. The extra left margin on the CTA stops the two reading as a
   pair of equal buttons. */
.mk-signin { font-weight: 500; color: var(--mk-muted); }
.mk-right .mk-cta { margin-left: 10px; }

.mk-cta {
  display: inline-flex; align-items: center; padding: 10px 20px;
  border-radius: 999px; border: 1px solid transparent;
  background: var(--mk-primary); color: var(--mk-on-primary);
  font: 600 14px/1 'Geist', ui-sans-serif, system-ui, sans-serif;
  text-decoration: none; white-space: nowrap; transition: background .16s;
}
.mk-cta:hover { background: var(--mk-primary-hover); }

/* Theme control slot — filled per page family (mode toggle or theme picker).
   The picker (.theme-menu) is styled by global.css and only ships on pages
   that load it. The binary toggle also lands on help/privacy/terms/
   data-security, which have no global.css, so it is styled here too. */
.mk-theme-slot { display: flex; align-items: center; }

.mk-nav .mk-mode-toggle,
.mk-sheet .mk-mode-toggle {
  width: 36px; height: 36px; padding: 0;
  display: grid; place-items: center;
  border-radius: 9px; border: 1px solid transparent;
  background: none; cursor: pointer; color: var(--mk-muted);
  transition: color .16s, background .16s, border-color .16s;
}
.mk-nav .mk-mode-toggle:hover,
.mk-sheet .mk-mode-toggle:hover {
  color: var(--mk-heading); background: var(--mk-primary-soft); border-color: var(--mk-rule);
}
.mk-nav .mk-mode-toggle svg { width: 19px; height: 19px; }
.mk-nav .mk-mode-toggle .icon-sun  { display: none; }
.mk-nav .mk-mode-toggle .icon-moon { display: block; }
[data-theme="institutional-dark"] .mk-mode-toggle .icon-sun,
[data-theme="dark"] .mk-mode-toggle .icon-sun,
[data-theme="violet-night"] .mk-mode-toggle .icon-sun,
[data-theme="midnight"] .mk-mode-toggle .icon-sun { display: block; }
[data-theme="institutional-dark"] .mk-mode-toggle .icon-moon,
[data-theme="dark"] .mk-mode-toggle .icon-moon,
[data-theme="violet-night"] .mk-mode-toggle .icon-moon,
[data-theme="midnight"] .mk-mode-toggle .icon-moon { display: none; }

/* ─── Dropdown panels ──────────────────────────────────────── */
.mk-panel {
  position: absolute; top: calc(100% + 12px); left: -10px; width: 392px;
  background: var(--mk-surface); border: 1px solid var(--mk-rule);
  border-radius: 15px; box-shadow: var(--mk-panel-shadow); padding: 8px;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.mk-panel--right { left: auto; right: -10px; width: 322px; }

/* JS adds .is-open (and .mk-js on <html>). Without JS the panels still open
   on focus, so the nav stays usable — but that fallback must switch OFF once
   JS is running, or the trigger keeping focus after a click would hold the
   panel open and a second click could never close it. */
.mk-item.is-open > .mk-panel,
html:not(.mk-js) .mk-item:focus-within > .mk-panel {
  opacity: 1; visibility: visible; transform: translateY(0);
}

.mk-row {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 11px 12px; border-radius: 11px; text-decoration: none;
  position: relative; transition: background .15s;
}
.mk-row:hover, .mk-row:focus-visible { background: var(--mk-surface-2); }
.mk-row--grading:hover,  .mk-row--grading:focus-visible  { background: var(--mk-grading-tint); }
.mk-row--learning:hover, .mk-row--learning:focus-visible { background: var(--mk-learning-tint); }

.mk-row-tile {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-size: 15px; line-height: 1;
  border: 1px solid var(--mk-rule); background: var(--mk-surface-2);
}
.mk-row--grading  .mk-row-tile { background: var(--mk-grading-tint); }
.mk-row--learning .mk-row-tile { background: var(--mk-learning-tint); }

.mk-row-title { display: block; font-size: 14.5px; font-weight: 600; color: var(--mk-heading); line-height: 1.35; }
.mk-row-desc  { display: block; font-size: 12.5px; color: var(--mk-muted); line-height: 1.45; margin-top: 1px; }

.mk-row-badge {
  margin-left: auto; align-self: center;
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700;
  color: var(--mk-primary); background: var(--mk-primary-soft);
  border: 1px solid var(--mk-rule); border-radius: 999px;
  padding: 3px 8px; white-space: nowrap;
}

/* Current page marker inside the panel. */
.mk-row[aria-current="page"] { background: var(--mk-grading-tint); }
.mk-row[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--mk-primary);
}

.mk-divider { height: 1px; background: var(--mk-rule); margin: 7px 12px; }

/* ─── Tier 2 — product sub-nav ─────────────────────────────── */
.mk-subnav {
  position: sticky; top: 70px; z-index: 590;
  background: var(--mk-glass);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
          backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--mk-rule);
  font-family: 'Geist', ui-sans-serif, system-ui, sans-serif;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .mk-subnav { background: var(--mk-canvas); }
}
.mk-subnav-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px;
  height: 50px; display: flex; align-items: center; gap: 26px;
  overflow-x: auto; scrollbar-width: none;
}
.mk-subnav-inner::-webkit-scrollbar { display: none; }
.mk-subnav-label {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700;
  color: var(--mk-primary); padding-right: 22px;
  border-right: 1px solid var(--mk-rule); margin-right: 4px; white-space: nowrap; flex: none;
}
.mk-subnav a {
  font-size: 13.5px; font-weight: 500; color: var(--mk-muted); text-decoration: none;
  padding: 15px 0; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s; white-space: nowrap; flex: none;
}
.mk-subnav a:hover { color: var(--mk-heading); }
.mk-subnav a.is-active { color: var(--mk-heading); border-bottom-color: var(--mk-primary); }

/* ─── Mobile ───────────────────────────────────────────────── */
.mk-burger-input { position: absolute; opacity: 0; pointer-events: none; }
.mk-burger {
  display: none; width: 40px; height: 40px; border-radius: 9px;
  border: 1px solid var(--mk-rule); background: none; cursor: pointer;
  padding: 0; color: var(--mk-heading);
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
/* Explicit gap rather than margins: .mk-burger is a flex container, so margins
   do not collapse and the checked-state offset must equal gap + bar height. */
.mk-burger span {
  display: block; width: 17px; height: 1.7px; background: currentColor;
  border-radius: 2px; transition: transform .2s, opacity .2s;
}

@media (max-width: 940px) {
  /* Back to flex: with the links and the right cluster hidden, the desktop
     3-column grid would leave the burger stranded in the centre column. */
  .mk-nav-inner { height: 62px; display: flex; gap: 0; }
  .mk-burger { display: flex; margin-left: auto; }
  .mk-links, .mk-right { display: none; }

  .mk-sheet {
    position: fixed; inset: 62px 0 0; z-index: 599;
    background: var(--mk-canvas);
    padding: 14px 14px 32px; overflow-y: auto;
    display: none;
  }
  .mk-burger-input:checked ~ .mk-sheet { display: block; }
  .mk-burger-input:checked ~ .mk-nav .mk-burger span:nth-child(1) { transform: translateY(6.7px) rotate(45deg); }
  .mk-burger-input:checked ~ .mk-nav .mk-burger span:nth-child(2) { opacity: 0; }
  .mk-burger-input:checked ~ .mk-nav .mk-burger span:nth-child(3) { transform: translateY(-6.7px) rotate(-45deg); }

  /* Stop the page scrolling behind the open sheet. */
  .mk-burger-input:checked ~ .mk-subnav { display: none; }

  .mk-subnav { top: 62px; }
}
@media (min-width: 941px) { .mk-sheet { display: none !important; } }

.mk-sheet-label {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700;
  color: var(--mk-primary); padding: 16px 12px 7px;
}
.mk-sheet .mk-row { padding: 12px; }
.mk-sheet-plain {
  display: block; padding: 12px; border-radius: 11px; text-decoration: none;
  font-size: 15px; font-weight: 600; color: var(--mk-heading);
}
.mk-sheet-plain:hover { background: var(--mk-surface-2); }
.mk-sheet .mk-cta { display: flex; justify-content: center; margin: 16px 12px 0; padding: 13px; font-size: 15px; }
.mk-sheet-theme { padding: 14px 12px 0; display: flex; justify-content: flex-start; }

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  .mk-panel, .mk-chev, .mk-link, .mk-row, .mk-cta, .mk-burger span { transition: none; }
}
