/* ========================================
   RPG / CHARACTER SHEET
   personal.php: the Projects & Blog pane (php/personal/) and the
   Strange Frontiers pane (php/rpg/). Loaded from php/head-loads.php.
   ======================================== */

/* Keyword spans injected by the bold-keywords script in php/javascript-loads.php */
.mechanic-text {
    font-weight: 500;
}

/* php/rpg/rpg-stats.php, php/rpg/rpg-character.php */
.tiny-text {
    font-size: .75rem;
}

/* Spacer between blocks in the Mechanics and Setting partials (php/rpg/rpg-*.php)
   and between lore entries in php/rpg/lore.php */
.bumper {
    height: 48px;
    width: 100%;
}

/* php/rpg/rpg-stats.php: 48px each side, 24px below 1400px */
.column-image {
    width: 100%;
    padding: 0 48px;
    object-fit: contain;

    @media (max-width: 1399px) {
        padding: 0 24px;
    }
}

/* Trait cards, php/rpg/rpg-traits.php */
.trait-box {
    padding: 0 1rem 1rem 1rem;
    color: var(--portfolio-black);
    background-color: var(--portfolio-light-gray);
    border: 1px solid var(--portfolio-gray);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    gap: 0.5rem;
    flex-direction: column;
    width: 100%;
    font-size: 14px;

    .trait-name {
        font-size: 1rem;
        font-weight: 600;
        margin-left: -1rem;
        margin-right: -1rem;
        background-color: var(--portfolio-gray);
        padding: .5rem 1rem;
        color: var(--portfolio-white);
        .mechanic-text {
            font-weight: 600;
        }
    }

    .badge {
        width: fit-content;
        font-weight: 600;
        padding: .5rem 1rem;
        .mechanic-text {
            font-weight: 600;
        }

        .bg-dark {
            background-color: var(--portfolio-gray);
        }
    }
}

strong .mechanic-text {
    font-weight: 600;
}

/* Strange Frontiers side nav, rendered by php/rpg/rpg-links.php. The rail
   sits in personal.php's Setting and Mechanics panels; white invert copies are
   included in the black sections of rpg-traits, rpg-items, rpg-technologies
   and rpg-spacecraft. The dot is positioned by php/javascript-loads.php. */

/* Sticky side nav in a full-height rail so it travels with the panel,
   then pins at top: 134px. Invert copies stay viewport-fixed and clipped
   to black breakouts. */
.rpg-links-rail {
    position: absolute;
    top: 100px;
    bottom: 100px;
    left: 60px;
    z-index: 3;
    width: max-content;
    pointer-events: none;
}

.rpg-links-clip {
    z-index: 4;
    pointer-events: none;
    clip-path: inset(0);
}

.rpg-links-clip .logo-bug,
.rpg-links-clip .section-logo-bug,
.rpg-links-clip .section-about-social-container {
    pointer-events: auto;
}

.breakout:has(> .rpg-links-clip) {
    position: relative;
    z-index: 4;
}

.rpg-links {
    position: sticky;
    top: 134px;
    display: flex;
    gap: .5rem;
    flex-direction: column;
    align-self: flex-start;
    padding-right: 14px;
    pointer-events: auto;

    a {
        display: inline-block;
        width: fit-content;
    }

    .badge {
        background-color: var(--portfolio-black);
        color: var(--portfolio-white);
        padding: .25rem .5rem;
        transition: background-color 200ms;
    }

    /* Opaque blend instead of opacity: the black and white navs are stacked,
       so a translucent link would show the other nav through it. */
    a:hover .badge {
        background-color: color-mix(in srgb, var(--portfolio-black) 66%, var(--portfolio-white));
    }

    &.white a:hover .badge {
        background-color: color-mix(in srgb, var(--portfolio-white) 66%, var(--portfolio-black));
    }

    &.white .badge {
        background-color: var(--portfolio-white);
        color: var(--portfolio-black);
    }
}

.rpg-links-clip .rpg-links {
    position: fixed;
    top: 134px;
    left: 60px;
}

.rpg-links-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--portfolio-black);
    pointer-events: none;
    opacity: 0;

    .white & {
        background-color: var(--portfolio-white);
    }

    &.is-ready {
        opacity: 1;
        transition: top 200ms ease, left 200ms ease, opacity 200ms ease;
    }
}

/* overflow-x: hidden on body creates a scroll container that traps sticky.
   clip keeps horizontal overflow hidden without breaking the side nav. */
body:has(.rpg-links-rail),
body:has(.personal-shell) {
    overflow-x: clip;
}

/* The slide shrinks the page to one viewport, which drops the scrollbar and
   nudges the right-aligned chrome sideways. */
html:has(.personal-shell) {
    scrollbar-gutter: stable;
}

/* Two-pane slider in personal.php (Projects & Blog and Strange Frontiers).
   is-personal, is-frontiers, is-sliding and is-revealing are toggled by
   showPersonalPage in php/javascript-loads.php. */
.personal-shell {
    position: relative;
    width: 100%;
    overflow: clip;
}

/* One hero chrome for both panes. It lives outside the track so the slide
   transform can't carry it, and it's clipped to the hero height like the
   per-section copies elsewhere. */
.personal-hero-clip {
    bottom: auto;
    height: 75vh;
    z-index: 5;
    pointer-events: none;
    clip-path: inset(0 0 -1px 0);
}

.personal-hero-clip > * {
    pointer-events: auto;
}

.personal-hero-clip .logo-bug {
    background-color: var(--portfolio-white);
    color: var(--portfolio-black);
}

.personal-hero-clip .social-link svg {
    fill: var(--portfolio-black);
}

.personal-shell.is-personal .nav-bullet-frontiers,
.personal-shell.is-frontiers .nav-bullet-personal {
    display: none;
}

.personal-track {
    display: flex;
    width: 100vw;
    align-items: flex-start;
    position: relative;
    left: 0;
}

