/* ==================================================
   yesan.xyz - Isometric Ledger-World Styles
   ================================================== */

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

:root {
    --midnight-ledger: #0C1222;
    --slate-rule: #1E2A42;
    --paper-cream: #F0E6D3;
    --aged-vellum: #C4B59A;
    --shadow-bisque: #8A7B66;
    --brass-abacus: #D4A44C;
    --ink-black: #1A1610;
    --red-margin: #B84233;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--midnight-ledger);
    color: var(--ink-black);
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    line-height: 1.75;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Typography --- */
.display-font {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    line-height: 1.1;
}

.korean-text {
    font-family: 'Nanum Myeongjo', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 2.5rem);
    color: var(--ink-black);
    line-height: 1.3;
}

.korean-sub {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--ink-black);
    opacity: 0.7;
    margin-top: 0.5rem;
}

.body-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.5vw, 1.2rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    color: var(--ink-black);
}

/* --- Isometric Grid Background --- */
#iso-grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background-color: var(--midnight-ledger);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cline x1='0' y1='0' x2='60' y2='34.64' stroke='%231E2A42' stroke-width='0.5'/%3E%3Cline x1='60' y1='0' x2='0' y2='34.64' stroke='%231E2A42' stroke-width='0.5'/%3E%3Cline x1='0' y1='34.64' x2='60' y2='60' stroke='%231E2A42' stroke-width='0.5'/%3E%3Cline x1='60' y1='34.64' x2='0' y2='60' stroke='%231E2A42' stroke-width='0.5'/%3E%3C/svg%3E");
    background-size: 60px 60px;
}

/* --- Isometric Block System --- */
.iso-block {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 0;
    perspective: 1000px;
}

.iso-block-inner {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 0;
    transform-style: preserve-3d;
}

/* --- Face Styles --- */
.face {
    position: relative;
    overflow: hidden;
}

.face-top {
    grid-column: 1 / -1;
    grid-row: 1;
    background-color: var(--paper-cream);
    padding: 2.5rem 3rem;
    transform: skewY(-2deg);
    transform-origin: top left;
    min-height: 200px;
}

.face-left {
    grid-column: 1;
    grid-row: 2;
    background-color: var(--aged-vellum);
    padding: 2rem 2rem;
    transform: skewX(4deg) skewY(-2deg);
    transform-origin: top right;
    min-height: 120px;
}

.face-right {
    grid-column: 2;
    grid-row: 2;
    background-color: var(--shadow-bisque);
    padding: 2rem 2rem;
    transform: skewX(-4deg) skewY(-2deg);
    transform-origin: top left;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* --- Ledger Lines (ruled background) --- */
.ledger-lines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent calc(1.75rem - 1px),
        var(--aged-vellum) calc(1.75rem - 1px),
        var(--aged-vellum) 1.75rem
    );
    opacity: 0.5;
}

/* --- Red Margin Line --- */
.margin-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 15%;
    width: 1px;
    z-index: 1;
    pointer-events: none;
    border-left: 1px dashed var(--red-margin);
    opacity: 0.6;
}

.face-top .face-content {
    padding-left: calc(15% + 1.5rem);
    position: relative;
}

/* --- Stamp Watermark --- */
.stamp-watermark {
    position: absolute;
    top: 50%;
    right: 5%;
    transform: translateY(-50%) rotate(-12deg);
    opacity: 0.05;
    width: 120px;
    height: 120px;
    pointer-events: none;
}

.stamp-svg {
    width: 100%;
    height: 100%;
}

/* --- Hero Block --- */
#hero {
    padding-top: 15vh;
    padding-bottom: 10vh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#hero .iso-block-inner {
    opacity: 0;
}

#hero .face-top {
    min-height: 250px;
    display: flex;
    align-items: center;
}

#hero-title {
    font-size: clamp(3rem, 8vw, 7rem);
    color: var(--ink-black);
    display: inline;
}

.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 0.9em;
    background-color: var(--brass-abacus);
    margin-left: 4px;
    vertical-align: baseline;
    animation: blink-cursor 0.8s step-end infinite;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

#hero .korean-text {
    font-size: clamp(2rem, 4vw, 4rem);
}

