/* ============================================================
   diplomatic.quest — Declassified Dossier Aesthetic
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --parchment-base: #f4e8c1;
    --document-white: #faf6eb;
    --ink-primary: #2c2416;
    --stamp-vermillion: #c4453a;
    --brass-accent: #b8860b;
    --leather-dark: #4a3728;
    --redacted-black: #1a1a1a;
    --shadow-warm: #d4a857;

    --font-display: 'Roboto Slab', serif;
    --font-body: 'Courier Prime', 'Courier New', monospace;
    --font-accent: 'Special Elite', cursive;

    --content-width: 680px;
    --section-padding: clamp(3rem, 6vw, 6rem);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.75;
    color: var(--ink-primary);
    background-color: var(--parchment-base);
    overflow-x: hidden;
}

/* --- Aged Paper Texture (CSS-only) --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(212, 168, 87, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 50%, rgba(212, 168, 87, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(180, 140, 60, 0.05) 0%, transparent 55%);
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Hero Section --- */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--parchment-base);
    z-index: 1;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(244, 232, 193, 1) 0%, transparent 70%),
        radial-gradient(ellipse at 20% 70%, rgba(212, 168, 87, 0.03) 0%, transparent 50%);
    z-index: 0;
}

.hero-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 20%, rgba(212, 168, 87, 0.08) 0%, transparent 60%);
    z-index: 1;
    transition: opacity 0.3s ease;
}

.hero-seal-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    z-index: 1;
    opacity: 0.6;
    pointer-events: none;
}

.hero-seal-watermark svg {
    width: 100%;
    height: 100%;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: var(--content-width);
    padding: 0 2rem;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 7vw, 6rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--ink-primary);
    display: inline;
    line-height: 1.2;
}

.hero-cursor {
    display: inline-block;
    width: 0;
    height: clamp(2.5rem, 7vw, 6rem);
    border-right: 3px solid var(--ink-primary);
    vertical-align: bottom;
    margin-left: 2px;
    animation: blink 0.8s step-end infinite;
}

.hero-cursor.fade-out {
    animation: cursorFadeOut 0.5s ease forwards;
}

@keyframes blink {
    0%, 100% { border-color: var(--ink-primary); }
    50% { border-color: transparent; }
}