.personal-shell.transitions-on.is-sliding .personal-track {
    transition: transform 700ms cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.personal-shell.is-frontiers:not(.is-sliding) .personal-track {
    left: 0;
}

.personal-pane {
    width: 100vw;
    flex: 0 0 100vw;
    min-height: 100vh;
}

.personal-shell.is-personal:not(.is-sliding) .pane-frontiers,
.personal-shell.is-frontiers:not(.is-sliding) .pane-personal {
    height: 0;
    min-height: 0;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
}

/* Only the two heroes move. Full-page `left` animation was laying out both
   documents every frame; transform is compositor-only and the rest stays out. */
.personal-shell.is-sliding .personal-pane {
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    visibility: visible;
}

.personal-shell.is-sliding .personal-pane > :not(.short-section) > * {
    visibility: hidden;
    opacity: 0;
}

/* Transform on the track creates a stacking context, so the page-level black
   EW would paint over the heroes. Hide it during the slide. */
body:has(.personal-shell.is-sliding) > .section-logo-bug,
body:has(.personal-shell.is-sliding) > .section-about-social-container {
    visibility: hidden;
}

/* Fade what's inside each section, not the sections, so panel whites and the
   footer tint land immediately instead of fading up from the night sky. */
.personal-shell.transitions-on.is-revealing .personal-pane.is-visible > :not(.short-section) > * {
    opacity: 0;
    transition: opacity 350ms ease;
}

.personal-shell.transitions-on.is-revealing.is-revealed .personal-pane.is-visible > :not(.short-section) > * {
    opacity: 1;
}

.personal-shell.is-revealing:not(.is-revealed) .personal-pane.is-visible > :not(.short-section) {
    pointer-events: none;
}

/* Hero nav (Projects & Blog / Strange Frontiers), php/personal/page-nav.php */
.personal-page-nav a {
    display: inline-block;
    position: relative;
}

/* The dot sits in em, so it moves in as the nav shrinks: 18px out at 28px,
   about 16px at 24px and 13px at 20px */
.personal-page-nav .nav-bullet {
    left: auto;
    right: -0.65em;
}

/* Its labels run longer than the homepage's, so it takes the homepage nav's
   smaller sizes sooner: 1.5rem (the homepage's size on short windows and
   phones) below 1400px, and 1.25rem (its own phone size) below 1200px */
@media (max-width: 1399px) {
    .section-scroll-links.personal-page-nav {
        font-size: 1.5rem;
        line-height: 1.35;
    }
}

@media (max-width: 1199px) {
    .section-scroll-links.personal-page-nav {
        font-size: 1.25rem;
    }
}

/* Green Strange Frontiers accent: hero title in personal.php and its nav link */
.frontiers-accent,
.personal-page-nav a.frontiers-accent,
.personal-page-nav a.frontiers-accent .nav-bullet {
    color: var(--frontiers-green);
}

/* Glitching Strange Frontiers title (personal.php hero and the homepage advert), after codepen.io/chasebank/pen/qZNLyx: a green glow that
   flares, cyan and red slices that jump around, and the odd violent skew. */
.frontiers-glitch {
    position: relative;
    isolation: isolate;
    text-shadow: 0 -5px 10px var(--frontiers-green);
    animation: frontiers-glitch-shift 4s ease-in-out infinite alternate, frontiers-glitch-glow 8s ease-in-out infinite alternate;

    &::before, &::after {
        content: attr(data-text);
        position: absolute;
        top: 0;
        width: 100%;
        color: transparent;
        clip-path: inset(0 0 100% 0);
        animation: frontiers-glitch-shift 4s ease-in-out infinite alternate;
    }

    &::before {
        left: 1px;
        z-index: -1;
        opacity: .8;
        text-shadow: -3px 0 cyan;
        animation-name: frontiers-glitch-shift, frontiers-glitch-noise-1;
        animation-duration: 4s, 3s;
        animation-timing-function: ease-in-out, linear;
        animation-direction: alternate, alternate-reverse;
    }

    &::after {
        left: 3px;
        z-index: -2;
        opacity: .7;
        text-shadow: -1px 0 red;
        animation-name: frontiers-glitch-shift, frontiers-glitch-noise-2;
        animation-duration: 4s, 3s;
        animation-timing-function: ease-in-out, linear;
        animation-direction: alternate, alternate-reverse;
    }
}

/* The Strange Frontiers logo (index.php's hero; rpg-components.php, Title): the sheets'
   four-pointed star, hanging out to the left of the glitching title so the title's S
   lines up with the content below, centered on the title's first line. The whole
   logo skews as one (frontiers-glitch-shift on .sf-logo, so the star goes with the
   words); the words keep the title's glow and cyan and red slices but not their own
   skew, which would double it. The star has its own glow: a purple pulse in its own
   color. */
.sf-logo {
    position: relative;
    animation: frontiers-glitch-shift 4s ease-in-out infinite alternate;

    .frontiers-glitch {
        animation: frontiers-glitch-glow 8s ease-in-out infinite alternate;

        &::before {
            animation-name: frontiers-glitch-noise-1;
            animation-duration: 3s;
            animation-timing-function: linear;
            animation-direction: alternate-reverse;
        }

        &::after {
            animation-name: frontiers-glitch-noise-2;
            animation-duration: 3s;
            animation-timing-function: linear;
            animation-direction: alternate-reverse;
        }
    }
}

.sf-logo-star {
    position: absolute;
    right: 100%;
    /* Centered on the first line; Bebas Neue's capitals sit a little above its middle */
    top: calc((1lh - .5em) / 2 - .08em);
    width: .5em;
    height: .5em;
    margin-right: .18em;
    fill: var(--sf-purple-500);
    animation: sf-logo-star-pulse 2.4s ease-in-out infinite alternate;
}

/* On phones the hero runs to the screen's edge, so it makes room for the star */
@media (max-width: 575px) {
    .hero-statement:has(.sf-logo) {
        padding-left: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sf-logo,
    .sf-logo .frontiers-glitch,
    .sf-logo .frontiers-glitch::before,
    .sf-logo .frontiers-glitch::after {
        animation: none;
    }

    .sf-logo-star {
        animation: none;
        filter: drop-shadow(0 0 6px var(--sf-purple-500));
    }
}

@keyframes sf-logo-star-pulse {
    /* Two shadows at both ends so the browser can blend between them */
    from {
        filter: drop-shadow(0 0 2px var(--sf-purple-500)) drop-shadow(0 0 4px transparent);
    }
    to {
        filter: drop-shadow(0 0 6px var(--sf-purple-500)) drop-shadow(0 0 14px var(--sf-purple-500));
    }
}

@keyframes frontiers-glitch-glow {
    0%, 40%, 50%, 60%, 90%, 95%, 100% {
        text-shadow: 0 -5px 10px var(--frontiers-green), 0 0 5px transparent, 0 0 10px transparent, 2px 1px 15px transparent, 0 0 20px transparent;
    }
    45%, 75% {
        text-shadow: 0 -5px 10px var(--frontiers-green), 0 0 5px var(--frontiers-green), 0 0 10px var(--frontiers-green), 2px 1px 15px rgb(100, 240, 255), 0 0 20px var(--frontiers-green);
    }
    97.5% {
        text-shadow: 0 -5px 10px transparent, 0 0 5px transparent, 0 0 10px transparent, 2px 1px 4px rgb(255, 100, 100), 0 0 20px transparent;
    }
}

/* The stat diagram's Character Level glitches like the creator's glitching
   buttons (sf-glitch-small in the creator's styles): the title's rhythm, but a
   faint green glow, a cyan and red split that widens on the flares, and a
   slight skew. Every frame has the same three shadows so they blend. */
@keyframes stat-ring-level-glow {
    0%, 40%, 50%, 60%, 90%, 95%, 100% {
        filter: drop-shadow(0 0 2px rgb(45 252 100 / 35%)) drop-shadow(-1.5px 0 0 rgb(0 255 255 / 60%)) drop-shadow(1.5px 0 0 rgb(255 0 0 / 60%));
    }
    45%, 75% {
        filter: drop-shadow(0 0 4px rgb(45 252 100 / 70%)) drop-shadow(-3px 0 0 rgb(0 255 255 / 85%)) drop-shadow(3px 0 0 rgb(255 0 0 / 75%));
    }
    97.5% {
        filter: drop-shadow(0 0 2px rgb(45 252 100 / 0%)) drop-shadow(-1.5px 0 0 rgb(0 255 255 / 60%)) drop-shadow(4px 0 0 rgb(255 0 0 / 90%));
    }
}

@keyframes stat-ring-level-shift {
    0%, 40%, 44%, 58%, 61%, 65%, 69%, 73%, 100% { transform: none; }
    41% { transform: skewX(2deg); }
    42% { transform: skewX(-2deg); }
    59% { transform: skewX(5deg); }
    60% { transform: skewX(-5deg); }
    63% { transform: skewX(2deg); }
    70% { transform: skewX(-6deg); }
    71% { transform: skewX(2deg); }
}

@keyframes frontiers-glitch-shift {
    0%, 40%, 44%, 58%, 61%, 65%, 69%, 73%, 100% { transform: skewX(0deg); }
    41% { transform: skewX(10deg); }
    42% { transform: skewX(-10deg); }
    59% { transform: skewX(40deg) skewY(10deg); }
    60% { transform: skewX(-40deg) skewY(-10deg); }
    63% { transform: skewX(10deg) skewY(-5deg); }
    70% { transform: skewX(-50deg) skewY(-20deg); }
    71% { transform: skewX(10deg) skewY(-10deg); }
}

@keyframes frontiers-glitch-noise-1 {
    0% { clip-path: inset(41% 0 81% 0); }
    5% { clip-path: inset(50% 0 17% 0); }
    10% { clip-path: inset(6% 0 91% 0); }
    15% { clip-path: inset(68% 0 88% 0); }
    20% { clip-path: inset(46% 0 26% 0); }
    25% { clip-path: inset(7% 0 36% 0); }
    30% { clip-path: inset(27% 0 96% 0); }
    35% { clip-path: inset(11% 0 45% 0); }
    40% { clip-path: inset(53% 0 92% 0); }
    45% { clip-path: inset(30% 0 89% 0); }
    50% { clip-path: inset(70% 0 46% 0); }
    55% { clip-path: inset(7% 0 28% 0); }
    60% { clip-path: inset(15% 0 72% 0); }
    65% { clip-path: inset(80% 0 20% 0); }
    70% { clip-path: inset(74% 0 93% 0); }
    75% { clip-path: inset(73% 0 26% 0); }
    80% { clip-path: inset(50% 0 94% 0); }
    85% { clip-path: inset(28% 0 95% 0); }
    90% { clip-path: inset(71% 0 83% 0); }
    95% { clip-path: inset(37% 0 47% 0); }
    100% { clip-path: inset(18% 0 31% 0); }
}

@keyframes frontiers-glitch-noise-2 {
    0% { clip-path: inset(15% 0 27% 0); }
    5% { clip-path: inset(39% 0 29% 0); }
    10% { clip-path: inset(87% 0 77% 0); }
    15% { clip-path: inset(13% 0 26% 0); }
    20% { clip-path: inset(73% 0 19% 0); }
    25% { clip-path: inset(24% 0 53% 0); }
    30% { clip-path: inset(12% 0 30% 0); }
    35% { clip-path: inset(91% 0 92% 0); }
    40% { clip-path: inset(72% 0 93% 0); }
    45% { clip-path: inset(79% 0 74% 0); }
    50% { clip-path: inset(63% 0 13% 0); }
    55% { clip-path: inset(68% 0 46% 0); }
    60% { clip-path: inset(99% 0 60% 0); }
    65% { clip-path: inset(59% 0 26% 0); }
    70% { clip-path: inset(58% 0 54% 0); }
    75% { clip-path: inset(38% 0 69% 0); }
    80% { clip-path: inset(23% 0 11% 0); }
    85% { clip-path: inset(99% 0 69% 0); }
    90% { clip-path: inset(10% 0 27% 0); }
    95% { clip-path: inset(38% 0 33% 0); }
    100% { clip-path: inset(63% 0 57% 0); }
}

@media (prefers-reduced-motion: reduce) {
    .frontiers-glitch, .frontiers-glitch::before, .frontiers-glitch::after { animation: none; }
}

/* Pane tab bars along the bottom of each hero in personal.php
   (Blog / Projects / Photos and Setting / Mechanics / Change Log) */
.rpg-tabs {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;

    .container {
        height: auto;
    }
}

.rpg-tab-list {
    display: flex;
    align-items: stretch;
    gap: .5rem;
}

.rpg-tab {
    appearance: none;
    font-family: 'bebas_neueregular', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 1px;
    line-height: 1;
    padding: .75rem 1.5rem;
    background: var(--portfolio-gray);
    color: var(--portfolio-white);
    border: 0;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    transition: background-color 200ms;
}

.rpg-tab.is-active {
    background: var(--portfolio-white);
    color: var(--portfolio-black) !important;
    /* Cover the subpixel gap so the white tab meets the white panel */
    box-shadow: 0 1px 0 var(--portfolio-white);
}

/* Over dark panels (index.php's $rpgPanelTone), the active tab is the
   panel's gray, as in the Character Creator */
.pane-frontiers:has(.rpg-panel.black-bg) .rpg-tab.is-active {
    background: var(--sf-gray-700);
    color: var(--sf-gray-0) !important;
    box-shadow: 0 1px 0 var(--sf-gray-700);
}

/* Phones: the Change Log tab doesn't fit beside the other three */
@media (max-width: 575px) {
    #tab-changelog {
        display: none;
    }
}

/* Boxed sub-tabs inside Setting: php/rpg/rpg-setting.php (Timeline),
   rpg-technologies, rpg-planes, rpg-spacecraft and rpg-parabiology.
   tech-fields-light is the black-on-white version used in rpg-setting,
   rpg-planes and rpg-parabiology, on light (.white-bg) panels; on dark
   ones it's the usual white tab. */
.tech-fields {
    /* Pulled out by its padding and border, so the contents line up with the
       text above and below the box */
    --tech-fields-inset: 24px;
    margin-left: calc(-1 * var(--tech-fields-inset) - 1px);
    margin-right: calc(-1 * var(--tech-fields-inset) - 1px);
    padding: 0 var(--tech-fields-inset) 36px;
    border: 1px solid #949798;
    border-radius: 10px;
    overflow: hidden;

    /* Phones have a narrower page gutter: a smaller inset keeps the side borders on screen */
    @media (max-width: 767px) {
        --tech-fields-inset: 12px;
    }

    /* The Character Creator and Player Tools (.sf-creator) keep their boxes inside
       their containers, like Player Tools' level up Stats inside the character box */
    .sf-creator & {
        margin-left: 0;
        margin-right: 0;
    }
}

.tech-field-tab-list {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: .5rem;
    margin-bottom: 36px;
}

.tech-field-tab {
    appearance: none;
    font-family: 'bebas_neueregular', sans-serif;
    font-size: 1.25rem;
    letter-spacing: 1px;
    line-height: 1;
    padding: .6rem 1.1rem;
    background: var(--portfolio-gray);
    color: var(--portfolio-white);
    border: 0;
    border-radius: 0 0 4px 4px;
    cursor: pointer;
    transition: background-color 200ms;
}

@media (hover: hover) {
    .rpg-tab:not(.is-active):hover,
    .tech-field-tab:not(.is-active):hover {
        background-color: color-mix(in srgb, var(--portfolio-gray) 66%, transparent);
    }
}

.tech-field-tab.is-active {
    background: var(--portfolio-white);
    color: var(--portfolio-black);
}

.white-bg .tech-fields-light .tech-field-tab.is-active {
    background: var(--portfolio-black);
    color: var(--portfolio-white);
}

.black-bg .tech-fields-light .tech-field-tab.is-active {
    background: var(--portfolio-white);
    color: var(--portfolio-black);
}

.rpg-tab:focus,
.tech-field-tab:focus {
    outline: none;
}

.rpg-tab:focus-visible,
.tech-field-tab:focus-visible {
    outline: 2px solid var(--frontiers-green);
    outline-offset: -2px;
}

/* Inline lore links built by sf_lore_link() in php/rpg/lore.php, used
   throughout the Strange Frontiers copy */
.lore-link {
    color: var(--frontiers-lore);
    font-weight: 600;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    cursor: pointer;
}

.lore-link:hover {
    color: var(--frontiers-lore);
    text-decoration-style: solid;
}

/* The lighter purple on black (see css/tokens.css) */
.black-bg .lore-link,
.black-bg .lore-link:hover {
    color: var(--frontiers-lore-on-black);
}

.lore-link:focus {
    outline: none;
}

.lore-link:focus-visible {
    outline: 2px solid var(--frontiers-green);
    outline-offset: 2px;
    border-radius: 2px;
}

/* What the lore popup holds (php/rpg/lore-modal.php, opened and filled by
   php/javascript-loads.php). The popup itself is the popup component
   (php/rpg/components/popup.php, css/sf-popup.css). */
.sf-popup-body .d-flex.flex-wrap {
    flex-direction: column;
    gap: 24px;
}

/* The popup is too narrow for two text columns. */
.sf-popup-body .text-cols {
    column-count: 1;
}

/* A dark popup's panel on the site also takes black-bg for its light text
   and links, but keeps the popup's own gray */
.sf-popup--dark .sf-popup-panel.black-bg {
    background-color: var(--popup-panel);
}

/* Strange Frontiers search, personal.php. Indexed and filled by
   php/javascript-loads.php; results open in the lore popup. */
.rpg-search {
    position: fixed;
    top: 32px;
    left: 50%;
    z-index: 5;
    display: none;
    width: 320px;
    transform: translateX(-50%);
}

body:has(.personal-shell.is-frontiers:not(.is-sliding)) .rpg-search {
    display: block;
}

.rpg-search-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    width: 15px;
    height: 15px;
    color: #989b9c;
    transform: translateY(-50%);
    pointer-events: none;
}

