/* ===================================================
   transactology.dev — Watercolor Transaction Theory
   =================================================== */

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

:root {
    --deep-cerulean: #2B4C7E;
    --washed-cerulean: #5B8CB8;
    --burnt-sienna: #C45D3E;
    --diluted-sienna: #E8A87C;
    --paper-white: #F4EDE4;
    --prussian-depth: #1E3553;
    --paper-shadow: #D6CFC5;
    --clean-white: #FFFFFF;

    --ease-watercolor: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --grid-gap-h: 28px;
    --grid-gap-v: 36px;
    --max-width: 1120px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.68;
    color: var(--prussian-depth);
    background-color: var(--paper-white);
    overflow-x: hidden;
}

/* Paper texture background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Navigation --- */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(244, 237, 228, 0.92);
    backdrop-filter: blur(8px);
    z-index: 100;
    border-bottom: 1px solid var(--paper-shadow);
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--deep-cerulean);
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    gap: 24px;
}

.nav-link {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--washed-cerulean);
    text-decoration: none;
    position: relative;
    padding-bottom: 4px;
    transition: color 0.3s var(--ease-watercolor);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--burnt-sienna);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s var(--ease-watercolor);
    filter: url(#watercolor-edge);
    opacity: 0.6;
}

.nav-link:hover {
    color: var(--deep-cerulean);
}

.nav-link:hover::after {
    transform: scaleX(1);
}

/* --- Hero Section --- */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding-top: 48px;
}

.hero-wash {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.hero-wash-1 {
    width: 70vw;
    height: 70vw;
    top: -10%;
    left: -15%;
    background: radial-gradient(ellipse at 40% 40%, rgba(91, 140, 184, 0.1), transparent 65%);
}

.hero-wash-2 {
    width: 50vw;
    height: 50vw;
    bottom: -10%;
    right: -10%;
    background: radial-gradient(ellipse at 60% 60%, rgba(196, 93, 62, 0.06), transparent 65%);
}

.hero-canvas {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 0 24px;
}

.hero-title-svg {
    width: 100%;
    max-width: 700px;
    height: auto;
    overflow: visible;
}

.hero-title-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 96px;
    fill: var(--deep-cerulean);
    stroke: var(--deep-cerulean);
    stroke-width: 0.5;
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
    animation: strokeReveal 2.5s var(--ease-watercolor) forwards;
    opacity: 0;
}

@keyframes strokeReveal {
    0% {
        stroke-dashoffset: 1500;
        opacity: 1;
        fill-opacity: 0;
    }
    60% {
        fill-opacity: 0;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 1;
        fill-opacity: 1;
    }
}

.hero-subtitle {
    display: block;
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 2.4rem;
    color: var(--burnt-sienna);
    margin-top: -8px;
    opacity: 0;
    animation: subtitleFade 1s var(--ease-watercolor) 2s forwards;
}

@keyframes subtitleFade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-tagline {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: 1rem;
    color: var(--washed-cerulean);
    max-width: 520px;
    margin: 24px auto 0;
    opacity: 0;
    animation: subtitleFade 1s var(--ease-watercolor) 2.5s forwards;
}

.hero-flow-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.flow-line {
    stroke-dasharray: 12 8;
    animation: flowDash 8s linear infinite;
}

.flow-line-2 {
    animation-delay: -3s;
    animation-duration: 10s;
}

.flow-line-3 {
    animation-delay: -5s;
    animation-duration: 12s;
}

@keyframes flowDash {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -200; }
}

/* --- Drip Separators --- */
.drip-separator {
    display: flex;
    justify-content: center;
    padding: 16px 0;
    position: relative;
    z-index: 2;
}

.drip-svg {
    width: 40px;
    height: 120px;
}

.drip-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.2s var(--ease-watercolor);
}

.drip-separator.visible .drip-path {
    stroke-dashoffset: 0;
}

/* --- Card Sections --- */
.card-section {
    position: relative;
    padding: 60px 24px;
    z-index: 2;
}

