/* 1. THE ARCHIVE THEME (VARIABLES) */
:root {
    /* Layout - Kept similar to your original for stability */
    --bg-color: #0b0e14;
    --card-bg: #161b22;
    --border: #30363d;

    /* Text - Kept your original shades for readability */
    --text-main: #c9d1d9;
    --text-muted: #8b949e;

    /* BRAND UPDATE - Using colors from the new logo */
    --accent: #3498db;           /* Replaces the old blue with your Logo Blue */
    --accent-purple: #8e44ad;    /* New: For "Index" or Personnel links */
    --accent-glow: #00d2ff;      /* New: For UFO-style highlights */
    
    /* Functional */
    --success: #238636;
    --error: #ff7b72;

    /* Slug links ([[...]] glossary) — accent family, not default hyperlink chrome */
    --slug-link: #5dade2;
    --slug-link-hover: #a8d8f5;
    --slug-link-visited: #4a8eb8;
    --slug-link-visited-hover: #7ec4ea;

    /* Index gateway tiles (match header nav); each has distinct hover tint */
    --gateway-people: #a371f7;
    --gateway-locations: #2ea043;
    --gateway-events: #3498db;
    --gateway-glossary: #d29922;
    --gateway-concepts: #db61a2;
    --gateway-resources: #f0883e;
}

/* 2. BASE RESET */
body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    text-align: left; /* Global anchor to the left */
}

/* 3. THE MASTER CONTAINER (The Eye Anchor) */
.container {
    max-width: 900px;
    margin: 0 auto;    /* Centers the box on the screen */
    padding: 20px;
    text-align: left;  /* Forces content inside to stay left */
    display: block;
}

/* 4. NAVIGATION BAR (The "No-Smoosh" Nav) */
.main-nav {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 0;
    margin-bottom: 2rem;
}

.nav-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-weight: bold;
    font-size: 1.1rem;
    color: #ffffff;
}

.nav-links {
    display: flex;
    gap: 12px;
    flex-wrap: nowrap;
}

.nav-links a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 10px;
    white-space: nowrap;
    transition: 0.2s;
}

.nav-links a:hover {
    background: rgba(88, 166, 255, 0.1);
    border-radius: 4px;
    color: #ffffff;
}

/* 5. CONTENT CARDS */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 24px;
    margin-bottom: 20px;
    text-align: left;
}

h1, h2, h3 {
    color: #ffffff;
    margin-top: 0;
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    background: var(--border);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* 6. FORMS & INPUTS */
label {
    display: block;
    margin-top: 15px;
    font-weight: bold;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input, textarea, select {
    background-color: #0d1117;
    border: 1px solid var(--border);
    color: white;
    padding: 10px;
    border-radius: 4px;
    width: 100%;
    margin-top: 5px;
    box-sizing: border-box; /* Critical: keeps width 100% inside the card */
}

button, .button {
    background-color: var(--success);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
}

button:hover, .button:hover {
    filter: brightness(1.1);
}

/* --- ARCHIVE COMPONENTS --- */

/* The A-Z Jump Bar */
.jump-bar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 30px;
    display: flex;
    gap: 20px; /* More space between letters */
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.jump-link {
    color: var(--accent) !important; /* Forces your blue color */
    text-decoration: none !important; /* Kills the purple underline */
    font-weight: bold;
    font-size: 1.1rem;
    line-height: 1;
    transition: transform 0.2s;
}

.jump-link:hover {
    transform: scale(1.2); /* Slight pop when hovering */
    color: #ffffff !important;
}

/* The Grid Layout */
.archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 40px;
}

/* The "File" Card Link */
.file-link {
    text-decoration: none !important; /* Kills purple underline */
    color: inherit !important;
    display: block;
}

.file-card {
    margin-bottom: 0;
    padding: 15px;
    transition: all 0.2s ease;
    border-left: 3px solid var(--border);
    background: var(--card-bg);
}

.file-link:hover .file-card {
    border-left-color: var(--accent);
    background: rgba(88, 166, 255, 0.08);
    transform: translateY(-2px); /* Lift effect */
}

/* Index home gateway: preserve per-section color on hover (nav order) */
.index-gateway-cards .file-link:hover .gateway-card--people {
    border-left-color: var(--gateway-people);
    background: rgba(163, 113, 247, 0.1);
}
.index-gateway-cards .file-link:hover .gateway-card--locations {
    border-left-color: var(--gateway-locations);
    background: rgba(46, 160, 67, 0.12);
}
.index-gateway-cards .file-link:hover .gateway-card--events {
    border-left-color: var(--gateway-events);
    background: rgba(52, 152, 219, 0.1);
}
.index-gateway-cards .file-link:hover .gateway-card--glossary {
    border-left-color: var(--gateway-glossary);
    background: rgba(210, 153, 34, 0.1);
}
.index-gateway-cards .file-link:hover .gateway-card--concepts {
    border-left-color: var(--gateway-concepts);
    background: rgba(219, 97, 162, 0.1);
}
.index-gateway-cards .file-link:hover .gateway-card--resources {
    border-left-color: var(--gateway-resources);
    background: rgba(240, 136, 62, 0.12);
}

/* The Detailed "Manila Folder" View */
.folder-card {
    border-top: 5px solid var(--accent);
    padding: 30px; /* Added internal padding */
}

.folder-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #e6edf3; /* Brighter white for readability */
    max-width: 750px;
}