.rpg-search-input {
    display: block;
    width: 100%;
    height: 35px;
    padding: 0 16px 0 38px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 18px;
    background: var(--portfolio-black);
    color: var(--portfolio-white);
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    transition: border-color 200ms;
}

.rpg-search-input::placeholder {
    color: #989b9c;
    opacity: 1;
}

.rpg-search-input:focus {
    outline: none;
    border-color: var(--frontiers-green);
}

.rpg-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    width: 440px;
    max-width: calc(100vw - 40px);
    max-height: min(60vh, 520px);
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
    border-radius: 8px;
    background: var(--portfolio-white);
    color: var(--portfolio-black);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .4);
    transform: translateX(-50%);
}

.rpg-search-result {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.rpg-search-result:hover,
.rpg-search-result.is-active {
    background: #ebeced;
}

.rpg-search-result-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.rpg-search-result-context {
    display: block;
    margin-top: 2px;
    color: #696b6d;
    font-size: 11px;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.rpg-search-result-snippet {
    display: block;
    margin-top: 4px;
    color: #424446;
    font-size: 12px;
    line-height: 1.45;
}

.rpg-search-result mark {
    padding: 0;
    background: color-mix(in srgb, var(--frontiers-green) 45%, transparent);
    color: inherit;
}

.rpg-search-empty {
    padding: 8px 12px;
    color: #696b6d;
    font-size: 13px;
}

@media (max-width: 991px) {
    body:has(.personal-shell.is-frontiers:not(.is-sliding)) .rpg-search {
        display: none;
    }
}

/* Panels switched by the .tech-field-tab buttons above */
.tech-field-panel {
    display: none;
}

.tech-field-panel.is-active {
    display: block;
}

/* Info box columns in the plane, Ark, nation, and corporation lore entries, php/rpg/lore/ */
.info-cols {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 24px;
    margin: 2rem 0 0;
}

.info-cols > * {
    flex: 0 0 auto;
    width: max-content;
    max-width: 100%;
}

/* Nation attribute columns (rpg-setting.php) share the row equally */
.info-cols > .flex-1 {
    flex: 1;
    width: auto;
    min-width: 160px;
}

@media (min-width: 768px) {
    /* One row: the third column shrinks rather than the image or itself wrapping. */
    #plane-known .info-cols {
        flex-wrap: nowrap;
    }

    #plane-known .info-cols > :nth-child(1) {
        width: 128px;
    }

    #plane-known .info-cols > :nth-child(2) {
        flex: 0 0 256px;
        width: auto;
    }

    /* The third column fills the row; the square image placeholder after it
       (shown from 1500px, like the other placeholders) keeps its size. */
    #plane-known .info-cols > :nth-child(3) {
        flex: 0 1 480px;
        width: auto;
        min-width: 0;
    }

    #plane-known .info-cols > .plane-image {
        flex: 0 0 360px;
        aspect-ratio: 4 / 3;
        margin: 0 0 1rem;
    }
}

