/* ============================================================
   PPADDL.com - Swiss-Zen Contemplative Design
   ============================================================ */

/* --- Custom Properties --- */
:root {
    /* Palette */
    --bg-primary: #f5f0e8;         /* Warm Parchment */
    --bg-secondary: #e8ede4;       /* Pale Sage */
    --text-primary: #3d3a35;       /* Charcoal Warm */
    --text-secondary: #8a8278;     /* Stone */
    --accent-blush: #d4a8a0;       /* Faded Rose */
    --accent-blue: #a8b4c8;        /* Muted Periwinkle */
    --accent-lavender: #c0b0cc;    /* Dusty Wisteria */
    --surface-grain: #e8e2d8;      /* Warm Linen */
    --deep-accent: #5a5470;        /* Aged Indigo */
    --hud-line: #b8b0a8;           /* HUD progress line */
    --ghost-col-border: #d4cfc8;   /* Ghost column rule */

    /* Grid */
    --grid-columns: 12;
    --grid-gutter: 24px;

    /* Curve animations */
    --curve-duration: 3s;
    --curve-delay-step: 300ms;
    --curve-easing: cubic-bezier(0.4, 0, 0.2, 1);

    /* Typography sizes */
    --hero-size: clamp(2.2rem, 6vw, 5.5rem);
    --section-heading-size: clamp(1.6rem, 3vw, 2.8rem);
    --body-size: clamp(1rem, 1.15vw, 1.2rem);
    --ghost-numeral-size: clamp(8rem, 20vw, 18rem);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-size: var(--body-size);
    line-height: 1.85;
    letter-spacing: 0.015em;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
    transition: background-color 1.2s ease;
}

/* --- Grain Overlay (primary) --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.05;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23grain)' opacity='0.5'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    transition: opacity 1.2s ease;
}

/* --- Grain Overlay (secondary luminous) --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9998;
    pointer-events: none;
    opacity: 0.02;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='grain2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23grain2)' opacity='0.4'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* --- Paused State --- */
body.paused {
    background-color: var(--bg-secondary);
}

body.paused::after {
    opacity: 0.12;
}

body.paused .frame:not(.frame--active) {
    opacity: 0;
    transition: opacity 1.2s ease;
}

body.paused .frame.frame--active {
    opacity: 1;
}

body.paused * {
    animation-play-state: paused !important;
}

/* --- Ghost Grid --- */
.ghost-grid {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--grid-gutter);
    padding: 0 var(--grid-gutter);
    z-index: 1;
    pointer-events: none;
}

.ghost-col {
    border-left: 1px solid #d4cfc8;
    border-right: 1px solid #d4cfc8;
    opacity: 0.08;
}

/* --- HUD Overlay --- */
.hud {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    will-change: transform;
    padding: 28px 32px;
}

/* HUD Watermark (top-left) */
.hud-watermark {
    position: absolute;
    top: 28px;
    left: 32px;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-variant: small-caps;
    font-size: 12px;
    letter-spacing: 0.4em;
    color: var(--text-secondary);
    opacity: 0.35;
}

/* HUD Section Counter (top-right) */
.hud-counter {
    position: absolute;
    top: 28px;
    right: 32px;
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.15em;
    color: var(--accent-blue);
    opacity: 0.7;
}

.hud-counter-current {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    color: var(--accent-blue);
}

/* HUD Progress Bar (bottom-left) */
.hud-progress {
    position: absolute;
    bottom: 32px;
    left: 0;
    width: 40%;
    height: 1px;
    background-color: #b8b0a8;
    opacity: 0.4;
}

.hud-progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--accent-blush);
    opacity: 1;
    transition: width 0.3s ease-out;
}

.hud-progress:hover .hud-progress-bar {
    opacity: 0.7;
}

/* HUD Pause Glyph (bottom-right) */
.hud-pause {
    position: absolute;
    bottom: 26px;
    right: 32px;
    pointer-events: auto;
    cursor: pointer;
    background: none;
    border: none;
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.pause-line {
    display: block;
    width: 2px;
    height: 14px;
    background-color: var(--deep-accent);
    opacity: 0.7;
    border-radius: 1px;
    transition: opacity 0.3s ease;
}

.hud-pause:hover .pause-line {
    opacity: 1;
}

body.paused .hud-pause {
    transform: rotate(90deg);
}

/* --- Frame (Full-Viewport Sections) --- */
.frame {
    position: relative;
    min-height: 100vh;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--grid-gutter);
    padding: 15vh var(--grid-gutter);
    align-items: center;
    z-index: 2;
    transition: opacity 1.2s ease;
}

