/*
=========================================================
THE CRIMSON COURT — SHARED CHROME
=========================================================

The gothic-encyclopedia shell every Crimson Court page wears: the masthead,
the heraldic banner, the midnight reading surface and the royal footer.

Load order on a court page is always:

    normalize.css → styles.css → crimson-court.css → <page>.css
        → court-chrome.css → court-page.css | court-encyclopedia.css

This file comes after the page stylesheets on purpose. It restyles the
banner and footer that crimson-court.css draws in the older, centred way,
and undoes the main site's bare-element chrome, both of which are written
earlier in the cascade — see the "Cascade traps" table in BRANDING.md.

Colours come from the :root block in crimson-court.css. Nothing here invents
one; gold is structure, crimson is voice, parchment is speech.
*/

html { scroll-behavior: smooth; }

body.crimson-court-page {
    background: var(--royal-black) !important;
    color: var(--ink);
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 20px;
    line-height: 1.65;
    overflow: auto !important;
    scrollbar-color: var(--royal-gold) var(--royal-black);
}

/* The seal under the decree is not drawn on the encyclopedia footer. */
.royal-seal {
    display: none !important;
}

.container {
    max-width: 1160px;
    padding: 0 44px;
    width: 100%;
    margin: auto;
}

a { color: var(--oxblood); }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--gold) !important;
    outline-offset: 4px;
}

h1, h2, h3, h4 {
    font-family: 'Cinzel', Georgia, serif !important;
    font-weight: 500 !important;
    letter-spacing: 0 !important;
    text-shadow: none !important;
    color: var(--royal-gold-light) !important;
    line-height: 1.3;
}

/*
=========================================================
MASTHEAD
=========================================================
styles.css styles bare `header` (light slab, sticky, blur, shadow) — all of
it has to be put back off here, not just the background.
*/
header.encyclopedia-header {
    position: relative;
    top: 0;
    z-index: 50;
    background: var(--royal-black) !important;
    border: 0;
    border-bottom: 1px solid var(--court-border) !important;
    box-shadow: none;
    backdrop-filter: none;
    padding: 0;
}

.masthead {
    max-width: 1440px;
    margin: auto;
    min-height: 96px;
    padding: 18px 32px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.encyclopedia-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    color: var(--royal-gold-light);
    font-family: 'Cinzel', Georgia, serif;
    font-size: 18px;
    line-height: 1.1;
    text-decoration: none;
}

.encyclopedia-brand img {
    width: 40px;
    height: 48px;
    object-fit: contain;
}

.encyclopedia-brand small {
    display: block;
    font: 10px 'Cinzel', Georgia, serif;
    letter-spacing: .16em;
    color: var(--court-secondary);
    margin-top: 9px;
}

.masthead nav {
    display: flex;
    gap: 16px;
    margin-left: auto;
}

.masthead nav a,
.main-site {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 12px;
    line-height: normal;
    letter-spacing: .12em;
    color: var(--parchment);
    text-decoration: none;
    padding: 12px 0;
}

.masthead nav a { text-transform: uppercase; }

.masthead nav a:hover {
    color: var(--parchment);
    border-bottom: 2px solid var(--royal-gold);
}

/* Crimson is "the current thing", so the page you are on is crimson. */
.masthead nav a[aria-current] {
    color: var(--crimson-light);
    border-bottom: 2px solid var(--crimson-blood);
}

.main-site {
    font-size: 10px;
    letter-spacing: .1em;
    white-space: nowrap;
}

/*
Court-wide search, fed by js/court-search.js.

crimson-court.css widens the *input* on focus. In the masthead that is the one
thing it must not do: the row measures this box, so a wider input inside a
fixed box simply reached across the main-site link. Here the box itself grows,
the input stays at its full width, and the flex row reflows around it.
*/
.court-search {
    width: 185px;
    flex: 0 1 auto;
    min-width: 0;
    margin: 0;
    position: relative;
    transition: width 0.2s ease;
}

.court-search:focus-within {
    width: 250px;
}

.court-search input,
.court-search input:focus {
    width: 100%;
}

.court-search-icon { display: none; }