.info-cols > .flex-1:first-child {
    max-width: 360px;
}

.info-cols > :last-child {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
}

@media (max-width: 767px) {
    .info-cols {
        flex-direction: column;
        gap: 12px;
    }

    .info-cols > *,
    .info-cols > :last-child {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
    }

    .info-cols > .attr-list {
        margin-bottom: 0;
    }

    .info-cols > :last-child,
    #plane-known .info-cols > :nth-child(3) {
        margin-bottom: 1rem;
    }
}

/* Info box entries: small label stacked above its value */
.attr-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0 0 1rem;
    padding-inline-start: 0;

    dt {
        font-size: 0.75rem;
        font-weight: 400;
        letter-spacing: 0.04em;
        line-height: 1.2;
        opacity: 0.6;
    }

    dd {
        margin: 0;
    }

    dd:empty::before {
        content: "\2014";
        opacity: 0.4;
    }
}

/* Reference tables in Planar Properties (php/rpg/rpg-planes.php) and Incidents (rpg-incidents.php):
   Compatibility, Stability, and Aperture scales. */
.sf-table {
    width: 100%;
    margin: 1rem 0 0;
    border-collapse: collapse;

    th,
    td {
        padding: 8px 12px;
        border-bottom: 1px solid rgb(0 0 0 / 15%);
        text-align: left;
        vertical-align: top;
    }

    th {
        font-weight: 700;
        white-space: nowrap;
    }

    td:first-child {
        white-space: nowrap;
        font-weight: 700;
    }

    .black-bg & :is(th, td) {
        border-bottom-color: rgb(255 255 255 / 25%);
    }

    tbody tr:last-child td {
        border-bottom: 0;
    }

    td:empty::before {
        content: "\2014";
        opacity: 0.4;
    }
}

/* Sample Skill Checks (rpg-skills.php): a group heading row per core Stat, and
   each check's graded targets as label-and-number pairs */
.sf-check-table {
    .sf-table-group th {
        padding-top: 20px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    tbody tr:first-child th {
        padding-top: 8px;
    }
}

.sf-check-targets {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
    margin: 0;
    padding: 0;
    list-style: none;

    li {
        display: inline-flex;
        gap: 6px;
        white-space: nowrap;
    }

    strong {
        font-weight: 700;
    }
}

/* Collapsible "Details" section under an attribute block: plane, Ark, and
   corporation lore entries in php/rpg/lore/, the Nations tab in rpg-setting.php, and
   the Starships tab in rpg-spacecraft.php.
   Boxed whether open or closed; border matches .line. */
.lore-details {
    border: 1px solid rgb(0 0 0 / 15%);
    border-radius: var(--portfolio-radius);
    padding: 16px;

    .black-bg & {
        border-color: rgb(255 255 255 / 25%);
    }

    > summary {
        display: block;
        list-style: none;
        cursor: pointer;
        margin-bottom: 0;

        &::-webkit-details-marker {
            display: none;
        }

        .line {
            display: none;
        }

        h5 > strong,
        h5::after {
            font-weight: 300;
        }

        h5 > strong,
        h5::after {
            transition: opacity 0.2s ease;
        }

        /* The + and − icons, drawn in the text's color */
        h5::after {
            content: "";
            display: inline-block;
            width: 18px;
            height: 18px;
            margin-left: 8px;
            vertical-align: -0.15em;
            background-color: currentColor;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath d='M432 256c0 17.69-14.33 32.01-32 32.01H256v144c0 17.69-14.33 31.99-32 31.99s-32-14.3-32-31.99v-144H48c-17.67 0-32-14.32-32-32.01s14.33-31.99 32-31.99H192v-144c0-17.69 14.33-32.01 32-32.01s32 14.32 32 32.01v144h144C417.7 224 432 238.3 432 256z'/%3E%3C/svg%3E") center / contain no-repeat;
        }

        &:hover h5 > strong,
        &:hover h5::after {
            opacity: 0.6;
        }

        &:focus-visible {
            outline: 2px solid var(--frontiers-green);
            outline-offset: 2px;
        }
    }

    &[open] > summary {
        margin-bottom: 20px;

        h5::after {
            mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath d='M400 288h-352c-17.69 0-32-14.32-32-32.01s14.31-31.99 32-31.99h352c17.69 0 32 14.3 32 31.99S417.7 288 400 288z'/%3E%3C/svg%3E");
        }
    }

    > :last-child {
        margin-bottom: 0;
    }

    /* Overview / History / Geography / Territories columns: plain bold
       titles instead of the ruled heading. */
    > .d-flex {
        gap: 20px 40px;

        @media (max-width: 959px) {
            column-gap: 24px;
        }

        > :is(.flex-6, .flex-7) {
            > :last-child {
                margin-bottom: 0;
            }
        }

        .line-container {
            margin-bottom: 12px;

            h5 {
                padding: 0;
            }

            .line {
                display: none;
            }
        }
    }
}

.personal-pane .section-clip {
    /* Let that 1px seam cover paint; keep the rest of the hero clip */
    clip-path: inset(0 0 -1px 0);
}

/* Tab panels for both panes in personal.php, switched by .rpg-tab */
.rpg-panel {
    display: none;
}

.rpg-panel.is-active {
    display: flex;
    flex-direction: column;
}

/* A panel that ends on a dark section (Mechanics, with the Sample Character Sheet)
   drops its white bottom padding, so the dark section meets the footer. */
.rpg-panel:has(> .container > .breakout:last-child) {
    padding-bottom: 0;
}

/* Setting and Mechanics sections in personal.php */
#rpg-setting.section.unlimited {
    padding-bottom: 0;
}

