/* ============================================
   sim-ai.com - Dark Academia meets Speculative Science
   ============================================ */

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

:root {
    --aged-walnut: #120e0a;
    --library-dusk: #1e1814;
    --amber-gold: #c9a84c;
    --old-parchment: #e8dcc4;
    --foxed-cream: #d4c4a0;
    --verdigris-tint: #5a8a6e;
    --ink-shadow: #2a2218;
    --inference-amber: #e8b44c;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--aged-walnut);
    color: var(--old-parchment);
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.7;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Grain Overlay --- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    filter: url(#grain);
    opacity: 0.08;
    mix-blend-mode: overlay;
    pointer-events: none;
    z-index: 9999;
}

/* --- Observatory Frame (Border-Animate) --- */
.observatory-frame {
    position: fixed;
    inset: 16px;
    pointer-events: none;
    z-index: 100;
}

.frame-edge {
    position: absolute;
    background: var(--amber-gold);
}

.frame-top {
    width: calc(100% - 0px);
    height: 1px;
    top: 0;
    left: 0;
    transform-origin: left;
    transform: scaleX(0);
    animation: frame-draw-x 200ms cubic-bezier(0.4, 0, 0.2, 1) 300ms forwards;
}

.frame-right {
    width: 1px;
    height: calc(100% - 0px);
    top: 0;
    right: 0;
    transform-origin: top;
    transform: scaleY(0);
    animation: frame-draw-y 200ms cubic-bezier(0.4, 0, 0.2, 1) 500ms forwards;
}

.frame-bottom {
    width: calc(100% - 0px);
    height: 1px;
    bottom: 0;
    right: 0;
    transform-origin: right;
    transform: scaleX(0);
    animation: frame-draw-x 200ms cubic-bezier(0.4, 0, 0.2, 1) 700ms forwards;
}

.frame-left {
    width: 1px;
    height: calc(100% - 0px);
    bottom: 0;
    left: 0;
    transform-origin: bottom;
    transform: scaleY(0);
    animation: frame-draw-y 200ms cubic-bezier(0.4, 0, 0.2, 1) 900ms forwards;
}

@keyframes frame-draw-x {
    to { transform: scaleX(1); }
}

@keyframes frame-draw-y {
    to { transform: scaleY(1); }
}

/* --- Scanning Line --- */
.scanning-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 1px;
    background: var(--inference-amber);
    opacity: 0.15;
    z-index: 98;
    pointer-events: none;
    animation: scanning 20s linear infinite;
    animation-delay: 2s;
}

@keyframes scanning {
    0% { top: 0; }
    100% { top: 100vh; }
}

/* --- Hero Section --- */
.hero {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    background: var(--aged-walnut);
    opacity: 1;
    transition: opacity 400ms ease, transform 400ms ease;
}

.hero.fade-out {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

.hero.hidden {
    display: none;
}

.hero-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--old-parchment);
    opacity: 0;
    transform: translateY(30px);
}

.hero-title.animate {
    animation: hero-rise 600ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes hero-rise {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-subtitle {
    margin-top: 1rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--amber-gold);
    opacity: 0.6;
    min-height: 1.2em;
}

.typewriter {
    display: inline-block;
}

/* --- Header Band --- */
.header-band {
    position: sticky;
    top: 16px;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 40px;
    margin: 0 16px;
    opacity: 0;
    transition: opacity 300ms ease;
}

.header-band.visible {
    opacity: 1;
}

.header-band.scrolled {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(18, 14, 10, 0.85);
}

.header-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--old-parchment);
    letter-spacing: -0.02em;
}

.header-nav {
    display: flex;
    gap: 8px;
}

.nav-pill {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--amber-gold);
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: 20px;
    padding: 6px 16px;
    cursor: pointer;
    transition: border-color 300ms ease, color 300ms ease;
}

.nav-pill:hover {
    border-color: var(--verdigris-tint);
    color: var(--verdigris-tint);
}

/* --- Data Flow Lines --- */
.data-flow-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: opacity 600ms ease;
}

.data-flow-container.visible {
    opacity: 1;
}

.data-flow-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(232, 180, 76, 0.08);
    overflow: hidden;
}

.data-flow-line:nth-child(1) { top: 30%; }
.data-flow-line:nth-child(2) { top: 55%; }
.data-flow-line:nth-child(3) { top: 78%; }

.data-flow-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: -80px;
    width: 80px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--inference-amber), transparent);
    opacity: 0.6;
    animation: dataflow 8s linear infinite;
    animation-delay: var(--flow-delay, 0s);
}

@keyframes dataflow {
    0% { left: -80px; }
    100% { left: calc(100vw + 80px); }
}

/* --- Masonry Grid --- */
.masonry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 40px 56px;
    max-width: 1400px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease, transform 600ms ease;
}

.masonry-grid.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Specimen Cards --- */
.specimen-card {
    position: relative;
    background: var(--library-dusk);
    border: 1px solid rgba(201, 168, 76, 0.15);
    border-radius: 3px;
    padding: 32px 28px;
    opacity: 0;
    transform: translateY(24px);
    transition: border-color 300ms ease;
}

.specimen-card.revealed {
    animation: card-reveal 500ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: calc(var(--card-index, 0) * 60ms);
}

@keyframes card-reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.specimen-card:hover {
    border-color: rgba(201, 168, 76, 0.5);
}