.court-search input {
    width: 100%;
    height: 40px;
    padding: 10px 12px !important;
    border: 1px solid var(--court-border) !important;
    border-radius: 2px;
    background: var(--court-raised) !important;
    color: var(--parchment) !important;
    font: 17px 'EB Garamond', Georgia, serif !important;
}

.court-search input::placeholder { color: var(--court-secondary); }

.court-search-results {
    background: var(--court-raised) !important;
    border: 1px solid var(--line) !important;
    box-shadow: 0 8px 30px #0003;
}

.court-search-results * {
    font-family: 'EB Garamond', Georgia, serif !important;
    color: var(--parchment) !important;
    text-shadow: none !important;
}

.court-search-results [aria-selected="true"] {
    background: var(--court-hover) !important;
    border-left: 2px solid var(--crimson-blood);
}

/* The last row of the dropdown: the way through to /search. Not an option, so
   the arrow keys walk past it and it carries no selected state. */
.court-search-all {
    display: block;
    padding: 9px 12px;
    border-top: 1px solid var(--court-line);
    color: var(--royal-gold) !important;
    font-size: 14px !important;
    text-decoration: none;
}

.court-search-all:hover { background: var(--court-hover) !important; }

/* What the spoiler shield kept out of the results. */
.court-search-hidden {
    padding: 8px 12px;
    border-top: 1px solid var(--court-line);
    color: var(--court-secondary) !important;
    font-size: 13px !important;
}

.court-search-hidden i { color: var(--crimson-light) !important; }

/*
A search term marked on the page a result led to, by js/court-search-highlight.js.
The browser's yellow block has no business on the dark reading field, so it is
stripped the same way the results page strips it: parchment ink at weight 700
carries the match. The first one gets a gold underline, because it is the one
the page scrolled to and it should be findable once the scroll stops.
*/
mark.court-hit {
    background: none;
    color: var(--parchment);
    font-weight: 700;
}

mark.court-hit.is-first {
    border-bottom: 2px solid var(--royal-gold);
}

/*
=========================================================
THE SPOILER SHIELD
=========================================================
The pill beside the search box and the panel under it (js/court-shield.js),
and the furniture every court page uses when the shield has held something
back: a row that says what is missing with a temporary reveal, a locked card
in a list, and the gate on a session page past the limit. Crimson is "the
current thing", so the pill goes crimson while a limit is set; gold frames
the panel and the buttons, as it frames everything else.
*/
.spoiler {
    position: relative;
    flex: none;
}

.spoiler-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--court-border);
    border-radius: 2px;
    background: var(--court-raised);
    color: var(--parchment);
    font: 12px 'Cinzel', Georgia, serif;
    letter-spacing: .08em;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color .18s ease, background-color .18s ease;
}

.spoiler-pill:hover { border-color: var(--royal-gold); }

.spoiler-pill i { color: var(--royal-gold); font-size: 12px; }

.spoiler-pill-label { text-transform: uppercase; color: var(--court-secondary); }

.spoiler-pill-value { color: var(--parchment); }

.spoiler-pill.is-on {
    border-color: var(--crimson-blood);
    background: rgba(195, 10, 61, .14);
}

.spoiler-pill.is-on i,
.spoiler-pill.is-on .spoiler-pill-value { color: var(--crimson-light); }

.spoiler-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    width: 340px;
    max-width: calc(100vw - 32px);
    padding: 18px 18px 16px;
    background: var(--court-raised);
    border: 1px solid var(--court-border);
    border-top: 3px double var(--court-border);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .72);
}

.spoiler-eyebrow {
    margin: 0 0 6px;
    font: 11px 'Cinzel', Georgia, serif;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--crimson-light);
}

.spoiler-status {
    margin: 0 0 14px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--parchment);
}

.spoiler-fields {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.spoiler-field {
    display: grid;
    gap: 4px;
    font: 11px 'Cinzel', Georgia, serif;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--court-secondary);
}

.spoiler-field select {
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--court-border);
    border-radius: 2px;
    background: var(--royal-black);
    color: var(--parchment);
    font: 15px 'EB Garamond', Georgia, serif;
}

.spoiler-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.spoiler-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--royal-gold);
    border-radius: 2px;
    background: var(--royal-gold);
    color: var(--royal-black);
    font: 600 11px 'Cinzel', Georgia, serif;
    letter-spacing: .1em;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}