/* Keep setting/mechanics section rows full-width inside the flex container
   so short placeholder blocks cannot sit side-by-side. */
#rpg-setting > .container > .d-flex,
#rpg-setting > .container > .w-100,
#rpg-mechanics > .container > .d-flex,
#rpg-mechanics > .container > .w-100,
#rpg-mechanics > .container > .separator,
#rpg-setting > .container > .separator {
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
}

.personal-pane .black-section {
    color: var(--portfolio-white);
}

@media (prefers-reduced-motion: reduce) {
    .personal-shell.transitions-on.is-sliding .personal-track {
        transition: none;
        will-change: auto;
    }

    .personal-shell.transitions-on.is-revealing .personal-pane.is-visible > :not(.short-section) > * {
        transition: none;
        opacity: 1;
    }
}

/* php/personal/blog.php, php/personal/projects.php */
.blog-content {
    max-width: 640px;
    width: 100%;
}

/* php/rpg/rpg-changelog.php, rpg-setting, rpg-technologies, rpg-planes, rpg-spacecraft */
.single-column-content {
    max-width: 768px;
    width: 100%;
}

/* Intro copy columns (Setting, Rebirth of Science, The Planes, The Stars, Parabiology)
   with a placeholder image beside it. The copy column is up to 768px, like the
   other single-column copy, and the image shows beside it from 960px up, where
   the copy takes half the row. */
.intro-with-image {
    container-type: inline-size;
    display: flex;
    gap: 40px;

    > .single-column-content {
        flex: 0 1 768px;
        max-width: 768px;
    }
}

.image-placeholder {
    display: none;
    flex: 1 1 0;
    min-width: 0;
    align-items: center;
    justify-content: center;
    background-color: var(--portfolio-light-gray);
    border-radius: var(--portfolio-radius);
    color: var(--portfolio-medium-gray);
    font-family: 'bebas_neueregular', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 1px;

    /* Inverted over dark sections (Rebirth of Science, The Stars). */
    .black-bg & {
        background-color: var(--portfolio-gray);
        color: var(--portfolio-white);
    }
}

/* Beside intro copy, the placeholder is a clear column as tall as the copy,
   and its gray box sits centered in it, no taller than 3:4. Its width is what's
   left of the row (the container) after the copy (half the row, up to 768px)
   and the gap. */
.intro-with-image > .image-placeholder {
    position: relative;
    isolation: isolate;
    background: none;

    &::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        height: min(100%, (100cqi - min(50cqi, 768px) - 40px) * 4 / 3);
        margin: auto 0;
        background-color: var(--portfolio-light-gray);
        border-radius: inherit;
    }
}

.black-bg .intro-with-image > .image-placeholder::before {
    background-color: var(--portfolio-gray);
}

/* A real image in the placeholder's spot. The planet GIFs are 100px pixel art,
   so they scale up in whole steps without smoothing. */
.intro-image {
    display: none;
    flex: 1 1 0;
    min-width: 0;
    align-items: center;
    justify-content: center;

    img {
        width: 100%;
        max-width: 400px;
        height: auto;
        image-rendering: pixelated;
    }
}

@media (min-width: 1500px) {
    .image-placeholder,
    .intro-image {
        display: flex;
    }
}

@media (min-width: 960px) {
    .intro-with-image > .image-placeholder,
    .intro-with-image > .intro-image {
        display: flex;
    }

    /* Beside its image, the copy takes half the row, up to 768px */
    .intro-with-image > .single-column-content {
        flex-basis: 50%;
    }
}

/* Below 1200px the side nav moves to the content's right edge, so the row
   keeps clear of it: the nav's 106px and the 40px gap */
@media (min-width: 960px) and (max-width: 1199px) {
    .intro-with-image {
        padding-right: 146px;
    }
}

/* The Stars: below 960px the planet sits after the third paragraph instead of
   hiding. The copy column's paragraphs join the intro's own column so the image
   can be ordered between them. */
@media (max-width: 959px) {
    .intro-with-image.image-in-copy {
        flex-direction: column;
        gap: 0;

        > .single-column-content {
            display: contents;
        }

        > .single-column-content > :nth-child(-n+3) {
            order: -2;
        }

        > .intro-image {
            display: flex;
            order: -1;
            /* 40px from the text on each side, counting the paragraph above's 1rem */
            margin: 1.5rem 0 2.5rem;

            img {
                max-width: 360px;
            }
        }

        /* The paragraphs keep the 768px copy width, and the planet centers on them */
        > .single-column-content > *,
        > .intro-image {
            max-width: 768px;
        }
    }
}

/* php/personal/blog.php */
.blog-posts {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* php/rpg/rpg-changelog.php */
.changelog-entries {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.changelog-list {
    margin: 0;
    padding-left: 1.25rem;
}

.changelog-list li + li {
    margin-top: 0.5rem;
}

/* Bordered cards: php/personal/blog.php, php/personal/projects.php,
   php/rpg/rpg-changelog.php, and the intro vignette in php/rpg/rpg-setting.php */
.blog-post {
    border: 1px solid var(--portfolio-light-gray);
    border-radius: 8px;
    padding: 1.5rem;
}

.blog-post .copy:last-child {
    margin-bottom: 0;
}

/* php/personal/blog.php */
.blog-post-images {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;

    img {
        display: block;
        width: 100%;
        height: auto;
        border-radius: 8px;
    }
}

/* php/personal/projects.php */
.project-entries {
    display: flex;
    flex-direction: column;
    gap: 48px;
}

.project-title {
    padding-bottom: .75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--portfolio-light-gray);
}

.project-images {
    display: flex;
    flex-direction: column;
    gap: 16px;

    img {
        display: block;
        width: 100%;
        height: auto;
        border-radius: 8px;
    }
}

.project-images-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    align-content: start;
}

/* Opening story card in the Introduction, php/rpg/rpg-setting.php */
.intro-vignette .copy {
    font-style: italic;
}

/* Model photos tab, php/personal/photos.php */
.model-photo-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    width: 100%;

    > * {
        position: relative;
        min-width: 0;
        min-height: 0;
        aspect-ratio: 1 / 1;
        overflow: hidden;
        border-radius: 8px;
    }

    img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
        display: block;
    }

    .is-featured {
        grid-column: 1 / -1;
        aspect-ratio: 16 / 9;
    }

    .is-hero {
        grid-column: span 2;
        grid-row: span 2;
        aspect-ratio: auto;
    }
}

/* A section's stinger (.copy.stinger.black, the label under its title) on a
   dark panel (index.php's $rpgPanelTone): white, like the black breakouts'
   .stinger.white */
.rpg-panel.black-bg .copy.stinger.black {
    background-color: var(--portfolio-white);
    color: var(--portfolio-black);
}

/* Heading with a rule running off to the right (.line-container + .line).
   Used across php/rpg/ partials and the lore entries in php/rpg/lore/. */
.line-container {
    position: relative;
    margin-bottom: 20px;

    /* The rule starts after the heading rather than running under a
       heading painted in the panel's color, so nothing shows behind the
       heading on the see-through panels */
    display: flex;
    align-items: center;

    h4, h5, h6 {
        flex: 0 1 auto;
        margin: 0;
        padding: 0 20px 0 0;
    }

    > .line {
        position: static;
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        transform: none;
    }
}

/* Alternating timeline: Setting > Timeline tab, php/rpg/rpg-setting.php.
   Each direct child is one entry (.line-container year + ul.copy). */
