/* Colors: #8b1a2b #c4922a #f5efe0 #2c1810 #1a3a5c #1a5c3a #6b3a6b #1a1a3c */
/* ===== Base Reset & Setup ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: #f5efe0;
    color: #2c1810;
    font-family: 'Lora', serif;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.75;
    overflow: hidden;
}

/* ===== Paper Grain Overlay ===== */
.grain-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9999;
    filter: url(#grain);
    opacity: 0.03;
}

/* ===== Scroll Container ===== */
.scroll-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
}

/* ===== Page Base ===== */
.page {
    position: relative;
    width: 100%;
    height: 100vh;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(2rem, 8vw, 6rem);
    overflow: hidden;
}

/* ===== Border Frames ===== */
.border-frame {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

.frame-path {
    stroke-dasharray: 3200;
    stroke-dashoffset: 3200;
    transition: stroke-dashoffset 2s ease-in-out;
}

.page.visible .frame-path {
    stroke-dashoffset: 0;
}

/* ===== Page 1: Title Card ===== */
.title-content {
    text-align: center;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.8s ease 0.5s;
}

.page-1.visible .title-content {
    opacity: 1;
}

.site-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: -0.02em;
    color: #2c1810;
    margin-bottom: 0.5rem;
}

.site-subtitle {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: #2c1810;
    opacity: 0;
    transition: opacity 0.8s ease 0.9s;
}

.page-1.visible .site-subtitle {
    opacity: 0.7;
}

/* ===== Floating Shapes ===== */
.floating-shapes {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 2;
}

.shape {
    position: absolute;
    opacity: 0;
    transition: opacity 1s ease, transform 1.5s ease;
}

.page-1.visible .shape {
    opacity: 1;
}

.shape-circle { width: 40px; top: 20%; left: 12%; animation: float 8s ease-in-out infinite; }
.shape-triangle { width: 40px; top: 15%; right: 15%; animation: float 7s ease-in-out 1s infinite; }
.shape-squiggle { width: 50px; bottom: 30%; left: 8%; animation: float 9s ease-in-out 0.5s infinite; }
.shape-star { width: 40px; bottom: 25%; right: 10%; animation: float 6s ease-in-out 2s infinite; }
.shape-diamond { width: 35px; top: 35%; right: 25%; animation: float 10s ease-in-out 1.5s infinite; }

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

/* ===== Scroll Arrow ===== */
.scroll-arrow {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    animation: bob 3s ease-in-out infinite;
}

.scroll-arrow svg {
    width: 30px;
    height: 40px;
}

@keyframes bob {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(8px); }
}

/* ===== Page Curl ===== */
.page-curl {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 60px;
    z-index: 3;
    background: linear-gradient(225deg, #f5efe0 45%, transparent 45%),
                linear-gradient(225deg, rgba(44,24,16,0.08) 50%, transparent 50%);
    cursor: pointer;
    transition: width 0.3s ease, height 0.3s ease;
}

.page-curl:hover {
    width: 80px;
    height: 80px;
}

.page-curl-large {
    width: 90px;
    height: 90px;
}

.page-curl-large:hover {
    width: 120px;
    height: 120px;
}

/* ===== Section Titles ===== */
.section-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: -0.02em;
    color: #2c1810;
    z-index: 2;
    margin-bottom: 1.5rem;
}

/* ===== Page 2: Gallery Cards ===== */
.gallery-cards {
    position: relative;
    width: 100%;
    height: 60vh;
    z-index: 2;
}

.card {
    position: absolute;
    width: clamp(140px, 18vw, 200px);
    height: clamp(180px, 24vw, 260px);
    left: var(--x);
    top: var(--y);
    transform: rotate(var(--rotate));
    perspective: 1000px;
    cursor: pointer;
    z-index: 2;
}

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

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

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.card-front {
    background: #f5efe0;
    box-shadow: inset 0 0 20px rgba(44, 24, 16, 0.1), 2px 3px 10px rgba(44, 24, 16, 0.15);
    border: 2px solid rgba(44, 24, 16, 0.2);
}

.card-front svg {
    width: 70%;
    height: auto;
    margin-bottom: 0.5rem;
}

.card-label {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: #2c1810;
}

.card-back {
    background: #1a1a3c;
    color: #f5efe0;
    transform: rotateY(180deg);
    box-shadow: 2px 3px 10px rgba(44, 24, 16, 0.2);
    border: 2px solid rgba(139, 26, 43, 0.4);
}

.card-back p {
    font-family: 'Caveat', cursive;
    font-size: clamp(1rem, 2vw, 1.3rem);
    text-align: center;
    line-height: 1.5;
}

/* Card initial state (face-down) before reveal */
.card.face-down .card-inner {
    transform: rotateY(180deg);
}

/* Corner fold on card front */
.card-front::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 20px; height: 20px;
    background: linear-gradient(225deg, rgba(44,24,16,0.06) 50%, #f5efe0 50%);
}

/* ===== Page 3: The Story ===== */
.story-content {
    z-index: 2;
    max-width: 650px;
    width: 100%;
    overflow-y: auto;
    max-height: 80vh;
    padding-right: 1rem;
}

.story-content::-webkit-scrollbar {
    width: 4px;
}

