/* Shared layout for every page: header + nav, page sections, footer.
   Colors match the search bar (charcoal #3b3640, gold #ffd52d) and were
   checked for WCAG AA contrast (4.5:1 for text, 3:1 for focus rings/borders). */

:root {
    --ink: #2b2730;
    --muted: #5f5a66;
    --charcoal: #3b3640;
    --charcoal-dark: #24212a;
    --gold: #ffd52d;
    --gold-soft: #fff5cc;
    --gold-dark: #7a5f00;
    --paper: #f7f3ea;
    --surface: #fff;
    --line: #e2dccf;
    --line-strong: #8d8794;
    --footer: #212529;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(43, 39, 48, .06), 0 8px 24px rgba(43, 39, 48, .08);
    --gutter: clamp(16px, 4vw, 40px);
    --serif: 'Libre Caslon Text', Georgia, 'Times New Roman', serif;
}

*, *::before, *::after { box-sizing: border-box; }
button, input { margin: 0; }
figure { margin: 0; }

/* keeps focused items from hiding under the sticky header */
html { scroll-padding-top: 96px; }
@media (max-width: 800px) { html { scroll-padding-top: 16px; } }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Source Sans Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 1.0625rem;
    line-height: 1.65;
}
img { max-width: 100%; height: auto; }
h1, h2, h3 { color: var(--ink); }

/* Links are always underlined so they don't rely on color alone */
a { color: #1d4f91; text-decoration: underline; text-underline-offset: .15em; }
a:hover { color: #123563; text-decoration-thickness: 2px; }

/* One consistent, highly visible keyboard focus ring */
:focus-visible {
    outline: 3px solid var(--charcoal);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px var(--gold);
}
:focus:not(:focus-visible) { outline: none; }
/* Targets of the skip link / results focus don't need a ring */
[tabindex="-1"]:focus { outline: none; box-shadow: none; }

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

.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 var(--gutter);
}
.section { padding: clamp(40px, 7vw, 80px) 0; }
.section-white { background: var(--surface); }

.eyebrow {
    margin: 0 0 6px;
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--gold-dark);
}
.section-title {
    margin: 0 0 24px;
    font-family: var(--serif);
    font-size: clamp(1.7rem, 3.5vw, 2.3rem);
    font-weight: 700;
    line-height: 1.2;
}
.section-head { max-width: 680px; margin-bottom: 32px; }
.section-head .section-title { margin-bottom: 0; }
.lead { font-size: clamp(1.15rem, 2vw, 1.3rem); line-height: 1.6; }
p { margin: 0 0 1em; }
.prose p { max-width: 70ch; }
.prose > :last-child { margin-bottom: 0; }

.icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--gold-soft);
    color: var(--gold-dark);
    font-size: 1.35rem;
}