.sf-timeline {
    --sf-timeline-marker: 11px;
    --sf-timeline-gutter: 32px;

    position: relative;
    display: flex;
    flex-direction: column;
    row-gap: 20px;

    &::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: 50%;
        width: 1px;
        background-color: rgb(0 0 0 / 15%);
        transform: translateX(-50%);
    }

    > div {
        position: relative;
        width: 50%;
        padding-right: var(--sf-timeline-gutter);
        text-align: right;

        &::before {
            content: "";
            position: absolute;
            top: 5px;
            right: calc(var(--sf-timeline-marker) / -2);
            width: var(--sf-timeline-marker);
            height: var(--sf-timeline-marker);
            border-radius: 50%;
            background-color: var(--portfolio-black);
            z-index: 1;
        }
    }

    /* On dark panels: a light rule and markers */
    .black-bg &::before {
        background-color: rgb(255 255 255 / 25%);
    }

    .black-bg & > div::before {
        background-color: var(--sf-gray-100);
    }

    > div:nth-child(even) {
        align-self: flex-end;
        padding-right: 0;
        padding-left: var(--sf-timeline-gutter);
        text-align: left;

        &::before {
            right: auto;
            left: calc(var(--sf-timeline-marker) / -2);
        }
    }

    .line-container {
        margin-bottom: 4px;

        h6 {
            padding: 0;
        }

        .line {
            display: none;
        }
    }

    ul.copy {
        list-style: none;
        padding-left: 0;
        margin-bottom: 0;
    }

    @media (max-width: 767px) {
        &::before {
            left: calc(var(--sf-timeline-marker) / 2);
        }

        > div,
        > div:nth-child(even) {
            align-self: stretch;
            width: 100%;
            padding-right: 0;
            padding-left: var(--sf-timeline-gutter);
            text-align: left;

            &::before {
                right: auto;
                left: 0;
            }
        }
    }
}

/* php/rpg/rpg-setting.php, rpg-planes, rpg-spacecraft, rpg-technologies, plane lore entries */
.content-stack {
    display: flex;
    flex-direction: column;
    gap: 48px;

    /* The gap does the spacing, not the children's own margins. */
    > * {
        margin-top: 0;
        margin-bottom: 0;
    }

    > * > :last-child {
        margin-bottom: 0;
    }
}

/* Lore entries in two columns: The Stars' Systems tab (rpg-spacecraft.php) and the
   Setting's Corporations tab (rpg-setting.php) */
.content-stack.lore-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 48px 40px;

    @media (max-width: 960px) {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Side by side entries share row heights for the title, info and Details,
       so the Details boxes line up and opening one doesn't move its neighbor's */
    > .lore-entry {
        display: grid;
        grid-row: span 3;
        grid-template-rows: subgrid;
        row-gap: 0;
        align-content: start;
    }

    > .lore-entry > .lore-body {
        display: contents;
    }

    /* A closed Details box keeps its own height when its neighbor opens */
    .lore-details {
        align-self: start;
    }

    /* The info block 1rem under the name, rather than the entries' usual 2rem
       stacked on the title's own spacing */
    > .lore-entry > :first-child {
        margin-bottom: 1rem;
    }

    .info-cols {
        margin-top: 0;
    }
}

/* Corporations' four facts in two columns: Headquartered and Employees, then
   Market Cap and Industry */
#timeline-corporations .attr-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 24px;
}

/* Two-column content rows in Strange Frontiers, php/rpg/ and php/rpg/lore/ */
.split-cols {
    gap: 48px 40px;

    @media (max-width: 959px) {
        column-gap: 24px;
    }
}

/* Building a Character (php/rpg/rpg-character.php): the text 4 to the
   background cards' 6, and as the row narrows, neither is crushed. The
   text keeps at least 22rem; the cards go from two by two to one column
   once two wouldn't each get 18rem, and the cards then wrap under the text
   once they'd go under 18rem themselves. */
.sample-backgrounds {
    > :first-child {
        min-width: min(22rem, 100%);
    }

    > :last-child {
        min-width: min(18rem, 100%);
    }

    .bg-card-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, max(18rem, calc((100% - 12px) / 2))), 1fr));
    }
}

/* Explaining Stats' Stat Types tab (php/rpg/rpg-stats.php): Physical, Social and Mental
   as rows, one above the other, each with its three focus Stats side by side. The
   Stats stack at 960px and below. */
.stat-types-grid {
    display: flex;
    flex-direction: column;
    gap: 48px;

    > .content-stack {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px 40px;

        > h4 {
            grid-column: 1 / -1;
        }

        @media (max-width: 960px) {
            grid-template-columns: minmax(0, 1fr);
        }
    }
}

/* Tab panels whose entries flow across two columns, each entry kept whole: Explaining
   Traits' Trait Rules and Trait Categories (php/rpg/rpg-traits.php), Skill Checks'
   Difficulty Ranges (rpg-skills.php) and the Items tabs, Example Items' categories
   included (rpg-items.php). One column at 960px and below. */
.tab-panel-cols {
    column-count: 2;
    column-gap: 40px;

    @media (max-width: 960px) {
        column-count: 1;
    }

    > * {
        break-inside: avoid;
        margin-bottom: 36px;
    }

    > :last-child {
        margin-bottom: 0;
    }
}

/* Explaining Traits' Example Traits tab: each category's cards in a grid of three
   columns, two at 1200px and below, one at 767px and below, each card as tall as
   the tallest in its row. */
/* Background cards two to a row, as tall as the taller of the pair:
   Building a Dreftian's Backgrounds tab (php/rpg/dreftian-starters.php),
   where Origins, Professions and Pasts each get a full-width row, and
   Edwin's four beside Building a Character (php/rpg/rpg-character.php) */
.bg-card-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;

    @media (max-width: 767px) {
        grid-template-columns: minmax(0, 1fr);
    }
}

.trait-card-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;

    @media (max-width: 1200px) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    @media (max-width: 767px) {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* A section's text flowing across two text columns: tab panels in php/rpg/, the Details of
   plane, nation, ark and technology entries in php/rpg/lore/, and each Exotic Materials entry
   (.lore-text-cols, rpg-planes.php). */
.text-cols,
.lore-text-cols > .lore-entry > .lore-body {
    column-count: 2;
    column-gap: 40px;

    @media (max-width: 960px) {
        column-count: 1;
    }

    > :last-child {
        margin-bottom: 0;
    }

    h5,
    h6 {
        break-after: avoid;
    }

    /* Spacecraft classes (rpg-spacecraft.php): keep each short ship entry whole. */
    > .lore-entry {
        break-inside: avoid;
    }

    > .lore-entry + .lore-entry {
        margin-top: 20px;
    }

    /* History timelines and other lists: keep each item in one column. */
    li {
        break-inside: avoid;
    }
}

/* Timeline (rpg-setting.php), starship classes (rpg-spacecraft.php) */
.content-stack-sm {
    gap: 20px;
}

/* Mechanics pages: a ruled title and its paragraphs (xs), a small heading and its text (xxs). */
.content-stack-xs {
    gap: 16px;
}

.content-stack-xxs {
    gap: 8px;
}

.lore-body > :last-child {
    margin-bottom: 0;
}

.fst-italic {
    font-style: italic;
}

.line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%; 
    height: 1px;
    background-color: rgb(0 0 0 / 15%);
    transform: translateY(-50%); 
    z-index: 1; 

    .black-bg & {
        background-color: rgb(255 255 255 / 25%);
    }
}

/* The sample sheet's pieces (php/rpg/rpg-character.php). Its layout is the
   sheet layout (php/rpg/components/sheet.php, css/sf-sheet.css) and its stats
   the stat block (php/rpg/components/stats.php, css/sf-stats.css). */
.empty-list {
    list-style-type: none;
    padding-left: 0;
    margin-left: 0;
}

.empty-list.call-response {
    li {
        margin-bottom: .5rem;
        font-weight: 600;
    }
    li:nth-child(odd) {
        margin-bottom: 0;
        font-weight: 300;
    }
}

/* Inline damage type icons beside their labels (rpg-items, rpg-character).
   They take the text color, so they work on light, dark and night backgrounds. */
.damage-icon {
    display: inline-block;
    width: 1.15em;
    height: 1.15em;
    margin-right: .35em;
    vertical-align: -.2em;
    fill: currentColor;

    /* On the sheet the icon stands in for the label, with nothing after it. */
    &:last-child {
        margin-right: 0;
    }
}

/* HP, VP, SP and MP in their colors, as in Player Tools (tokens.css). */
.resource-hp { color: var(--frontiers-hp); }
.resource-vp { color: var(--frontiers-vp); }
.resource-sp { color: var(--frontiers-sp); }
.resource-mp { color: var(--frontiers-mp); }

