/* ==========================================================================
   concurrent.day — Analog Computing Nostalgia
   A 1967 university computing laboratory aesthetic
   ========================================================================== */

/* ---------- CSS Custom Properties ---------- */
:root {
    /* Palette */
    --aged-vellum: #f5e6c8;
    --filing-cabinet-gray: #3d3530;
    --typewriter-ink: #2a2018;
    --sunset-amber: #d4863c;
    --burnt-sienna: #9e4a2f;
    --faded-ribbon: #8a6e52;
    --cream-onionskin: #faf2e2;
    --coffee-stained-manila: #e8d0a8;
    --correction-fluid: #f8f4ec;
    --carbon-copy-blue: #6a7a8a;
    --ruled-blue: #b8c8d8;

    /* Typography scale */
    --font-heading: 'Arvo', 'Rockwell', 'Georgia', serif;
    --font-body: 'Courier Prime', 'Courier New', monospace;
    --font-accent: 'Roboto Slab', 'Georgia', serif;

    /* Baseline grid */
    --baseline: 1.75rem;

    /* Layout */
    --content-max-width: 960px;
    --left-margin: clamp(2rem, 10vw, 6rem);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    background-color: var(--filing-cabinet-gray);
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--typewriter-ink);
    background-color: var(--filing-cabinet-gray);
    overflow-x: hidden;
}

/* ---------- Selection ---------- */
::selection {
    background: var(--sunset-amber);
    color: var(--cream-onionskin);
}

/* ---------- Links ---------- */
a {
    color: var(--burnt-sienna);
    text-decoration: none;
    background-image: linear-gradient(currentColor, currentColor);
    background-position: bottom left;
    background-repeat: no-repeat;
    background-size: 0% 2px;
    transition: background-size 250ms ease;
}

a:hover {
    background-size: 100% 2px;
}

/* ---------- Typewriter corrections ---------- */
del {
    text-decoration: line-through;
    color: var(--faded-ribbon);
    opacity: 0.7;
}

ins {
    text-decoration: none;
    color: var(--burnt-sienna);
    font-style: normal;
}

/* ---------- Header Strip ---------- */
.header-strip {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 8vh;
    min-height: 48px;
    background-color: var(--aged-vellum);
    border-bottom: 2px solid var(--coffee-stained-manila);
    z-index: 100;
    display: flex;
    align-items: center;
}

.header-content {
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 var(--left-margin);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-domain {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1rem, 2vw, 1.4rem);
    letter-spacing: 0.04em;
    color: var(--typewriter-ink);
    text-shadow:
        0.5px 0px 0px rgba(42, 32, 24, 0.3),
        -0.3px 0.2px 0px rgba(42, 32, 24, 0.15);
}

.amber-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: var(--sunset-amber);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 530ms infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.header-date {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--faded-ribbon);
}

/* ---------- Navigation Index Card ---------- */
.index-card {
    position: fixed;
    top: calc(8vh + 1rem);
    right: 1.5rem;
    width: 160px;
    background-color: var(--cream-onionskin);
    border: 1px solid var(--coffee-stained-manila);
    box-shadow: 2px 2px 6px rgba(42, 32, 24, 0.1);
    z-index: 99;
    opacity: 0.5;
    transition: opacity 300ms ease, transform 300ms ease, box-shadow 300ms ease;
    padding-bottom: 0.75rem;
}

.index-card:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 2px 4px 10px rgba(42, 32, 24, 0.15);
}

.index-card:hover .index-tab {
    border-bottom-color: var(--sunset-amber);
}

.index-tab {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--faded-ribbon);
    text-align: center;
    padding: 0.35rem 0;
    border-bottom: 2px solid var(--coffee-stained-manila);
    background-color: var(--correction-fluid);
    cursor: pointer;
    transition: border-bottom-color 300ms ease;
}

.index-list {
    list-style: none;
    padding: 0.5rem 1rem;
}

.index-list li {
    margin-bottom: 0.25rem;
}

.index-list a {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: var(--burnt-sienna);
    display: block;
    padding: 0.15rem 0;
    background-image: none;
}

.index-list a:hover {
    color: var(--sunset-amber);
    background-image: none;
}

/* ---------- Section Base ---------- */
.section {
    position: relative;
    width: 100%;
    min-height: 80vh;
    background-color: var(--aged-vellum);
    overflow: hidden;
}