/* --- Abacus --- */
.abacus-svg {
    width: 100%;
    max-width: 180px;
}

.abacus-bead {
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.abacus-bead:active {
    transform: scale(0.95);
}

#abacus-count {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--paper-cream);
    text-align: center;
    margin-top: 0.5rem;
    letter-spacing: 0.2em;
}

/* --- Isometric Shadow --- */
.iso-shadow {
    position: absolute;
    bottom: 60px;
    left: 5%;
    right: 5%;
    height: 40px;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.3) 0%, transparent 70%);
    filter: blur(15px);
    transform: skewX(-15deg);
    z-index: 0;
    pointer-events: none;
}

/* --- Content Blocks --- */
.content-block {
    padding: 40px 0;
    min-height: auto;
}

.content-block h2 {
    font-size: clamp(1.5rem, 3vw, 3rem);
    color: var(--ink-black);
    margin-bottom: 1rem;
}

.content-block .face-top {
    min-height: 180px;
}

/* Block positioning: zigzag stagger */
.block-right {
    margin-left: auto;
    margin-right: 5%;
}

.block-left {
    margin-left: 5%;
    margin-right: auto;
}

/* --- Block Animation States --- */
.content-block .face-top,
.content-block .face-left,
.content-block .face-right {
    opacity: 0;
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.content-block .face-top {
    transform: skewY(-2deg) translateY(-20px);
}

.content-block.block-right .face-left {
    transform: skewX(4deg) skewY(-2deg) translateX(-30px);
}

.content-block.block-right .face-right {
    transform: skewX(-4deg) skewY(-2deg) translateX(30px);
}

.content-block.block-left .face-left {
    transform: skewX(4deg) skewY(-2deg) translateX(-30px);
}

.content-block.block-left .face-right {
    transform: skewX(-4deg) skewY(-2deg) translateX(30px);
}

/* Assembled state */
.content-block.assembled .face-top {
    opacity: 1;
    transform: skewY(-2deg) translateY(0);
}

.content-block.assembled .face-left {
    opacity: 1;
    transform: skewX(4deg) skewY(-2deg) translateX(0);
}

.content-block.assembled .face-right {
    opacity: 1;
    transform: skewX(-4deg) skewY(-2deg) translateX(0);
}

/* --- Hover Lift --- */
.content-block .iso-block-inner {
    transition: transform 0.25s ease-out;
}

.content-block .iso-shadow {
    transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}

.content-block:hover .iso-block-inner {
    transform: translateY(-8px);
}

.content-block:hover .iso-shadow {
    transform: skewX(-15deg) scale(1.05);
    opacity: 0.8;
}

/* --- Abacus Divider --- */
.abacus-divider {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 20px 0;
    opacity: 0.5;
}

.mini-abacus {
    width: 80px;
    height: 20px;
}

/* --- Corner Coin Stacks --- */
.corner-coins {
    position: absolute;
    z-index: 2;
    pointer-events: none;
}

.corner-coins-tl {
    top: 30px;
    left: -25px;
}

.corner-coins-br {
    bottom: 30px;
    right: -25px;
}

.floating-coins {
    width: 30px;
    animation: float 4s ease-in-out infinite;
}

.corner-coins-tl .floating-coins {
    animation-delay: 0s;
}

.corner-coins-br .floating-coins {
    animation-delay: -1.5s;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* --- Motif SVGs in Right Faces --- */
.coin-stack {
    width: 60px;
    height: auto;
}

.mini-abacus-motif {
    width: 60px;
    height: auto;
}

.geometric-motif {
    width: 60px;
    height: auto;
}

.ink-pot-motif {
    width: 55px;
    height: auto;
}

.books-motif {
    width: 60px;
    height: auto;
}

/* --- Footer --- */
#ledger-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 80px 20px 120px;
    margin-top: 40px;
}

.ledger-total-line {
    width: 60%;
    max-width: 500px;
    height: 1px;
    background-color: var(--aged-vellum);
    margin: 0 auto 3rem;
    transform: skewX(-15deg);
    opacity: 0.6;
}

.ledger-total {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.total-text {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(1.5rem, 3vw, 3rem);
    color: var(--paper-cream);
    letter-spacing: 0.2em;
    display: block;
}

.total-underline {
    display: block;
    width: 60%;
    max-width: 300px;
    height: 1px;
    background-color: var(--brass-abacus);
    margin-top: 8px;
}

.total-double-underline {
    display: block;
    width: 60%;
    max-width: 300px;
    height: 1px;
    background-color: var(--brass-abacus);
    margin-top: 4px;
}

/* --- Footer Seal --- */
.footer-seal {
    margin-top: 3rem;
    opacity: 0;
    transform: scale(0) rotate(-12deg);
    transition: opacity 0.6s ease-out, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.footer-seal.visible {
    opacity: 1;
    transform: scale(1) rotate(-12deg);
}

.seal-svg {
    width: 80px;
    height: 80px;
}

/* --- Hero Face Animation Keyframes --- */
@keyframes fadeInTop {
    from {
        opacity: 0;
        transform: skewY(-2deg) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: skewY(-2deg) translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: skewX(4deg) skewY(-2deg) translateX(-30px);
    }
    to {
        opacity: 1;
        transform: skewX(4deg) skewY(-2deg) translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: skewX(-4deg) skewY(-2deg) translateX(30px);
    }
    to {
        opacity: 1;
        transform: skewX(-4deg) skewY(-2deg) translateX(0);
    }
}

#hero.animating .iso-block-inner {
    opacity: 1;
}

#hero.animating .face-top {
    animation: fadeInTop 0.6s ease-out forwards;
    animation-delay: 0.4s;
    opacity: 0;
}

#hero.animating .face-left {
    animation: slideInLeft 0.5s ease-out forwards;
    animation-delay: 0.6s;
    opacity: 0;
}

