/* ==========================================================================
   Zentek — site navigation (desktop and tablet)
   The mega menu that drops out of the sticky <nav> from 768px up: design
   option D of the Claude Design export "Zentek ZenGUARD Page.dc.html", with
   narrower tablet layouts of its panels from 768 to 1023px. Loaded on every
   page after the page's own inline <style>, so these rules win on equal
   specificity — same contract as /css/newsletter.css. The phone form (below
   768px: the "Menu" toggle and the accordion panel /js/mobile-nav.js builds
   from this same markup) is styled in /mobile.css, and the ticker's 1100px
   cut-off lives there too.

   The markup lives inside the .nav-links of every page and carries no <div>
   of its own (the nav byte-identity check reads .nav-links up to its first
   closing </div>), and every <a> in it carries exactly class="" or
   class="on" — so links are styled by their parents, never by a class:

     .nav-links > ul.nav-list > li.nav-item
       a plain <a> (News, Contact)
       or <button class="nav-trigger"> + its panel, one of:
         ul.mega.mega-plat   Platforms: li.mega-k kicker, then per platform
                             li.plat > a (the row) + ul.pp (its pane)
         ul.mega.mega-cols   Company / Investors: li.mi (intro column), then
                             one li.mg per group of links

   Each platform's pane follows its row in the DOM, so Tab walks row, pane,
   next row, next pane; only the active pane (li.plat.is-active) is displayed,
   so focus never lands on a hidden link. The Graphene Coatings row carries
   .is-active in the markup — the default pane, and the only one without JS.
   /js/mobile-nav.js moves it on hover and focus and resets it on each open,
   to the current page's platform when the page is under Platforms.
   ========================================================================== */

/* --- The top row --------------------------------------------------------- */
.nav-list {
  display: flex;
  align-items: center;
  gap: 30px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Deliberately static: each panel is positioned against <nav> rather than
   against its own <li>, which is what lets it run the full width of the bar
   instead of the width of one label. */
.nav-item { position: static; }

/* A group trigger has to read as one of the links beside it. */
.nav-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  font: inherit;
  color: var(--ink2);
  background: none;
  border: 0;
  cursor: pointer;
  transition: color .18s;
}
.nav-trigger:hover,
.nav-trigger[aria-expanded="true"],
.nav-trigger.on { color: var(--ink); }
.nav-trigger:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

/* The only affordance that says a label opens a panel rather than navigating.
   It turns with aria-expanded, so open/closed is not signalled by colour
   alone. The transition is dropped under prefers-reduced-motion by the
   `*{transition:none!important}` rule each page already carries. */
.nav-trigger::after {
  content: '';
  flex: none;
  /* The pages' `*{box-sizing:border-box}` does not reach pseudo-elements;
     the design's 5px chevron includes its borders. */
  box-sizing: border-box;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .18s ease;
}
.nav-trigger[aria-expanded="true"]::after { transform: translateY(1px) rotate(-135deg); }

.nav-links a { transition: color .18s; }

/* Visually hidden text: "Shop ↗" is read as "Shop ZenGUARD™". */
.nav-vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Desktop panels ------------------------------------------------------
   768px up only; below that the whole .nav-links row is display:none and the
   phone panel takes over. */
