/* ============================================
   daitoua.com — Digital Tea House at Midnight
   ============================================ */

/* === CSS Custom Properties === */
:root {
    --primary-dark: #0a0a0f;
    --secondary-dark: #12101e;
    --mesh-indigo: #1a1145;
    --mesh-violet: #2d1b69;
    --mesh-teal: #0d4a4a;
    --accent-gold: #c9a96e;
    --text-primary: #e8dcc8;
    --text-secondary: #a8a0b4;
    --seam-glow: #7b5ea7;
    --annotation: #5e5a7e;

    --split-left: 52%;
    --split-right: 48%;
    --seam-width: 3px;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--primary-dark);
    color: var(--text-primary);
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 300;
    line-height: 1.85;
    letter-spacing: 0.03em;
    overflow-x: hidden;
}

/* === Sections === */
.section {
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* === Split Container === */
.split-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

/* === Panels === */
.panel {
    position: relative;
    height: 100%;
    overflow: hidden;
    transition: flex 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.panel-left {
    flex: 0 0 var(--split-left);
    background-color: var(--primary-dark);
}

.panel-right {
    flex: 0 0 var(--split-right);
    background-color: var(--secondary-dark);
}

/* === The Seam === */
.seam {
    width: var(--seam-width);
    height: 100%;
    position: relative;
    flex-shrink: 0;
    background: linear-gradient(to bottom, transparent 5%, var(--seam-glow) 30%, var(--seam-glow) 70%, transparent 95%);
    filter: blur(2px);
    opacity: 0;
    z-index: 10;
    transition: opacity 0.6s ease, width 0.5s ease;
}

.seam.visible {
    opacity: 1;
}

.beat-seam {
    width: var(--seam-width);
    height: 100%;
    position: relative;
    flex-shrink: 0;
    background: linear-gradient(to bottom, transparent 5%, var(--seam-glow) 30%, var(--seam-glow) 70%, transparent 95%);
    filter: blur(2px);
    opacity: 1;
    z-index: 10;
    transition: width 0.5s ease;
}

/* === Gradient Meshes === */
.gradient-mesh {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.gradient-mesh.visible {
    opacity: 1;
}

/* Opening Mesh */
.mesh-opening {
    background:
        radial-gradient(ellipse 80% 60% at 30% 40%, var(--mesh-indigo) 0%, transparent 70%),
        radial-gradient(ellipse 60% 80% at 70% 60%, var(--mesh-violet) 0%, transparent 65%),
        radial-gradient(ellipse 50% 50% at 50% 50%, var(--mesh-teal) 0%, transparent 60%),
        radial-gradient(ellipse 90% 40% at 20% 80%, var(--mesh-indigo) 0%, transparent 55%),
        radial-gradient(ellipse 40% 70% at 80% 20%, var(--mesh-violet) 0%, transparent 50%);
    animation: meshDrift1 25s ease-in-out infinite alternate;
}

/* Shan Shui Mesh - horizontal layered mist */
.mesh-shanshui {
    background:
        radial-gradient(ellipse 120% 30% at 50% 20%, var(--mesh-indigo) 0%, transparent 70%),
        radial-gradient(ellipse 100% 25% at 40% 45%, var(--mesh-violet) 0%, transparent 60%),
        radial-gradient(ellipse 110% 20% at 60% 70%, var(--mesh-teal) 0%, transparent 65%),
        radial-gradient(ellipse 90% 35% at 30% 90%, var(--mesh-indigo) 0%, transparent 55%),
        radial-gradient(ellipse 80% 15% at 70% 55%, rgba(45, 27, 105, 0.5) 0%, transparent 60%);
    animation: meshDrift2 30s ease-in-out infinite alternate;
}

/* Batik Mesh */
.mesh-batik {
    background:
        radial-gradient(circle 40% at 25% 25%, var(--mesh-violet) 0%, transparent 70%),
        radial-gradient(circle 35% at 75% 30%, var(--mesh-teal) 0%, transparent 65%),
        radial-gradient(circle 45% at 50% 70%, var(--mesh-indigo) 0%, transparent 60%),
        radial-gradient(circle 30% at 20% 80%, var(--mesh-violet) 0%, transparent 55%),
        radial-gradient(circle 38% at 80% 75%, var(--mesh-teal) 0%, transparent 50%);
    animation: meshDrift3 35s ease-in-out infinite alternate;
}

/* Silk Flow Left */
.mesh-silk-left {
    background:
        radial-gradient(ellipse 40% 120% at 70% 30%, var(--mesh-violet) 0%, transparent 70%),
        radial-gradient(ellipse 30% 100% at 40% 60%, var(--mesh-indigo) 0%, transparent 65%),
        radial-gradient(ellipse 50% 80% at 80% 80%, var(--mesh-teal) 0%, transparent 60%),
        radial-gradient(ellipse 25% 110% at 55% 10%, rgba(45, 27, 105, 0.4) 0%, transparent 55%);
    animation: silkFlow 20s ease-in-out infinite alternate;
}

/* Silk Flow Right */
.mesh-silk-right {
    background:
        radial-gradient(ellipse 40% 120% at 30% 70%, var(--mesh-teal) 0%, transparent 70%),
        radial-gradient(ellipse 30% 100% at 60% 40%, var(--mesh-indigo) 0%, transparent 65%),
        radial-gradient(ellipse 50% 80% at 20% 20%, var(--mesh-violet) 0%, transparent 60%),
        radial-gradient(ellipse 25% 110% at 45% 90%, rgba(13, 74, 74, 0.4) 0%, transparent 55%);
    animation: silkFlow 22s ease-in-out infinite alternate-reverse;
}

/* Convergence Mesh - full screen aurora */
.mesh-convergence {
    background:
        radial-gradient(ellipse 80% 60% at 20% 30%, var(--mesh-indigo) 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 80% 70%, var(--mesh-violet) 0%, transparent 55%),
        radial-gradient(ellipse 70% 50% at 50% 50%, var(--mesh-teal) 0%, transparent 50%),
        radial-gradient(ellipse 90% 40% at 70% 20%, var(--mesh-violet) 0%, transparent 45%),
        radial-gradient(ellipse 50% 90% at 30% 80%, var(--mesh-indigo) 0%, transparent 60%),
        radial-gradient(ellipse 60% 60% at 60% 40%, rgba(13, 74, 74, 0.6) 0%, transparent 55%);
    opacity: 1;
    animation: meshConvergence 40s ease-in-out infinite alternate;
}

/* Batik pattern overlay */
.batik-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.15;
    background:
        repeating-conic-gradient(
            from 0deg at 50% 50%,
            transparent 0deg 30deg,
            rgba(123, 94, 167, 0.1) 30deg 60deg,
            transparent 60deg 90deg
        );
    background-size: 80px 80px;
    animation: batikShift 60s linear infinite;
}

/* === Mesh Animations === */
@keyframes meshDrift1 {
    0% {
        background-position: 30% 40%, 70% 60%, 50% 50%, 20% 80%, 80% 20%;
    }
    33% {
        background-position: 40% 30%, 60% 70%, 55% 45%, 25% 75%, 75% 25%;
    }
    66% {
        background-position: 35% 50%, 65% 50%, 45% 55%, 30% 70%, 70% 30%;
    }
    100% {
        background-position: 25% 45%, 75% 55%, 50% 50%, 15% 85%, 85% 15%;
    }
}

@keyframes meshDrift2 {
    0% {
        background-position: 50% 20%, 40% 45%, 60% 70%, 30% 90%, 70% 55%;
    }
    50% {
        background-position: 45% 25%, 55% 40%, 50% 75%, 35% 85%, 65% 60%;
    }
    100% {
        background-position: 55% 15%, 35% 50%, 65% 65%, 25% 95%, 75% 50%;
    }
}

@keyframes meshDrift3 {
    0% {
        background-position: 25% 25%, 75% 30%, 50% 70%, 20% 80%, 80% 75%;
    }
    50% {
        background-position: 30% 30%, 70% 35%, 55% 65%, 25% 75%, 75% 70%;
    }
    100% {
        background-position: 20% 20%, 80% 25%, 45% 75%, 15% 85%, 85% 80%;
    }
}

@keyframes silkFlow {
    0% {
        background-position: 70% 30%, 40% 60%, 80% 80%, 55% 10%;
    }
    50% {
        background-position: 65% 40%, 45% 50%, 75% 70%, 60% 20%;
    }
    100% {
        background-position: 75% 25%, 35% 70%, 85% 85%, 50% 5%;
    }
}

@keyframes meshConvergence {
    0% {
        background-position: 20% 30%, 80% 70%, 50% 50%, 70% 20%, 30% 80%, 60% 40%;
    }
    50% {
        background-position: 30% 40%, 70% 60%, 45% 55%, 60% 30%, 40% 70%, 50% 50%;
    }
    100% {
        background-position: 25% 35%, 75% 65%, 55% 45%, 65% 25%, 35% 75%, 55% 45%;
    }
}

@keyframes batikShift {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === Typography === */

/* Domain Title - Fraunces variable */
.domain-title {
    font-family: 'Fraunces', serif;
    font-size: clamp(5rem, 14vw, 12rem);
    font-weight: 400;
    font-variation-settings: 'wght' 400, 'WONK' 1, 'opsz' 144;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.02em;
    opacity: 0;
    transition: opacity 1s ease 0.8s;
    animation: fontBreathe 4s ease-in-out infinite;
}

.domain-title.visible {
    opacity: 1;
}

@keyframes fontBreathe {
    0% { font-variation-settings: 'wght' 200, 'WONK' 1, 'opsz' 144; }
    50% { font-variation-settings: 'wght' 800, 'WONK' 1, 'opsz' 144; }
    100% { font-variation-settings: 'wght' 200, 'WONK' 1, 'opsz' 144; }
}

/* Initial title entrance animation */
@keyframes fontInhale {
    0% { font-variation-settings: 'wght' 100, 'WONK' 1, 'opsz' 144; }
    50% { font-variation-settings: 'wght' 900, 'WONK' 1, 'opsz' 144; }
    100% { font-variation-settings: 'wght' 400, 'WONK' 1, 'opsz' 144; }
}

.domain-title.inhale {
    animation: fontInhale 2s ease-in-out forwards;
}

.subtitle {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--annotation);
    opacity: 0;
    transition: opacity 1s ease 1.5s;
}

.subtitle.visible {
    opacity: 1;
}

.title-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 2rem;
    gap: 1.5rem;
}

/* Cultural Characters */
.cultural-char {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: clamp(5rem, 14vw, 12rem);
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1;
    display: block;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* Split character for Beat 3 */
.split-char-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.split-char-left {
    position: absolute;
    right: -0.5em;
    top: 50%;
    transform: translateY(-50%);
    clip-path: inset(0 50% 0 0);
    color: var(--accent-gold);
}

.split-char-right {
    position: absolute;
    left: -0.5em;
    top: 50%;
    transform: translateY(-50%);
    clip-path: inset(0 0 0 50%);
    color: var(--accent-gold);
}

.split-char.visible {
    opacity: 1;
    transform: translateY(-50%);
}

/* Beat text */
.beat-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 3rem;
    position: relative;
    z-index: 5;
    text-align: center;
}

.beat-text {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.85;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    max-width: 480px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 0.3s, transform 0.8s ease 0.3s;
}

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

.silk-text {
    position: relative;
    z-index: 5;
}

/* === Decorative SVG Elements === */
.enso {
    position: absolute;
    opacity: 0.3;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.enso-1 {
    top: 15%;
    left: 20%;
}

.enso-2 {
    bottom: 20%;
    right: 10%;
}

.enso-drift {
    top: 30%;
    right: 15%;
    animation: ensoDrift 60s linear infinite;
}

@keyframes ensoDrift {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(20px, -10px) rotate(90deg); }
    50% { transform: translate(-10px, -20px) rotate(180deg); }
    75% { transform: translate(-20px, 10px) rotate(270deg); }
    100% { transform: translate(0, 0) rotate(360deg); }
}

.torii {
    position: absolute;
    bottom: 8%;
    right: 10%;
    opacity: 0.4;
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.torii-wide {
    bottom: 12%;
    left: 10%;
    right: auto;
}

.spiral {
    position: absolute;
    opacity: 0.4;
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.spiral-1 {
    top: 25%;
    right: 15%;
    animation: spiralRotate 60s linear infinite;
}

.spiral-2 {
    bottom: 25%;
    left: 20%;
    animation: spiralRotate 45s linear infinite reverse;
}

@keyframes spiralRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === The Convergence === */
.convergence {
    height: 100vh;
}

.convergence-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-dark);
    overflow: hidden;
}

.convergence-seam {
    position: absolute;
    left: 50%;
    top: 0;
    width: 5px;
    height: 100%;
    background: linear-gradient(to bottom, transparent 5%, var(--seam-glow) 30%, var(--seam-glow) 70%, transparent 95%);
    filter: blur(3px);
    transform: translateX(-50%);
    transition: width 1s ease, opacity 1s ease, filter 1s ease;
    z-index: 2;
}

.convergence-seam.expanded {
    width: 100vw;
    opacity: 0.3;
    filter: blur(80px);
}

.convergence-char {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: clamp(6rem, 18vw, 16rem);
    font-weight: 200;
    color: var(--text-primary);
    opacity: 0;
    position: relative;
    z-index: 5;
    transition: opacity 4s ease;
    animation: convergenceBreathe 6s ease-in-out infinite;
}

.convergence-char.visible {
    opacity: 0.3;
}

.convergence-char.full {
    opacity: 1;
}

@keyframes convergenceBreathe {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* === Beat Section Specific Styles === */

/* Beat 1 - Shan Shui */
#beat1 .panel-left {
    background-color: var(--primary-dark);
}

#beat1 .panel-right {
    background-color: var(--secondary-dark);
}

