/* ─── TOKENS ───────────────────────────────────────────────────── */
:root {
    --red:        #9c140a;
    --red-dark:   #7a0f08;
    --red-light:  #ca1a0a;
    --white:      #ffffff;
    --off-white:  #fafaf8;
    --light-bg:   #d1cab0;
    --text:       #393939;
    --text-muted: #666;
    --border:     #ddd;
    --font:       'Lato', sans-serif;
    --mono:       'Courier New', Courier, monospace;
}

/* ─── RESET ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; height: 100%; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--off-white);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── HEADER / TOP BAR ─────────────────────────────────────────── */
.site-header { width: 100%; }

.header-top {
    background: var(--white);
    border-bottom: 1px solid rgba(156, 20, 10, 0.15);
    position: relative;
    z-index: 10;
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-img {
    height: 44px;
    width: auto;
    display: block;
}

.logo-mark {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--red);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.logo-divider {
    color: var(--light-bg);
    font-weight: 300;
    font-size: 1.2rem;
}

.logo-sub {
    font-size: 0.88rem;
    font-weight: 400;
    color: var(--red);
}

/* ─── NAV ──────────────────────────────────────────────────────── */
.site-nav {
    display: flex;
    align-items: center;
    gap: 28px;
}

.site-nav a {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--red);
    text-decoration: none;
    padding: 4px 0;
    position: relative;
    transition: opacity 0.2s;
}

.site-nav a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--red);
    transition: width 0.2s ease;
}

.site-nav a:hover::after,
.site-nav a.nav-active::after { width: 100%; }
.site-nav a.nav-active { font-weight: 600; }

/* ─── HERO BANNER ──────────────────────────────────────────────── */
.hero-banner {
    position: relative;
    height: 300px;
    background:
        linear-gradient(90deg, rgba(156,20,10,0.92) 0%, rgba(201,26,10,0.60) 60%, rgba(50,10,5,0.50) 100%),
        linear-gradient(135deg, #1a0502 0%, #2d0b07 40%, #0d1a1f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hero-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
}

.hero-banner--slim { height: 180px; }

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 0 32px;
    max-width: 860px;
}

.hero-content h1 {
    font-size: clamp(1.3rem, 2.8vw, 1.9rem);
    font-weight: 700;
    color: var(--white);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.3;
    margin-bottom: 12px;
}

.hero-content h2 {
    font-size: clamp(0.85rem, 1.6vw, 1rem);
    font-weight: 300;
    color: rgba(255,255,255,0.85);
    letter-spacing: 0.02em;
    line-height: 1.6;
}

/* ─── MAIN ─────────────────────────────────────────────────────── */
.site-main {
    padding: 48px 16px 64px;
    flex: 1;
}

.content-container {
    max-width: 860px;
    margin: 0 auto;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 40px 48px;
}

.content-container--wide { max-width: 980px; }

/* ─── SECTIONS ─────────────────────────────────────────────────── */
.section-block { padding: 24px 0; }

.section-heading {
    font-size: 1.55rem;
    font-weight: 600;
    color: var(--red);
    letter-spacing: 0.02em;
    margin-bottom: 20px;
    text-align: center;
}

.section-block > p {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text);
}

.section-divider {
    height: 1px;
    background: #000;
    margin: 8px 0;
    opacity: 0.12;
}

.section-block--centered > p { text-align: center; }

/* ─── FILE LIST ────────────────────────────────────────────────── */
.file-list {
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 24px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.file-row:last-child { border-bottom: none; }
.file-row:hover { background: #fdf5f4; }

.file-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.file-name {
    font-family: var(--mono);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.file-desc {
    font-size: 0.87rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 4px;
}

/* ─── BUTTON GROUP ─────────────────────────────────────────────── */
.btn-group {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* ─── BUTTONS ──────────────────────────────────────────────────── */
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    background: var(--red);
    color: var(--white);
    font-family: var(--font);
    font-size: 0.83rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 100px;
    white-space: nowrap;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.download-btn:hover { background: var(--red-dark); transform: translateY(-1px); }
.download-btn:active { transform: translateY(0); }

.download-btn--secondary {
    background: transparent;
    color: var(--red);
    border: 2px solid var(--red);
}
.download-btn--secondary:hover { background: var(--red); color: var(--white); }

.download-btn--ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.download-btn--ghost:hover { border-color: var(--red); color: var(--red); background: transparent; }

/* ─── README HEADER (download buttons + partner logos) ─────────── */
.readme-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

/* .readme-logos is the class used in the HTML template */
.readme-logo-group,
.readme-logos {
    display: flex;
    align-items: center;
    gap: 18px;
}

/* Scale label text down so CGDC item height matches the PCGL logo */
.readme-logos .funding-label {
    line-height: 1.25;
}

.readme-logos .funding-label span {
    font-size: 0.40rem;
}

.readme-logo {
    height: 60px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    opacity: 0.95;
}

/* ─── MARKDOWN BODY ────────────────────────────────────────────── */
.markdown-body {
    font-size: 0.96rem;
    line-height: 1.8;
    color: var(--text);
}

.markdown-body h1 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--red);
    margin: 36px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(156,20,10,0.15);
}

.markdown-body h1:first-child { margin-top: 0; }

.markdown-body h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin: 28px 0 10px;
}

.markdown-body h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 20px 0 8px;
}

.markdown-body p { margin-bottom: 14px; }

