/* =============================================
   yesan.xyz - Styles
   Japanese-minimal aesthetic with ma-governed layout
   ============================================= */

/* CSS Custom Properties */
:root {
    --washi-cream: #F5EDE0;
    --warm-linen: #EDE4D3;
    --sumi-charcoal: #3A3228;
    --kintsugi-amber: #C4A97D;
    --persimmon-soft: #D4896A;
    --stone-moss: #8A9178;
    --urushi-dark: #2C2418;

    --font-display: 'Zen Kaku Gothic New', sans-serif;
    --font-body: 'Nunito Sans', sans-serif;
    --font-accent: 'Caveat', cursive;

    --baseline: 28px;
    --section-gap-sm: 140px;
    --section-gap-lg: 280px;
    --golden-ratio: 38.2%;
}

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

html {
    font-size: 16px;
    scroll-behavior: auto;
}

body {
    background-color: var(--washi-cream);
    color: var(--sumi-charcoal);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.15vw, 1.125rem);
    line-height: 1.85;
    overflow-x: hidden;
    position: relative;
}

/* Paper grain texture overlay */
.paper-texture-filter {
    position: absolute;
    width: 0;
    height: 0;
}

.paper-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
    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.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* Golden ratio vertical guideline */
.golden-guideline {
    position: fixed;
    left: var(--golden-ratio);
    top: 0;
    width: 1px;
    height: 100vh;
    background-color: var(--kintsugi-amber);
    opacity: 0.12;
    z-index: 1;
    pointer-events: none;
}

/* =============================================
   Floating Leaves (CSS-only animation)
   ============================================= */