/* Beat 2 - Batik */
#beat2 .panel-left {
    background-color: var(--secondary-dark);
}

#beat2 .panel-right {
    background-color: var(--primary-dark);
}

/* Beat 3 - Silk Flow */
#beat3 .panel-left {
    background-color: var(--primary-dark);
}

#beat3 .panel-right {
    background-color: var(--secondary-dark);
}

/* === Noise Texture Overlay (SVG turbulence) === */
.gradient-mesh::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    opacity: 0.3;
}

/* === Scroll-Driven Panel Ratios === */
.beat[data-beat="1"] .panel-left {
    flex: 0 0 35%;
}
.beat[data-beat="1"] .panel-right {
    flex: 0 0 calc(65% - var(--seam-width));
}

.beat[data-beat="2"] .panel-left {
    flex: 0 0 65%;
}
.beat[data-beat="2"] .panel-right {
    flex: 0 0 calc(35% - var(--seam-width));
}

.beat[data-beat="3"] .panel-left {
    flex: 0 0 50%;
}
.beat[data-beat="3"] .panel-right {
    flex: 0 0 calc(50% - var(--seam-width));
}

/* === Gold Accent Highlights === */
.cultural-char[data-char="mountain"] {
    color: var(--text-primary);
}

.cultural-char[data-char="weave"] {
    color: var(--text-primary);
}

