/* mybadge.page - Scandinavian candlelit badge display */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Lora', serif;
    color: #2C2418;
    background-color: #F5EDE0;
    background-image: radial-gradient(ellipse at 50% 30%, #F5EDE0 0%, #E8D9C4 70%, #D4C4A8 100%);
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== Page Wrapper ===== */
.page-wrapper {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 clamp(2rem, 8vw, 6rem);
}

/* ===== Hero Section ===== */
.hero {
    height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.hero-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-title {
    position: absolute;
    top: clamp(2rem, 6vh, 4rem);
    left: 0;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #6B5B4A;
}

.candle-flame-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hero-flame {
    position: relative;
}

.hero-flame .candle-flame {
    width: 30px;
    height: 60px;
}

/* Candle flame animation - three independent timelines with prime-adjacent durations */
.candle-flame {
    animation:
        flame-sway 3.1s ease-in-out infinite alternate,
        flame-scale 2.7s ease-in-out infinite alternate,
        flame-flicker 4.3s ease-in-out infinite alternate;
    will-change: transform, opacity;
}

@keyframes flame-sway {
    0% { transform: skewX(-2deg); }
    100% { transform: skewX(2deg); }
}

@keyframes flame-scale {
    0% { transform: scaleY(0.95); }
    100% { transform: scaleY(1.05); }
}

@keyframes flame-flicker {
    0% { opacity: 0.85; }
    50% { opacity: 1; }
    100% { opacity: 0.9; }
}

.candle-flame-small {
    width: 12px;
    height: 20px;
}

/* ===== Badge Shelf Sections ===== */
.badge-shelf {
    position: relative;
    margin-bottom: clamp(6rem, 12vh, 10rem);
    padding: clamp(2rem, 4vw, 3rem);
    opacity: 0;
    transform: translateY(40px);
    transition: none;
}

.badge-shelf.is-visible {
    opacity: 1;
    transform: translateY(0);
    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);
}

/* ===== Border Draw Animation ===== */
.shelf-border-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.border-line {
    position: absolute;
    background-color: #C4973B;
    transition: background-color 0.5s ease 1.4s;
}

/* Horizontal lines */
.border-top-left,
.border-top-right,
.border-bottom-left,
.border-bottom-right {
    height: 1px;
    width: 50%;
    transform: scaleX(0);
}

.border-top-left {
    top: 0;
    left: 0;
    transform-origin: left center;
}

.border-top-right {
    top: 0;
    right: 0;
    transform-origin: right center;
}

.border-bottom-left {
    bottom: 0;
    left: 0;
    transform-origin: left center;
}

.border-bottom-right {
    bottom: 0;
    right: 0;
    transform-origin: right center;
}

/* Vertical lines */
.border-left-top,
.border-left-bottom,
.border-right-top,
.border-right-bottom {
    width: 1px;
    height: 50%;
    transform: scaleY(0);
}

.border-left-top {
    top: 0;
    left: 0;
    transform-origin: center top;
}

.border-left-bottom {
    bottom: 0;
    left: 0;
    transform-origin: center bottom;
}

.border-right-top {
    top: 0;
    right: 0;
    transform-origin: center top;
}

.border-right-bottom {
    bottom: 0;
    right: 0;
    transform-origin: center bottom;
}

/* Animate borders when visible */
.badge-shelf.is-visible .border-top-left,
.badge-shelf.is-visible .border-top-right,
.badge-shelf.is-visible .border-bottom-left,
.badge-shelf.is-visible .border-bottom-right {
    animation: border-draw-h 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.badge-shelf.is-visible .border-left-top,
.badge-shelf.is-visible .border-left-bottom,
.badge-shelf.is-visible .border-right-top,
.badge-shelf.is-visible .border-right-bottom {
    animation: border-draw-v 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s forwards;
}

.badge-shelf.is-visible .border-line {
    transition: background-color 0.5s ease 1.4s;
}

.badge-shelf.border-settled .border-line {
    background-color: #D4C4A8;
}

@keyframes border-draw-h {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@keyframes border-draw-v {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

/* ===== Shelf Label ===== */
.shelf-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
}

.shelf-label-text {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #8B7355;
    white-space: nowrap;
}

.stitch-line {
    flex: 1;
    position: relative;
    height: 2px;
    max-width: 40%;
    border-top: 2px dashed #8B7355;
}

.needle-hole {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #8B7355;
    top: 50%;
    transform: translateY(-50%);
}

.needle-hole-left {
    left: -2px;
}

.needle-hole-right {
    right: -2px;
}

/* ===== Shelf Content Layout ===== */
.shelf-content {
    display: flex;
    align-items: flex-start;
    gap: clamp(1.5rem, 3vw, 2.5rem);
}

.shelf-content--left {
    flex-direction: row;
}

.shelf-content--right {
    flex-direction: row-reverse;
}

.shelf-content--left .story-text {
    margin-left: -10%;
}

.shelf-content--right .story-text {
    margin-right: -10%;
}

/* ===== Badge Composition ===== */
.badge-composition {
    position: relative;
    flex-shrink: 0;
    width: clamp(160px, 28vw, 220px);
    height: clamp(160px, 28vw, 220px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-reveal {
    opacity: 0;
    transform: translateY(30px);
}

.badge-shelf.is-visible .badge-reveal {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.text-reveal {
    opacity: 0;
    transform: translateY(30px);
}

.badge-shelf.is-visible .text-reveal {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s,
                transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s;
}

/* Torn paper elements */
.torn-paper {
    position: absolute;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(60, 42, 20, 0.08);
}

.torn-paper-1 {
    width: 85%;
    height: 85%;
    top: 8%;
    left: 12%;
    background-color: #F5EDE0;
    transform: rotate(2deg);
}

.torn-paper-2 {
    width: 80%;
    height: 80%;
    top: 4%;
    left: 4%;
    background-color: #E8D9C4;
    transform: rotate(-1.5deg);
}

.torn-paper-3 {
    width: 78%;
    height: 78%;
    top: 10%;
    left: 8%;
    background-color: #D4C4A8;
    transform: rotate(1deg);
}

/* Badge shapes */
.badge-shape {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px dashed #C4973B;
    border-spacing: 4px;
    box-shadow: 0 8px 32px rgba(60, 42, 20, 0.12);
    overflow: hidden;
    transition: transform 0.4s ease, box-shadow 0.4s ease, border-color 0.4s ease;
}

.badge-shape:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(60, 42, 20, 0.2);
    border-color: #C4973B;
}

.badge-shield {
    width: 130px;
    height: 150px;
    clip-path: polygon(0% 0%, 100% 0%, 100% 70%, 50% 100%, 0% 70%);
    border-radius: 0;
    border: none;
    background-color: #F5EDE0;
    padding: 20px 15px;
}

.badge-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background-color: #F5EDE0;
    padding: 25px;
}

.badge-hexagon {
    width: 140px;
    height: 130px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border: none;
    background-color: #F5EDE0;
    padding: 25px 15px;
}

.badge-rounded-rect {
    width: 140px;
    height: 130px;
    border-radius: 16px;
    background-color: #F5EDE0;
    padding: 20px;
}

/* Fabric textures */
.fabric-texture {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.15;
    pointer-events: none;
}

.linen-texture {
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(139, 115, 85, 0.3) 2px,
            rgba(139, 115, 85, 0.3) 3px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 2px,
            rgba(139, 115, 85, 0.2) 2px,
            rgba(139, 115, 85, 0.2) 3px
        );
}

.felt-texture {
    background-image: radial-gradient(
        circle at 50% 50%,
        rgba(139, 115, 85, 0.15) 1px,
        transparent 1px
    );
    background-size: 4px 4px;
}

.canvas-texture {
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 3px,
            rgba(139, 115, 85, 0.2) 3px,
            rgba(139, 115, 85, 0.2) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 3px,
            rgba(139, 115, 85, 0.15) 3px,
            rgba(139, 115, 85, 0.15) 4px
        );
}

/* Embroidered text */
.embroidered-text {
    position: relative;
    z-index: 2;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: #C4973B;
    text-shadow:
        1px 1px 0 rgba(196, 151, 59, 0.4),
        -1px -1px 0 rgba(196, 151, 59, 0.2);
    -webkit-text-stroke: 0.5px rgba(196, 151, 59, 0.3);
}

.badge-icon {
    position: relative;
    z-index: 2;
}

/* ===== Story Text ===== */
.story-text {
    flex: 1;
    position: relative;
    z-index: 1;
    padding-top: 1rem;
}

.story-text p {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw + 0.5rem, 1.15rem);
    line-height: 1.75;
    color: #2C2418;
    margin-bottom: 1rem;
}

.story-text em {
    font-weight: 600;
    font-style: italic;
}

.handwritten-note {
    display: block;
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.9rem, 1vw + 0.4rem, 1.05rem);
    color: #6B5B4A;
    margin-top: 0.5rem;
    transform: rotate(-1deg);
}

