/* =========================================================================
   Legend of Fenrirak — shared site navigation & scroll-experience kit.

   One flat, quiet bar used by every page, plus a small set of reusable
   scroll-experience components (lightbox, progress bar, back-to-top)
   used by the longer story-style pages. Edit here, not in each page.

   Also below: a further set of opt-in accents for story-style pages —
   hover brighten, push-tilt, an ambient cursor light, a soothing drifting glow
   border, scroll parallax, and a scroll-scrubbed text glow. Same rule as
   everything above: nothing activates on a page unless that page adds
   the matching class.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Comfortaa&display=swap');

.topbar {
    /* Set here rather than relying on a global reset: without it the side
       padding is added on top of width:100% and the bar overflows the page. */
    box-sizing: border-box;

    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    padding: 0 12px;
    background: #16161a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    position: sticky;
    top: 0;
    z-index: 200;
    margin-bottom: 34px;
}

.topbar .nav-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;

    /* Without this a flex child refuses to shrink below its content width,
       which is what pushed the last link off the right of the screen. */
    min-width: 0;
    max-width: 100%;
}

.topbar .nav-links a,
.topbar .nav-trigger {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 15px 14px;
    margin: 0;
    border: none;
    border-radius: 0;
    background: none;
    box-shadow: none;
    white-space: nowrap;
    text-decoration: none;
    font-family: Allegro, serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #9c9a95;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.topbar .nav-links svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
    flex-shrink: 0;
    opacity: 0.75;
}

.topbar .nav-links a:hover,
.topbar .nav-trigger:hover {
    color: #e8e4dc;
}

.topbar .nav-links a:hover svg,
.topbar .nav-trigger:hover svg { opacity: 1; }

/* Current page: a quiet underline, not a filled bubble. */
.topbar .nav-links a.active,
.topbar .nav-trigger.active {
    border-color: rgba(217, 163, 92, 0.85);
    color: #efe9de;
}

.topbar .nav-links a.active svg,
.topbar .nav-trigger.active svg { opacity: 1; }

/* ---- Games dropdown --------------------------------------------------- */

.nav-group { position: relative; display: flex; }

.nav-trigger .caret {
    width: 11px;
    height: 11px;
    stroke-width: 2.2;
    opacity: 0.55;
    transition: transform 0.15s ease;
}

.nav-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 210px;
    display: none;
    flex-direction: column;
    padding: 5px 0;
    background: #1b1b20;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-top: none;
    border-radius: 0 0 9px 9px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
    z-index: 210;
}

/* Hover only where hovering is a real thing; taps use the .open class. */
@media (hover: hover) {
    .nav-group:hover .nav-menu { display: flex; }
    .nav-group:hover .nav-trigger .caret { transform: rotate(180deg); }
}
.nav-group:focus-within .nav-menu,
.nav-group.open .nav-menu { display: flex; }
.nav-group.open .nav-trigger .caret { transform: rotate(180deg); }

.topbar .nav-menu a {
    padding: 11px 16px;
    border-bottom: none;
    border-left: 2px solid transparent;
    font-size: 13px;
}

.topbar .nav-menu a:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.topbar .nav-menu a.active {
    border-bottom: none;
    border-left-color: rgba(217, 163, 92, 0.85);
    color: #efe9de;
}

/* Small gold "pick" bubble next to an item in the Games dropdown.
   Add <span class="nav-badge">…</span> after the link's <span> label. */
.nav-menu .nav-badge {
    display: inline-block;
    padding: 2px 8px;
    font-family: Allegro, serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 1.5;
    color: #241a03;
    background: #d2a236;
    border-radius: 999px;
    white-space: nowrap;
}

/* ---- narrow screens --------------------------------------------------- */