.title-card {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: 8vh;
}

.section-inner {
    position: relative;
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: calc(var(--baseline) * 3) var(--left-margin);
    z-index: 2;
}

/* ---------- Paper Textures ---------- */
.paper-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* Age spots (radial gradients) + edge vignette */
.paper-texture::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 150px 120px at 15% 25%, rgba(232, 208, 168, 0.2), transparent),
        radial-gradient(ellipse 100px 180px at 75% 60%, rgba(232, 208, 168, 0.15), transparent),
        radial-gradient(ellipse 200px 100px at 50% 85%, rgba(232, 208, 168, 0.18), transparent),
        radial-gradient(ellipse at center, transparent 40%, rgba(58, 53, 48, 0.08) 100%);
}

/* Fold crease */
.paper-texture::after {
    content: '';
    position: absolute;
    top: 0;
    left: 45%;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, rgba(138, 110, 82, 0.08) 20%, rgba(138, 110, 82, 0.08) 80%, transparent);
}

.paper-variant-light {
    background-color: var(--cream-onionskin);
}

.section:nth-child(odd) > .paper-texture::after {
    left: auto;
    right: 35%;
}

.paper-variant-dark {
    background-color: var(--coffee-stained-manila);
}

/* Horizontal fold for dark variant */
.paper-variant-dark::after {
    top: 55%;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(138, 110, 82, 0.08) 20%, rgba(138, 110, 82, 0.08) 80%, transparent);
}

/* ---------- Hole-Punch Margin ---------- */
.hole-punch-margin {
    position: absolute;
    left: clamp(0.5rem, 2vw, 1.5rem);
    top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(3rem, 8vh, 6rem);
    z-index: 1;
}

.hole-punch-margin .hole {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--filing-cabinet-gray);
    opacity: 0.2;
}

/* ---------- Red Margin Line ---------- */
.red-margin-line {
    position: absolute;
    top: 0;
    left: var(--left-margin);
    width: 1px;
    height: 100%;
    background-color: var(--burnt-sienna);
    opacity: 0.25;
    z-index: 1;
}

/* ---------- Ruled Lines (Blue) ---------- */
.ruled-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent calc(var(--baseline) - 1px),
        rgba(184, 200, 216, 0.08) calc(var(--baseline) - 1px),
        rgba(184, 200, 216, 0.08) var(--baseline)
    );
    pointer-events: none;
    z-index: 1;
}

/* ---------- Section Numbers ---------- */
.section-number {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    letter-spacing: 0.04em;
    color: var(--burnt-sienna);
    margin-bottom: var(--baseline);
    line-height: 1.2;
}

/* ---------- Headings ---------- */
h1 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4.8rem);
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: var(--typewriter-ink);
    text-shadow:
        0.5px 0px 0px rgba(42, 32, 24, 0.3),
        -0.3px 0.2px 0px rgba(42, 32, 24, 0.15),
        0px 0.5px 0px rgba(42, 32, 24, 0.1);
    margin-bottom: var(--baseline);
}

h2 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: var(--typewriter-ink);
    text-shadow:
        0.3px 0px 0px rgba(42, 32, 24, 0.2),
        -0.2px 0.1px 0px rgba(42, 32, 24, 0.1);
    margin-bottom: calc(var(--baseline) * 1.5);
}

/* ---------- Body Text ---------- */
.section-inner p {
    max-width: 42em;
    margin-bottom: var(--baseline);
    text-align: left;
}

.section-inner p + p {
    text-indent: 2em;
}

.section-inner p.typewriter-phrase {
    text-indent: 0;
}

/* Hero text */
.hero-title {
    font-size: clamp(2.5rem, 6vw, 5rem);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.75;
    color: var(--typewriter-ink);
    max-width: 42em;
    overflow: hidden;
    opacity: 0;
}

/* Typewriter phrase within sections */
.typewriter-phrase {
    font-weight: 700;
    color: var(--typewriter-ink);
    overflow: hidden;
}

/* ---------- Carbon-copy hover effect ---------- */
.content-section:hover .section-inner p {
    text-shadow: 2px 2px 0px rgba(106, 122, 138, 0.02);
    transition: text-shadow 300ms ease;
}

/* ---------- Section hover: paper lift ---------- */
.content-section {
    transition: box-shadow 300ms ease, transform 300ms ease;
}

