/* ============================================
   blockchain.day -- Styles
   Scandinavian Institutional Blockchain Design
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-sapphire: #1B3A5C;
    --emerald-depth: #1A6B52;
    --amethyst-quiet: #5B3A6B;
    --ruby-ember: #8B2E3B;
    --nordic-linen: #F5F0E8;
    --birch-mist: #EDE7DB;
    --slate-murmur: #6B7B8D;
    --fjord-charcoal: #1E2A35;

    --font-display: 'Fira Sans', sans-serif;
    --font-body: 'Source Sans 3', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--slate-murmur);
    background-color: var(--nordic-linen);
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- Typography --- */
.display-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--nordic-linen);
}

.title-dot {
    color: var(--emerald-depth);
}

.title-emphasis {
    font-weight: 500;
    color: var(--emerald-depth);
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    letter-spacing: -0.01em;
    line-height: 1.15;
    color: var(--deep-sapphire);
    margin-bottom: 2rem;
}

.heading-emphasis {
    font-weight: 500;
    color: var(--ruby-ember);
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.005em;
    color: var(--slate-murmur);
    margin-bottom: 1.5rem;
}

.chain-term {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.9em;
    color: var(--deep-sapphire);
    background-color: rgba(27, 58, 92, 0.08);
    padding: 0.1em 0.3em;
    border-radius: 2px;
    position: relative;
    display: inline-block;
}

.chain-term::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: var(--deep-sapphire);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.chain-term.visible::after {
    transform: scaleX(1);
}

.image-caption {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: var(--slate-murmur);
    margin-top: 1rem;
    opacity: 0.8;
}

/* --- Navigation --- */
#nav-trigger {
    position: fixed;
    top: 2rem;
    left: 2rem;
    z-index: 1000;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 42, 53, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 4px;
    transition: background 0.3s ease;
}

#nav-trigger:hover {
    background: rgba(30, 42, 53, 0.85);
}

#nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--fjord-charcoal);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 10%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.5s;
}

#nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

#nav-overlay-content {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.nav-link {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: var(--nordic-linen);
    text-decoration: none;
    letter-spacing: -0.01em;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.4s ease, transform 0.4s ease, color 0.3s ease;
}

#nav-overlay.active .nav-link {
    opacity: 1;
    transform: translateX(0);
}

#nav-overlay.active .nav-link:nth-child(1) { transition-delay: 0.1s; }
#nav-overlay.active .nav-link:nth-child(2) { transition-delay: 0.2s; }
#nav-overlay.active .nav-link:nth-child(3) { transition-delay: 0.3s; }
#nav-overlay.active .nav-link:nth-child(4) { transition-delay: 0.4s; }

.nav-link:hover {
    color: var(--ruby-ember);
}

.nav-link::before {
    content: attr(data-section);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--amethyst-quiet);
    display: block;
    margin-bottom: 0.3rem;
    letter-spacing: 0.05em;
}

#nav-close {
    position: absolute;
    top: 2rem;
    left: 2rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Sections Common --- */
.section {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* --- Section Dividers --- */
.section-divider {
    height: 100px;
    position: relative;
    background: linear-gradient(to bottom, var(--nordic-linen), var(--birch-mist));
}

.divider-svg {
    width: 100%;
    height: 100%;
}

.divider-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 3s cubic-bezier(0.4, 0, 0.2, 1);
}

.divider-path.drawn {
    stroke-dashoffset: 0;
}

/* --- SECTION 1: THE THRESHOLD --- */
.section--threshold {
    min-height: 100vh;
    height: 100vh;
    background-color: var(--fjord-charcoal);
    display: grid;
    grid-template-columns: 1fr 2fr;
    align-items: center;
    position: relative;
}

.threshold-content {
    padding-left: 8%;
    z-index: 2;
}

.threshold-title {
    opacity: 0;
    transform: translateY(20px);
    animation: threshold-enter 1.2s cubic-bezier(0.4, 0, 0.2, 1) 0.5s forwards;
}

@keyframes threshold-enter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.threshold-network {
    position: absolute;
    top: 0;
    right: 0;
    width: 66%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

#threshold-svg {
    width: 100%;
    height: 80%;
    max-height: 600px;
}

.network-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 4s cubic-bezier(0.4, 0, 0.2, 1);
}

.network-path.drawn {
    stroke-dashoffset: 0;
}

.network-node {
    opacity: 0;
    transform-origin: center;
    transition: opacity 0.6s ease;
}

.network-node.visible {
    opacity: 1;
    animation: node-pulse 2s ease-in-out infinite;
}

@keyframes node-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* --- SECTION 2: THE PROPOSITION --- */
.section--proposition {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--birch-mist) 0%, var(--nordic-linen) 100%);
    padding: 8rem 0;
}

.proposition-layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 4%;
}