.card {
    padding: clamp(20px, 3vw, 32px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.card > :last-child, .card p:last-child { margin-bottom: 0; }

/* ---------- Skip link ---------- */
.skip-link {
    position: absolute;
    left: 16px;
    top: -100px;
    z-index: 10001;
    padding: 12px 18px;
    border-radius: 0 0 8px 8px;
    background: var(--gold);
    color: var(--ink);
    font-weight: 700;
}
.skip-link:focus { top: 0; color: var(--ink); }

/* ---------- Header + nav ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--charcoal);
    border-bottom: 4px solid var(--gold);
    color: #fff;
}
.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px var(--gutter);
}
.site-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    color: #fff !important;
    text-decoration: none !important;
    line-height: 1.2;
}
.site-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--charcoal);
    font-size: 1.15rem;
}
.site-brand-text { display: flex; flex-direction: column; }
.site-brand-name {
    font-family: var(--serif);
    font-size: 1.4rem;
    font-weight: 700;
}
.site-brand-sub { font-size: .875rem; color: var(--gold); }
.site-brand:hover .site-brand-name { text-decoration: underline; }

.site-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.site-nav a {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 14px;
    border-radius: 999px;
    color: #fff !important;
    font-weight: 600;
    text-decoration: none !important;
}
.site-nav a:hover { background: rgba(255, 255, 255, .1); text-decoration: underline !important; }
.site-nav a[aria-current="page"] { background: var(--gold); color: var(--ink) !important; }
.site-nav .fa-external-link-alt { font-size: .75em; }
.site-nav a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px var(--gold); }

.nav-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-height: 44px;
    padding: 8px 14px;
    border: 2px solid var(--gold);
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.nav-toggle:hover { background: var(--charcoal-dark); }
.nav-toggle:focus-visible { outline: 2px solid #fff; box-shadow: 0 0 0 5px var(--gold); }

/* Small screens: the menu collapses behind the button (only once the script
   is running, so the links stay visible if JavaScript fails) */
@media (max-width: 800px) {
    .site-header { position: relative; }
    .site-brand-mark { display: none; }
    .site-brand-name { font-size: 1.25rem; }
    .site-brand-sub { font-size: .8rem; }
    .site-nav.is-ready .nav-toggle { display: inline-flex; }
    .site-nav.is-ready ul {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        padding: 8px var(--gutter) 16px;
        background: var(--charcoal);
        border-bottom: 4px solid var(--gold);
        box-shadow: 0 8px 16px rgba(0, 0, 0, .3);
    }
    .site-nav.is-ready ul.is-open { display: flex; }
    .site-nav a { border-radius: 10px; }
}

/* ---------- Home: hero banner + search ---------- */
.hero { margin: 0; line-height: 0; background: #f2c230; }
.hero img { display: block; width: 100%; }

.search-wrap {
    position: relative;
    z-index: 2;
    margin-top: clamp(-56px, -4vw, -16px);
    padding-bottom: 8px;
}
.search-panel {
    max-width: 880px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 36px);
    border: 4px solid var(--gold);
    border-radius: 20px;
    background: var(--charcoal);
    color: #fff;
    box-shadow: 0 12px 40px rgba(43, 39, 48, .3);
}
.search-panel h2 {
    margin: 0 0 20px;
    font-family: var(--serif);
    font-size: clamp(1.25rem, 3vw, 1.65rem);
    font-weight: 700;
    line-height: 1.35;
    color: #fff;
    text-align: center;
}
.search-panel label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    color: var(--gold);
}
.search-row { display: flex; flex-wrap: wrap; gap: 10px; }
.search-field { position: relative; flex: 1 1 220px; min-width: 0; }
.search-field i {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.search-field input {
    width: 100%;
    min-height: 56px;
    padding: 8px 16px 8px 48px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 1.25rem;
}
.search-field input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; box-shadow: none; }
.search-row button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 56px;
    padding: 8px 32px;
    border: 2px solid var(--gold);
    border-radius: 999px;
    background: var(--gold);
    color: var(--ink);
    font: inherit;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
}
.search-row button:hover { background: #ffe066; }
.search-row button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: none; }
.search-hint { margin: 12px 0 0; color: #e9e6ec; text-align: center; }
@media (max-width: 480px) {
    .search-row button { flex: 1 1 100%; }
}

/* Story: a photo next to two short cards */
.story-grid {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: clamp(24px, 4vw, 48px);
    align-items: center;
}
.story-photo { margin: 0; }
.story-photo img {
    display: block;
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transform: rotate(-1.5deg);
    border: 10px solid #fff;
}
.story-photo figcaption { margin-top: 12px; font-size: .95rem; color: var(--muted); text-align: center; }
.story-cards { display: grid; gap: 20px; }
.story-card { display: flex; flex-direction: row; gap: 18px; align-items: flex-start; }
@media (max-width: 800px) {
    .story-grid { grid-template-columns: 1fr; }
    .story-photo { max-width: 420px; margin: 0 auto; }
}
@media (max-width: 480px) {
    .story-card { flex-direction: column; gap: 12px; }
}

/* How to search: numbered steps that open and close */
.steps {
    display: grid;
    gap: 14px;
    max-width: 860px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.step {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.step[open] { border-color: var(--line-strong); }
.step summary {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 44px;
    padding: 18px 22px;
    border-radius: var(--radius);
    cursor: pointer;
    list-style: none;
    font-size: 1.2rem;
    font-weight: 700;
}
.step summary::-webkit-details-marker { display: none; }
.step summary:hover .step-title { text-decoration: underline; }
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--charcoal);
    color: var(--gold);
    font-weight: 700;
}
.step-title { flex: 1; }
.step-chevron { color: var(--muted); transition: transform .2s; }
.step[open] .step-chevron { transform: rotate(180deg); }
.step-body { padding: 0 22px 22px 78px; }
.step-body > :last-child { margin-bottom: 0; }
@media (max-width: 480px) {
    .step summary { padding: 16px; gap: 12px; font-size: 1.1rem; }
    .step-body { padding: 0 16px 18px; }
}
@media (prefers-reduced-motion: reduce) {
    .step-chevron { transition: none; }
}

/* ---------- Inner page header ---------- */
.page-header {
    position: relative;
    overflow: hidden;
    padding: clamp(40px, 7vw, 72px) 0;
    background: var(--charcoal);
    color: #fff;
}
.page-header::after {
    /* a faint strip of the envelope banner, purely decorative */
    content: "";
    position: absolute;
    inset: 0;
    background: url('../img/bkg3.jpg') center bottom / cover;
    opacity: .07;
}
.page-header .container { position: relative; z-index: 1; }
.page-header .eyebrow { color: var(--gold); }
.page-title {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    font-weight: 700;
    line-height: 1.1;
    color: #fff;
}
.page-header .prose { margin-top: 20px; }
.page-header .prose a { color: #fff; }
.page-header .prose a:hover { color: var(--gold); }

/* Decorative strips of scanned envelopes between sections */
.photo-band {
    height: clamp(120px, 18vw, 220px);
    background: #d8c9a3 center / cover no-repeat;
}
.photo-band-letter2 { background-image: url('../img/letter2_band.jpg'); }
.photo-band-letter3 { background-image: url('../img/letter3_band.jpg'); }

/* ---------- Loading overlay ---------- */
.loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
}
.loader-overlay[hidden] { display: none; }
.spinner {
    width: 96px;
    height: 96px;
    border: 12px solid #f3f3f3;
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 6s; }
}