/* Mon-inspired emblems as watermarks */
.beat::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    border: 1px solid rgba(26, 17, 69, 0.15);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
}

.beat[data-beat="1"]::before {
    border-radius: 50%;
    width: 280px;
    height: 280px;
    border: 2px solid rgba(13, 74, 74, 0.1);
}

.beat[data-beat="2"]::before {
    border-radius: 0;
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%) rotate(45deg);
    border: 2px solid rgba(45, 27, 105, 0.1);
}

.beat[data-beat="3"]::before {
    width: 320px;
    height: 320px;
    border: 2px solid rgba(123, 94, 167, 0.08);
    border-radius: 50% 0 50% 0;
}

/* === Beat Seam Width Variations === */
.beat[data-beat="1"] .beat-seam {
    width: 5px;
}

.beat[data-beat="2"] .beat-seam {
    width: 5px;
}

.beat[data-beat="3"] .beat-seam {
    width: 3px;
}

/* === Responsive Adjustments === */
@media (max-width: 768px) {
    .split-container {
        flex-direction: column;
    }

    .panel-left, .panel-right,
    .beat[data-beat="1"] .panel-left,
    .beat[data-beat="1"] .panel-right,
    .beat[data-beat="2"] .panel-left,
    .beat[data-beat="2"] .panel-right,
    .beat[data-beat="3"] .panel-left,
    .beat[data-beat="3"] .panel-right {
        flex: 0 0 50%;
    }

    .seam, .beat-seam {
        width: 100% !important;
        height: 3px;
    }

    .cultural-char {
        font-size: clamp(4rem, 12vw, 8rem);
    }

    .domain-title {
        font-size: clamp(3rem, 12vw, 6rem);
    }

    .beat-content {
        padding: 1.5rem;
    }

    .split-char-left {
        right: auto;
        clip-path: none;
    }

    .split-char-right {
        left: auto;
        clip-path: none;
        display: none;
    }
}
