/* paragram.dev — Swiss International Typographic / Ma Negative Space */

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

:root {
    --ink: #1A1A1A;
    --ground: #F5F0EB;
    --accent: #C84B31;
    --neutral: #8A8A8A;
    --tertiary: #D4CFC9;
    --deep: #2D2D2D;
    --muted: #CCCCCC;

    --col-gutter: 32px;
    --max-width: 1440px;
    --col-count: 12;

    --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-body: "Libre Baskerville", Georgia, serif;
    --font-mono: "IBM Plex Mono", "Space Mono", ui-monospace, monospace;
}

html,
body {
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.15vw, 1.125rem);
    line-height: 1.75;
    letter-spacing: 0.005em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    position: relative;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ---------- Grid Overlay (fixed, faint scaffold) ---------- */
.grid-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(212, 207, 201, 0.45) 0,
            rgba(212, 207, 201, 0.45) 1px,
            transparent 1px,
            transparent 120px
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(212, 207, 201, 0.45) 0,
            rgba(212, 207, 201, 0.45) 1px,
            transparent 1px,
            transparent 120px
        );
    opacity: 0;
    transition: opacity 600ms ease-out;
}

.grid-overlay.visible {
    opacity: 0.18;
}

/* ---------- Frame (12-col grid) ---------- */
.frame {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--col-gutter);
}

/* ---------- Panel layout ---------- */
.panel {
    position: relative;
    min-height: 100vh;
    display: grid;
    grid-template-columns: repeat(var(--col-count), 1fr);
    column-gap: var(--col-gutter);
    align-content: center;
}

/* ---------- Opening ---------- */
.opening .opening-cluster,
.coda .opening-cluster {
    position: relative;
    grid-column: 3 / span 5;
    align-self: start;
    margin-top: 61.8vh;
    transform: translateY(-50%);
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--ink);
    display: inline-block;
}

.wordmark .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
    will-change: opacity, transform;
}

.wordmark.revealed .letter {
    opacity: 1;
    transform: translateY(0);
}

.descriptor {
    margin-top: 1.618rem;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.15vw, 1.125rem);
    color: var(--deep);
    max-width: 38ch;
    opacity: 0;
    transition: opacity 400ms ease-out;
}

.descriptor.revealed {
    opacity: 1;
}

.threshold {
    display: block;
    margin-top: 2.618rem;
    border: none;
    height: 1px;
    background: var(--ink);
    width: 0;
    max-width: 100%;
    transition: width 500ms ease-out;
    position: relative;
}

.threshold.drawn {
    width: 100%;
}

.threshold::before,
.threshold::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 60px;
    height: 1px;
    transform: translateY(-50%);
    background: linear-gradient(to right, transparent, rgba(200, 75, 49, 0.18), transparent);
    opacity: 0;
    transition: opacity 600ms ease-out 600ms;
}

.threshold::before {
    left: -60px;
}

.threshold::after {
    right: -60px;
}

.threshold.drawn::before,
.threshold.drawn::after {
    opacity: 1;
}

/* ---------- Content panels ---------- */
.content-panel .info-panel {
    grid-column: 2 / span 5;
    display: grid;
    grid-template-columns: 1fr 4fr;
    column-gap: var(--col-gutter);
    align-items: start;
    padding-top: 22vh;
}

.label-col {
    padding-top: 0.6rem;
}

.label {
    display: inline-block;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.7rem, 0.85vw, 0.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--neutral);
    line-height: 1.4;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 350ms ease-out, transform 350ms ease-out;
}

.content-col {
    color: var(--ink);
}

.content-col .section-heading,
.content-col .body,
.content-col .rule {
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.25rem, 2.5vw, 2rem);
    letter-spacing: -0.01em;
    line-height: 1.15;
    color: var(--ink);
    margin-bottom: 1.618rem;
    max-width: 28ch;
}

.body {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.15vw, 1.125rem);
    line-height: 1.75;
    color: var(--deep);
    max-width: 52ch;
    margin-bottom: 1.236rem;
}

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

.rule {
    margin-top: 1.618rem;
    border: none;
    height: 1px;
    background: var(--ink);
    width: 0;
    transition: width 500ms ease-out;
    position: relative;
}

/* In-view reveal */
.panel.in-view .marker {
    transform: scale(1);
    opacity: 1;
}

.panel.in-view .label {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 550ms;
}

.panel.in-view .section-heading {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 650ms;
}

.panel.in-view .body {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 750ms;
}

.panel.in-view .body:nth-of-type(2) {
    transition-delay: 850ms;
}

.panel.in-view .rule {
    width: 80%;
    transition-delay: 950ms;
}

.panel.in-view .flare {
    opacity: var(--flare-opacity, 0.1);
    transition-delay: 450ms;
}

/* ---------- Section markers ---------- */
.marker {
    position: absolute;
    top: 18vh;
    left: calc((100% / 12) * 1 + var(--col-gutter) / 2);
    transform: scale(0);
    opacity: 0;
    transition: transform 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 300ms ease-out;
    will-change: transform;
}

.panel.in-view .marker {
    animation: pulse 4s ease-in-out infinite;
}