/* Damage Types headings in the write-up (rpg-items): a larger icon centered on its label. */
.damage-type {
    display: flex;
    align-items: center;
    gap: 8px;

    .damage-icon {
        width: 1.75rem;
        height: 1.75rem;
        margin-right: 0;
        flex-shrink: 0;
    }
}

/* The whole pixel-art portrait fits in the square, unsmoothed. */
.c-sheet-image {
    width: 100%;
    object-fit: contain;
    aspect-ratio: 1/1;
    image-rendering: pixelated;
}

.c-variables {
    column-gap: 12px;
}

/* Mechanics tab: the Character Creator's dark look (its src/app/styles.css).
   Trait cards go black with a darker name bar, rounded corners and light
   text; the example stats and the sample character sheet sit on the
   creator's dark grays, with light core badges, earned points in green, the
   Kind's starting point in purple and open slots a lighter outline. */
/* Also covers Adventures, whose Building a Dreftian uses the background cards */
:is(#rpg-mechanics, #rpg-adventure) {
    --panel: #292b2c;
    --panel-box: #343638;
    --panel-text: #e7e8e9;
    --panel-soft: #b2b3b4;
    --panel-rule: rgb(255 255 255 / 18%);

    .trait-box {
        color: var(--panel-text);
        background-color: var(--portfolio-black);
        /* A 1px border the color of the name bar, and a soft shadow, as in
           the creator and Player Tools */
        border: 1px solid #161819;
        border-radius: 12px;
        box-shadow: 0 4px 10px #00000030;

        .trait-name {
            /* The bar rounds its own top corners */
            border-radius: 10px 10px 0 0;
            padding: 10px 16px;
            background-color: #161819;
            color: var(--panel-text);
        }

        /* As on the creator's sheet: the name at the left of the bar and,
           at the right, the Trait's flags and category as chips */
        .trait-name-with-chip {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;

            > span:first-child {
                min-width: 0;
            }
        }

        .trait-name-chips {
            flex: none;
            display: flex;
            flex-wrap: wrap;
            justify-content: flex-end;
            align-items: center;
            gap: 4px;
        }

        /* The creator's chips: gray, since black ones would vanish into the
           card, with the flags (Background, Mastery...) muted */
        .chip {
            display: inline-block;
            padding: .2rem .5rem;
            border-radius: 4px;
            background-color: var(--portfolio-gray);
            color: var(--portfolio-white);
            font-size: .75rem;
            font-weight: 600;
            white-space: nowrap;
        }

        .chip-muted {
            background-color: var(--portfolio-light-gray);
            color: var(--portfolio-black);
        }

        .copy {
            margin-bottom: 0;
        }

        .muted {
            color: var(--panel-soft);
        }

        .small {
            font-size: .75rem;
        }
    }

    /* Isekai's cards, as in the creator: Dreft's green border and header,
       and the Isekai mark (an inline SVG) before the name */
    .trait-box.region-dreft {
        border-color: var(--frontiers-dreft);

        .trait-name {
            background-color: var(--frontiers-dreft);
        }
    }

    .setting-icon {
        display: inline-block;
        flex-shrink: 0;
        width: 1.15em;
        height: 1.15em;
        margin-right: .45em;
        vertical-align: -.2em;
        fill: currentColor;
    }

    /* Condition cards in grays, as on the creator's sheet and in Player
       Tools: a mid gray border and a light gray name bar with dark text */
    .trait-box.condition-box {
        border-color: #626466;

        .trait-name {
            background-color: #b7b4b4;
            color: var(--portfolio-black);
        }
    }

    .stat-panel {
        color: var(--panel-text);

        .line {
            background-color: var(--panel-rule);
        }
    }

    /* Only as wide as its stat lines need, centered in its column */
    .stat-panel {
        align-self: center;
        width: fit-content;
        max-width: 100%;
        padding: 24px;
        background-color: var(--panel);
        border: 1px solid rgb(255 255 255 / 12%);
        border-radius: 12px;
    }

    /* The backgrounds Edwin uses, beside Building a Character, as the
       creator's background cards: what it gives in rows, each a label over
       its badges, the Bonus and Grants in the lighter gray */
    .sample-bg-card {
        .chip-accent {
            background-color: #696b6d;
            color: var(--portfolio-white);
        }

        .small {
            font-size: .75rem;
        }
    }

    .sample-bg-grants {
        display: grid;
        gap: 12px;

        > div {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
        }
    }

    .sample-bg-label {
        flex-basis: 100%;
        font-size: .75rem;
        font-weight: 600;
    }

    /* The sample sheet (css/sf-sheet.css draws its layout): pulled out by
       its padding and border, like the tab boxes (.tech-fields), so the
       boxes inside line up with the text above, in the page's Open Sans.
       The head box's contents are the site's own: the portrait, name and
       character line, and the description in the creator's black field. */
    .sample-sheet {
        margin-top: 40px;
        margin-left: -17px;
        margin-right: -17px;
        font-family: 'Open Sans', sans-serif;

        .sheet-portrait {
            width: 256px;
            max-width: 100%;
        }

        .sheet-name {
            margin: 0 0 8px;
            font-family: 'Open Sans', sans-serif;
            font-size: 36px;
            font-weight: 300;
            line-height: 1.2;
            color: var(--panel-text);
        }

        /* Age, gender, height and weight on a row, then the Kind and the
           Backgrounds, then Wealth: each a label over its value */
        .sheet-line {
            display: flex;
            flex-direction: column;
            gap: 16px;
            font-size: 14px;
        }

        .sheet-line-row {
            display: flex;
            flex-wrap: wrap;
            gap: 8px 24px;
            margin: 0;
        }

        .sheet-line-item {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 2px;
        }

        .field-label {
            font-size: 12px;
            font-weight: 600;
        }

        .sf-sheet-description {
            min-height: 160px;
            padding: 9.6px 12px;
            background-color: var(--portfolio-black);
            border-radius: 16px;

            p {
                margin: 0;
                color: var(--panel-text);
                font-size: 14.4px;
                line-height: 1.5;
            }
        }

        /* Links in the panel's purple */
        .lore-link {
            color: var(--frontiers-lore-on-black);
        }
    }
}

/* ========================================
   RPG MEDIA QUERIES
   1199px: the side gutters collapse, so the side nav moves to the right edge
           with its dot on the left to keep clear of headings and opening copy.
   992px: side nav and character sheet tighten.
   767px: side nav moves to the bottom-right corner, tabs and gallery shrink.
   ======================================== */

/* Strange Frontiers pages (the personal page's Strange Frontiers pane, the
   Character Creator and Player Tools) from 1200px to 1399px: the column drops
   the 120px it keeps clear for the nav, so content runs wider, and the nav sits
   30px from the sides instead of 60px, inside the column's side gutters (or,
   on the creator pages, level with the content's 30px padding). */
@media only screen and (min-width: 1200px) and (max-width: 1399px) {
    :is(body:has(.personal-shell.is-frontiers), body:has(.creator-shell)) {
        .container {
            max-width: min(1920px, 100%);
        }

        :is(.logo-bug, .section-logo-bug, .scroll-links, .section-scroll-links, .rpg-links-rail, .rpg-links-clip .rpg-links) {
            left: 30px;
        }

        :is(.about-social-container, .section-about-social-container) {
            right: 30px;
        }
    }

}

/* The Character Creator, Player Tools and the Game Master Tools: their
   full-width bands (.breakout, like the footer) are 100vw wide, which takes
   in the window's scrollbar, so they ran about 8px past each side of the page
   and it scrolled sideways. The page clips them at its own edges. Clip, not
   hidden, so nothing inside becomes a scroll box and the sticky d20 and chat
   column still sticks. */
.creator-shell {
    overflow-x: clip;
}

/* The Character Creator, Player Tools and the Game Master Tools have no side
   gutters in their column, so below 1400px their content runs the width of
   the page with 30px padding, level with the nav from 1200px to 1399px, and
   keeps it at every narrower width instead of going back to the site's wider
   margins; on phones it's the site's 20px. */
@media only screen and (max-width: 1399px) {
    .creator-shell .container {
        max-width: min(1920px, 100%);
        padding-inline: 30px;
    }
}