.leaf {
    position: fixed;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.leaf svg {
    width: 100%;
    height: 100%;
}

.leaf-1 {
    width: 24px;
    height: 40px;
    left: 15%;
    top: -50px;
    animation: leafFall1 45s linear infinite;
}

.leaf-2 {
    width: 20px;
    height: 32px;
    left: 55%;
    top: -40px;
    animation: leafFall2 52s linear infinite;
    animation-delay: -15s;
}

.leaf-3 {
    width: 18px;
    height: 30px;
    left: 78%;
    top: -45px;
    animation: leafFall3 67s linear infinite;
    animation-delay: -30s;
}

.leaf-4 {
    width: 16px;
    height: 28px;
    left: 35%;
    top: -35px;
    animation: leafFall4 58s linear infinite;
    animation-delay: -10s;
}

.leaf-5 {
    width: 22px;
    height: 36px;
    left: 88%;
    top: -48px;
    animation: leafFall5 62s linear infinite;
    animation-delay: -25s;
}

@keyframes leafFall1 {
    0% { transform: translateY(-50px) rotate(0deg); opacity: 0; }
    5% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { transform: translateY(105vh) rotate(360deg); opacity: 0; }
}

@keyframes leafFall2 {
    0% { transform: translateY(-40px) rotate(15deg) translateX(0); opacity: 0; }
    5% { opacity: 0.5; }
    50% { transform: translateY(50vh) rotate(195deg) translateX(30px); }
    90% { opacity: 0.5; }
    100% { transform: translateY(105vh) rotate(375deg) translateX(-10px); opacity: 0; }
}

@keyframes leafFall3 {
    0% { transform: translateY(-45px) rotate(-10deg) translateX(0); opacity: 0; }
    5% { opacity: 0.4; }
    33% { transform: translateY(33vh) rotate(110deg) translateX(-20px); }
    66% { transform: translateY(66vh) rotate(230deg) translateX(15px); }
    90% { opacity: 0.4; }
    100% { transform: translateY(105vh) rotate(350deg) translateX(-5px); opacity: 0; }
}

@keyframes leafFall4 {
    0% { transform: translateY(-35px) rotate(25deg); opacity: 0; }
    5% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% { transform: translateY(105vh) rotate(385deg); opacity: 0; }
}

@keyframes leafFall5 {
    0% { transform: translateY(-48px) rotate(-20deg) translateX(0); opacity: 0; }
    5% { opacity: 0.35; }
    50% { transform: translateY(52vh) rotate(160deg) translateX(-25px); }
    90% { opacity: 0.35; }
    100% { transform: translateY(105vh) rotate(340deg) translateX(10px); opacity: 0; }
}

/* Branch motif */
.branch-motif {
    position: absolute;
    top: 40vh;
    left: -40px;
    width: 300px;
    height: 120px;
    z-index: 2;
    pointer-events: none;
}

/* =============================================
   Header / Logotype
   ============================================= */
.site-header {
    position: fixed;
    top: 28px;
    left: 28px;
    z-index: 100;
}

.logotype {
    font-family: var(--font-accent);
    font-size: 1.2rem;
    color: var(--urushi-dark);
    letter-spacing: 0.02em;
    opacity: 0.8;
    transition: opacity 0.4s ease;
}

.logotype:hover {
    opacity: 1;
}

/* =============================================
   Section: Opening (0-100vh)
   ============================================= */
.section-opening {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.opening-content {
    position: absolute;
    top: 38.2%;
    left: var(--golden-ratio);
    transform: translate(-50%, -50%);
    text-align: center;
}

.opening-title {
    font-family: var(--font-accent);
    font-weight: 400;
    font-size: clamp(3.5rem, 8vw, 7rem);
    color: var(--sumi-charcoal);
    letter-spacing: 0.06em;
    opacity: 0;
}

.opening-title .char {
    display: inline-block;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.opening-title .char.visible {
    opacity: 1;
    transform: scale(1);
}

.brush-divider-opening {
    width: clamp(120px, 20vw, 200px);
    margin-top: 24px;
    opacity: 0;
    transition: opacity 1s ease 2s;
}

.brush-divider-opening.visible {
    opacity: 1;
}

.brush-stroke-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1.5s ease 2.2s;
}

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

/* =============================================
   Brush Dividers (general)
   ============================================= */
.brush-divider {
    display: block;
    margin: 60px 0;
    opacity: 0.7;
}

.brush-divider-1 {
    width: clamp(100px, 16vw, 160px);
    margin-left: 42%;
}

.brush-divider-2 {
    width: clamp(80px, 12vw, 120px);
    margin-left: 30%;
}

.brush-divider-3 {
    width: clamp(120px, 18vw, 180px);
    margin-left: 35%;
}

.brush-divider-4 {
    width: clamp(90px, 14vw, 140px);
    margin-left: 50%;
}

/* =============================================
   Section: Philosophy (100vh-250vh)
   ============================================= */
.section-philosophy {
    padding: var(--section-gap-lg) 0;
    position: relative;
    min-height: 150vh;
}

.philosophy-block {
    max-width: 480px;
    padding: var(--baseline) 0;
    margin-bottom: var(--section-gap-sm);
    position: relative;
}

.philosophy-block-1 {
    margin-left: 12%;
}

.philosophy-block-2 {
    margin-left: 52%;
}

.philosophy-block-3 {
    margin-left: 8%;
}

.philosophy-block-4 {
    margin-left: 32%;
    max-width: 400px;
}

.philosophy-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.15vw, 1.125rem);
    line-height: 1.85;
    color: var(--sumi-charcoal);
}

.philosophy-text em {
    font-style: italic;
    color: var(--sumi-charcoal);
}

.highlight-word {
    color: var(--kintsugi-amber);
    font-weight: 600;
}

/* =============================================
   Margin Illustrations
   ============================================= */
.margin-illust {
    position: absolute;
    pointer-events: none;
}

.margin-illust-cup {
    width: 48px;
    height: 48px;
    top: -10px;
    right: -72px;
}

.margin-illust-envelope {
    width: 56px;
    height: 40px;
    top: 50%;
    right: -80px;
    transform: translateY(-50%);
}

.margin-illust-bamboo {
    width: 40px;
    height: 80px;
    top: -20px;
    left: -60px;
}

.margin-illust-maple {
    width: 48px;
    height: 48px;
    bottom: -10px;
    right: -72px;
}

/* =============================================
   Section: Core Content (250vh-500vh)
   ============================================= */
.section-core {
    padding: var(--section-gap-sm) 0 var(--section-gap-lg);
    position: relative;
    min-height: 250vh;
}

.core-block {
    max-width: 520px;
    padding: var(--baseline) 0;
    margin-bottom: var(--section-gap-sm);
    position: relative;
}

.core-block-1 {
    margin-left: 10%;
}

.core-block-2 {
    margin-left: 48%;
}

.core-block-3 {
    margin-left: 15%;
}

.core-block-4 {
    margin-left: 50%;
}