.marker-circle {
    width: 12px;
    height: 12px;
    border: 1px solid var(--deep);
    border-radius: 50%;
    background: transparent;
}

.panel.in-view .marker-circle {
    background: var(--accent);
    border-color: var(--accent);
}

.marker-square {
    width: 10px;
    height: 10px;
    border: 1px solid var(--tertiary);
    background: transparent;
    transform: scale(0) rotate(45deg);
}

.panel.in-view .marker-square {
    transform: scale(1) rotate(45deg);
    border-color: var(--deep);
}

.marker-triangle {
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 12px solid var(--neutral);
    background: transparent;
}

@keyframes pulse {
    0%, 100% {
        scale: 1;
    }
    50% {
        scale: 1.08;
    }
}

/* ---------- Lens flare artifacts ---------- */
.flare {
    position: absolute;
    pointer-events: none;
    opacity: 0;
    transition: opacity 400ms ease-out;
    z-index: 0;
}

.flare-hex {
    width: 18px;
    height: 18px;
    background: var(--accent);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    --flare-opacity: 0.12;
}

.flare-streak {
    width: 100px;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--accent) 50%, transparent);
    --flare-opacity: 0.18;
}

.flare-halo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(200, 75, 49, 0.22) 0%, rgba(200, 75, 49, 0.08) 35%, transparent 70%);
    --flare-opacity: 0.6;
    box-shadow:
        0 0 30px rgba(200, 75, 49, 0.05),
        0 0 60px rgba(200, 75, 49, 0.03);
}

/* opening flare positions */
.flare-opening-1 {
    top: -40px;
    left: -28px;
}

.flare-opening-2 {
    top: 50%;
    right: -120px;
    transform: translateY(-50%);
}

.flare-opening-3 {
    bottom: -100px;
    right: 8%;
}

/* near-marker flares for content panels */
.flare-near-marker {
    top: 17vh;
    left: calc((100% / 12) * 1 + var(--col-gutter) / 2 + 24px);
}

.flare-near-marker-2 {
    top: calc(18vh + 6px);
    left: calc((100% / 12) * 1 + var(--col-gutter) / 2 + 16px);
}

.flare-near-marker-3 {
    top: calc(18vh - 30px);
    left: calc((100% / 12) * 1 + var(--col-gutter) / 2 - 30px);
}

/* opening flare default opacity (visible after opening reveal) */
.opening.in-view .flare,
.opening .flare {
    opacity: 0;
}

.opening.revealed .flare-opening-1 { opacity: 0.14; }
.opening.revealed .flare-opening-2 { opacity: 0.20; }
.opening.revealed .flare-opening-3 { opacity: 0.55; }

/* ---------- Coda ---------- */
.coda .opening-cluster {
    margin-top: 61.8vh;
}

.wordmark-coda .letter {
    opacity: 1;
    transform: translateY(0);
}

.coda .colophon {
    margin-top: 2.618rem;
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.85vw, 0.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--neutral);
    line-height: 1.4;
}

.registration {
    position: absolute;
    top: 38vh;
    left: 50%;
    width: 16px;
    height: 16px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.cross-h,
.cross-v {
    position: absolute;
    background: var(--deep);
}

.cross-h {
    top: 50%;
    left: 0;
    width: 8px;
    height: 1px;
    transform: translateY(-50%);
}

.cross-v {
    left: 50%;
    top: 0;
    width: 1px;
    height: 8px;
    transform: translateX(-50%);
}

/* ---------- Navigation dots ---------- */
.dot-nav {
    position: fixed;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 22px;
    z-index: 10;
}

.dot-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 28px;
    height: 14px;
    cursor: pointer;
}

.dot {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    transition: background 150ms ease-out, transform 150ms ease-out, box-shadow 150ms ease-out;
}

.dot.active {
    background: var(--accent);
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(200, 75, 49, 0.18);
}

.dot-link:hover .dot {
    background: var(--accent);
    transform: scale(1.5);
}

.dot-label {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--neutral);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease-out, transform 200ms ease-out;
    margin-right: 12px;
}

.dot-link:hover .dot-label {
    opacity: 1;
    transform: translateY(-50%) translateX(-2px);
}

/* ---------- Threshold opening hover (subtle) ---------- */
.threshold:hover {
    transition: width 200ms ease-out;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .opening .opening-cluster,
    .coda .opening-cluster {
        grid-column: 1 / span 10;
        margin-top: 50vh;
    }

    .content-panel .info-panel {
        grid-column: 1 / span 10;
        grid-template-columns: 1fr;
        row-gap: 1rem;
        padding-top: 18vh;
    }

    .marker {
        left: var(--col-gutter);
    }

    .flare-near-marker {
        left: calc(var(--col-gutter) + 24px);
    }

    .flare-near-marker-2 {
        left: calc(var(--col-gutter) + 16px);
    }

    .flare-near-marker-3 {
        left: calc(var(--col-gutter) - 30px);
    }

    .dot-nav {
        right: 12px;
        gap: 18px;
    }

    .dot-label {
        display: none;
    }

    .registration {
        left: 50%;
    }
}