/* ===== Candle Glow Highlight ===== */
.badge-shelf[data-shelf="1"] .badge-composition::after,
.badge-shelf[data-shelf="3"] .badge-composition::after,
.badge-shelf[data-shelf="5"] .badge-composition::after {
    content: '';
    position: absolute;
    top: -20%;
    left: -20%;
    right: -20%;
    bottom: -20%;
    background: radial-gradient(ellipse at center, rgba(240, 217, 160, 0.25) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ===== Footer ===== */
.footer {
    position: relative;
    margin-top: clamp(4rem, 8vh, 8rem);
}

.footer-fade {
    height: 30vh;
    background: linear-gradient(to bottom, #F5EDE0, #3E2F1C);
    margin-left: calc(-1 * clamp(2rem, 8vw, 6rem));
    margin-right: calc(-1 * clamp(2rem, 8vw, 6rem));
}

.footer-content {
    background-color: #3E2F1C;
    padding: clamp(2rem, 4vw, 4rem) 0 clamp(1.5rem, 3vw, 2rem);
    margin-left: calc(-1 * clamp(2rem, 8vw, 6rem));
    margin-right: calc(-1 * clamp(2rem, 8vw, 6rem));
    padding-left: clamp(2rem, 8vw, 6rem);
    padding-right: clamp(2rem, 8vw, 6rem);
    text-align: center;
}

.footer-message {
    display: block;
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1.2rem, 1.5vw + 0.5rem, 1.6rem);
    color: #F0D9A0;
    margin-bottom: 1.5rem;
}

.footer-line {
    width: 60px;
    height: 1px;
    background-color: #8B7355;
    margin: 0 auto 1rem;
}

.footer-copyright {
    display: block;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #6B5B4A;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .shelf-content {
        flex-direction: column;
        align-items: center;
    }

    .shelf-content--right {
        flex-direction: column;
    }

    .shelf-content--left .story-text,
    .shelf-content--right .story-text {
        margin-left: 0;
        margin-right: 0;
    }

    .badge-composition {
        width: 160px;
        height: 160px;
    }

    .hero-title {
        top: clamp(1.5rem, 4vh, 2.5rem);
    }
}