@media (max-width: 760px) {
    .topbar {
        padding: 0;
        margin-bottom: 24px;
    }

    .topbar .nav-links {
        width: 100%;
        justify-content: space-evenly;
    }

    .topbar .nav-links a,
    .topbar .nav-trigger {
        padding: 12px 10px;
        font-size: 12px;
    }

    .topbar .nav-links > a > span,
    .topbar .nav-trigger > span { display: none; }

    .topbar .nav-links svg { width: 18px; height: 18px; }
    .nav-trigger .caret { width: 10px; height: 10px; }

    /* Anchor the menu to the bar rather than to the button, so it cannot run
       off the edge when the Games button sits near the right of the screen.
       .topbar is position:sticky, so it is the containing block once the
       group itself stops being positioned. */
    .nav-group { position: static; }

    .nav-menu {
        top: 100%;
        left: 8px;
        right: 8px;
        transform: none;
        min-width: 0;
        border-radius: 0 0 9px 9px;
    }

    .topbar .nav-menu a span { display: inline; }
}

/* ---- "Support the Creators" button ------------------------------------
   One shared solid gold-yellow rectangular button, used two ways: a
   compact size in the topbar (beside the Games button) and a bigger
   block CTA (add the .block modifier) at the bottom of every page. Same
   fill, font and hover on both, so they read as one button wherever
   they appear. */
.support-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: Allegro, serif;
    font-weight: 700;
    text-decoration: none;
    color: #121212;
    background: #e8b64d;
    border: 1px solid #c99a3a;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.support-btn svg {
    width: 15px;
    height: 15px;
    stroke: #121212;
    fill: none;
    stroke-width: 1.9;
    flex-shrink: 0;
}
.support-btn:hover {
    background: #f2c565;
    transform: translateY(-2px);
}

/* Compact size, sits in the nav row to the right of the Games button. */
.topbar .nav-links a.support-btn {
    padding: 8px 16px;
    margin-left: 4px;
    font-size: 13px;
    letter-spacing: 0.3px;
}
@media (max-width: 760px) {
    .topbar .nav-links a.support-btn > span { display: none; }
    .topbar .nav-links a.support-btn {
        padding: 9px 11px;
        margin-left: 2px;
    }
    .topbar .nav-links a.support-btn svg { width: 17px; height: 17px; }
}

/* Full-size block CTA, sized to match the site's existing button footprint. */
.support-btn.block {
    margin: 10px auto;
    padding: 15px;
    width: 80%;
    max-width: 320px;
    font-size: 18px;
}
.support-btn.block svg { width: 18px; height: 18px; }
@media (max-width: 600px) {
    .support-btn.block { width: 90%; font-size: 17px; }
}

/* =========================================================================
   SHARED SCROLL-EXPERIENCE COMPONENTS
   Used by the longer, scrolling story-style pages (About, Creators).
   Every rule below is inert unless the matching element exists on the page,
   so it never changes how the short pages (Home, AfterShowdowns) look.
   ========================================================================= */

/* ---- pop-in-as-you-scroll -----------------------------------------------
   No CSS here hides anything. site-nav.js computes each ".pop-in"
   element's opacity live, every scroll frame, from its position on
   screen, and applies it as an inline style — so it stays perfectly in
   sync with the scrollbar (scroll partway and content sits partway
   revealed; scroll back up and it recedes again). Since only that
   running script ever sets those styles, a page with JavaScript
   disabled (or a blocked/broken script) simply shows this content
   normally — it is never hidden by a stylesheet rule with no way back. */

/* ---- top scroll-progress thread ---------------------------------------- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, rgba(217, 163, 92, 0.55), rgb(242, 204, 143));
    z-index: 400;
    transition: width 0.1s linear;
}
@media (prefers-reduced-motion: reduce) {
    .scroll-progress { transition: none; }
}

/* ---- floating back-to-top ----------------------------------------------- */
.back-to-top {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 300;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #1b1b20;
    border: 1px solid rgba(217, 163, 92, 0.4);
    color: rgb(242, 204, 143);
    text-decoration: none;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.25s ease, background-color 0.25s ease;
}
.back-to-top svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}
.back-to-top.visible {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}
.back-to-top:hover {
    background-color: #292930;
    border-color: rgb(217, 163, 92);
}