.core-block-5 {
    margin-left: 25%;
    max-width: 460px;
}

.core-block-6 {
    margin-left: 12%;
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.04em;
    color: var(--sumi-charcoal);
    margin-bottom: calc(var(--baseline) * 0.75);
    line-height: 1.3;
}

.core-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.15vw, 1.125rem);
    line-height: 1.85;
    color: var(--sumi-charcoal);
}

.core-text-accent {
    font-family: var(--font-accent);
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    line-height: 1.6;
    color: var(--sumi-charcoal);
    opacity: 0.85;
}

.amber-highlight {
    color: var(--kintsugi-amber);
    font-weight: 600;
    position: relative;
    display: inline;
}

.amber-highlight::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--kintsugi-amber);
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.amber-highlight.underlined::after {
    width: 100%;
}

/* =============================================
   Scroll Reveal Animation
   ============================================= */
.scroll-reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* =============================================
   Section: Closing (500vh-600vh)
   ============================================= */
.section-closing {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: var(--section-gap-lg) 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.closing-content {
    text-align: center;
    position: relative;
    z-index: 5;
}

.closing-enso-container {
    width: clamp(160px, 30vw, 280px);
    height: clamp(160px, 30vw, 280px);
    margin: 0 auto 48px;
}

.closing-enso {
    width: 100%;
    height: 100%;
}

.enso-circle-path {
    stroke-dasharray: 480;
    stroke-dashoffset: 480;
    transition: stroke-dashoffset 3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.enso-circle-path.drawing {
    /* Leave ~15 degree gap: 480 * (15/360) = 20 */
    stroke-dashoffset: 20;
}

.closing-text {
    font-family: var(--font-accent);
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: var(--sumi-charcoal);
    letter-spacing: 0.02em;
    opacity: 0;
    transition: opacity 1.2s ease 1s;
}

.closing-text.visible {
    opacity: 1;
}

/* Darkened state for closing section */
.section-closing.darkened {
    background-color: var(--urushi-dark);
}

.section-closing.darkened .closing-text {
    color: var(--washi-cream);
}

/* =============================================
   Footer
   ============================================= */
.site-footer {
    background-color: var(--urushi-dark);
    position: relative;
    padding: 80px 0 48px;
    overflow: hidden;
}

.mountain-ridge {
    position: absolute;
    top: -1px;
    left: 0;
    width: 100%;
    height: 120px;
}

.footer-content {
    text-align: center;
    position: relative;
    z-index: 5;
}

.footer-mark {
    font-family: var(--font-accent);
    font-size: 1rem;
    color: var(--washi-cream);
    opacity: 0.5;
    letter-spacing: 0.04em;
}

/* =============================================
   Enso Progress Indicator
   ============================================= */
.enso-progress {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 48px;
    height: 48px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.enso-progress.visible {
    opacity: 1;
}

.enso-progress-track {
    opacity: 0.3;
}

.enso-progress-fill {
    stroke-dasharray: 125.66;
    stroke-dashoffset: 125.66;
    transition: stroke-dashoffset 0.15s ease;
}

/* =============================================
   Responsive Adjustments
   ============================================= */
@media (max-width: 768px) {
    .philosophy-block,
    .core-block {
        max-width: 85vw;
        margin-left: 7% !important;
    }

    .philosophy-block[data-offset="right"],
    .core-block[data-offset="right"] {
        margin-left: 10% !important;
    }

    .margin-illust {
        display: none;
    }

    .branch-motif {
        opacity: 0.5;
    }

    .golden-guideline {
        display: none;
    }

    .brush-divider-1,
    .brush-divider-2,
    .brush-divider-3,
    .brush-divider-4 {
        margin-left: 7%;
    }
}

@media (max-width: 480px) {
    .opening-content {
        left: 50%;
    }

    .site-header {
        top: 16px;
        left: 16px;
    }

    .enso-progress {
        bottom: 16px;
        right: 16px;
    }
}

/* =============================================
   Prefers Reduced Motion
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    .leaf {
        animation: none !important;
        display: none;
    }

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

    .opening-title .char {
        opacity: 1;
        transform: none;
        transition: none;
    }

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

    .enso-circle-path {
        transition: none;
    }

    .closing-text {
        opacity: 1;
        transition: none;
    }

    .amber-highlight::after {
        width: 100%;
        transition: none;
    }
}