.frame--sage {
    background-color: var(--bg-secondary);
}

/* Ghost Numerals */
.frame-ghost-numeral {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: var(--ghost-numeral-size);
    color: var(--surface-grain);
    opacity: 0.2;
    z-index: 0;
    pointer-events: none;
    line-height: 1;
    user-select: none;
}

/* Frame Content */
.frame-content {
    z-index: 2;
    max-width: 38ch;
}

.frame-content--left {
    grid-column: 2 / 6;
}

.frame-content--right {
    grid-column: 7 / 11;
}

/* Frame Motifs */
.frame-motif {
    z-index: 1;
}

.frame-motif--right {
    grid-column: 7 / 11;
}

.frame-motif--left {
    grid-column: 2 / 6;
}

/* --- Typography --- */
.heading {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.heading--hero {
    font-size: var(--hero-size);
}

.heading--section {
    font-size: var(--section-heading-size);
}

/* Per-character animation containers */
.heading .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.heading .char.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Body text */
.body-text {
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-size: var(--body-size);
    line-height: 1.85;
    letter-spacing: 0.015em;
    color: var(--text-primary);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.body-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.body-text + .body-text {
    text-indent: 1.5em;
}

/* --- Flowing Curve SVGs --- */
.flowing-curve {
    width: 100%;
    height: 70vh;
    overflow: visible;
}

.curve-path {
    fill: none;
    stroke: var(--accent-lavender);
    stroke-width: 1.2;
    opacity: 0.4;
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
    stroke-linecap: round;
    transition: stroke-dashoffset var(--curve-duration) var(--curve-easing);
    transition-delay: calc(var(--curve-index, 0) * var(--curve-delay-step));
}

.curve-path--rose {
    stroke: var(--accent-blush);
    opacity: 0.35;
}

.curve-path.animate {
    stroke-dashoffset: 0;
}

/* Node points on curves */
.curve-node {
    fill: var(--surface-grain);
    opacity: 0;
    transform-origin: center;
    transition: opacity 0.5s ease 0.5s;
}

.curve-node.animate {
    opacity: 1;
    animation: pulse-node 3s ease-in-out infinite;
    animation-delay: var(--node-delay, 0s);
}

@keyframes pulse-node {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* --- Section Dividers --- */
.section-divider {
    position: relative;
    z-index: 2;
    height: 30px;
    overflow: visible;
}

.divider-curve {
    width: 100%;
    height: 30px;
}

.divider-path {
    fill: none;
    stroke: var(--accent-lavender);
    stroke-width: 1;
    opacity: 0.15;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.5s var(--curve-easing);
}

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

/* --- Underline-Draw Pattern --- */
.underline-draw {
    position: relative;
    text-decoration: none;
    color: var(--accent-blue);
    cursor: pointer;
}

.underline-draw::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: var(--accent-blush);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.underline-draw:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

.underline-draw:not(:hover)::after {
    transform-origin: right;
}

/* --- Hero-specific styling --- */
.frame-hero .heading--hero {
    margin-bottom: 2rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .frame {
        grid-template-columns: 1fr;
        padding: 10vh 24px;
        gap: 2rem;
    }

    .frame-content--left,
    .frame-content--right {
        grid-column: 1;
    }

    .frame-motif--left,
    .frame-motif--right {
        grid-column: 1;
    }

    .ghost-grid {
        display: none;
    }

    .hud-watermark {
        font-size: 10px;
        left: 16px;
        top: 16px;
    }

    .hud-counter {
        right: 16px;
        top: 16px;
    }

    .hud-pause {
        right: 16px;
        bottom: 16px;
    }

    .hud-progress {
        bottom: 16px;
    }

    .frame-ghost-numeral {
        font-size: clamp(5rem, 15vw, 10rem);
    }

    .flowing-curve {
        height: 40vh;
    }

    .frame-content {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .heading--hero {
        font-size: clamp(1.8rem, 10vw, 3rem);
    }

    .heading--section {
        font-size: clamp(1.4rem, 5vw, 2rem);
    }
}