#hero.animating .face-right {
    animation: slideInRight 0.5s ease-out forwards;
    animation-delay: 0.7s;
    opacity: 0;
}

/* --- Content Block Face Transitions with Delays --- */
.content-block.assembled .face-top {
    transition-delay: 0s;
}

.content-block.assembled .face-left {
    transition-delay: 0.15s;
}

.content-block.assembled .face-right {
    transition-delay: 0.25s;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .iso-block {
        width: 95%;
    }

    .iso-block-inner {
        grid-template-columns: 1fr;
    }

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

    .face-left {
        grid-row: 2;
    }

    .face-right {
        grid-row: 3;
    }

    .face-top {
        transform: none;
        min-height: 150px;
    }

    .face-left {
        transform: none;
    }

    .face-right {
        transform: none;
    }

    .content-block .face-top {
        transform: translateY(-20px);
    }

    .content-block.assembled .face-top {
        transform: translateY(0);
    }

    .content-block .face-left {
        transform: translateX(-30px);
    }

    .content-block.assembled .face-left {
        transform: translateX(0);
    }

    .content-block .face-right {
        transform: translateX(30px);
    }

    .content-block.assembled .face-right {
        transform: translateX(0);
    }

    .face-top .face-content {
        padding-left: 1.5rem;
    }

    .block-right,
    .block-left {
        margin-left: auto;
        margin-right: auto;
    }

    .corner-coins {
        display: none;
    }

    #hero {
        padding-top: 10vh;
        min-height: auto;
    }

    #hero .face-top {
        min-height: 150px;
    }

    #hero.animating .face-top {
        animation-name: fadeInTopMobile;
    }

    #hero.animating .face-left {
        animation-name: slideInLeftMobile;
    }

    #hero.animating .face-right {
        animation-name: slideInRightMobile;
    }

    @keyframes fadeInTopMobile {
        from { opacity: 0; transform: translateY(-20px); }
        to { opacity: 1; transform: translateY(0); }
    }

    @keyframes slideInLeftMobile {
        from { opacity: 0; transform: translateX(-30px); }
        to { opacity: 1; transform: translateX(0); }
    }

    @keyframes slideInRightMobile {
        from { opacity: 0; transform: translateX(30px); }
        to { opacity: 1; transform: translateX(0); }
    }
}

@media (max-width: 480px) {
    .face-top {
        padding: 1.5rem 1.5rem;
    }

    .face-left,
    .face-right {
        padding: 1.5rem;
    }

    #hero-title {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }
}