/* Their nav stays 30px from the sides with it, as from 1200px to 1399px,
   down to phones (which have the site's own 20px) */
@media only screen and (min-width: 768px) and (max-width: 1199px) {
    body:has(.creator-shell) {
        :is(.logo-bug, .section-logo-bug, .scroll-links, .section-scroll-links) {
            left: 30px;
        }

        :is(.about-social-container, .section-about-social-container) {
            right: 30px;
        }
    }
}

@media only screen and (max-width: 767px) {
    .creator-shell .container {
        padding-inline: 20px;
    }
}

@media only screen and (max-width: 1199px) {
    .rpg-links-rail {
        left: auto;
        right: 60px;
    }

    /* The rail is measured from the panel, which spans the full 100vw, but the
       fixed copy is measured from the viewport inside the scrollbar. Pull it
       back by the scrollbar's width (100vw - 100%) so the two navs line up. */
    .rpg-links-clip .rpg-links {
        left: auto;
        right: calc(60px - (100vw - 100%));
    }

    .rpg-links-rail .rpg-links,
    .rpg-links-clip .rpg-links {
        align-items: end;
        padding-right: 0;
        padding-left: 14px;
    }
}

@media only screen and (max-width: 992px) {
    .rpg-links-rail {
        right: 5vw;
    }

    .rpg-links-clip .rpg-links {
        right: calc(5vw - (100vw - 100%));
    }

}

@media only screen and (max-width: 767px) {
    .rpg-links-rail {
        position: fixed;
        top: auto;
        bottom: 24px;
        right: 24px;
        z-index: 4;
    }

    .rpg-links-rail .rpg-links {
        position: static;
    }

    .rpg-links-clip .rpg-links {
        top: auto;
        bottom: 24px;
        right: 24px;
    }

    .rpg-tab {
        font-size: 1.25rem;
        padding: .6rem 1rem;
    }

    .tech-field-tab {
        font-size: 1.1rem;
        padding: .5rem .85rem;
    }

    .model-photo-gallery {
        grid-template-columns: 1fr;
        gap: 30px;

        .is-featured,
        .is-hero {
            grid-column: auto;
            grid-row: auto;
            aspect-ratio: 1 / 1;
        }
    }

    .section-scroll-links.personal-page-nav {
        display: block;
        font-size: 1.25rem;
    }

    .c-variables {
        column-gap: 4px
    }

    .c-variables, .c-variables h5 {
        font-size:3.6vw;
        margin-bottom: 0;
        align-self: center;
    }

}

/* Hero image pulled 48px past both sides of its column (Isekai map, personal.php) */
.breakout-img {
    width: calc(100% + 96px);
    max-width: none;
    margin-left: -48px;
    margin-right: -48px;

    /* Up to 992px the container is 90vw, so the gutter is 5vw: never pull past it */
    @media (max-width: 992px) {
        width: calc(100% + min(96px, 10vw));
        margin-left: max(-48px, -5vw);
        margin-right: max(-48px, -5vw);
    }

    /* Below 768px the page gutter is only 20px: go edge to edge */
    @media (max-width: 767px) {
        width: calc(100% + 40px);
        margin-left: -20px;
        margin-right: -20px;
    }
}

/* Starter Kinds, Origins, Professions, Pasts (php/rpg/dreftian-starters.php) */
.starter-entry + .starter-entry {
    margin-top: 1.5rem;
}

.starter-entry h6 {
    margin-bottom: .5rem;
}

/* Character Creator page, creator.php. The creator brings only its own styles
   (creator/assets/, scoped to .sf-creator) and wears the rest of this site's
   CSS. personal.php clips its fixed chrome to the hero; the creator has no
   fixed-height hero, so here the logo, social links and page nav scroll away
   with the top of the page. */
.creator-shell {
    position: relative;
    /* The app fills the screen down to the footer, so a short page shows
       the footer at the bottom of the screen instead of scrolling to it. */
    display: flex;
    flex-direction: column;
    min-height: 100vh;

    > #root {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .sf-creator {
        flex: 1;
        min-height: 0;
    }
}

.creator-shell :is(.logo-bug, .section-about-social-container, .section-scroll-links, .rpg-search) {
    position: absolute;
}

/* The Strange Frontiers search, as on its pane (hidden below 992px like there) */
@media (min-width: 992px) {
    .creator-shell .rpg-search {
        display: block;
    }
}

/* The same white logo and black social icons as personal.php's hero */
.creator-shell .logo-bug {
    background-color: var(--portfolio-white);
    color: var(--portfolio-black);
}

.creator-shell .social-link svg {
    fill: var(--portfolio-black);
}

/* The creator's hero clears the logo, search and social links along the top
   (--sf-creator-top), and its title and describe box sit to the right of the
   page nav (--sf-creator-left); both are read by the creator's .builder-hero.
   Phones show the nav above the content (see .personal-page-nav above), so
   there the hero starts below it instead. */
.creator-shell {
    --sf-creator-top: 112px;
    --sf-creator-left: 200px;
}

/* The nav's smaller size below 1200px is narrower, so the hero moves in */
@media (max-width: 1199px) {
    .creator-shell {
        --sf-creator-left: 172px;
    }
}

@media only screen and (max-width: 767px) {
    .creator-shell {
        --sf-creator-top: 222px;
        --sf-creator-left: 0px;
    }
}

/* A printed character sheet without the site around it */
@media print {
    body:has(.sf-creator) .rpg-night,
    .creator-shell > :not(#root) {
        display: none !important;
    }
}

/* Stat diagram: each category in its resource's color, as in the stat lines
   and the creator: Physical red, Social purple, Mental yellow. The inner part
   (each core Stat's circle and its branch from Character Level) takes the
   group's dark shade, like the core stat badges; the focus Stats and their
   branches take the full color. Character Level is near-black, like the
   labels. */
.stat-ring {
    [data-group="physical"],
    .stat-ring-link:is([data-from="physical"], [data-to="physical"]) {
        --stat-color: var(--frontiers-hp);
    }

    [data-group="social"],
    .stat-ring-link:is([data-from="social"], [data-to="social"]) {
        --stat-color: var(--frontiers-vp);
    }

    [data-group="mental"],
    .stat-ring-link:is([data-from="mental"], [data-to="mental"]) {
        --stat-color: var(--frontiers-sp);
    }

    .stat-ring-group ellipse {
        fill: var(--stat-color);
    }

    .stat-ring-link {
        stroke: var(--stat-color, #959899);
    }

    .stat-ring-core ellipse {
        fill: color-mix(in srgb, var(--stat-color) 50%, black);
    }

    .stat-ring-link[data-from="level"] {
        stroke: color-mix(in srgb, var(--stat-color) 50%, black);
    }

    .stat-ring-level ellipse {
        fill: #1f2122;
    }

    /* On dark panels the labels go light (they're near-black in the SVG) */
    .black-bg & .stat-ring-label {
        fill: var(--sf-gray-100);
    }

    /* Character Level glitches like the creator's glitching buttons, the
       circle and its label as one piece */
    .stat-ring-level {
        transform-box: fill-box;
        transform-origin: center;
        animation: stat-ring-level-shift 4s ease-in-out infinite alternate, stat-ring-level-glow 8s ease-in-out infinite alternate;
    }

    @media (prefers-reduced-motion: reduce) {
        .stat-ring-level {
            animation: none;
        }
    }
}

/* ========================================
   CARD LAYOUT ON THE SITE
   ========================================
   The cards themselves are in css/sf-cards.css, a copy of the Character
   Creator's src/app/cards.css. These are the site's own places for them. */

/* A grid of cards, columns at least 256px wide */
.sf-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(256px, 100%), 1fr));
    align-items: start;
    gap: 16px;
}

/* Rules added while testing combat (11/18/2026), highlighted neon yellow so
   they're easy to find and work into the copy. Remove the class to clear one. */
mark.rules-new {
	background: #e6ff00;
	color: #111;
	padding: 0 2px;
}
.sf-card.rules-new {
	box-shadow: 0 0 0 3px #e6ff00;
}
tr.rules-new td {
	background: #e6ff00;
	color: #111;
}
