/* ============================================
   aiice.dev - Victorian Mechanical Computing Laboratory
   ============================================ */

/* CSS Custom Properties (Color Palette) */
:root {
    --obsidian-leather: #1A1210;
    --aged-brass: #B8860B;
    --burnt-sienna: #8B4513;
    --parchment-cream: #F5E6C8;
    --verdigris: #2E8B7A;
    --deep-mahogany: #4A0E0E;
    --gaslight-amber: #E8A317;
    --tarnished-silver: #8A8A7A;
    --dark-umber: #2E1A0E;
    --warm-parchment: #E8D4A8;
    --tooled-dark: #3D2215;
    --cordovan: #5C1A1A;
    --foxing: #C4A87A;

    /* Gradients */
    --hero-gradient: linear-gradient(165deg, #1A1210 0%, #4A0E0E 35%, #2E1A0E 70%, #1A1210 100%);
    --panel-gradient: linear-gradient(180deg, #F5E6C8 0%, #E8D4A8 100%);
    --accent-gradient: linear-gradient(90deg, #B8860B 0%, #E8A317 50%, #B8860B 100%);

    /* Typography */
    --font-heading: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-subheading: 'Cormorant Garamond', Garamond, 'Times New Roman', serif;
    --font-body: 'IBM Plex Mono', 'Courier New', Courier, monospace;
    --font-decorative: 'IM Fell English', Georgia, serif;

    /* Spacing */
    --section-gap: 80px;
    --subsection-gap: 40px;
    --outer-margin: 64px;
    --gutter: 20px;
}

/* ============================================
   BASE RESET & DEFAULTS
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--obsidian-leather);
    color: var(--parchment-cream);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* ============================================
   SPREAD (SECTION) BASE
   ============================================ */
.spread {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ============================================
   TEXTURE BACKGROUNDS
   ============================================ */

/* Tooled Leather */
.tooled-leather-bg {
    position: absolute;
    inset: 0;
    background: var(--hero-gradient);
    z-index: 0;
}

.tooled-leather-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-radial-gradient(circle at 30px 30px, transparent 0, transparent 18px, rgba(61, 34, 21, 0.3) 18px, rgba(61, 34, 21, 0.3) 20px),
        repeating-radial-gradient(circle at 60px 60px, transparent 0, transparent 12px, rgba(61, 34, 21, 0.2) 12px, rgba(61, 34, 21, 0.2) 14px);
    background-size: 80px 80px, 60px 60px;
    opacity: 0.6;
}

.tooled-leather-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
    opacity: 0.08;
    pointer-events: none;
}

/* Vellum (aged parchment) */
.vellum-bg {
    position: absolute;
    inset: 0;
    background: var(--panel-gradient);
    z-index: 0;
}

.vellum-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    opacity: 0.4;
    pointer-events: none;
}

.vellum-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 15% 25%, var(--foxing) 0%, transparent 2%),
        radial-gradient(circle at 72% 18%, var(--foxing) 0%, transparent 1.5%),
        radial-gradient(circle at 45% 82%, var(--foxing) 0%, transparent 2.5%),
        radial-gradient(circle at 88% 65%, var(--foxing) 0%, transparent 1.8%),
        radial-gradient(circle at 30% 55%, var(--foxing) 0%, transparent 1.2%),
        radial-gradient(circle at 60% 40%, var(--foxing) 0%, transparent 2%),
        radial-gradient(circle at 8% 72%, var(--foxing) 0%, transparent 1.4%),
        radial-gradient(circle at 92% 35%, var(--foxing) 0%, transparent 1.6%);
    opacity: 0.1;
    pointer-events: none;
}

/* Smooth Cordovan */
.cordovan-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, var(--cordovan) 0%, var(--deep-mahogany) 60%, #2A0808 100%);
    z-index: 0;
}

.cordovan-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 50%, rgba(255,255,255,0.01) 100%);
    pointer-events: none;
}

.cordovan-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
    opacity: 0.06;
    pointer-events: none;
}

/* ============================================
   HERO SECTION
   ============================================ */
.spread--hero {
    justify-content: center;
    padding: var(--outer-margin);
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 900px;
}

.hero-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 5.5rem);
    color: var(--aged-brass);
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin-bottom: 0.3em;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 40px rgba(184, 134, 11, 0.15);
}

.hero-title em {
    font-style: italic;
}

.hero-title-dot {
    color: var(--verdigris);
}

.hero-masthead {
    display: flex;
    align-items: center;
    gap: 24px;
    justify-content: center;
    margin-top: 20px;
}