.markdown-body ul, .markdown-body ol {
    padding-left: 24px;
    margin-bottom: 14px;
}

.markdown-body li { margin-bottom: 6px; }

.markdown-body ul ul,
.markdown-body ol ul {
    margin-top: 6px;
    margin-bottom: 6px;
}

.markdown-body code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: #f4f0ed;
    color: var(--red-dark);
    padding: 2px 5px;
    border-radius: 3px;
}

.markdown-body pre {
    background: #f4f0ed;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px 20px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: var(--text);
    font-size: 0.88rem;
}

.markdown-body strong { font-weight: 700; color: var(--text); }

.markdown-body a {
    color: var(--red);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.markdown-body a:hover { color: var(--red-dark); }

.markdown-body blockquote {
    border-left: 3px solid var(--red);
    margin: 0 0 14px;
    padding: 8px 16px;
    color: var(--text-muted);
    font-style: italic;
}

/* ─── MARKDOWN TABLES ──────────────────────────────────────────── */
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 20px;
    font-size: 0.92rem;
}

.markdown-body table th {
    background: #f4f0ed;
    color: var(--text);
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    border: 1px solid var(--border);
    letter-spacing: 0.02em;
}

.markdown-body table td {
    padding: 9px 14px;
    border: 1px solid var(--border);
    color: var(--text);
    vertical-align: top;
}

.markdown-body table tr:nth-child(even) td { background: #fafaf8; }
.markdown-body table tr:hover td { background: #fdf5f4; }

/* ─── CONTACT CARD ─────────────────────────────────────────────── */
.contact-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
    padding: 28px 32px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fdf9f8;
}

.contact-line { justify-content: center; }
.contact-icon { color: var(--red); flex-shrink: 0; margin-top: 4px; }

.contact-details h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.contact-line svg { flex-shrink: 0; color: var(--red); }

/* ─── FUNDING (inline small acknowledgement text) ──────────────── */
.funding-block p {
    font-size: 0.84rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.7;
}

/* ─── FUNDING PAGE ─────────────────────────────────────────────── */
/* 2×2 grid — fixed column width keeps logos snug together */
.funding-logos {
    display: grid;
    grid-template-columns: repeat(2, auto);
    justify-content: center;  /* centres the whole grid horizontally */
    gap: 32px 48px;           /* row-gap col-gap — tweak col-gap to taste */
    margin-top: 32px;
    align-items: center;
    justify-items: center;
}

.funding-logos img {
    max-height: 80px;
    width: auto;
    object-fit: contain;
}

/* Each logo + label pair */
.funding-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.funding-item img {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.funding-label {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    text-align: left;
}

.funding-label span {
    font-size: 0.55rem;
    opacity: 1.0;
    margin-bottom: 4px;
}

.funding-label .en { margin-bottom: 4px; }

/* ─── FOOTER ───────────────────────────────────────────────────── */
.site-footer {
    margin-top: auto;
    background: var(--red);
    color: var(--white);
    border-top: 1px solid rgba(255,255,255,0.08);
}

.footer-main {
    padding: 22px 16px;
}

.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

.footer-column--logo { flex-shrink: 0; }

.footer-cfi-logo {
    display: block;
    width: 180px;
    max-width: 100%;
    height: auto;
    opacity: 0.95;
}

.footer-column--text { text-align: left; }

.footer-column--text p {
    margin: 0;
    line-height: 1.5;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.88);
    letter-spacing: 0.01em;
}

.footer-column--text p + p { margin-top: 4px; }

.footer-column--text a {
    color: rgba(255,255,255,0.95);
    text-decoration: none;
}

.footer-column--text a:hover { text-decoration: underline; }

/* ─── SCROLLBAR ────────────────────────────────────────────────── */
html {
    font-size: 16px;
    scroll-behavior: smooth;
    height: 100%;
    overflow-y: scroll;
}

/* ─── PLOTS ────────────────────────────────────────────────────── */
.structure-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 8px;
    align-items: start;
}

.structure-figure {
    position: relative;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px;
}

.structure-figure img {
    width: 100%;
    height: auto;
    display: block;
}

.figure-label {
    position: absolute;
    top: 8px;
    left: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

.figure-caption {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* ─── RESPONSIVE ───────────────────────────────────────────────── */
@media (max-width: 800px) {
    .structure-panel { grid-template-columns: 1fr; }
    .readme-header { flex-direction: column; align-items: center; text-align: center; }
    .readme-logo-group { justify-content: center; }
}

@media (max-width: 768px) {
    .footer-main { padding: 20px 16px; }
    .footer-inner { flex-direction: column; text-align: center; gap: 18px; padding: 0 20px; }
    .footer-column--text { text-align: center; }
    .footer-cfi-logo { width: 150px; }
    .funding-item { flex-direction: column; text-align: center; }
    .funding-label { text-align: center; }
    .funding-logos { grid-template-columns: repeat(2, auto); gap: 24px 32px; }
}

@media (max-width: 700px) {
    .header-inner  { flex-direction: column; height: auto; padding: 16px; gap: 12px; }
    .site-nav      { gap: 16px; flex-wrap: wrap; justify-content: center; }
    .hero-banner   { height: 220px; }
    .hero-banner--slim { height: 160px; }
    .content-container { padding: 24px 20px; }
    .file-row      { flex-direction: column; align-items: flex-start; }
    .btn-group     { width: 100%; }
    .contact-card  { padding: 20px; }
    .funding-logos { grid-template-columns: 1fr; }
}