.spoiler-btn:hover { background: var(--royal-gold-light); border-color: var(--royal-gold-light); }

.spoiler-btn--quiet {
    background: transparent;
    color: var(--royal-gold);
    border-color: var(--court-border);
}

.spoiler-btn--quiet:hover {
    background: var(--court-hover);
    color: var(--royal-gold-light);
    border-color: var(--royal-gold);
}

.spoiler-note {
    margin: 12px 0 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--court-secondary);
}

/* What a list ends on when the shield held something back. */
.spoiler-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 18px 0;
    padding: 14px 18px;
    border: 1px dashed var(--court-border);
    color: var(--court-secondary);
    font-size: 16px;
}

.spoiler-row i { color: var(--crimson-light); }

.spoiler-row-text { flex: 1 1 200px; }

/* A card that stands in for a session past the limit. */
.spoiler-locked {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 18px 26px;
    border: 1px dashed var(--court-border);
    color: var(--court-secondary);
}

.spoiler-locked-label {
    font: 12px 'Cinzel', Georgia, serif;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--court-secondary);
}

.spoiler-locked-text {
    flex: 1 1 200px;
    font-size: 16px;
}

.spoiler-locked-text i { color: var(--crimson-light); margin-right: 6px; }

/* The gate on a session page past the limit, and the line that moves it. */
.spoiler-gate {
    max-width: 760px;
    margin: 0 auto 28px;
    padding: 26px 28px;
    border: 1px solid var(--court-border);
    border-top: 3px double var(--court-border);
    background: var(--court-raised);
}

.spoiler-gate h2 {
    margin: 0 0 8px;
    font-size: 22px !important;
}

.spoiler-gate p {
    margin: 0 0 16px;
    color: var(--court-secondary);
}

.spoiler-mark {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 0 0 26px;
    padding: 12px 16px;
    border: 1px solid var(--court-line);
    color: var(--court-secondary);
    font-size: 15px;
}

.spoiler-mark i { color: var(--royal-gold); }

.spoiler-mark span { flex: 1 1 200px; }

/* A spoiler inside prose: a span marked data-revealed-in, held back with a
   small mark in its place (js/court-shield.js, gateInline). */
.spoiled[data-revealed-in] { display: none; }

.spoiler-inline {
    font-style: italic;
    color: var(--court-secondary);
}

/* A name in a recap, linked to the person: js/court-wikilinks.js. Kept quiet
   - the recap is prose first - with a dotted gold hairline, and a solid line
   on hover. An heir's link is the same in crimson, so the family reads apart
   from the court around them. */
.wiki-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted var(--court-border);
    transition: border-color .18s ease, color .18s ease;
}

.wiki-link:hover,
.wiki-link:focus-visible {
    color: var(--royal-gold-light);
    border-bottom: 1px solid var(--royal-gold);
}

.wiki-link--heir { border-bottom-color: rgba(214, 51, 92, .45); }

/* A glossary term reads a shade quieter than a person. */
.wiki-link--term { border-bottom-style: dashed; }

/* The card beside a link, on hover or focus: js/court-hovercards.js. A
   raised surface with the gold hairline, the kind in small caps, the name
   in Cinzel, two sentences in Garamond, and the hint in secondary. */
.court-hovercard {
    position: absolute;
    z-index: 9000;
    width: min(340px, calc(100vw - 16px));
    padding: 14px 16px 12px;
    background: var(--court-raised);
    border: 1px solid var(--court-border);
    border-top: 2px solid var(--royal-gold);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .55);
    color: var(--parchment);
    font-family: 'EB Garamond', Georgia, serif;
    pointer-events: auto;
}

.court-hovercard[hidden] { display: none; }

.court-hovercard.is-above { border-top: 1px solid var(--court-border); border-bottom: 2px solid var(--royal-gold); }

.court-hovercard p { margin: 0; }

.court-hovercard-eyebrow {
    font: 600 10px 'Cinzel', Georgia, serif;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--court-secondary);
    margin-bottom: 3px;
}

.court-hovercard-eyebrow[hidden] { display: none; }

