@import url('https://fonts.googleapis.com/css2?family=Fjalla+One&family=Michroma&display=swap');

:root {
    color-scheme: dark;
    --bg: #070c16;
    --panel: #101c2d;
    --line: #355473;
    --text: #eaf3fa;
    --muted: #bbcfdf;
    --gold: #f0c66d;
    --blue: #8dd2ff;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
    scrollbar-color: #b99a58 #101c2d;
    scrollbar-width: auto;
}

/* Custom scrollbars for browsers supporting the WebKit pseudo-elements.
   Standard scrollbar-color above takes precedence where supported. */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #101c2d;
}

::-webkit-scrollbar-thumb {
    background: #b99a58;
    border: 3px solid #101c2d;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #f0c66d;
}

::-webkit-scrollbar-corner {
    background: #101c2d;
}

body {
    margin: 0;
    background-color: var(--bg);
    background-image:
        linear-gradient(rgba(7, 12, 22, .48), rgba(7, 12, 22, .48)),
        url('graphics/TyphonLogo.svg'),
        radial-gradient(ellipse at 85% 8%, rgba(32, 111, 173, .18), transparent 36%),
        linear-gradient(155deg, #08121f, var(--bg) 65%);
    background-size: auto, 350px 470px, auto, auto;
    background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
    background-position: center, center, center, center;
    background-attachment: fixed, fixed, fixed, fixed;
    color: var(--text);
    font: 16px/1.7 system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

a {
    color: var(--blue);
}

a:focus-visible,
.manual-menu summary:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 3px;
}

.skip {
    position: absolute;
    top: -5rem;
    left: 1rem;
    z-index: 60;
    padding: .7rem 1rem;
    background: var(--gold);
    color: #08111c;
}

.skip:focus {
    top: 1rem;
}

.shell {
    width: min(1050px, calc(100% - 2rem));
    margin-inline: auto;
}

/* Shared navigation supplied by includes/layout.php. */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid rgba(141, 210, 255, .22);
    background: rgba(7, 12, 22, .96);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.topbar-inner {
    min-height: 4.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    color: var(--text);
    font: 400 .78rem/1.5 'Michroma', 'Fjalla One', sans-serif;
    letter-spacing: .04em;
    text-decoration: none;
    text-transform: uppercase;
}

.brand-short {
    display: none;
}

.brand-delta,
.footer-delta {
    display: block;
    width: 14px;
    min-width: 14px;
    max-width: 14px;
    height: 14px;
    min-height: 14px;
    max-height: 14px;
    flex: 0 0 14px;
    object-fit: contain;
}

.brand span {
    color: var(--gold);
}

.brand,
.eyebrow,
.manual-menu summary,
.entry .label,
.chapter .number {
    -webkit-text-stroke: .38px currentColor;
    text-shadow: 0 0 .3px currentColor;
}

.topbar nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .3rem 1rem;
    font-size: .9rem;
}

.topbar nav a {
    color: var(--muted);
    text-decoration: none;
}

.topbar nav a:hover {
    color: var(--gold);
    text-decoration: underline;
}

.manual-menu {
    position: relative;
}

.manual-menu summary {
    cursor: pointer;
    color: var(--gold);
    padding: .25rem .45rem;
}

.manual-menu-links {
    position: absolute;
    z-index: 20;
    right: 0;
    top: calc(100% + .45rem);
    width: min(520px, calc(100vw - 2rem));
    max-height: min(65vh, 520px);
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .35rem;
    padding: .55rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: var(--panel);
    box-shadow: 0 15px 32px rgba(0, 0, 0, .55);
    scrollbar-color: #b99a58 #101c2d;
    scrollbar-width: auto;
}

.manual-menu:not([open]) .manual-menu-links {
    display: none;
}

.manual-menu-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: .1rem;
}

.manual-menu-links a {
    display: flex;
    align-items: center;
    min-height: 2.5rem;
    min-width: 0;
    padding: .35rem .55rem;
    border-radius: .25rem;
    overflow-wrap: normal;
    word-break: normal;
}