/* --- FOLDER HEADER LOGIC --- */

/* The wrapper for the Title and the ID */
.folder-header {
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start; 
    margin-bottom: 30px;
    gap: 20px; /* Ensures a gap between Title and ID */
}

/* The Title side: grows to fill space */
.folder-title-block {
    flex: 1;
}

/* The ID side: Never wraps, never shrinks */
.record-meta {
    text-align: right;
    white-space: nowrap; /* THE FIX: Keeps #PS-0001 on one line */
    flex-shrink: 0;      /* Prevents the ID box from getting squished */
}

.record-id {
    margin: 0;
    font-weight: bold;
    letter-spacing: 1px;
    font-family: monospace; /* Optional: gives it a "Serial Number" look */
}

/* Nav search: align field and button (emoji baseline) */
.nav-search-wrap {
    flex: 1 1 0;
    min-width: 120px;
    max-width: 300px;
    margin: 0 20px;
    display: flex;
    align-items: center;
}

/* Row layout: global `input { width:100% }` would stack the button; force inline flex row */
.nav-search-form {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    margin: 0;
    gap: 0;
}

.nav-search-input {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    max-width: none;
    margin-top: 0;
    padding: 0 12px;
    border-radius: 4px 0 0 4px;
    border: 1px solid var(--border);
    border-right: none;
    background: #0d1117;
    color: #fff;
    font-size: 0.875rem;
    line-height: 1.25;
    height: 34px;
    box-sizing: border-box;
}

.nav-search-submit {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    width: auto;
    padding: 0 10px;
    margin: 0;
    margin-top: 0;
    border-radius: 0 4px 4px 0;
    border: 1px solid var(--border);
    background: var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    height: 34px;
    box-sizing: border-box;
}

.nav-search-submit:hover {
    background: #3d444d;
    color: #c9d1d9;
}

/* Image caption: only when DB has attribution (same tone as former Identification Archive line) */
.img-attribution-block {
    margin: 12px 0 0;
    padding: 0 6px 4px;
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-muted);
    line-height: 1.5;
    letter-spacing: normal;
    text-transform: none;
    opacity: 0.7;
}

.img-attribution-block__label {
    display: block;
    margin: 0;
    padding: 0;
    letter-spacing: 0.12em;
    text-transform: none;
}

