
/* ========================================
   LOVELLE LAB — Yours in Starlight
   File: base.css
   Version: 2.0
   Cinematic Layout & Interaction System
======================================== */


/* ========================================
   01. GLOBAL RESET
======================================== */

*,
*::before,
*::after {

    box-sizing: border-box;

    margin: 0;

    padding: 0;
}


html {

    width: 100%;

    height: 100%;

    font-size: 16px;

    overflow: hidden;

    -webkit-text-size-adjust: 100%;

    overscroll-behavior: none;
}


body {

    width: 100%;

    height: 100vh;

    height: 100dvh;

    min-height: 0;

    overflow: hidden;

    background: var(--bg-primary, #250E19);

    color: var(--text-primary, #E8C9AD);

    font-family: "Cormorant Garamond", serif;

    -webkit-font-smoothing: antialiased;

    -moz-osx-font-smoothing: grayscale;

    overscroll-behavior: none;
}


/* ========================================
   02. DEFAULT ELEMENTS
======================================== */

button {

    font: inherit;

    color: inherit;

    border: none;

    background: transparent;

    cursor: pointer;

    appearance: none;

    -webkit-appearance: none;

    -webkit-tap-highlight-color: transparent;
}


button:focus:not(:focus-visible) {

    outline: none;

    box-shadow: none;
}


button:focus-visible {

    outline: 1px solid var(--gold-primary, #C9A477);

    outline-offset: 6px;
}


img {

    display: block;

    max-width: 100%;

    user-select: none;

    -webkit-user-select: none;

    -webkit-user-drag: none;
}


canvas {

    display: block;
}


[hidden] {

    display: none !important;
}


::selection {

    background: var(--gold-primary, #C9A477);

    color: var(--bg-primary, #250E19);
}


/* ========================================
   03. GLOBAL DESIGN VARIABLES
======================================== */

:root {

    /* Envelope geometry */

    --envelope-width: clamp(150px, 18vw, 240px);

    --envelope-ratio: 1.6667;

    --envelope-bottom: clamp(55px, 12vh, 120px);


    /* Letter layout */

    --letter-top: 5%;

    --letter-envelope-gap: 24px;


    /* Perspective */

    --perspective: 1200px;


    /* Motion curves */

    --ease-smooth:
        cubic-bezier(0.22, 1, 0.36, 1);

    --ease-cinematic:
        cubic-bezier(0.65, 0, 0.35, 1);


    /* Animation duration */

    --duration-fast: 350ms;

    --duration-normal: 800ms;

    --duration-slow: 1400ms;


    /* Layer system */

    --z-background: 0;

    --z-particles: 10;

    --z-scene: 20;

    --z-letter: 30;

    --z-envelope: 40;

    --z-controls: 100;
}


/* ========================================
   04. MAIN EXPERIENCE
======================================== */

.experience {

    position: relative;

    width: 100%;

    height: 100vh;

    height: 100dvh;

    min-height: 0;

    overflow: hidden;

    isolation: isolate;

    perspective: var(--perspective);

    background:
        var(--gradient-background, #250E19);

    -webkit-tap-highlight-color: transparent;
}


/* ========================================
   05. BACKGROUND CONTAINER
======================================== */

.background {

    position: absolute;

    inset: 0;

    z-index: var(--z-background);

    overflow: hidden;

    pointer-events: none;

    user-select: none;
}


.background-image,

.background-glow,

.background-vignette {

    pointer-events: none;

    user-select: none;
}


/* ========================================
   06. PARTICLES CANVAS
======================================== */

.particles-canvas {

    position: absolute;

    inset: 0;

    width: 100%;

    height: 100%;

    z-index: var(--z-particles);

    pointer-events: none;

    user-select: none;
}


/* All decorative canvas layers */

.experience canvas {

    pointer-events: none;
}


/* ========================================
   07. 3D SCENE
======================================== */

.scene-container {

    position: absolute;

    inset: 0;

    width: 100%;

    height: 100%;

    z-index: var(--z-scene);

    overflow: hidden;

    pointer-events: none;

    user-select: none;
}


.scene-container canvas {

    width: 100%;

    height: 100%;

    pointer-events: none;
}


/* ========================================
   08. LETTER CONTAINER

   Final dimensions are controlled
   by responsive.css.
======================================== */

.letter-container {

    position: absolute;

    top: var(--letter-top, 5%);

    left: 50%;

    width: min(88%, 1100px);

    min-height: 0;

    transform: translateX(-50%);

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: flex-start;

    z-index: var(--z-letter);

    overflow: hidden;

    pointer-events: none;

    scrollbar-width: none;

    -ms-overflow-style: none;
}


/* ========================================
   09. LETTER CONTENT
======================================== */

.letter-content {

    position: relative;

    flex: 0 0 auto;

    width: 100%;

    max-width: 100%;

    min-height: 0;

    text-align: center;

    overflow-wrap: anywhere;

    word-break: normal;

    box-sizing: border-box;
}


/* ========================================
   10. LETTER READING MODE

   Enable scrolling only after opening.
======================================== */

.experience.is-open:not(.is-opening):not(.is-closing)
.letter-container {

    pointer-events: auto;

    overflow-x: hidden;

    overflow-y: auto;

    overscroll-behavior: contain;

    touch-action: pan-y;

    -webkit-overflow-scrolling: touch;

    scrollbar-width: none;

    -ms-overflow-style: none;
}


/* Invisible scrollbar */

.letter-container::-webkit-scrollbar {

    display: none !important;

    width: 0 !important;

    height: 0 !important;
}


/* Disable reading interaction during animation */

.experience.is-opening .letter-container,

.experience.is-closing .letter-container {

    pointer-events: none;
}


/* ========================================
   11. ENVELOPE STAGE
======================================== */

.envelope-stage {

    position: absolute;

    left: 50%;

    bottom: var(--envelope-bottom);

    transform: translateX(-50%);

    width: var(--envelope-width);

    z-index: var(--z-envelope);

    display: flex;

    flex-direction: column;

    align-items: center;

    perspective: var(--perspective);

    overflow: visible;

    pointer-events: none;

    user-select: none;

    -webkit-user-select: none;
}


/* ========================================
   12. ENVELOPE TRIGGER
======================================== */

.envelope-trigger {

    position: relative;

    display: block;

    width: 100%;

    aspect-ratio: var(--envelope-ratio);

    padding: 0;

    margin: 0;

    border: none;

    background: transparent;

    box-shadow: none;

    overflow: visible;

    cursor: pointer;

    pointer-events: auto;

    touch-action: manipulation;

    user-select: none;

    -webkit-user-select: none;

    -webkit-tap-highlight-color: transparent;
}


/* Restore interaction when animation finishes */

.experience:not(.is-opening):not(.is-closing)
.envelope-trigger {

    pointer-events: auto;

    cursor: pointer;
}


/* Prevent repeated clicks during animation */

.experience.is-opening .envelope-trigger,

.experience.is-closing .envelope-trigger {

    pointer-events: none;

    cursor: default;
}


/* ========================================
   13. INTERACTION HINT
======================================== */

.interaction-hint {

    position: relative;

    margin-top: 22px;

    font-family: "Cormorant Garamond", serif;

    font-size: 15px;

    font-style: italic;

    font-weight: 400;

    letter-spacing: 1.2px;

    color: var(--text-primary, #E8C9AD);

    opacity: 0.8;

    text-align: center;

    white-space: nowrap;

    pointer-events: none;

    user-select: none;

    -webkit-user-select: none;

    transition:
        opacity var(--duration-normal)
        var(--ease-smooth),

        transform var(--duration-normal)
        var(--ease-smooth);
}


/* ========================================
   14. SOUND CONTROL

   Single source of styling.
   Responsive sizes remain available.
======================================== */

.sound-toggle {

    position: absolute;

    right: max(
        24px,
        env(safe-area-inset-right, 0px)
    );

    bottom: max(
        24px,
        env(safe-area-inset-bottom, 0px)
    );

    width: 44px;

    height: 44px;

    display: flex;

    align-items: center;

    justify-content: center;

    z-index: var(--z-controls);

    padding: 0;

    border: 1px solid rgba(201, 164, 119, 0.4);

    border-radius: 50%;

    color: var(--gold-primary, #C9A477);

    background: rgba(25, 11, 18, 0.45);

    backdrop-filter: blur(8px);

    -webkit-backdrop-filter: blur(8px);

    opacity: 0.85;

    visibility: visible;

    cursor: pointer;

    pointer-events: auto;

    touch-action: manipulation;

    user-select: none;

    -webkit-tap-highlight-color: transparent;

    transition:

        opacity 350ms ease,

        background 350ms ease,

        border-color 350ms ease;
}


/* ========================================
   15. SOUND ICON
======================================== */

.sound-toggle svg {

    display: block;

    width: 20px;

    height: 20px;

    flex-shrink: 0;

    pointer-events: none;
}


.sound-toggle svg * {

    pointer-events: none;
}


/* ========================================
   16. SOUND STATES
======================================== */

.sound-toggle.is-playing {

    opacity: 1;

    color: var(--gold-primary, #C9A477);
}


.sound-toggle.is-muted {

    opacity: 0.75;

    color: var(--text-primary, #E8C9AD);
}


@media (hover: hover) and (pointer: fine) {

    .sound-toggle:hover {

        opacity: 1;

        background: rgba(81, 38, 56, 0.5);

        border-color:
            var(--gold-primary, #C9A477);
    }
}


.sound-toggle:active {

    opacity: 1;
}


/* ========================================
   17. FOCUS MANAGEMENT
======================================== */

.envelope-trigger:focus:not(:focus-visible),

.sound-toggle:focus:not(:focus-visible) {

    outline: none;

    box-shadow: none;
}


.envelope-trigger:focus-visible,

.sound-toggle:focus-visible {

    outline: 1px solid rgba(201, 164, 119, 0.65);

    outline-offset: 6px;
}


/* ========================================
   18. HIDDEN AUDIO ELEMENTS
======================================== */

audio:not([controls]) {

    display: none;
}


/* ========================================
   19. REDUCED MOTION
======================================== */

@media (prefers-reduced-motion: reduce) {

    *,

    *::before,

    *::after {

        animation-duration: 0.01ms !important;

        animation-iteration-count: 1 !important;

        transition-duration: 0.01ms !important;
    }


    .letter-container {

        scroll-behavior: auto !important;
    }
}


/* ========================================
   END OF BASE.CSS

   LOVELLE LAB
   Yours in Starlight
======================================== */