.content-section:hover {
    box-shadow: 0 2px 8px rgba(42, 32, 24, 0.08);
    transform: translateY(-0.5px);
}

/* ---------- Page Numbers ---------- */
.page-number {
    position: absolute;
    bottom: calc(var(--baseline) * 1.5);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    color: var(--faded-ribbon);
    z-index: 2;
}

/* ---------- Margin Annotations ---------- */
.margin-annotation {
    position: absolute;
    right: clamp(0.5rem, 2vw, 2rem);
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--faded-ribbon);
    transform: rotate(-90deg);
    transform-origin: right center;
    white-space: nowrap;
    z-index: 2;
    opacity: 0.6;
}

/* ---------- Tear Lines (Perforated) ---------- */
.tear-line {
    position: relative;
    width: 100%;
    height: 24px;
    background-color: var(--filing-cabinet-gray);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.tear-dash {
    width: 100%;
    height: 0;
    border-top: 2px dashed rgba(245, 230, 200, 0.3);
}

.tear-holes-top,
.tear-holes-bottom {
    width: 100%;
    height: 8px;
    display: flex;
    justify-content: center;
    gap: 48px;
    align-items: center;
}

.tear-holes-top::before,
.tear-holes-top::after,
.tear-holes-bottom::before,
.tear-holes-bottom::after {
    content: '';
    display: none;
}

/* Generate tractor-feed holes via repeating background */
.tear-holes-top,
.tear-holes-bottom {
    background-image: radial-gradient(circle 3px at center, rgba(245, 230, 200, 0.3) 2.5px, transparent 3px);
    background-size: 48px 8px;
    background-repeat: repeat-x;
    background-position: center;
}

/* ---------- Footer Strip ---------- */
.footer-strip {
    width: 100%;
    min-height: 15vh;
    background-color: var(--filing-cabinet-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--baseline) * 2) var(--left-margin);
}

.footer-content {
    text-align: center;
}

.end-document {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    letter-spacing: 0.12em;
    color: var(--cream-onionskin);
    margin-bottom: calc(var(--baseline) * 0.5);
}

.end-rule {
    font-family: var(--font-body);
    color: var(--faded-ribbon);
    margin-bottom: calc(var(--baseline) * 0.5);
    opacity: 0.5;
}

.filing-notation {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--faded-ribbon);
}

/* ---------- Content Section Scroll Reveal ---------- */
.content-section {
    opacity: 0;
    transform: translateY(12px);
}

.content-section.revealed {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1.0),
                transform 600ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

/* Vignette settling effect */
.content-section .paper-texture::before {
    opacity: 0;
    transition: opacity 900ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.content-section.revealed .paper-texture::before {
    opacity: 1;
}

/* ---------- Typewriter cursor for hero ---------- */
.hero-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background-color: var(--sunset-amber);
    vertical-align: text-bottom;
    animation: blink 530ms infinite;
    margin-left: 1px;
}

/* ---------- Typing character strike effect ---------- */
@keyframes strike {
    0% { transform: translateY(0); }
    30% { transform: translateY(1px); }
    100% { transform: translateY(0); }
}

.char-strike {
    display: inline-block;
    animation: strike 80ms ease-out;
}

/* ---------- Mobile Responsive ---------- */
@media (max-width: 768px) {
    :root {
        --left-margin: 1.5rem;
    }

    .index-card {
        width: auto;
        top: auto;
        bottom: 1rem;
        right: 1rem;
        padding-bottom: 0;
    }

    .index-card .index-list {
        display: none;
        padding: 0.5rem 0.75rem;
    }

    .index-card.expanded .index-list {
        display: block;
    }

    .index-tab {
        padding: 0.5rem 1rem;
        cursor: pointer;
    }

    .hole-punch-margin {
        display: none;
    }

    .red-margin-line {
        left: 1rem;
    }

    .margin-annotation {
        display: none;
    }

    .header-content {
        padding: 0 1.5rem;
    }

    .section-inner {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .hero-title {
        white-space: normal;
    }
}

@media (max-width: 480px) {
    :root {
        --left-margin: 1rem;
    }

    .header-strip {
        height: 56px;
    }

    .title-card {
        padding-top: 56px;
    }

    .index-card {
        bottom: 0.5rem;
        right: 0.5rem;
    }
}
