/* ========================
   EESUGI.COM — STYLES
   ======================== */

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: #f5ede0;
    color: #2e1f14;
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* === NOISE TEXTURE OVERLAY === */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#grain);
    opacity: 0.04;
    pointer-events: none;
    z-index: 9999;
}

/* === THE CANOPY === */
#canopy {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.canopy-light {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 30%, rgba(196, 154, 60, 0.12) 0%, transparent 70%);
    pointer-events: none;
}

.canopy-content {
    position: relative;
    text-align: center;
    z-index: 1;
}

.canopy-title-wrap {
    position: relative;
    display: inline-block;
}

.canopy-ghost {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(calc(-50% + 4px), calc(-50% + 8px));
    font-family: 'Noto Serif JP', serif;
    font-weight: 500;
    font-size: clamp(3.2rem, 9.6vw, 8rem);
    color: #c49a3c;
    opacity: 0.25;
    pointer-events: none;
    white-space: nowrap;
    z-index: 0;
}

.canopy-title {
    position: relative;
    font-family: 'Commissioner', sans-serif;
    font-weight: 800;
    font-size: clamp(4rem, 12vw, 10rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: #2e1f14;
    z-index: 1;
}

.canopy-subtitle {
    margin-top: 1.5rem;
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: clamp(0.95rem, 1.5vw, 1.2rem);
    color: #5a3e2b;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.canopy-arrow {
    margin-top: 3rem;
    animation: bounceArrow 2s infinite ease-in-out;
}

@keyframes bounceArrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(10px); }
}

/* === MAIN BODY LAYOUT === */
#main-body {
    position: relative;
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding: 4rem 2rem 4rem 2rem;
}

/* === MARGINALIA === */
#marginalia {
    position: sticky;
    top: 2rem;
    width: 180px;
    min-width: 180px;
    height: fit-content;
    padding-right: 2rem;
    flex-shrink: 0;
}

.margin-note {
    position: absolute;
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    line-height: 1.5;
    color: #9e8d7a;
    max-width: 160px;
}

.ref-mark {
    font-size: 0.85rem;
    color: #c49a3c;
    margin-right: 0.2em;
}

/* === COLLECTION GRID === */
#collection {
    flex: 1;
    min-width: 0;
}

.section-rule {
    text-align: center;
    margin: 2rem 0;
    color: #c49a3c;
    font-size: 1.2rem;
    position: relative;
}

.section-rule::before,
.section-rule::after {
    content: '';
    position: absolute;
    top: 50%;
    height: 1px;
    width: calc(50% - 2rem);
    background-color: #5a3e2b;
    opacity: 0.3;
}

.section-rule::before {
    left: 0;
}

.section-rule::after {
    right: 0;
}

/* === CARD GRID === */
#collection {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    grid-auto-flow: dense;
    gap: 1rem;
}

.section-rule {
    grid-column: 1 / -1;
}

/* === CARD === */
.card {
    perspective: 1200px;
    cursor: pointer;
    min-height: 280px;
}

.card--tall {
    grid-row: span 2;
}

.card--wide {
    grid-column: span 2;
}

.card--feature {
    grid-column: span 2;
    grid-row: span 2;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 280px;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-inner.flipped {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border: 1px solid #5a3e2b;
    padding: 1.8rem;
    overflow: hidden;
}

.card-front {
    background-color: #faf6ef;
}

.card-back {
    background-color: #3b2a1a;
    color: #f0e4cc;
    transform: rotateY(180deg);
}

/* Card inner decorative border */
.card-border-inner {
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 1px dashed #c49a3c;
    pointer-events: none;
    opacity: 0.5;
}

/* Card candlelight */
.card-light {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 10%, rgba(196, 154, 60, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

.card-light--back {
    background: radial-gradient(ellipse at 50% 90%, rgba(196, 154, 60, 0.1) 0%, transparent 60%);
}

/* Card typography */
.card-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 800;
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 1rem;
    color: #2e1f14;
    position: relative;
    z-index: 1;
}

.card-excerpt {
    font-family: 'Source Serif 4', serif;
    font-size: clamp(0.9rem, 1.1vw, 1rem);
    line-height: 1.65;
    color: #5a3e2b;
    text-align: justify;
    hyphens: auto;
    position: relative;
    z-index: 1;
}

.card-back-text {
    font-family: 'Source Serif 4', serif;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    line-height: 1.7;
    color: #f0e4cc;
    text-align: justify;
    hyphens: auto;
    position: relative;
    z-index: 1;
}

/* Card motifs */
.card-motif {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 1;
}

.card-motif--seal {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: radial-gradient(circle, #c49a3c 40%, #d4874d 60%, transparent 70%);
    opacity: 0.5;
}

.card-motif--brush {
    width: 40px;
    height: 6px;
    background: linear-gradient(90deg, transparent, #c49a3c, #d4874d, transparent);
    border-radius: 3px;
    opacity: 0.5;
}

.card-motif--spine {
    width: 8px;
    height: 40px;
    background: #5a3e2b;
    opacity: 0.3;
    position: absolute;
    bottom: 12px;
    right: 16px;
}

.card-motif--spine::before,
.card-motif--spine::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: #c49a3c;
}

.card-motif--spine::before { top: 25%; }
.card-motif--spine::after { top: 75%; }

/* Card entrance animation */
.card {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

/* === THE COLOPHON === */
#colophon {
    max-width: 700px;
    margin: 4rem auto;
    padding: 3rem 2rem;
    text-align: center;
}

.colophon-rule {
    width: 60%;
    height: 1px;
    background: #5a3e2b;
    margin: 0 auto 2rem;
    opacity: 0.4;
}

.colophon-seal {
    margin-bottom: 1.5rem;
}

.colophon-text {
    font-family: 'Source Serif 4', serif;
    font-size: 0.8rem;
    line-height: 1.8;
    color: #9e8d7a;
    text-align: justify;
    hyphens: auto;
}

.colophon-text strong {
    color: #5a3e2b;
    font-weight: 600;
}

.colophon-date {
    margin-top: 1.5rem;
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    color: #c49a3c;
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
    #marginalia {
        display: none;
    }

    #main-body {
        padding: 2rem 1rem;
    }
}

@media (max-width: 640px) {
    #collection {
        grid-template-columns: 1fr;
    }

    .card--wide,
    .card--feature {
        grid-column: span 1;
    }

    .card--tall,
    .card--feature {
        grid-row: span 1;
    }

    .card {
        min-height: auto;
    }

    .card-inner {
        min-height: auto;
    }

    /* On mobile: expand/collapse instead of flip */
    .card-front,
    .card-back {
        position: relative;
        backface-visibility: visible;
        -webkit-backface-visibility: visible;
    }

    .card-back {
        transform: none;
        max-height: 0;
        padding: 0 1.8rem;
        overflow: hidden;
        transition: max-height 0.5s ease, padding 0.5s ease;
    }

    .card-inner.flipped .card-back {
        max-height: 500px;
        padding: 1.8rem;
    }

    .card-inner {
        transform: none !important;
    }
}