.img-attribution-block__value {
    display: block;
    margin: 0.45em 0 0;
    padding: 0;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.5;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/*
 * External credit / provenance URLs (detail captions, primary source links, credits index).
 * Uses slug-link palette so :visited stays readable on dark backgrounds (not browser purple).
 */
a.credit-source-link,
a.img-attribution-block__link {
    color: var(--slug-link);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.16s ease;
}

.img-attribution-block a.credit-source-link,
.img-attribution-block a.img-attribution-block__link {
    font-size: 0.8rem;
    opacity: 1;
}

a.credit-source-link:hover,
a.img-attribution-block__link:hover {
    color: var(--slug-link-hover);
}

a.credit-source-link:visited,
a.img-attribution-block__link:visited {
    color: var(--slug-link-visited);
}

a.credit-source-link:visited:hover,
a.img-attribution-block__link:visited:hover {
    color: var(--slug-link-visited-hover);
}

a.credit-source-link:focus-visible,
a.img-attribution-block__link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/*
 * Slug links — [[...]] glossary markup (person bios, etc.)
 * Reads like body copy with a slight accent tint; hover gets a soft “bubble” ring.
 */
a.slug-link {
    color: var(--slug-link);
    text-decoration: none;
    font-style: normal;
    font-weight: inherit;
    cursor: pointer;
    border-radius: 4px;
    transition:
        color 0.16s ease,
        background-color 0.16s ease,
        box-shadow 0.16s ease;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

a.slug-link:hover {
    color: var(--slug-link-hover);
    background-color: rgba(52, 152, 219, 0.12);
    box-shadow:
        0 0 0 1px rgba(52, 152, 219, 0.45),
        0 0 0 3px rgba(52, 152, 219, 0.06);
}

a.slug-link:visited {
    color: var(--slug-link-visited);
}

a.slug-link:visited:hover {
    color: var(--slug-link-visited-hover);
    background-color: rgba(74, 142, 184, 0.14);
    box-shadow:
        0 0 0 1px rgba(74, 142, 184, 0.5),
        0 0 0 3px rgba(52, 152, 219, 0.05);
}

a.slug-link:focus-visible {
    outline: none;
    color: var(--slug-link-hover);
    background-color: rgba(52, 152, 219, 0.14);
    box-shadow:
        0 0 0 2px var(--accent),
        0 0 0 5px rgba(52, 152, 219, 0.12);
}

/* --- EXTERNAL LINKS HUB (resources_links) --- */

.link-hub-section {
    margin-bottom: 42px;
}

.link-hub-section__title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin: 0 0 18px 0;
}

.link-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.link-hub-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-left: 3px solid var(--border);
    transition: border-left-color 0.2s ease, box-shadow 0.2s ease;
}

.link-hub-card:hover {
    border-left-color: var(--accent);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.link-hub-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.link-hub-card__edit {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 4px;
}

.link-hub-card__edit:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.link-hub-card__title {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.35;
}

.link-hub-card__title a {
    color: #e6edf3;
    text-decoration: none;
}

.link-hub-card__title a:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.link-hub-card__desc {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-muted);
    flex: 1;
}

/* Trust badges (icons via label; colors = scan-friendly) */
.trust-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: bold;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.trust-badge--gov {
    background: rgba(52, 152, 219, 0.12);
    border-color: var(--accent);
    color: #79c0ff;
}

.trust-badge--science {
    background: rgba(35, 134, 54, 0.15);
    border-color: var(--success);
    color: #56d364;
}

.trust-badge--media {
    background: rgba(210, 153, 34, 0.12);
    border-color: #d29922;
    color: #e3b341;
}

.trust-badge--civilian {
    background: rgba(142, 68, 173, 0.15);
    border-color: var(--accent-purple);
    color: #c586f0;
}

/* Admin: destructive delete (detail + edit footers) */
a.admin-delete-record {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #ff7b72 !important;
    text-decoration: none !important;
    border: 1px solid #ff7b72;
    padding: 5px 10px;
    border-radius: 4px;
    text-align: center;
}

a.admin-delete-record:hover {
    background: rgba(255, 123, 114, 0.12);
    color: #ffa198 !important;
}