.masthead-rule {
    display: block;
    flex: 1;
    max-width: 120px;
    height: 1px;
    background: var(--accent-gradient);
}

.masthead-text {
    font-family: var(--font-body);
    font-size: clamp(0.75rem, 1.2vw, 1.1rem);
    color: var(--tarnished-silver);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ============================================
   ORNAMENTAL DIVIDERS
   ============================================ */
.ornamental-divider {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 600px;
    margin: var(--subsection-gap) auto;
    display: flex;
    justify-content: center;
}

.divider-svg {
    width: 100%;
    height: 40px;
    color: var(--aged-brass);
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
}

.divider-svg.drawn {
    animation: drawDivider 1.2s ease-out forwards;
}

@keyframes drawDivider {
    to {
        stroke-dashoffset: 0;
    }
}

.hero-divider {
    margin-top: 60px;
}

/* ============================================
   SCROLL INDICATOR (MANICULE)
   ============================================ */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    animation: bobDown 2s ease-in-out infinite;
}

.manicule {
    width: 32px;
    height: 48px;
    color: var(--aged-brass);
    opacity: 0.7;
}

@keyframes bobDown {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(10px); }
}

/* ============================================
   FLOATING ELEMENTS
   ============================================ */
.floating-gear,
.floating-element {
    position: absolute;
    z-index: 1;
    pointer-events: none;
    will-change: transform;
}

.floating-gear {
    color: var(--aged-brass);
    opacity: 0.35;
    filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.4));
}

.floating-gear--large svg {
    width: 120px;
    height: 120px;
}

.floating-gear--medium svg {
    width: 80px;
    height: 80px;
}

.floating-gear--small svg {
    width: 48px;
    height: 48px;
}

@keyframes rotateGear {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes rotateGearReverse {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-4px) rotate(1.5deg); }
    50% { transform: translateY(-8px) rotate(0deg); }
    75% { transform: translateY(-4px) rotate(-1.5deg); }
}

@keyframes floatSlow {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    33% { transform: translateY(-6px) rotate(2deg); }
    66% { transform: translateY(-3px) rotate(-1deg); }
}

.floating-gear svg {
    animation: rotateGear 60s linear infinite;
}

.floating-gear:nth-child(even) svg {
    animation-name: rotateGearReverse;
}

.floating-element {
    animation: float 6s ease-in-out infinite;
}

.floating-element:nth-child(even) {
    animation: floatSlow 8s ease-in-out infinite;
}

/* ============================================
   MAGAZINE LAYOUT (Two-column)
   ============================================ */
.spread-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1200px;
    padding: var(--section-gap) var(--outer-margin);
}

.magazine-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--subsection-gap);
}

/* ============================================
   TYPOGRAPHY - ARTICLE SECTIONS
   ============================================ */
.section-heading {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: var(--burnt-sienna);
    letter-spacing: 0.02em;
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

.spread--article .section-heading,
.spread--article .body-text,
.spread--article .pull-quote blockquote {
    color: var(--obsidian-leather);
}

.spread--technical .section-heading,
.spread--technical .body-text {
    color: var(--obsidian-leather);
}

.drop-cap {
    font-family: var(--font-decorative);
    font-size: 4em;
    float: left;
    line-height: 0.75;
    margin-right: 0.08em;
    margin-top: 0.05em;
    color: var(--aged-brass);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.drop-cap.visible {
    opacity: 1;
    transform: scale(1);
}

.body-text {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--parchment-cream);
    margin-bottom: 1.25rem;
}

.body-text em {
    font-style: italic;
    color: var(--verdigris);
}

/* ============================================
   PULL QUOTES
   ============================================ */
.pull-quote {
    position: relative;
    margin: var(--subsection-gap) -20px;
    padding: 30px 40px;
    text-align: center;
}

.pull-quote blockquote {
    font-family: var(--font-subheading);
    font-style: italic;
    font-weight: 500;
    font-size: clamp(1.2rem, 2vw, 2rem);
    line-height: 1.5;
    letter-spacing: 0.04em;
    color: var(--burnt-sienna);
}

.pull-quote-mark {
    font-family: var(--font-decorative);
    font-size: 4rem;
    color: var(--aged-brass);
    line-height: 1;
    position: absolute;
    opacity: 0.6;
}

.pull-quote-mark:first-child {
    top: -10px;
    left: 10px;
}

.pull-quote-mark--end {
    bottom: -30px;
    right: 10px;
}

/* ============================================
   SIDEBAR COLUMN
   ============================================ */
.sidebar-column {
    display: flex;
    flex-direction: column;
    gap: 30px;
    position: relative;
}

/* ============================================
   SPECIMEN CARDS
   ============================================ */
.specimen-card {
    background: var(--parchment-cream);
    border: 1px solid var(--aged-brass);
    padding: 24px 20px 20px;
    position: relative;
    box-shadow:
        inset 0 1px 3px rgba(0,0,0,0.1),
        0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: default;
}

.specimen-card:hover {
    transform: scale(1.04);
}

.specimen-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--aged-brass);
}