@keyframes cursorFadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.hero-subtitle {
    font-family: var(--font-accent);
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
    letter-spacing: 0.2em;
    color: var(--stamp-vermillion);
    margin-top: 1.5rem;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.hero-subtitle.visible {
    opacity: 1;
}

/* --- Section Dividers --- */
.section-divider {
    position: relative;
    text-align: center;
    padding: 2rem 0;
    z-index: 1;
}

.typewriter-rule {
    font-family: var(--font-accent);
    font-size: 1.2rem;
    color: var(--ink-primary);
    letter-spacing: 0.3em;
    text-shadow: 0.5px 0.5px 0px rgba(44, 36, 22, 0.3);
    opacity: 0.5;
}

.declassified-stamp {
    font-family: var(--font-accent);
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: var(--stamp-vermillion);
    opacity: 0.06;
    transform: rotate(-12deg);
    letter-spacing: 0.15em;
    margin-top: -0.5rem;
    pointer-events: none;
    text-transform: uppercase;
}

/* --- Cable Sections --- */
.cable-section {
    position: relative;
    z-index: 1;
    padding: var(--section-padding) 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.cable-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Carbon copy ghost text */
.cable-section::after {
    content: attr(data-heading);
    position: absolute;
    top: calc(var(--section-padding) + 3px);
    left: calc(50% - var(--content-width) / 2 + 2px + 2rem);
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--shadow-warm);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

/* Paper texture variation per section */
.cable-section:nth-child(odd) {
    --texture-x: 40%;
    --texture-y: 30%;
    background:
        radial-gradient(ellipse at var(--texture-x) var(--texture-y), rgba(212, 168, 87, 0.03) 0%, transparent 50%);
}

.cable-section:nth-child(even) {
    --texture-x: 60%;
    --texture-y: 60%;
    background:
        radial-gradient(ellipse at var(--texture-x) var(--texture-y), rgba(212, 168, 87, 0.04) 0%, transparent 55%),
        linear-gradient(to bottom, var(--parchment-base), var(--document-white), var(--parchment-base));
}

.cable-content {
    max-width: var(--content-width);
    margin: 0 auto;
    position: relative;
}

/* Ring-binder margin line on wide screens */
@media (min-width: 1200px) {
    .cable-content {
        border-left: 1px solid rgba(139, 90, 43, 0.15);
        padding-left: 2rem;
    }
}

/* --- Cable Header (Memorandum Fields) --- */
.cable-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(74, 55, 40, 0.2);
}

.cable-field {
    font-family: var(--font-body);
    font-size: clamp(0.85rem, 1vw, 1rem);
    line-height: 2;
    display: flex;
    gap: 0.5rem;
}

.cable-field::before {
    content: attr(data-label);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(0.8rem, 0.9vw, 0.95rem);
    letter-spacing: 0.08em;
    color: var(--ink-primary);
    white-space: nowrap;
    min-width: 90px;
}

.cable-field::after {
    content: attr(data-value);
    flex: 1;
    border-bottom: 1px dashed var(--brass-accent);
    padding-bottom: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cable-field.typed::after {
    opacity: 1;
}

/* --- Cable Body --- */
.cable-body {
    text-align: justify;
}

.cable-body p {
    margin-bottom: 1.5rem;
    text-indent: 2rem;
}

.cable-body p:first-child {
    text-indent: 0;
}

/* --- Redaction Effect --- */
.redacted {
    position: relative;
    background-color: var(--redacted-black);
    color: transparent;
    padding: 0.05em 0.15em;
    cursor: pointer;
    filter: blur(0.5px);
    transition:
        background-color 0.4s ease,
        color 0.3s ease 0.1s,
        filter 0.3s ease;
    text-decoration: none;
    border-radius: 1px;
}

.redacted:hover,
.redacted.revealed {
    background-color: transparent;
    color: var(--stamp-vermillion);
    filter: blur(0);
    transform: scale(1.02);
}

/* --- Retro Border Pattern --- */
.cable-section:nth-child(4n+3) .cable-content::before {
    content: '';
    position: absolute;
    top: -1rem;
    left: -1rem;
    right: -1rem;
    bottom: -1rem;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent calc(100% - 2px),
            rgba(184, 134, 11, 0.08) calc(100% - 2px),
            rgba(184, 134, 11, 0.08) 100%
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent calc(100% - 2px),
            rgba(184, 134, 11, 0.08) calc(100% - 2px),
            rgba(184, 134, 11, 0.08) 100%
        );
    pointer-events: none;
    z-index: -1;
}

/* --- Footer --- */
.footer {
    position: relative;
    z-index: 1;
    padding: 4rem 2rem 6rem;
    background: linear-gradient(to bottom, var(--parchment-base), rgba(74, 55, 40, 0.08));
    text-align: center;
}

.footer-content {
    max-width: var(--content-width);
    margin: 0 auto;
}

.cable-ends {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--ink-primary);
    margin-bottom: 3rem;
    text-shadow: 0.5px 0.5px 0px rgba(44, 36, 22, 0.3);
}

.footer-seal {
    width: 150px;
    height: 150px;
    margin: 0 auto 2rem;
}

.seal-rosette {
    width: 100%;
    height: 100%;
}

.footer-classification {
    font-family: var(--font-accent);
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    color: var(--leather-dark);
    opacity: 0.5;
    margin-top: 2rem;
}

/* --- Selection styling --- */
::selection {
    background-color: var(--shadow-warm);
    color: var(--ink-primary);
}

/* --- Scrollbar Styling (Webkit) --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--parchment-base);
}

::-webkit-scrollbar-thumb {
    background: var(--leather-dark);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--brass-accent);
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .cable-field {
        flex-direction: column;
        gap: 0;
    }

    .cable-field::before {
        min-width: auto;
    }

    .cable-field::after {
        margin-left: 0;
    }

    .hero-seal-watermark {
        width: 300px;
        height: 300px;
    }

    .cable-section::after {
        display: none;
    }

    .cable-body p {
        text-indent: 1rem;
    }
}

/* --- Divider section reveal --- */
.section-divider {
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.section-divider.visible {
    opacity: 1;
}
