/* ============================================
   resar.one - Wabi-Sabi Bento Box
   Palette: Complementary (Terracotta / Oxidized Copper)
   Typography: Nunito 800, Quicksand 400/500, Caveat 400
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    color: #2d2a26;
    background-color: #f5f0e8;
    overflow-x: hidden;
    /* Tatami grid texture */
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 119px,
            rgba(107, 101, 96, 0.005) 119px,
            rgba(107, 101, 96, 0.005) 120px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 89px,
            rgba(107, 101, 96, 0.003) 89px,
            rgba(107, 101, 96, 0.003) 90px
        );
}

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

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    letter-spacing: 0.02em;
}

h2 {
    font-size: clamp(1.3rem, 2.8vw, 2rem);
    color: #2d2a26;
    margin-bottom: 1rem;
}

h3 {
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    letter-spacing: 0.04em;
    color: #2d2a26;
    margin-bottom: 0.75rem;
}

p {
    max-width: 38em;
    margin-bottom: 0.75rem;
    color: #2d2a26;
}

a {
    color: #5a7a6a;
    text-decoration: none;
    cursor: pointer;
}

.caveat-note {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    color: rgba(74, 85, 104, 0.7);
    display: block;
    margin-top: 0.5rem;
}

/* Stone Gray #6b6560 - secondary text color */
.text-secondary {
    color: #6b6560;
}

/* --- Hanko Seal Navigation --- */
#hanko-seal {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #b85c38;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 400ms ease-out;
}

#hanko-seal .hanko-glyph {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 18px;
    color: #b85c38;
    line-height: 1;
    transition: color 400ms ease-out;
}

#hanko-seal.active {
    border-color: #c9a84c;
}

#hanko-seal.active .hanko-glyph {
    color: #c9a84c;
}

/* --- Navigation Overlay --- */
#nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: rgba(245, 240, 232, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 400ms ease-out;
    display: flex;
    align-items: center;
    padding-left: 2rem;
}

#nav-overlay.open {
    transform: translateX(0);
}

#nav-overlay ul {
    list-style: none;
}

#nav-overlay li {
    margin-bottom: 1.5rem;
}

#nav-overlay .nav-link {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: #2d2a26;
    letter-spacing: 0.02em;
    text-decoration: none;
}

/* --- Entry Screen --- */
#entry-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #f5f0e8;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

#entry-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 600ms ease-out;
}

#ensou-entry {
    margin-bottom: 1.5rem;
}

#ensou-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
}

#entry-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(2.6rem, 6.5vw, 5.8rem);
    color: #2d2a26;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(8px);
}

#entry-subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    color: rgba(74, 85, 104, 0.7);
    opacity: 0;
    transform: translateY(8px);
    max-width: none;
}

/* --- Main Bento Grid --- */
#bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto;
    gap: clamp(1px, 0.3vw, 3px);
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(1px, 0.3vw, 3px);
    opacity: 0;
}

#bento-grid.visible {
    opacity: 1;
    transition: opacity 600ms ease-out;
}

/* --- Bento Cells --- */
.bento-cell {
    position: relative;
    overflow: hidden;
    padding: clamp(1.5rem, 3vw, 3rem);
    background: #f5f0e8;
}

.cell-content {
    position: relative;
    z-index: 2;
}

/* --- Tokonoma --- */
#tokonoma {
    grid-column: 1 / 8;
    min-height: 60vh;
    display: flex;
    align-items: center;
    background: #f5f0e8;
}

.ensou-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 1;
    z-index: 1;
    pointer-events: none;
}

.tokonoma-content {
    position: relative;
    z-index: 2;
}

.tokonoma-content h2 {
    color: #b85c38;
    font-size: clamp(1.3rem, 2.8vw, 2rem);
}

/* --- Tsubo-niwa --- */
#tsubo-niwa {
    grid-column: 8 / 13;
    min-height: 60vh;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: #ede5d8;
}

.tsubo-content {
    position: relative;
    width: 100%;
    height: 100%;
}

.tsubo-label {
    position: absolute;
    bottom: 0;
    right: 0;
    text-align: right;
}

/* --- Vertical Divider --- */
#vertical-divider {
    position: absolute;
    top: 0;
    left: calc((7 / 12) * 100%);
    width: 2px;
    height: 60vh;
    background: #5a7a6a;
    z-index: 10;
    pointer-events: none;
}

/* --- Falling Leaves --- */
#leaf-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.falling-leaf {
    position: absolute;
    width: 20px;
    height: 10px;
    background: rgba(90, 122, 106, 0.08);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    top: -20px;
}