.specimen-number {
    font-family: var(--font-decorative);
    font-size: 0.9rem;
    color: var(--aged-brass);
}

.specimen-class {
    font-family: var(--font-subheading);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--tarnished-silver);
}

.specimen-title {
    font-family: var(--font-subheading);
    font-weight: 600;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: var(--burnt-sienna);
    margin-bottom: 8px;
    letter-spacing: 0.04em;
}

.specimen-body {
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.65;
    color: var(--obsidian-leather);
}

.specimen-pin {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--aged-brass);
}

.specimen-pin svg {
    width: 16px;
    height: 24px;
}

/* ============================================
   SPECIMEN LABELS (floating tags)
   ============================================ */
.specimen-label {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    align-self: flex-start;
    cursor: default;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.specimen-label:hover {
    transform: scale(1.04) translateY(-4px);
}

.specimen-label-pin svg {
    width: 12px;
    height: 18px;
}

.specimen-label-text {
    font-family: var(--font-subheading);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--burnt-sienna);
    background: var(--parchment-cream);
    border: 1px solid var(--aged-brass);
    padding: 4px 12px;
    white-space: nowrap;
}

/* ============================================
   PUNCH CARDS
   ============================================ */
.punch-card {
    position: relative;
    filter: drop-shadow(2px 4px 8px rgba(0,0,0,0.2));
    cursor: default;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.punch-card:hover {
    transform: scale(1.04) perspective(500px) rotateX(2deg) rotateY(-2deg);
}

.punch-card svg {
    width: 200px;
    height: 90px;
}

/* ============================================
   FILIGREE CORNER ORNAMENTS
   ============================================ */
.filigree {
    position: absolute;
    z-index: 3;
    color: var(--verdigris);
    opacity: 0.5;
    pointer-events: none;
}

.filigree svg {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 0 6px rgba(46, 139, 122, 0.25));
}

.filigree--top-left {
    top: 40px;
    left: 40px;
}

.filigree--top-right {
    top: 40px;
    right: 40px;
}

.filigree--bottom-left {
    bottom: 40px;
    left: 40px;
}

.filigree--bottom-right {
    bottom: 40px;
    right: 40px;
}

/* ============================================
   FEATURE SPREAD
   ============================================ */
.spread--feature {
    padding: var(--section-gap) var(--outer-margin);
}

.feature-content {
    position: relative;
    z-index: 2;
    max-width: 700px;
    text-align: center;
}

.feature-epigraph {
    font-family: var(--font-decorative);
    font-size: clamp(1.1rem, 2vw, 1.6rem);
    color: var(--parchment-cream);
    line-height: 1.6;
    margin-bottom: 12px;
    opacity: 0.9;
}

.feature-attribution {
    font-family: var(--font-subheading);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--tarnished-silver);
    letter-spacing: 0.04em;
    margin-bottom: var(--subsection-gap);
}

.feature-thesis {
    text-align: left;
}

.feature-thesis p {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    line-height: 1.85;
    color: var(--parchment-cream);
    margin-bottom: 1.5rem;
    letter-spacing: 0.01em;
}

.feature-thesis strong {
    color: var(--gaslight-amber);
    font-weight: 600;
}

/* ============================================
   CODE SPECIMEN BLOCKS
   ============================================ */
.code-specimen {
    background: var(--obsidian-leather);
    border: 1px solid var(--aged-brass);
    margin: var(--subsection-gap) 0;
    box-shadow:
        inset 0 2px 6px rgba(0,0,0,0.3),
        0 4px 16px rgba(0,0,0,0.2);
}

.code-specimen-header {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(184, 134, 11, 0.3);
    background: rgba(184, 134, 11, 0.08);
}

.code-specimen-title {
    font-family: var(--font-subheading);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--aged-brass);
    letter-spacing: 0.04em;
    font-variant: small-caps;
}

.code-specimen-body {
    padding: 20px;
}