.court-hovercard-title {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--royal-gold-light);
    margin-bottom: 6px;
}

.court-hovercard-text {
    font-size: 15px;
    line-height: 1.5;
}

.court-hovercard-hint {
    margin-top: 8px;
    font-size: 12px;
    font-style: italic;
    color: var(--court-secondary);
}

.wiki-link--heir:hover,
.wiki-link--heir:focus-visible {
    color: var(--crimson-light);
    border-bottom-color: var(--crimson-light);
}

/* The button that copies a record's own address: js/court-share.js. The
   quiet spoiler button's shape, so it sits beside one without a seam. */
.court-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    border: 1px solid var(--court-border);
    border-radius: 2px;
    background: transparent;
    color: var(--royal-gold);
    font: 600 11px 'Cinzel', Georgia, serif;
    letter-spacing: .1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}

.court-share-btn:hover,
.court-share-btn:focus-visible {
    background: var(--court-hover);
    color: var(--royal-gold-light);
    border-color: var(--royal-gold);
}

.court-share-btn.is-done {
    color: var(--parchment);
    border-color: var(--royal-gold);
}

/* One picture full size over the page: js/court-lightbox.js. The backdrop
   is the court's black at nine tenths, the picture shown whole, the caption
   in the small-caps and Garamond of the page under it. */
.court-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 15, 26, .92);
}

.court-lightbox[hidden] { display: none; }

body.court-lightbox-open { overflow: hidden; }

.court-lightbox-figure {
    margin: 0;
    max-width: min(1100px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.court-lightbox-img {
    max-width: 100%;
    max-height: calc(100vh - 140px);
    object-fit: contain;
    border: 1px solid var(--court-border);
    box-shadow: 0 0 40px rgba(0, 0, 0, .6);
    background: var(--court-raised);
}

.court-lightbox figcaption {
    text-align: center;
    color: var(--parchment);
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 17px;
}

.court-lightbox figcaption[hidden] { display: none; }

.court-lightbox-title {
    display: block;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .06em;
}

.court-lightbox-caption {
    display: block;
    margin-top: 2px;
    font-size: 15px;
    color: var(--court-secondary);
}

.court-lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 42px;
    height: 42px;
    border: 1px solid var(--court-border);
    border-radius: 2px;
    background: var(--court-raised);
    color: var(--royal-gold);
    font-size: 18px;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}

.court-lightbox-close:hover,
.court-lightbox-close:focus-visible {
    background: var(--court-hover);
    color: var(--royal-gold-light);
    border-color: var(--royal-gold);
}

/* The one-time card on the hub for a first visit. */
.spoiler-prompt {
    margin: 0 0 18px;
    padding: 18px 20px;
    border: 1px solid var(--court-border);
    border-left: 2px solid var(--crimson-blood);
    background: var(--court-raised);
}

.spoiler-prompt p {
    margin: 0 0 12px;
    color: var(--parchment);
}

.spoiler-prompt .spoiler-actions { margin: 0; }

/*
=========================================================
HERALDIC BANNER
=========================================================
The page's title block. It sits on the reading surface rather than above it:
banner and surface are one panel, split by nothing but the crest's arch.
*/
.heraldic-banner {
    position: relative;
    max-width: 1160px;
    margin: 32px auto 0;
    padding: 38px 150px 34px 44px !important;
    background: var(--court-surface) !important;
    border: 1px solid var(--court-border) !important;
    border-bottom: 0 !important;
    border-top: 3px double var(--court-border) !important;
    box-shadow: none !important;
    text-align: left;
    min-height: 0;
    height: auto;
}

/* Gold corner rules, the one bit of ornament the panel gets. */
.heraldic-banner::before,
.heraldic-banner::after {
    content: '';
    display: block !important;
    position: absolute;
    top: 11px;
    width: 28px;
    height: 28px;
    z-index: 1;
    background: none;
    opacity: 1;
    transform: none;
    pointer-events: none;
}

.heraldic-banner::before {
    left: 11px;
    border-top: 1px solid var(--royal-gold);
    border-left: 1px solid var(--royal-gold);
}

.heraldic-banner::after {
    right: 11px;
    border-top: 1px solid var(--royal-gold);
    border-right: 1px solid var(--royal-gold);
}

/* The crest, in its arched niche at the banner's shoulder. */
.heraldic-banner .banner-emblem {
    display: block;
    position: absolute;
    right: 42px;
    top: 22px;
    width: 82px;
    height: 108px;
    margin: 0;
    padding: 13px 12px 8px;
    border: 1px solid var(--court-border);
    border-radius: 50% 50% 0 0 / 36% 36% 0 0;
    background: var(--royal-black);
    box-shadow: 0 0 0 5px var(--court-surface), 0 0 0 6px var(--court-line);
}

.heraldic-banner .royal-crest {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 3px 9px rgba(195, 10, 61, .24));
}