/* ---- lightbox ------------------------------------------------------------ */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5vh 5vw;
    background: rgba(8, 8, 9, 0.92);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}
.lightbox-overlay.open {
    opacity: 1;
    visibility: visible;
}
.lightbox-overlay img {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.lightbox-overlay .lightbox-close {
    position: absolute;
    top: 18px;
    right: 22px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #efe9de;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.lightbox-overlay .lightbox-close:hover { background: rgba(255, 255, 255, 0.14); }

/* Any image opted into the lightbox gets an inviting little lift. */
.lightbox-trigger { cursor: zoom-in; }

/* =========================================================================
   ABOUT-PAGE ACCENTS — hover brighten, push-tilt, ambient glow, drifting glow,
   parallax, text glow. Opt-in via class name, exactly like the scroll-
   experience kit above: add the class to an element in your HTML and
   site-nav.js does the rest. Nothing here runs, or even queries the DOM,
   unless its element exists.
   ========================================================================= */

/* ---- gentle whole-element brighten (hover) -------------------------------
   Put .glow-hover on a card, portrait, or panel — NOT directly on an
   <img>: browsers don't render ::after on replaced elements like img,
   video or input, so this would silently do nothing. Wrap the image in
   a plain <div class="glow-hover"> instead. A small, uniform lift across
   the whole element, not a spotlight that chases the cursor — so there's
   nothing for site-nav.js to track here, just a plain :hover/:focus-within. */
.glow-hover {
    position: relative;
    isolation: isolate;
}
.glow-hover::after {
    content: '';
    position: absolute;
    inset: 0;
    /* Matches whatever rounding the element already has — a background is
       always clipped to border-radius on its own, with no need for
       overflow: hidden, which would otherwise risk clipping something
       else on the same element (e.g. a hover shadow that's meant to
       spill outside the box, as on the .book-cover art below). */
    border-radius: inherit;
    background: rgba(242, 204, 143, 0.08);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    mix-blend-mode: screen;
}
.glow-hover:hover::after,
.glow-hover:focus-within::after { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    .glow-hover::after { transition: none; }
}

/* ---- cursor-tracked tilt / "push" (hover) --------------------------------
   Put .tilt-hover directly on an image (this one's fine on <img> — it's a
   real transform, not generated content) for a lean away from wherever
   the cursor is pushing from, in either direction on both axes — push
   from the left and it leans right, push from below and it leans up,
   and so on. Pairs well with .glow-hover on a wrapping element. */
.tilt-hover {
    transform: perspective(600px) rotateX(0deg) rotateY(0deg);
    transition: transform 0.12s ease-out;
    will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
    .tilt-hover { transition: none !important; transform: none !important; }
}

/* ---- grand wave glow (always on) ------------------------------------------
   Put .dye-hover on a card for a wide, luminous band just outside its
   edges, with one bright, hot "crest" that travels slowly and smoothly
   all the way around that band — like a single wave circling the
   border. The band itself is a conic-gradient (a dim base tint all the
   way around, with one wide, much brighter hump near one angle) masked
   down to a ring using the padding/content-box XOR trick: .dye-blob is
   a fully solid box, its background painted corner-to-corner, but the
   mask keeps only the padding-thick band around its own edge and cuts
   the solid middle out entirely — so what survives already has the
   card's own rounded-rectangle shape, not a circle. site-nav.js rotates
   the gradient's start angle (the --dye-angle custom property, set
   directly on .dye-blob) a tiny bit every frame, which is what makes
   the crest crawl around the band. The outer .dye-layer then
   blurs that ring and, on top of the blur, stacks two drop-shadows at
   different reaches — this is what gives it a big, layered bloom
   instead of a single soft edge, so it reads as grand rather than
   understated. Sits at z-index -1, so it always paints behind the
   card's own heading, copy and button. Under prefers-reduced-motion the
   ring is still drawn (so it's still visible) but --dye-angle is never
   updated, so the crest holds at one fixed spot. */
.dye-hover {
    position: relative;
    isolation: isolate;
}
.dye-hover .dye-layer {
    position: absolute;
    inset: -54px;
    pointer-events: none;
    z-index: -1;
    border-radius: 58px;
    overflow: visible;
    /* A single blur, not a blur-plus-two-drop-shadows stack. Every one
       of these filters has to be recomputed from scratch each time the
       gradient underneath repaints (see the note on .dye-blob below),
       and drop-shadow is by far the priciest of the three — it renders
       a whole separate blurred copy of the shape's alpha channel. Two
       of them stacked on top of a moving gradient was the main source
       of the lag; one blur, sized generously, gives most of the same
       soft, wide glow for a fraction of the cost. */
    filter: blur(26px);
}
.dye-hover .dye-blob {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-sizing: border-box;
    padding: 34px;
    /* This background repaints every frame (site-nav.js rotates
       --dye-angle), and a changing background can't be handed off to
       the compositor the way a transform or opacity change can — the
       browser has to re-rasterize it, then re-run .dye-layer's filter
       on the result, every single time. site-nav.js throttles how often
       that happens instead of doing it on every animation frame. */
    background: conic-gradient(
        from var(--dye-angle, 0deg),
        color-mix(in srgb, var(--accent, #4a82c7) 22%, transparent) 0deg,
        color-mix(in srgb, var(--accent, #4a82c7) 45%, transparent) 55deg,
        color-mix(in srgb, var(--accent, #4a82c7) 100%, white 45%) 90deg,
        color-mix(in srgb, var(--accent, #4a82c7) 45%, transparent) 125deg,
        color-mix(in srgb, var(--accent, #4a82c7) 22%, transparent) 180deg,
        color-mix(in srgb, var(--accent, #4a82c7) 22%, transparent) 360deg
    );
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 1;
}

/* ---- ambient ember light ---------------------------------------------
   Add one empty <div class="ember-field"></div>, once, right after the
   opening <body> tag. It sits behind nothing in particular — it's a
   fixed, page-wide layer — and casts a soft warm light that drifts
   toward wherever the cursor currently is, for atmosphere rather than
   as a UI control: pointer-events: none keeps it out of the way of every
   click, and it's the one accent on this page that simply doesn't render
   at all under prefers-reduced-motion rather than just holding still. */
.ember-field {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}
.ember-field::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 640px;
    height: 640px;
    margin: -320px 0 0 -320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(217, 163, 92, 0.16), transparent 70%);
    mix-blend-mode: screen;
    transform: translate(var(--ex, 0px), var(--ey, 0px));
    will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
    .ember-field { display: none; }
}

/* ---- scroll parallax drift ------------------------------------------
   Add .parallax, plus an optional data-speed (default 0.2), to anything
   you want drifting at a different rate than the page scrolls — a
   background portrait, a decorative rune, a title sitting behind copy.
   Keep values small (0.1–0.4); this is a drift, not a scene change. */
.parallax {
    will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
    .parallax { transform: none !important; }
}

/* ---- scroll-scrubbed text glow ---------------------------------------
   Add .reveal-text to a heading or paragraph of plain text (avoid nested
   links or bold/italic spans — site-nav.js rebuilds the element word by
   word). Words sit dim and brighten in sequence as the block travels
   through the reveal band, scrubbed by the scrollbar exactly like
   .pop-in above — scroll back up and they dim back down. */
.reveal-text .word {
    display: inline-block;
    opacity: 0.25;
}
@media (prefers-reduced-motion: reduce) {
    .reveal-text .word { opacity: 1; }
}