.code-line {
    display: flex;
    gap: 16px;
    line-height: 2;
}

.line-number {
    font-family: var(--font-decorative);
    font-size: 0.85rem;
    color: var(--tarnished-silver);
    min-width: 28px;
    text-align: right;
    user-select: none;
    opacity: 0.7;
}

.code-text {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--parchment-cream);
    letter-spacing: 0.02em;
    white-space: pre;
}

/* ============================================
   COLOPHON / CLOSING SPREAD
   ============================================ */
.spread--colophon {
    padding: var(--section-gap) var(--outer-margin);
}

.colophon-divider {
    margin-bottom: 60px;
}

.colophon-content {
    position: relative;
    z-index: 2;
    max-width: 600px;
    text-align: center;
}

.colophon-heading {
    font-family: var(--font-subheading);
    font-weight: 500;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--aged-brass);
    margin-bottom: 24px;
}

.colophon-text {
    margin-bottom: var(--subsection-gap);
}

.colophon-body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.75;
    color: var(--tarnished-silver);
    margin-bottom: 1rem;
}

/* Printer's Mark */
.printers-mark {
    margin: var(--subsection-gap) auto;
    color: var(--aged-brass);
    opacity: 0.6;
    cursor: default;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.printers-mark:hover {
    transform: scale(1.04);
    opacity: 0.9;
}

.printers-mark svg {
    width: 80px;
    height: 96px;
}

/* Credits */
.colophon-credits {
    margin-top: var(--subsection-gap);
    text-align: left;
    display: inline-block;
}

.credit-line {
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 2;
    color: var(--tarnished-silver);
}

.credit-label {
    font-family: var(--font-subheading);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: var(--aged-brass);
    display: inline-block;
    min-width: 100px;
    margin-right: 12px;
}

.colophon-closing {
    margin-top: var(--subsection-gap);
    font-family: var(--font-decorative);
    font-size: 1.4rem;
    color: var(--aged-brass);
    opacity: 0.7;
}

/* ============================================
   SECTION REVEAL ANIMATIONS
   ============================================ */
.spread--article .main-column > *,
.spread--article .sidebar-column > *,
.spread--technical .main-column > *,
.spread--technical .sidebar-column > *,
.spread--feature .feature-content > *,
.spread--colophon .colophon-content > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.spread--article .main-column > .revealed,
.spread--article .sidebar-column > .revealed,
.spread--technical .main-column > .revealed,
.spread--technical .sidebar-column > .revealed,
.spread--feature .feature-content > .revealed,
.spread--colophon .colophon-content > .revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   ENGRAVED BORDER FOR CONTENT PANELS
   ============================================ */
.spread--article .spread-content::before,
.spread--technical .spread-content::before {
    content: '';
    position: absolute;
    inset: 20px;
    border: 1px solid rgba(184, 134, 11, 0.15);
    box-shadow: inset 0 0 12px rgba(0,0,0,0.05);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 900px) {
    :root {
        --outer-margin: 24px;
        --section-gap: 48px;
        --subsection-gap: 24px;
    }

    .magazine-layout {
        grid-template-columns: 1fr;
    }

    .sidebar-column {
        order: 2;
    }

    .hero-masthead {
        flex-direction: column;
        gap: 12px;
    }

    .masthead-text {
        white-space: normal;
        text-align: center;
    }

    .masthead-rule {
        display: none;
    }

    .filigree--top-left,
    .filigree--top-right,
    .filigree--bottom-left,
    .filigree--bottom-right {
        display: none;
    }

    .floating-gear--large svg {
        width: 80px;
        height: 80px;
    }

    .floating-gear--medium svg {
        width: 56px;
        height: 56px;
    }

    .floating-gear--small svg {
        width: 36px;
        height: 36px;
    }

    .pull-quote {
        margin: 20px 0;
        padding: 20px;
    }

    .pull-quote-mark {
        font-size: 3rem;
    }

    .spread--article .spread-content::before,
    .spread--technical .spread-content::before {
        inset: 10px;
    }
}

@media (max-width: 600px) {
    :root {
        --outer-margin: 16px;
    }

    .hero-title {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    .specimen-card {
        padding: 18px 14px 14px;
    }

    .code-specimen-body {
        padding: 12px;
        overflow-x: auto;
    }

    .code-text {
        font-size: 12px;
    }

    .punch-card svg {
        width: 160px;
        height: 72px;
    }

    .ornamental-divider {
        max-width: 100%;
        padding: 0 16px;
    }
}