.specimen-card::before {
    content: '';
    position: absolute;
    inset: 0;
    filter: url(#grain-fine);
    opacity: 0.05;
    pointer-events: none;
    border-radius: 3px;
}

.span-2 {
    grid-row: span 2;
}

.span-3 {
    grid-row: span 2;
    grid-column: span 2;
}

/* --- Corner Brackets --- */
.card-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    pointer-events: none;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1), height 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card-corner::before,
.card-corner::after {
    content: '';
    position: absolute;
    background: var(--amber-gold);
}

.card-corner.tl {
    top: 4px;
    left: 4px;
}
.card-corner.tl::before {
    top: 0; left: 0; width: 20px; height: 2px;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
.card-corner.tl::after {
    top: 0; left: 0; width: 2px; height: 20px;
    transition: height 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card-corner.tr {
    top: 4px;
    right: 4px;
}
.card-corner.tr::before {
    top: 0; right: 0; width: 20px; height: 2px;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
.card-corner.tr::after {
    top: 0; right: 0; width: 2px; height: 20px;
    transition: height 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card-corner.bl {
    bottom: 4px;
    left: 4px;
}
.card-corner.bl::before {
    bottom: 0; left: 0; width: 20px; height: 2px;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
.card-corner.bl::after {
    bottom: 0; left: 0; width: 2px; height: 20px;
    transition: height 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card-corner.br {
    bottom: 4px;
    right: 4px;
}
.card-corner.br::before {
    bottom: 0; right: 0; width: 20px; height: 2px;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
.card-corner.br::after {
    bottom: 0; right: 0; width: 2px; height: 20px;
    transition: height 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover: Extend brackets */
.specimen-card:hover .card-corner.tl::before,
.specimen-card:hover .card-corner.tr::before,
.specimen-card:hover .card-corner.bl::before,
.specimen-card:hover .card-corner.br::before {
    width: 32px;
}

.specimen-card:hover .card-corner.tl::after,
.specimen-card:hover .card-corner.tr::after,
.specimen-card:hover .card-corner.bl::after,
.specimen-card:hover .card-corner.br::after {
    height: 32px;
}

/* --- Card Content --- */
.card-tag {
    display: inline-block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--amber-gold);
    margin-bottom: 16px;
}

.card-heading {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.01em;
    line-height: 1.2;
    color: var(--old-parchment);
    margin-bottom: 16px;
}

.card-body {
    color: var(--old-parchment);
    max-width: 65ch;
    margin-bottom: 16px;
}

.card-meta {
    display: flex;
    gap: 16px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--foxed-cream);
    opacity: 0.6;
}

/* --- Drop Cap --- */
.drop-cap {
    float: left;
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 900;
    font-size: 4.5rem;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 4px;
    color: var(--amber-gold);
    text-shadow: 0 0 20px rgba(201, 168, 76, 0.3);
}

/* --- Readout Labels (HUD) --- */
.readout-label {
    position: absolute;
    top: 12px;
    right: 12px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--amber-gold);
    opacity: 0;
    transition: opacity 400ms ease;
}

.readout-label.typed {
    opacity: 0.5;
}

/* --- Marginalia --- */
.marginalia {
    position: absolute;
    left: 8px;
    top: 40px;
    bottom: 40px;
    width: 1px;
    background: rgba(201, 168, 76, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
}

.margin-dot {
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--amber-gold);
    opacity: 0.4;
}

/* --- Ornamental Rule --- */
.ornamental-rule {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    position: relative;
}

.ornamental-rule::before,
.ornamental-rule::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--foxed-cream);
    opacity: 0.4;
}

.rule-diamond {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--amber-gold);
    opacity: 0.6;
    transform: rotate(45deg);
    margin: 0 16px;
    flex-shrink: 0;
}

/* --- Colophon Footer --- */
.colophon {
    position: relative;
    padding: 80px 40px;
    text-align: center;
    overflow: hidden;
}

.colophon-pattern {
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(201, 168, 76, 0.05) 10px,
            rgba(201, 168, 76, 0.05) 11px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 10px,
            rgba(201, 168, 76, 0.05) 10px,
            rgba(201, 168, 76, 0.05) 11px
        );
    pointer-events: none;
}

.colophon-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--old-parchment);
    font-variant: small-caps;
    position: relative;
    z-index: 1;
}

.colophon-sub {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--foxed-cream);
    opacity: 0.5;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .masonry-grid {
        grid-template-columns: 1fr;
        padding: 24px 32px;
    }

    .span-2,
    .span-3 {
        grid-row: span 1;
        grid-column: span 1;
    }

    .observatory-frame {
        inset: 8px;
    }

    .header-band {
        padding: 0 24px;
        margin: 0 8px;
        top: 8px;
    }

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

    .marginalia {
        display: none;
    }

    .specimen-card {
        padding: 24px 20px;
    }
}

@media (min-width: 1200px) {
    .masonry-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1500px) {
    .masonry-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* --- Selection --- */
::selection {
    background: rgba(201, 168, 76, 0.3);
    color: var(--old-parchment);
}

/* --- Links --- */
a {
    color: var(--verdigris-tint);
    text-decoration: none;
    transition: color 200ms ease;
}

a:hover {
    color: var(--amber-gold);
}