@media (min-width: 768px) {
  /* Every page's inline <style> still hides the row up to 920px (the old
     switch). This file loads after it, so the row comes back from 768px
     here instead of in 27 copies of that rule. */
  .nav-links { display: flex; }

  .mega {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1;
    display: grid;
    gap: 0 40px;
    margin: 0;
    /* The design's inner box is max 1160px with 28px 28px 34px padding; as
       one element that is the plain gutter while the viewport is under the
       1160px measure, half the leftover once there is any — which also lines
       the first column up with the logo. */
    padding: 28px max(28px, calc((100% - 1160px) / 2 + 28px)) 34px;
    list-style: none;
    /* .nav-links sets 13px / 500 for the top row; the panels start from the
       body copy instead. */
    font-size: 13px;
    font-weight: 400;
    line-height: 1.7;
    background: var(--paper);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 40px rgba(12, 14, 12, .10);
  }
  .mega ul { margin: 0; padding: 0; list-style: none; }
  .mega > li, .mega li { min-width: 0; }

  /* Hover bridge. The trigger row sits 25px above the panel (the bar's bottom
     padding plus the row's centring slack), and a pointer travelling down
     from the label to the first link crosses that gap; without this the
     :hover fallback would drop the panel half-way. Sized to the gap exactly,
     never taller, or it would sit over the neighbouring triggers and stop the
     pointer reaching them. */
  .mega::before {
    content: '';
    position: absolute;
    top: -25px;
    left: 0;
    right: 0;
    height: 25px;
  }

  /* Closed unless hovered or opened by /js/mobile-nav.js. .is-closed is the
     Escape / click-to-close override — it has to beat :hover so the panel
     stays shut with the pointer still resting on the trigger, which is why
     it is last. */
  .nav-item > .mega { display: none; }
  .nav-item:hover > .mega,
  .nav-item.is-open > .mega { display: grid; }
  .nav-item.is-closed > .mega { display: none; }

  /* Green mono kicker: the panel's own name (aria-hidden, the trigger already
     names it) and the label over each group of links. */
  .mega-k {
    margin: 0 0 12px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--green);
  }

  /* The site's .cta — uppercase label on a 1.5px green rule — restated for
     the panels, whose links cannot carry the class. */
  .nav-ctas {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
    margin-top: 6px;
  }
  .nav-links .nav-ctas a {
    display: inline-block;
    padding-bottom: 5px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .22em;
    line-height: 1.7;
    text-transform: uppercase;
    color: var(--ink);
    border-bottom: 1.5px solid var(--green);
  }
  .nav-links .nav-ctas a:hover,
  .nav-links .nav-ctas a.on { color: var(--green); }

  /* ---- Platforms: rows | active pane (overview | coatings / microsites) ---
     Rows are column 1, one grid row each under the kicker; the pane spans
     every row of columns 2-3, and the last row (1fr) absorbs whatever height
     the pane needs beyond the rows, so the rows keep their own height. Four
     auto rows = the kicker, three platforms and the coming-soon row; add one
     per new platform. */
  .mega-plat {
    grid-template-columns: 260px minmax(0, 1fr) minmax(0, 1.5fr);
    grid-template-rows: repeat(5, auto) 1fr;
  }
  .mega-plat > .mega-k { grid-column: 1; grid-row: 1; }
  /* The <li> steps out of the layout so its row and pane are placed on the
     panel's grid directly; the links in it are unaffected. */
  .mega-plat > .plat { display: contents; }

  .mega-plat > .plat > a {
    grid-column: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px 12px;
    padding: 14px 12px;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    transition: color .18s, background-color .18s;
  }
  .mega-plat > .mega-k + .plat > a { border-top: 1px solid var(--line); }
  .mega-plat > .plat > a .nl { font-size: 15px; font-weight: 600; line-height: 1.35; }
  .mega-plat > .plat > a .na { font-size: 14px; opacity: 0; transition: opacity .18s; }
  /* Sub-lines (here, on the feature card and under each coating) are --ink2
     where the design has --ink3: #8a8f8a on paper is 3.1:1, under the 4.5:1
     WCAG AA needs for 12-12.5px text, and CLAUDE.md says not to widen that
     known gap. --ink2 is 6.4:1 (5.9:1 on the active row's --paper2). */
  .mega-plat > .plat > a .ns { grid-column: 1 / -1; font-size: 12.5px; line-height: 1.5; color: var(--ink2); }
  .nav-links .mega-plat > .plat > a.on { color: var(--green); }
  .nav-links .mega-plat > .plat.is-active > a { color: var(--green); background: var(--paper2); }
  .mega-plat > .plat.is-active > a .na { opacity: 1; }

  /* A platform that is announced but has no page yet: same row geometry,
     no link, muted. WCAG 1.4.3 exempts text in an inactive component. */
  .mega-plat > .plat-soon { grid-column: 1; }
  .mega-plat > .plat-soon > p {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 14px 12px;
    color: var(--ink3);
    border-bottom: 1px solid var(--line);
    cursor: default;
  }
  .mega-plat > .plat-soon .nl { font-size: 15px; font-weight: 600; line-height: 1.35; }
  .mega-plat > .plat-soon .ns {
    justify-self: start;
    padding: 2px 7px;
    font-family: 'DM Mono', monospace;
    font-size: 10.5px;
    letter-spacing: .12em;
    text-transform: uppercase;
    line-height: 1.5;
    border: 1px solid var(--line);
  }

  /* The pane: hidden unless its platform is the active one. */
  .mega-plat .pp {
    grid-column: 2 / 4;
    grid-row: 1 / -1;
    display: none;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    gap: 0 40px;
    align-items: start;
    padding-top: 30px;
  }
  .mega-plat > .plat.is-active > .pp { display: grid; }

  .pp-a {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  /* The design sets this pane's call to action in a plain block rather than
     the flex row of the Company / Investors intros, and that block's 16px
     line box drops the link 5px lower. Restated as margin (6px + 5px). */
  .pp-a > .nav-ctas { margin-top: 11px; }
  .pp-t {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.01em;
    line-height: 1.15;
    color: var(--ink);
  }
  .pp-d {
    font-size: 14px;
    line-height: 1.65;
    color: var(--ink2);
    text-wrap: pretty;
  }
  .pp-b {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  /* Coatings / microsites: a ruled grid of name, optional shop link, sub. */
  .pp-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0 28px;
    border-top: 1px solid var(--line);
  }
  .pp-items > li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    /* Packed to the top, as the design's column: when a neighbour's sub-line
       wraps (around 1100px) the row grows, and this item's two rows must not
       spread apart to fill it. */
    align-content: start;
    align-items: baseline;
    gap: 2px 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  .nav-links .pp-items > li > a:first-child {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--ink);
  }
  .nav-links .pp-items > li > a + a {
    font-family: 'DM Mono', monospace;
    font-size: 10.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink2);
  }
  .nav-links .pp-items > li > a:hover,
  .nav-links .pp-items > li > a.on { color: var(--green); }
  .pp-items > li > span {
    grid-column: 1 / -1;
    font-size: 12px;
    line-height: 1.5;
    color: var(--ink2);
  }

  /* ---- Company / Investors: intro column | groups ------------------------
     The design's 40px between the intro and the groups is the 28px gap the
     groups keep between themselves plus the intro's 12px margin, which is
     why the first track is 272px: a 260px intro column and that margin. */
  .mega-cols {
    grid-template-columns: 272px;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0 28px;
  }
  .mi {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-right: 12px;
    padding-right: 32px;
    border-right: 1px solid var(--line);
  }
  .mi > .mega-k { margin: 0; }
  .mi-t {
    margin-top: 6px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.01em;
    line-height: 1.15;
    color: var(--ink);
  }
  .mi-d {
    font-size: 14px;
    line-height: 1.65;
    color: var(--ink2);
    text-wrap: pretty;
  }
  .mi-tick {
    padding: 10px 0;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    letter-spacing: .08em;
    color: var(--ink);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .mg { display: flex; flex-direction: column; }
  .mg > ul { border-top: 1px solid var(--line); }
  .nav-links .mg a {
    display: block;
    padding: 10px 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
  }
  .nav-links .mg a:hover,
  .nav-links .mg a.on { color: var(--green); }
}