.manual-menu-links a[aria-current='page'] {
    color: var(--gold);
    background: #263853;
}

/* Shared delta-ended divider for chapter headers and the index cover. */
.chapter-head,
.manual-divider {
    position: relative;
}

.chapter-head::before,
.manual-divider::before {
    content: "";
    position: absolute;
    left: 0;
    right: 26px;
    bottom: 9px;
    height: 2px;
    background: linear-gradient(90deg, rgba(86, 146, 215, 0) 0%, rgba(86, 146, 215, .35) 16%, #5692d7 32%, #e8b65d 64%, #b85655 100%);
}

.chapter-head::after,
.manual-divider::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    width: 20px;
    height: 20px;
    background: url('graphics/DeltaSm.svg') center / contain no-repeat;
    transform: rotate(90deg);
}

/* Chapter masthead. */
.chapter-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 145px;
    align-items: center;
    gap: 2rem;
    padding-block: 3.5rem calc(2.7rem + 20px);
}

.manual-divider {
    display: block;
    width: 100%;
    height: 20px;
}

.chapter-head > * {
    min-width: 0;
}

.chapter-head img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 0 25px rgba(98, 171, 224, .25));
}

.eyebrow {
    color: var(--gold);
    font: 400 .78rem/1.7 'Michroma', sans-serif;
    letter-spacing: .04em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    font-family: 'Fjalla One', Impact, sans-serif;
    font-weight: 400;
    line-height: 1.2;
}

h1 {
    margin: .7rem 0 1rem;
    font-size: clamp(2.8rem, 6vw, 4.5rem);
    text-transform: uppercase;
    color: var(--gold);
}

h2 {
    margin: 2.3rem 0 .7rem;
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: var(--gold);
    text-transform: uppercase;
}

h3 {
    margin: 1.5rem 0 .5rem;
    font-size: 1.4rem;
}

.deck {
    max-width: 44rem;
    margin: 0;
    color: var(--muted);
    font-size: 1.16rem;
}

/* Chapter body and reusable components. */
.article {
    max-width: 850px;
    margin-inline: auto;
    padding-block: 2.5rem 1.5rem;
}

.article h2:first-child {
    margin-top: 0;
}

.article p {
    margin: 0 0 1.1rem;
}

.article li {
    margin-bottom: .55rem;
}

.article ul,
.article ol {
    padding-left: 1.4rem;
}

.callout {
    margin: 1.7rem 0;
    padding: 1rem 1.3rem;
    border-left: 4px solid var(--gold);
    border-radius: 0 .45rem .45rem 0;
    background: var(--panel);
}

.callout p:last-child {
    margin-bottom: 0;
}

.muted {
    color: var(--muted);
}

.panel {
    margin: 1rem 0;
    padding: 1.15rem 1.35rem;
    border: 1px solid var(--line);
    border-radius: .55rem;
    background: var(--panel);
}

.panel h3 {
    margin-top: 0;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    margin: 1rem 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-color: #b99a58 #101c2d;
    scrollbar-width: auto;
}

table {
    width: 100%;
    min-width: 550px;
    border-collapse: collapse;
    background: var(--panel);
}

th,
td {
    padding: .75rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

th {
    background: #182b41;
    color: var(--gold);
}

.chapter-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
}

.chapter-links a {
    display: inline-block;
    padding: .65rem 1rem;
    border: 1px solid var(--line);
    border-radius: .4rem;
    background: var(--panel);
    text-decoration: none;
    font-weight: 700;
}

.chapter-links a:hover {
    border-color: var(--gold);
}

/* Shared footer styling; remove the trailing footer <style> block from includes/layout.php. */
footer {
    border-top: 1px solid var(--line);
    padding: .4rem 0;
    color: var(--muted);
    font-size: .87rem;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem 1rem;
}

.footer-text {
    display: inline;
    min-width: 0;
}