.proposition-text {
    grid-column: 2 / 8;
    padding-right: 5%;
}

.proposition-image {
    grid-column: 8 / 12;
    display: flex;
    align-items: flex-start;
    padding-top: 4rem;
}

.duotone-frame {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
}

.duotone-image {
    opacity: 0.85;
    border-radius: 2px;
    overflow: hidden;
}

.duotone-image svg {
    width: 100%;
    height: auto;
    display: block;
}

/* --- SECTION 3: THE MECHANISM --- */
.section--mechanism {
    min-height: 120vh;
    background-color: var(--nordic-linen);
    padding: 8rem 0;
    position: relative;
}

.mechanism-grid-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(var(--amethyst-quiet) 1px, transparent 1px),
        linear-gradient(90deg, var(--amethyst-quiet) 1px, transparent 1px);
    background-size: 34px 34px;
    opacity: 0.06;
    pointer-events: none;
}

.mechanism-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 4%;
    position: relative;
    z-index: 1;
}

.mechanism-content > .section-heading {
    grid-column: 2 / 8;
    margin-bottom: 4rem;
    padding-left: calc(100% / 12);
}

.mechanism-phases {
    display: flex;
    flex-direction: column;
    gap: 6rem;
}

.mechanism-phase {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    align-items: center;
    gap: 2rem;
}

.phase-visual {
    grid-column: 2 / 7;
}

.phase-text {
    grid-column: 7 / 11;
}

.phase-svg {
    width: 100%;
    height: auto;
}

.mechanism-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.mechanism-path.drawn {
    stroke-dashoffset: 0;
}

.verify-check {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    transition: stroke-dashoffset 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.verify-check.drawn {
    stroke-dashoffset: 0;
}

.phase-number {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--amethyst-quiet);
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.5rem;
}

.phase-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    color: var(--deep-sapphire);
    letter-spacing: -0.01em;
    margin-bottom: 1rem;
}

/* --- SECTION 4: THE HORIZON --- */
.section--horizon {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--birch-mist) 0%, var(--nordic-linen) 100%);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.horizon-grid-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#horizon-grid-svg {
    width: 90%;
    height: 80%;
    max-width: 1000px;
    max-height: 800px;
}

.horizon-grid-line {
    stroke: var(--amethyst-quiet);
    stroke-width: 1;
    opacity: 0.4;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.horizon-grid-line.drawn {
    stroke-dashoffset: 0;
}

.horizon-node {
    fill: var(--emerald-depth);
    opacity: 0;
    transform-origin: center;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.horizon-node.visible {
    opacity: 0.6;
}

.horizon-content {
    position: relative;
    z-index: 2;
    text-align: left;
    padding-left: 10%;
    max-width: 900px;
}

.horizon-statement {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--deep-sapphire);
    margin-bottom: 3rem;
}

.horizon-closing {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    color: var(--slate-murmur);
    letter-spacing: 0.02em;
}

/* --- Scroll Animations --- */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .threshold-title {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .network-path,
    .divider-path,
    .mechanism-path,
    .verify-check,
    .horizon-grid-line {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
        transition: none;
    }

    .network-node {
        opacity: 1;
        animation: none;
    }

    .horizon-node {
        opacity: 0.6;
        transition: none;
    }

    .animate-on-scroll {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .chain-term::after {
        transform: scaleX(1);
        transition: none;
    }

    .nav-link {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .section--threshold {
        grid-template-columns: 1fr;
    }

    .threshold-content {
        padding: 0 8%;
        position: relative;
        z-index: 3;
    }

    .threshold-network {
        width: 100%;
        opacity: 0.4;
    }

    .proposition-layout {
        grid-template-columns: 1fr;
        padding: 0 8%;
    }

    .proposition-text {
        grid-column: 1 / -1;
        padding-right: 0;
    }

    .proposition-image {
        grid-column: 1 / -1;
        padding-top: 2rem;
    }

    .duotone-frame {
        max-width: 320px;
    }

    .mechanism-content > .section-heading {
        padding-left: 0;
    }

    .mechanism-phase {
        grid-template-columns: 1fr;
    }

    .phase-visual {
        grid-column: 1 / -1;
    }

    .phase-text {
        grid-column: 1 / -1;
    }

    .horizon-content {
        padding: 0 8%;
    }
}

@media (max-width: 640px) {
    .section--threshold {
        min-height: 100svh;
    }

    .threshold-content {
        padding: 0 6%;
    }

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

    .section--proposition,
    .section--mechanism {
        padding: 5rem 0;
    }

    .mechanism-phases {
        gap: 4rem;
    }

    .horizon-statement {
        font-size: clamp(1.6rem, 6vw, 2.8rem);
    }

    #nav-trigger {
        top: 1rem;
        left: 1rem;
    }

    #nav-close {
        top: 1rem;
        left: 1rem;
    }
}