.section-wash {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

.section-cerulean .section-wash {
    background: radial-gradient(ellipse at 30% 40%, rgba(91, 140, 184, 0.08), transparent 70%);
}

.section-neutral .section-wash {
    background: radial-gradient(ellipse at 50% 50%, rgba(214, 207, 197, 0.12), transparent 70%);
}

.section-sienna .section-wash {
    background: radial-gradient(ellipse at 60% 50%, rgba(232, 168, 124, 0.08), transparent 70%);
}

/* --- Card Grid --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: var(--grid-gap-v) var(--grid-gap-h);
    max-width: var(--max-width);
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* --- Cards --- */
.card {
    position: relative;
    background: var(--clean-white);
    border-radius: 6px;
    overflow: visible;
    cursor: pointer;
    transition: transform 0.3s ease-out;
}

.card-wide {
    grid-column: 1 / -1;
}

.card:hover {
    transform: translateY(-3px);
}

/* Watercolor border bleed */
.card-watercolor-border {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 8px;
    background: radial-gradient(ellipse at 20% 20%, rgba(91, 140, 184, 0.08), transparent 50%),
                radial-gradient(ellipse at 80% 80%, rgba(196, 93, 62, 0.05), transparent 50%);
    opacity: 0.2;
    transition: opacity 0.8s var(--ease-watercolor);
    z-index: -1;
    filter: url(#watercolor-edge);
    pointer-events: none;
}

.card:hover .card-watercolor-border {
    opacity: 0.6;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
}

.card.in-view .card-watercolor-border {
    opacity: 0.6;
}

/* Pulse dot */
.card-pulse {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--burnt-sienna);
    opacity: 0;
    z-index: 3;
    transition: opacity 0.5s var(--ease-watercolor);
}

.card.in-view .card-pulse {
    opacity: 0.4;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

/* Card inner */
.card-inner {
    position: relative;
    padding: 32px 28px;
    z-index: 1;
}

.card-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 160px;
    height: 160px;
    pointer-events: none;
    z-index: 0;
}

.card-watermark svg {
    width: 100%;
    height: 100%;
}

.card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    color: var(--deep-cerulean);
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.card-body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.68;
    color: var(--prussian-depth);
    max-width: 640px;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.card-code {
    margin-bottom: 14px;
    position: relative;
    z-index: 1;
}

.card-code code {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.5;
    color: var(--prussian-depth);
    background: rgba(30, 53, 83, 0.05);
    padding: 4px 10px;
    border-radius: 3px;
    display: inline-block;
}

.card-annotation {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 18px;
    color: var(--burnt-sienna);
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

/* Card diagram */
.card-diagram {
    margin: 16px 0;
    position: relative;
    z-index: 1;
}

.diagram-svg {
    width: 100%;
    max-width: 300px;
    height: auto;
    overflow: visible;
}

.diagram-wide {
    max-width: 100%;
}

/* Expanded content */
.card-expanded-content {
    max-height: 0;
    overflow: hidden;
    padding: 0 28px;
    opacity: 0;
    transition: max-height 0.6s var(--ease-watercolor),
                opacity 0.4s var(--ease-watercolor),
                padding 0.4s var(--ease-watercolor);
}

.card.expanded .card-expanded-content {
    max-height: 500px;
    opacity: 1;
    padding: 0 28px 32px;
}

/* --- Footer --- */
.footer-wash {
    position: relative;
    height: 200px;
    overflow: hidden;
    z-index: 2;
}

.footer-gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom,
        var(--paper-white) 0%,
        rgba(214, 207, 197, 0.3) 40%,
        rgba(91, 140, 184, 0.06) 70%,
        var(--clean-white) 100%);
}

.footer-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.footer-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--paper-shadow);
    letter-spacing: 0.05em;
}

/* --- Connection Lines (background) --- */
.connection-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

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

    .card-wide {
        grid-column: 1;
    }

    .hero-title-text {
        font-size: 56px;
    }

    .hero-subtitle {
        font-size: 1.8rem;
    }

    .nav-links {
        gap: 16px;
    }

    .nav-link {
        font-size: 0.78rem;
    }

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

    .card-expanded-content {
        padding: 0 20px;
    }

    .card.expanded .card-expanded-content {
        padding: 0 20px 24px;
    }
}

@media (max-width: 480px) {
    .card-grid {
        grid-template-columns: 1fr;
        gap: 24px 20px;
    }

    .card-section {
        padding: 40px 16px;
    }

    .hero-tagline {
        font-size: 0.9rem;
    }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .hero-title-text {
        animation: none;
        stroke-dashoffset: 0;
        opacity: 1;
        fill-opacity: 1;
    }

    .hero-subtitle,
    .hero-tagline {
        animation: none;
        opacity: 1;
    }

    .flow-line {
        animation: none;
    }

    .card-pulse {
        animation: none;
    }

    .card {
        transition: none;
    }

    .card-watercolor-border {
        transition: none;
    }

    .card-expanded-content {
        transition: none;
    }

    .drip-path {
        transition: none;
        stroke-dashoffset: 0;
    }
}
