/* ===========================================================================
   nav.css — the site navigation, shared by both shells.

   Loaded by home-shell.hbs AND default.hbs, which have different design
   tokens: the Pubzi bundle names the accent --theme, screen.css names it
   --accent. Everything here resolves through --jn-* locals with a literal
   fallback, so the bar is identical in both and works even if neither
   stylesheet loaded.

   The bar is position:fixed and overlays the hero. Shells compensate:
   home.hbs wants the overlap, pages on home-shell already clear it with
   Pubzi's 120px .section-padding, and default.hbs adds .jn-offset to <main>.
   =========================================================================== */

:root {
    --jn-h: 84px;          /* bar height, desktop */
    --jn-h-sm: 64px;       /* bar height, mobile */
    --jn-accent: var(--theme, var(--accent, #CBFE1C));
    --jn-ink: var(--white, #fff);
    --jn-bg: var(--bg, #0B0E13);
    --jn-panel: #14171d;
    --jn-dim: var(--text, #ABABAB);
    --jn-line: rgba(255, 255, 255, 0.12);
    --jn-z: 1000;          /* under Ghost Portal, which sits at 3999999 */
}

.jn-sr,
.jn .visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* --- The bar -------------------------------------------------------------- */
.jn {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: var(--jn-z);
    background: transparent;
    border-bottom: 1px solid transparent;
    transition: background-color 0.28s ease, border-color 0.28s ease,
                transform 0.28s ease, height 0.28s ease;
    font-family: "Chakra Petch", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Only the homepage has a hero to sit on. Everywhere else content begins
   immediately under the bar, so a transparent bar would put nav labels on top
   of body copy. */
body:not(.home-template) .jn,
.jn.is-solid {
    background: rgba(11, 14, 19, 0.92);
    border-bottom-color: var(--jn-line);
    backdrop-filter: saturate(150%) blur(10px);
}
@supports not (backdrop-filter: blur(10px)) {
    body:not(.home-template) .jn,
    .jn.is-solid { background: var(--jn-bg); }
}

/* Reading a long exercise, the bar is in the way going down and wanted going
   back up. Only applies once past the fold, so short pages never lose it. */
.jn.is-hidden { transform: translateY(-100%); }

.jn-inner {
    max-width: 1730px;          /* matches .header-1 .container */
    margin: 0 auto;
    padding: 0 24px;
    height: var(--jn-h);
    display: flex;
    align-items: center;
    gap: 28px;
    transition: height 0.28s ease;
}
.jn.is-solid .jn-inner { height: 72px; }

/* --- Brand ---------------------------------------------------------------- */
.jn-brand {
    display: inline-flex;
    align-items: baseline;
    gap: 9px;
    text-decoration: none;
    font-family: "Days One", sans-serif;
    font-size: 24px;
    line-height: 1;
    color: var(--jn-ink);
    letter-spacing: -0.01em;
    flex: none;
}
.jn-mark { color: var(--jn-accent); font-size: 0.85em; }
.jn-brand:hover .jn-word { color: var(--jn-accent); }

/* --- Desktop list --------------------------------------------------------- */
.jn-main { margin-left: auto; }
.jn-list {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.jn-item { position: relative; }
.jn-item-cta { display: none; }        /* bar has its own CTA on desktop */

.jn-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    font: inherit;
    font-size: 0.95rem;
    line-height: 1;
    text-transform: none;
    color: var(--jn-ink);
    background: none;
    border: 0;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
}
.jn-link::after {
    content: "";
    position: absolute;
    left: 14px; right: 14px; bottom: 2px;
    height: 2px;
    background: var(--jn-accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.24s ease;
}
.jn-link:hover { color: var(--jn-accent); }
.jn-link:hover::after,
.jn-trigger[aria-expanded="true"]::after { transform: scaleX(1); }
.jn-link:focus-visible { outline: 2px solid var(--jn-accent); outline-offset: 2px; }

.jn-chev { transition: transform 0.24s ease; flex: none; }
.jn-trigger[aria-expanded="true"] .jn-chev { transform: rotate(180deg); }

/* Active page. Ghost's body_class is the whole mechanism — no helper, no JS.
   Kept as one rule per link so it reads as a table of what marks what. */
.page-curso-phaser-presencial .jn-clases,
.tag-curso .jn-clases,
.page-becas .jn-clases,
.page-taller-dibujos .jn-clases,
.tag-hash-ejercicio .jn-aprende,
.page-ejercicios .jn-aprende,
.tag-gratis .jn-aprende,
.tag-template.tag-fundamentos .jn-aprende,
.tag-template.tag-phaser .jn-aprende,
.tag-template.tag-javascript .jn-aprende,
.page-about .jn-sobre,
.page-contacto .jn-contacto {
    color: var(--jn-accent);
}
.page-curso-phaser-presencial .jn-clases::after,
.tag-curso .jn-clases::after,
.page-becas .jn-clases::after,
.page-taller-dibujos .jn-clases::after,
.tag-hash-ejercicio .jn-aprende::after,
.page-ejercicios .jn-aprende::after,
.tag-gratis .jn-aprende::after,
.page-about .jn-sobre::after,
.page-contacto .jn-contacto::after {
    transform: scaleX(1);
}

/* --- Dropdowns ------------------------------------------------------------ */
.jn-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    min-width: 330px;
    padding: 14px;
    background: var(--jn-panel);
    border: 1px solid var(--jn-line);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.jn-menu-wide { min-width: 620px; }

/* The nav group is right-aligned, so a wide menu anchored at left:0 runs off
   the viewport. nav.js measures each menu as it opens and flips it to
   right-anchored when it would overflow — position-dependent CSS guesswork
   (nth-last-of-type and friends) breaks the moment an item is added. */
.jn-menu.jn-menu-right { left: auto; right: 0; }

.jn-trigger[aria-expanded="true"] + .jn-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.jn-cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px 22px; }
.jn-col-head {
    margin: 6px 0 8px 12px;
    font-size: 0.72rem;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--jn-dim);
}
.jn-menu-list { list-style: none; margin: 0; padding: 0; }
.jn-menu-list a {
    display: block;
    padding: 11px 12px;
    text-decoration: none;
    color: var(--jn-ink);
    border-left: 2px solid transparent;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}
.jn-menu-list a:hover,
.jn-menu-list a:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--jn-accent);
    outline: none;
}
.jn-menu-list strong {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: none;
}
.jn-menu-list a:hover strong { color: var(--jn-accent); }
.jn-menu-list span {
    display: block;
    margin-top: 4px;
    font-size: 0.83rem;
    line-height: 1.45;
    color: var(--jn-dim);
    text-transform: none;
}
.jn-menu-tight a { padding: 8px 12px; }

/* --- Right-hand actions --------------------------------------------------- */
.jn-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.jn-icon {
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    color: var(--jn-ink);
    border: 1px solid var(--jn-line);
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.jn-icon:hover { color: var(--jn-accent); border-color: var(--jn-accent); }

.jn-cta {
    display: inline-flex;
    align-items: center;
    padding: 12px 22px;
    font-size: 0.92rem;
    line-height: 1;
    font-weight: 600;
    text-transform: none;
    text-decoration: none;
    color: #0B0E13;
    background: var(--jn-accent);
    white-space: nowrap;
    clip-path: polygon(11px 0, 100% 0, 100% calc(100% - 11px), calc(100% - 11px) 100%, 0 100%, 0 11px);
    transition: filter 0.2s ease;
}
.jn-cta:hover { filter: brightness(1.12); }
.jn-cta:focus-visible { outline: 2px solid var(--jn-ink); outline-offset: 2px; }

/* --- Burger --------------------------------------------------------------- */
.jn-burger {
    display: none;
    width: 42px; height: 42px;
    padding: 0;
    background: none;
    border: 1px solid var(--jn-line);
    cursor: pointer;
}
.jn-burger-bars { display: grid; gap: 5px; justify-items: center; }
.jn-burger-bars i {
    display: block;
    width: 20px; height: 2px;
    background: var(--jn-ink);
    transition: transform 0.25s ease, opacity 0.2s ease;
}
.jn-burger[aria-expanded="true"] .jn-burger-bars i:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.jn-burger[aria-expanded="true"] .jn-burger-bars i:nth-child(2) { opacity: 0; }
.jn-burger[aria-expanded="true"] .jn-burger-bars i:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.jn-scrim {
    position: fixed;
    inset: 0;
    z-index: calc(var(--jn-z) - 1);
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.jn-scrim.is-open { opacity: 1; }
.jn-scrim[hidden] { display: none; }

/* Set by nav.js while the drawer is open. */
body.jn-locked { overflow: hidden; }

/* --- Content offset ------------------------------------------------------
   Only default.hbs needs it: its <main> starts 48px from the top, which the
   84px bar would cover. home-shell pages already clear it with 120px of
   .section-padding, and the homepage wants the overlap. */
.jn-offset { padding-top: var(--jn-h); }

/* ===========================================================================
   Below 1024px the same markup becomes an off-canvas panel: .jn-main goes
   fixed, the list stacks, and every dropdown flattens into an accordion.
   No second copy of the tree, so the two can never disagree.
   =========================================================================== */
@media (max-width: 1023px) {
    .jn-inner { height: var(--jn-h-sm); gap: 14px; padding: 0 18px; }
    .jn.is-solid .jn-inner { height: var(--jn-h-sm); }
    .jn-offset { padding-top: var(--jn-h-sm); }

    .jn-burger { display: grid; place-items: center; }
    .jn-cta-bar { display: none; }
    .jn-item-cta { display: block; margin-top: 22px; padding: 0 4px; }
    .jn-item-cta .jn-cta { width: 100%; justify-content: center; padding: 16px; }

    .jn-main {
        position: fixed;
        top: 0; right: 0; bottom: 0;
        width: min(380px, 88vw);
        margin: 0;
        padding: calc(var(--jn-h-sm) + 22px) 20px 40px;
        background: var(--jn-bg);
        border-left: 1px solid var(--jn-line);
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        /* These are z-indexes *inside* .jn, which already made a stacking
           context at --jn-z, so they only rank against each other — the whole
           header is above the scrim regardless. The panel is anchored top:0
           and covers the burger, which is the close button once open; without
           lifting .jn-actions above it the only ways out are the scrim and
           Escape. The panel's top padding means nothing is hidden by it. */
        z-index: 1;
    }
    .jn-actions { position: relative; z-index: 2; }
    .jn-main.is-open { transform: translateX(0); }

    .jn-list { display: block; }
    .jn-item { border-bottom: 1px solid var(--jn-line); }
    .jn-item-cta { border-bottom: 0; }
    .jn-link {
        display: flex;
        justify-content: space-between;
        width: 100%;
        padding: 17px 4px;
        font-size: 1.05rem;
    }
    .jn-link::after { display: none; }

    /* The dropdown stops being a popover and becomes a collapsed block.
       max-height rather than display:none so it animates; the value only has
       to exceed the tallest menu. */
    .jn-menu {
        position: static;
        min-width: 0;
        max-height: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
        background: none;
        clip-path: none;
        opacity: 1;
        visibility: visible;
        overflow: hidden;
        transform: none;
        transition: max-height 0.3s ease;
    }
    .jn-trigger[aria-expanded="true"] + .jn-menu { max-height: 720px; padding-bottom: 10px; }
    .jn-menu-wide { min-width: 0; }
    .jn-cols { grid-template-columns: 1fr; gap: 0; }
    .jn-col-head { margin-left: 4px; }
    .jn-menu-list a { padding-left: 16px; }
}

/* --- Motion --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .jn, .jn-inner, .jn-menu, .jn-main, .jn-chev, .jn-link::after, .jn-scrim {
        transition: none;
    }
    .jn.is-hidden { transform: none; }
}