.footer-separator {
    color: var(--gold);
}

.footer-sfi-logo {
    display: block;
    width: 60px;
    height: 60px;
    object-fit: contain;
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

pre,
code,
.article,
.deck,
.callout,
.panel,
th,
td {
    overflow-wrap: anywhere;
}

@media (max-width: 680px) {
    html {
        scroll-padding-top: 8.5rem;
    }

    body {
        background-attachment: scroll, scroll, scroll, scroll;
        background-size: auto, min(65vw, 260px) auto, auto, auto;
        background-position: center, center 9rem, center, center;
    }

    .shell {
        width: calc(100% - 1.5rem);
    }

    .topbar-inner {
        min-height: 0;
        align-items: stretch;
        flex-direction: column;
        gap: .35rem;
        padding-block: .55rem;
    }

    .brand {
        align-self: flex-start;
        max-width: 100%;
        font-size: .7rem;
        line-height: 1.45;
    }

    .brand-full {
        display: none;
    }

    .brand-short {
        display: inline;
    }

    .topbar nav {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
        gap: .5rem;
    }

    .topbar nav a,
    .manual-menu summary {
        min-height: 2.75rem;
        display: inline-flex;
        align-items: center;
        padding: .55rem .65rem;
    }

    .manual-menu {
        position: static;
    }

    .manual-menu-links {
        left: .75rem;
        right: .75rem;
        top: 100%;
        width: auto;
        max-height: min(65vh, 500px);
        grid-template-columns: minmax(0, 1fr);
    }

    .manual-menu-links a {
        min-height: 2.75rem;
        padding: .6rem .7rem;
    }

    .chapter-head {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.25rem;
        padding-block: 2rem calc(1.6rem + 20px);
    }

    .chapter-head img {
        width: 110px;
        justify-self: center;
    }

    h1 {
        font-size: clamp(2.25rem, 12vw, 3.6rem);
        overflow-wrap: anywhere;
    }

    h2 {
        font-size: clamp(1.35rem, 7vw, 1.8rem);
    }

    .deck {
        font-size: 1.05rem;
    }

    .article {
        padding-block: 1.75rem 1.5rem;
    }

    .grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .callout,
    .panel {
        padding: .9rem 1rem;
    }

    .chapter-links {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: .7rem;
    }

    .chapter-links a {
        width: 100%;
        text-align: center;
    }

    table {
        min-width: 520px;
        font-size: .92rem;
    }

    th,
    td {
        padding: .6rem;
    }

    .footer-inner {
        max-width: 100%;
        gap: .4rem;
    }

    .footer-text {
        line-height: 1.6;
        overflow-wrap: normal;
    }
}

@media (max-width: 600px) {
    .footer-inner {
        justify-content: center;
        text-align: center;
    }

    .footer-sfi-logo {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 400px) {
    .shell {
        width: calc(100% - 1rem);
    }

    .brand {
        font-size: .66rem;
    }

    .manual-menu-links {
        left: .5rem;
        right: .5rem;
    }

    .chapter-head img {
        width: 90px;
    }

    .article ul,
    .article ol {
        padding-left: 1.15rem;
    }

    .footer-inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        align-items: center;
        gap: .4rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

@media print {
    body {
        background: #fff;
        color: #000;
    }

    .topbar,
    .chapter-links,
    .skip {
        display: none;
    }

    .chapter-head::before,
    .chapter-head::after,
    .manual-divider::before,
    .manual-divider::after {
        display: none;
    }

    .chapter-head {
        padding-bottom: 2.7rem;
        border-bottom: 2px solid #333;
    }

    .manual-divider {
        height: 0;
    }

    h1,
    h2 {
        color: #111;
    }

    .panel,
    .callout {
        background: #fff;
        color: #000;
        border-color: #666;
    }

    footer {
        color: #333;
    }

    .footer-sfi-logo {
        width: 50px;
        height: 50px;
    }

    a {
        color: #111;
    }
}