.royal-title {
    width: auto;
    font-size: 40px !important;
    line-height: 1.12 !important;
    margin: 0 0 10px !important;
    background: none !important;
    color: var(--royal-gold-light) !important;
    -webkit-text-fill-color: var(--royal-gold-light) !important;
}

.royal-title::before,
.royal-title::after { display: none !important; }

.royal-subtitle {
    width: auto;
    margin: 0 !important;
    padding-left: 16px;
    border-left: 2px solid var(--crimson-dark);
    font-family: 'EB Garamond', Georgia, serif !important;
    font-size: 19px !important;
    line-height: normal;
    font-style: italic !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    color: var(--court-secondary) !important;
}

/*
=========================================================
READING SURFACE
=========================================================
The panel the page's content sits on, continuing the banner downward.
*/
.court-surface {
    max-width: 1160px;
    margin: 0 auto;
    background: var(--court-surface);
    border: 1px solid var(--court-border);
    border-top: 0;
}

/* A breadcrumb line, where a page opens with one. */
.article-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font: 12px 'Cinzel', Georgia, serif;
    color: var(--muted);
    margin-bottom: 34px;
}

.article-breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}

/*
=========================================================
ROYAL FOOTER
=========================================================
*/
.royal-footer {
    background: var(--charcoal) !important;
    border: 0;
    padding: 30px 0;
    box-shadow: none !important;
}

.royal-decree {
    max-width: 800px;
    margin: auto;
    padding-top: 22px;
    text-align: center;
}

.royal-decree::before {
    content: '';
    display: block;
    position: static;
    width: 6px;
    height: 6px;
    margin: 0 auto 14px;
    background: var(--royal-gold);
    transform: rotate(45deg);
    opacity: .7;
}

.royal-decree::after { display: none; }

.royal-decree p {
    font: italic 18px 'EB Garamond', Georgia, serif;
    color: var(--court-secondary);
}

/*
=========================================================
RESPONSIVE
=========================================================
*/
@media (max-width: 1240px) {
    .masthead {
        flex-wrap: wrap;
        gap: 12px 24px;
    }

    .masthead nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .court-search { margin-left: auto; }
}

@media (max-width: 1200px) {
    .heraldic-banner,
    .court-surface { width: calc(100% - 48px); }
}

@media (max-width: 700px) {
    .masthead {
        padding: 16px 20px;
        gap: 16px;
    }

    .encyclopedia-brand { font-size: 16px; }

    .main-site { margin-left: auto; }

    .court-search,
    .court-search:focus-within {
        order: 2;
        flex-basis: 100%;
        width: 100%;
    }

    .masthead nav {
        order: 3;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 4px 18px;
    }

    .masthead nav a { padding: 6px 0; }

    .spoiler { order: 4; }

    .spoiler-panel {
        right: auto;
        left: 0;
    }

    .heraldic-banner,
    .court-surface {
        width: calc(100% - 24px);
        margin-top: 16px;
    }

    .court-surface { margin-top: 0; }

    .heraldic-banner { padding: 30px 22px 26px !important; }

    .heraldic-banner .banner-emblem { display: none !important; }

    .royal-title { font-size: 30px !important; }

    .royal-subtitle {
        font-size: 18px !important;
        width: 100%;
        padding-left: 12px;
    }

    .container { padding: 0 22px; }

    .article-breadcrumb {
        font-size: 11px;
        margin-bottom: 28px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    * {
        animation: none !important;
        transition: none !important;
    }
}