/* --- Tablet panels (768-1023px) ------------------------------------------
   The desktop geometry needs about 1024px: below that the Platforms pane's
   overview column drops under 140px and the Company groups under 120px. The
   panels keep their markup, behaviour and type; only the grids change.
   1024px up is untouched. (.98: a zoomed or scaled viewport can be a
   fractional width, and must still land on one side of the switch.) */
@media (min-width: 768px) and (max-width: 1023.98px) {
  /* This range includes every phone held sideways (about 390px tall), and
     the panel hangs off a sticky bar, so a panel taller than the room under
     the bar could never be scrolled into view. It scrolls inside itself
     instead. (The scroller clips the hover bridge above the panel; the
     script's leave grace covers that gap for a pointer.) 73px = the bar. */
  .mega {
    max-height: calc(100vh - 73px);
    max-height: calc(100dvh - 73px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Platforms: a 210px rows column, and the active pane's overview stacked
     above its items, whose grid (minmax 190px) then runs two or three
     across instead of one. */
  .mega-plat {
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 0 32px;
  }
  /* The rows' sub-lines wrap at this width: no lone last word ("ON"). */
  .mega-plat > .plat > a .ns,
  .mega-plat > .plat-soon .nl { text-wrap: pretty; }
  .mega-plat .pp {
    grid-column: 2;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px 0;
  }
  .pp-d { max-width: 60ch; }

  /* Company / Investors: the intro becomes a band across the top — kicker,
     then the title beside its description, figures and calls to action —
     and the groups share the row under it, on the same three columns. */
  .mega-cols {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-flow: row;
  }
  .mi {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: baseline;
    gap: 12px 28px;
    margin: 0 0 24px;
    padding: 0 0 24px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .mi > .mega-k { grid-column: 1 / -1; }
  .mi-t { grid-column: 1; margin-top: 0; }
  .mi-d,
  .mi-tick,
  .mi > .nav-ctas { grid-column: 2 / -1; }
}