.leaf-1 { left: 10%; animation: leafFall 25s linear infinite; animation-delay: 0s; }
.leaf-2 { left: 30%; animation: leafFall 20s linear infinite; animation-delay: 3s; }
.leaf-3 { left: 50%; animation: leafFall 30s linear infinite; animation-delay: 7s; }
.leaf-4 { left: 70%; animation: leafFall 22s linear infinite; animation-delay: 2s; }
.leaf-5 { left: 85%; animation: leafFall 28s linear infinite; animation-delay: 10s; }
.leaf-6 { left: 20%; animation: leafFall 35s linear infinite; animation-delay: 5s; }
.leaf-7 { left: 60%; animation: leafFall 24s linear infinite; animation-delay: 12s; }

@keyframes leafFall {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg);
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    95% {
        opacity: 1;
    }
    100% {
        transform: translateY(calc(60vh + 20px)) translateX(40px) rotate(360deg);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .falling-leaf {
        animation: none;
        display: none;
    }
}

/* --- Noren Dividers --- */
.noren-divider {
    grid-column: 1 / 13;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10%;
    padding: 0.5rem 0;
}

.noren-left,
.noren-right {
    display: block;
    width: 45%;
    height: 4px;
    background: #4a5568;
    transform: scaleX(0);
    transition: transform 600ms ease-out;
}

.noren-left {
    transform-origin: right center;
}

.noren-right {
    transform-origin: left center;
}

.noren-divider.revealed .noren-left,
.noren-divider.revealed .noren-right {
    transform: scaleX(1);
}

/* --- Jubako Rows --- */
.jubako-row {
    grid-column: 1 / 13;
}

.jubako-row-1 {
    background: #ede5d8;
    border-top: 1px solid #4a5568;
}

.jubako-row-2 {
    background: #f5f0e8;
    border-top: 1px solid #4a5568;
}

.jubako-row-3 {
    background: #ede5d8;
    border-top: 1px solid #4a5568;
}

/* Jubako Inner Splits */
.jubako-inner {
    display: grid;
    gap: clamp(1rem, 2vw, 2rem);
}

.jubako-split-5-7 {
    grid-template-columns: 5fr 7fr;
}

.jubako-split-4-4-4 {
    grid-template-columns: 1fr 1fr 1fr;
}

.jubako-split-8-4 {
    grid-template-columns: 8fr 4fr;
}

.jubako-sub {
    padding: 1rem 0;
}

/* --- Hanko Bullet --- */
.hanko-bullet {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #b85c38;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Kintsugi Crack SVGs --- */
.kintsugi-crack {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.kintsugi-crack path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1200ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.bento-cell.crack-revealed .kintsugi-crack path {
    stroke-dashoffset: 0;
}

/* --- Moss Texture Corners --- */
.moss-corner {
    position: absolute;
    width: 120px;
    height: 120px;
    pointer-events: none;
    z-index: 1;
}

.moss-tl {
    top: 0;
    left: 0;
    background: radial-gradient(ellipse at top left, rgba(90, 122, 106, 0.04), transparent 60%);
}

.moss-br {
    bottom: 0;
    right: 0;
    background: radial-gradient(ellipse at bottom right, rgba(90, 122, 106, 0.04), transparent 60%);
}

.moss-bl {
    bottom: 0;
    left: 0;
    background: radial-gradient(ellipse at bottom left, rgba(90, 122, 106, 0.04), transparent 60%);
}

/* --- Ripple Effect --- */
.ripple-span {
    position: absolute;
    border: 1px solid #5a7a6a;
    border-radius: 50%;
    pointer-events: none;
    animation: rippleExpand 800ms ease-out forwards;
    z-index: 50;
}

@keyframes rippleExpand {
    0% {
        width: 0;
        height: 0;
        opacity: 0.15;
    }
    100% {
        width: 400px;
        height: 400px;
        opacity: 0;
    }
}

/* --- Footer --- */
#site-footer {
    grid-column: 1 / 13;
    background: #2d2a26;
    padding: clamp(1.5rem, 3vw, 3rem);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-domain {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    color: #f5f0e8;
    letter-spacing: 0.02em;
}

.footer-note {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    color: #6b6560;
}

/* --- First Letter Accent --- */
.jubako-sub > p:first-of-type::first-letter {
    color: #b85c38;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.3em;
}

/* --- Section Headings Color --- */
.jubako-sub h3 {
    color: #b85c38;
}

/* --- Mobile --- */
@media (max-width: 768px) {
    #bento-grid {
        display: flex;
        flex-direction: column;
        gap: clamp(1px, 0.3vw, 3px);
    }

    #tokonoma {
        min-height: 50vh;
    }

    #tsubo-niwa {
        min-height: 30vh;
    }

    #vertical-divider {
        display: none;
    }

    .jubako-split-5-7,
    .jubako-split-4-4-4,
    .jubako-split-8-4 {
        grid-template-columns: 1fr;
    }

    .falling-leaf {
        animation-play-state: paused;
    }

    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    #hanko-seal {
        top: 1rem;
        left: 1rem;
    }
}

/* --- Blockquote Styling --- */
blockquote {
    border-left: 2px solid #5a7a6a;
    padding-left: 1rem;
    margin: 1rem 0;
}