.story-content::-webkit-scrollbar-thumb {
    background: rgba(44, 24, 16, 0.2);
    border-radius: 2px;
}

.story-text p {
    margin-bottom: 1.5rem;
    text-align: left;
}

.story-illustration {
    float: left;
    margin: 0 1.5rem 1rem 0;
    shape-outside: circle(50%);
}

.story-illus-2 {
    float: right;
    margin: 0 0 1rem 1.5rem;
}

.story-illustration svg {
    width: 70px;
    height: 70px;
}

.annotation {
    font-family: 'Caveat', cursive;
    color: #6b3a6b;
    font-size: clamp(1rem, 2vw, 1.4rem);
    margin: 0.5rem 0 1.5rem;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    padding-left: 1rem;
    border-left: 2px solid #6b3a6b;
}

.page-3.visible .annotation {
    opacity: 1;
    transform: translateX(0);
}

.annotation-1 { transition-delay: 0.5s; }
.annotation-2 { transition-delay: 1s; }
.annotation-3 { transition-delay: 1.5s; }

.divider-line {
    width: 100%;
    height: 20px;
    margin: 1rem 0 1.5rem;
    display: block;
}

/* ===== Page 4: Collection Carousel ===== */
.carousel-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 900px;
    z-index: 2;
    gap: 1rem;
}

.carousel-track {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 1.5rem 0.5rem;
    flex: 1;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar {
    display: none;
}

.carousel-arrow {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.carousel-arrow:hover {
    opacity: 1;
}

.carousel-arrow svg {
    width: 25px;
    height: 35px;
}

.collection-card {
    flex-shrink: 0;
    width: 240px;
    height: 340px;
    perspective: 1000px;
    cursor: pointer;
}

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

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

.collection-card .card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: #f5efe0;
    box-shadow: inset 0 0 20px rgba(44, 24, 16, 0.1), 2px 4px 15px rgba(44, 24, 16, 0.15);
    border: 2px solid rgba(44, 24, 16, 0.2);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.collection-card .card-front svg {
    width: 80%;
    height: auto;
    margin-bottom: 1rem;
}

.collection-card .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transform: rotateY(180deg);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-shadow: 2px 4px 15px rgba(44, 24, 16, 0.2);
}

.collection-card .card-back p {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    line-height: 1.6;
    text-align: center;
}

.collection-card .card-label {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1rem;
}

/* Pattern backgrounds for card backs */
.pattern-stipple {
    background-color: #1a1a3c;
    color: #f5efe0;
    background-image: radial-gradient(circle, rgba(245,239,224,0.15) 1px, transparent 1px);
    background-size: 8px 8px;
}

.pattern-stripes {
    background-color: #1a3a5c;
    color: #f5efe0;
    background-image: repeating-linear-gradient(47deg, transparent, transparent 6px, rgba(245,239,224,0.1) 6px, rgba(245,239,224,0.1) 7px);
}

.pattern-chevron {
    background-color: #1a5c3a;
    color: #f5efe0;
    background-image:
        linear-gradient(135deg, rgba(245,239,224,0.08) 25%, transparent 25%),
        linear-gradient(225deg, rgba(245,239,224,0.08) 25%, transparent 25%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 0;
}

.pattern-crosshatch {
    background-color: #2c1810;
    color: #f5efe0;
    background-image:
        repeating-linear-gradient(43deg, transparent, transparent 5px, rgba(196,146,42,0.12) 5px, rgba(196,146,42,0.12) 6px),
        repeating-linear-gradient(137deg, transparent, transparent 5px, rgba(196,146,42,0.12) 5px, rgba(196,146,42,0.12) 6px);
}

.pattern-dots {
    background-color: #6b3a6b;
    color: #f5efe0;
    background-image: radial-gradient(circle, rgba(245,239,224,0.2) 2px, transparent 2px);
    background-size: 12px 12px;
}

/* ===== Page 5: Farewell ===== */
.farewell-content {
    z-index: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.farewell-illustration {
    width: clamp(280px, 50vw, 400px);
}

.farewell-svg {
    width: 100%;
    height: auto;
}

.farewell-shape {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.5s ease;
}

.page-5.visible .s1 { stroke-dashoffset: 0; transition-delay: 0.2s; }
.page-5.visible .s2 { stroke-dashoffset: 0; transition-delay: 0.5s; }
.page-5.visible .s3 { stroke-dashoffset: 0; transition-delay: 0.8s; }
.page-5.visible .s4 { stroke-dashoffset: 0; transition-delay: 1.1s; }
.page-5.visible .s5 { stroke-dashoffset: 0; transition-delay: 1.4s; }

.farewell-signature {
    width: clamp(200px, 40vw, 300px);
}

.signature-svg {
    width: 100%;
    height: auto;
}

.signature-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease 1.8s;
}

.page-5.visible .signature-path {
    stroke-dashoffset: 0;
}

.farewell-note {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: #6b3a6b;
    opacity: 0;
    transition: opacity 1s ease 3s;
}

.page-5.visible .farewell-note {
    opacity: 1;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .card {
        width: clamp(110px, 30vw, 160px);
        height: clamp(140px, 40vw, 210px);
    }

    .collection-card {
        width: 200px;
        height: 280px;
    }

    .gallery-cards {
        height: 55vh;
    }
}