/* ---------- About page ---------- */
.split {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: clamp(24px, 5vw, 64px);
    align-items: center;
}
@media (max-width: 800px) {
    .split { grid-template-columns: 1fr; }
}
.framed-photo { margin: 0; }
.framed-photo img {
    display: block;
    border: 10px solid #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transform: rotate(1.5deg);
}
.framed-photo figcaption { margin-top: 12px; font-size: .95rem; color: var(--muted); text-align: center; }
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
}
.info-grid .card { display: flex; flex-direction: column; gap: 14px; }

.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.feature-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(43, 39, 48, .16); }
.feature-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    object-position: top;
}
.feature-card-body { padding: 18px 22px 22px; }
.feature-card h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.3rem; font-weight: 700; }
.feature-card h3 a { color: var(--ink); }
/* The whole card is clickable, but only the title is announced as the link */
.feature-card h3 a::after { content: ""; position: absolute; inset: 0; }
.feature-card:hover h3 a { text-decoration-thickness: 3px; }
.feature-card:focus-within { outline: 3px solid var(--charcoal); outline-offset: 3px; box-shadow: 0 0 0 9px var(--gold); }
.feature-card h3 a:focus-visible { outline: none; box-shadow: none; }
.feature-card p { margin: 0; color: var(--muted); }
.feature-card .fa-external-link-alt { font-size: .7em; color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
    .feature-card { transition: none; }
    .feature-card:hover { transform: none; }
}

/* ---------- More Names page ---------- */
.name-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 24px;
    margin-bottom: 28px;
    padding: 20px 24px;
}
.name-filter { flex: 1 1 280px; }
.name-filter label { display: block; margin-bottom: 6px; font-weight: 700; }
.name-filter .search-field input { min-height: 50px; font-size: 1.1rem; border: 2px solid var(--line-strong); }
.name-filter .search-field input:focus-visible { outline: 3px solid var(--charcoal); box-shadow: 0 0 0 6px var(--gold); outline-offset: 2px; }
.name-count { margin: 0; padding-bottom: 12px; font-weight: 600; color: var(--muted); }
.name-jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.name-jump a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 6px 16px;
    border: 2px solid var(--charcoal);
    border-radius: 999px;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}
.name-jump a:hover { background: var(--charcoal); color: #fff; }

.name-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    align-items: start;
}
.name-group h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gold);
    font-family: var(--serif);
    font-size: 1.6rem;
    font-weight: 700;
}
.name-list { margin: 0; padding: 0; list-style: none; }
.name-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 40px;
    padding: 6px 10px;
    margin: 0 -10px;
    border-radius: 8px;
    color: var(--ink);
    text-decoration-color: var(--line-strong);
}
.name-list a::after {
    content: "\f35d";
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: .7em;
    color: var(--muted);
    opacity: 0;
}
.name-list a:hover { background: var(--gold-soft); text-decoration-color: currentColor; }
.name-list a:hover::after, .name-list a:focus-visible::after { opacity: 1; }
.name-group[hidden], .name-list li[hidden] { display: none; }
.name-empty { padding: 24px; text-align: center; }

/* ---------- Footer ---------- */
.site-footer {
    background: var(--footer);
    color: #fff;
    font-size: 1rem;
    line-height: 1.6;
    border-top: 4px solid var(--gold);
}
.site-footer-inner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px 64px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 48px var(--gutter);
}
.site-footer h2 {
    margin: 0 0 14px;
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--gold);
}
.site-footer p { margin: 0 0 12px; }
.site-footer a { color: #fff; text-decoration: underline; }
.site-footer a:hover { color: var(--gold); }
.site-footer a:focus-visible { outline: 3px solid var(--gold); box-shadow: none; }
.footer-links { margin: 0; padding: 0; list-style: none; }
.footer-links li { margin-bottom: 14px; }
