/* ============================================================
   munju.im — charm-bracelet diary on polished onyx
   Palette: Monochrome marble + single bleeding accent
   Typography: Unica One, DM Serif Display, Manrope (with the
   MySpace flourish of 2003-era Space-charm gel buttons drained
   into monochrome marble).
   ============================================================ */

:root {
    --ink-deep:        #0E0D11;
    --ink-mid:         #2A2830;
    --stone-veined:    #3A3741;
    --stone-pale:      #C9C5CE;
    --gel-shine:       #F4F2F6;
    --paper-warm:      #EDE7DC;
    --bleed-accent:    #A8423C;
    --leaf-shadow:     #1A1A1F;

    --ease-lift: cubic-bezier(.2, .8, .2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    background: var(--ink-deep);
    color: var(--stone-pale);
    font-family: 'Manrope', 'Inter', system-ui, sans-serif;
    font-weight: 300;
    line-height: 1.7;
    overflow-x: hidden;
}

body {
    position: relative;
    min-height: 100vh;
}

/* ============================================================
   MARBLE SLAB
   ============================================================ */
.slab {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    animation: slab-fade 800ms ease-out 100ms forwards;
}

.slab-base {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 60% at 28% 24%, rgba(58,55,65,0.35), transparent 70%),
        radial-gradient(ellipse 60% 50% at 78% 70%, rgba(42,40,48,0.5), transparent 75%),
        radial-gradient(ellipse 90% 100% at 50% 50%, var(--ink-deep), #08070a 90%),
        conic-gradient(from 200deg at 60% 40%, rgba(58,55,65,0.18), rgba(14,13,17,0) 30%, rgba(58,55,65,0.12) 60%, rgba(14,13,17,0));
    background-blend-mode: screen, screen, normal, screen;
}

.slab-veins {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.veins-svg {
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0.95;
}

@keyframes slab-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   LEAF CANVAS + POOL
   ============================================================ */
.leaf-canvas {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.leaf-canvas .leaf {
    position: absolute;
    width: 56px;
    height: 56px;
    will-change: transform, opacity;
    filter: drop-shadow(0 6px 6px rgba(0,0,0,0.45));
    transition: filter 600ms ease;
}

.leaf-canvas .leaf.fresh {
    filter: drop-shadow(0 6px 6px rgba(0,0,0,0.45));
}

.leaf-canvas .leaf svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* The most-recent leaf gets a thin warm border for 3 seconds */
.leaf-canvas .leaf.recent svg path,
.leaf-canvas .leaf.recent svg circle,
.leaf-canvas .leaf.recent svg ellipse {
    stroke: var(--bleed-accent) !important;
    stroke-width: 1px !important;
}

.pool {
    position: fixed;
    left: 18%;
    top: 32%;
    width: 26vw;
    height: 36vh;
    z-index: 1;
    pointer-events: none;
}

.pool-label {
    position: absolute;
    left: 22%;
    top: 56%;
    z-index: 4;
    color: var(--stone-veined);
    font-family: 'Manrope', sans-serif;
    font-weight: 300;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: lowercase;
    opacity: 0.45;
    user-select: none;
    pointer-events: none;
    transform: rotate(-2deg);
}

.pool-label::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 1px;
    background: var(--stone-veined);
    vertical-align: middle;
    margin-right: 8px;
    opacity: 0.5;
}

/* ============================================================
   STAGE
   ============================================================ */
.stage {
    position: relative;
    z-index: 3;
    width: 100%;
    min-height: 100vh;
    padding: 60px 80px 220px 80px;
}

/* ============================================================
   ANCHOR MONOGRAM
   ============================================================ */
.anchor {
    position: relative;
    width: 38vw;
    max-width: 720px;
    margin-top: 40px;
    margin-left: 20px;
    z-index: 6;
    cursor: default;
}

.monogram {
    font-family: 'Unica One', 'Inter', sans-serif;
    font-size: clamp(72px, 11vw, 144px);
    line-height: 0.95;
    letter-spacing: 0.04em;
    color: var(--stone-pale);
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.04em;
    text-transform: lowercase;
    user-select: none;
}

.charm-glyph {
    display: inline-block;
    position: relative;
    padding: 0.06em 0.18em;
    margin: 0.04em 0.02em;
    border-radius: 14px;
    color: var(--stone-pale);
    background:
        radial-gradient(ellipse 100% 70% at 50% 0%, rgba(244,242,246,0.45) 0%, rgba(244,242,246,0.05) 55%, transparent 70%),
        linear-gradient(180deg, var(--stone-veined) 0%, var(--ink-mid) 100%);
    box-shadow:
        inset 0 1px 0 rgba(244,242,246,0.6),
        inset 0 -2px 4px rgba(0,0,0,0.5),
        inset 0 0 0 1px rgba(201,197,206,0.30),
        0 4px 14px rgba(0,0,0,0.55),
        0 1px 0 rgba(244,242,246,0.05);
    transform: rotate(var(--rest-rotate, 0deg)) translateY(0);
    opacity: 0;
    animation:
        glyph-enter 700ms var(--ease-lift) calc(var(--i, 0) * 60ms + 800ms) forwards,
        charm-wobble 4s ease-in-out calc(var(--i, 0) * 0.6s + 1800ms) infinite alternate;
    transform-origin: 50% 60%;
    transition: transform 280ms var(--ease-lift);
}

@keyframes glyph-enter {
    0% {
        opacity: 0;
        transform: rotate(-90deg) translateY(8px) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: rotate(var(--rest-rotate, 0deg)) translateY(0) scale(1);
    }
}

@keyframes charm-wobble {
    0%   { transform: rotate(calc(var(--rest-rotate, 0deg) - 1.5deg)) translateY(-1px); }
    100% { transform: rotate(calc(var(--rest-rotate, 0deg) + 1.5deg)) translateY(1px); }
}

/* tiny rhinestone glints */
.charm-glyph::before,
.charm-glyph::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    box-shadow: 0 0 4px white;
    border-radius: 1px;
}
.charm-glyph::before { top: 6px; right: 8px; }
.charm-glyph::after  { bottom: 8px; left: 6px; opacity: 0.7; }

/* hover: settle to 0deg */
.monogram.settle .charm-glyph {
    animation-play-state: paused, paused;
    transform: rotate(0deg) translateY(-2px);
    transition: transform 200ms ease-out;
}

/* monogram pendulum re-settle every 7s — pulse via transform on .anchor */
.anchor {
    animation: pendant 7s ease-in-out 2400ms infinite;
}

@keyframes pendant {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    20%      { transform: rotate(-0.6deg) translateY(-1px); }
    50%      { transform: rotate(0.4deg) translateY(0); }
    80%      { transform: rotate(-0.2deg) translateY(0.5px); }
}

.subtitle {
    margin-top: 18px;
    margin-left: 8px;
    font-family: 'Manrope', sans-serif;
    font-weight: 300;
    font-size: 16px;
    letter-spacing: 0.06em;
    color: var(--stone-pale);
    opacity: 0;
    animation: fade-up 800ms var(--ease-lift) 2200ms forwards;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 0.85; transform: translateY(0); }
}

.dot-i {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bleed-accent);
    margin-left: 3px;
    transform: translateY(-10px);
    box-shadow: 0 0 10px rgba(168,66,60,0.55);
}

/* ============================================================
   STICKER OVERLAYS
   ============================================================ */
.sticker {
    position: absolute;
    width: 28px;
    height: 28px;
    transform: rotate(var(--rand, 0deg));
    filter: drop-shadow(0 1px 0 rgba(0,0,0,0.6));
    pointer-events: none;
    opacity: 0;
    animation: sticker-pop 600ms var(--ease-lift) 2600ms forwards;
}

.sticker-star      { width: 26px; height: 26px; }
.sticker-heart     { width: 24px; height: 24px; }
.sticker-asterisk  { width: 22px; height: 22px; }

@keyframes sticker-pop {
    0%   { opacity: 0; transform: rotate(var(--rand, 0deg)) scale(0.4); }
    70%  { opacity: 1; transform: rotate(var(--rand, 0deg)) scale(1.08); }
    100% { opacity: 1; transform: rotate(var(--rand, 0deg)) scale(1); }
}

/* ============================================================
   DRIFT COLUMN (DIARY TABS)
   ============================================================ */
.drift {
    position: absolute;
    right: 5vw;
    top: 14vh;
    width: 28vw;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    z-index: 5;
}

.tab {
    position: relative;
    background: linear-gradient(180deg, var(--paper-warm) 0%, #d6cfc0 100%);
    color: var(--ink-deep);
    padding: 18px 22px 18px 22px;
    border-radius: 4px 14px 4px 14px;
    box-shadow:
        0 2px 6px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.6),
        inset 0 0 0 1px rgba(42,40,48,0.10);
    transform: rotate(var(--rest-rotate, 0deg));
    cursor: pointer;
    --rest-rotate: 0deg;
    opacity: 0;
    transform-origin: 80% 50%;
    animation: tab-slide 700ms var(--ease-lift) forwards;
}

.tab:nth-child(1) { animation-delay: 1900ms; }
.tab:nth-child(2) { animation-delay: 2050ms; }
.tab:nth-child(3) { animation-delay: 2200ms; }
.tab:nth-child(4) { animation-delay: 2350ms; }
.tab:nth-child(5) { animation-delay: 2500ms; }

@keyframes tab-slide {
    from { opacity: 0; transform: translateX(60px) rotate(var(--rest-rotate, 0deg)); }
    to   { opacity: 1; transform: translateX(0) rotate(var(--rest-rotate, 0deg)); }
}

/* The "stitched" tab — applied via JS to one random tab */
.tab.stitched {
    box-shadow:
        0 2px 6px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.6),
        inset 0 0 0 1px rgba(168,66,60,0.55);
}

.tab.stitched::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px dashed var(--bleed-accent);
    border-radius: 3px 12px 3px 12px;
    pointer-events: none;
    opacity: 0.85;
}

.tab-pin {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 26px;
    height: 26px;
    transform: rotate(-22deg);
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.45));
}

.tab-pin svg {
    width: 100%;
    height: 100%;
}

.tab-title {
    font-family: 'DM Serif Display', 'Lora', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(22px, 1.95vw, 32px);
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--ink-deep);
    margin-bottom: 0;
    position: relative;
    padding-bottom: 4px;
}

.tab-underline {
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 100%;
    height: 6px;
    pointer-events: none;
    overflow: visible;
}

.tab-underline path {
    stroke-dasharray: 240;
    stroke-dashoffset: 240;
    transition: stroke-dashoffset 220ms ease-out;
}

.tab:hover .tab-underline path {
    stroke-dashoffset: 0;
}

.tab-body {
    margin-top: 14px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 320ms var(--ease-lift), margin-top 320ms var(--ease-lift), opacity 220ms ease;
    opacity: 0;
}

.tab.open .tab-body {
    max-height: 360px;
    opacity: 1;
}

.tab-body p {
    font-family: 'Manrope', sans-serif;
    font-weight: 300;
    font-size: 15px;
    line-height: 1.7;
    color: var(--ink-mid);
}

/* ============================================================
   HOVER-LIFT (shared utility)
   ============================================================ */
.lift {
    transition: transform 280ms var(--ease-lift), box-shadow 280ms var(--ease-lift), filter 280ms var(--ease-lift);
}

.lift:hover {
    transform: translateY(-8px) rotate(var(--rest-rotate, 0deg));
    box-shadow:
        0 14px 28px rgba(0,0,0,0.55),
        inset 0 1px 0 rgba(255,255,255,0.6),
        inset 0 0 0 1px rgba(42,40,48,0.10);
}

.tab.lift.stitched:hover {
    box-shadow:
        0 14px 28px rgba(0,0,0,0.55),
        inset 0 1px 0 rgba(255,255,255,0.6),
        inset 0 0 0 1px rgba(168,66,60,0.7);
}

/* ============================================================
   WRIST CHARMS (lower-left cluster)
   ============================================================ */
.wrist {
    position: absolute;
    left: 6vw;
    bottom: 18vh;
    display: flex;
    gap: 14px;
    z-index: 5;
}

.charm {
    display: inline-block;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background:
        radial-gradient(ellipse 80% 50% at 50% 10%, rgba(244,242,246,0.55) 0%, rgba(244,242,246,0) 60%),
        linear-gradient(180deg, var(--stone-veined) 0%, var(--ink-mid) 100%);
    box-shadow:
        inset 0 1px 0 rgba(244,242,246,0.5),
        inset 0 0 0 1px rgba(201,197,206,0.30),
        0 4px 12px rgba(0,0,0,0.5);
    transform: rotate(var(--rest-rotate, 0deg));
    --rest-rotate: 0deg;
    position: relative;
    opacity: 0;
    animation: fade-up 700ms var(--ease-lift) 2700ms forwards, charm-pulse 11s ease-in-out 4s infinite;
}

.charm:nth-child(2) { animation-delay: 2820ms, 4.5s; }
.charm:nth-child(3) { animation-delay: 2940ms, 5s; }
.charm:nth-child(4) { animation-delay: 3060ms, 5.5s; }

.charm svg {
    width: 60%;
    height: 60%;
    position: absolute;
    top: 20%;
    left: 20%;
    opacity: 0.8;
}

/* tiny rhinestone glint */
.charm::before {
    content: '';
    position: absolute;
    top: 6px;
    right: 8px;
    width: 2px;
    height: 2px;
    background: white;
    box-shadow: 0 0 4px white;
    border-radius: 1px;
    z-index: 2;
}

@keyframes charm-pulse {
    0%, 95%, 100% { box-shadow: inset 0 1px 0 rgba(244,242,246,0.5), inset 0 0 0 1px rgba(201,197,206,0.30), 0 4px 12px rgba(0,0,0,0.5), 0 0 0 0 rgba(244,242,246,0); }
    50%           { box-shadow: inset 0 1px 0 rgba(244,242,246,0.5), inset 0 0 0 1px rgba(201,197,206,0.30), 0 4px 12px rgba(0,0,0,0.5), 0 0 0 6px rgba(244,242,246,0.10); }
}

/* ============================================================
   WHISPER PARAGRAPH
   ============================================================ */
.whisper {
    position: absolute;
    left: 8vw;
    top: 56vh;
    max-width: 380px;
    z-index: 4;
    font-family: 'Manrope', sans-serif;
    font-weight: 300;
    font-size: 15px;
    line-height: 1.7;
    color: var(--stone-pale);
    opacity: 0;
    animation: fade-up 900ms var(--ease-lift) 3200ms forwards;
    transform: rotate(-1.2deg);
    text-transform: lowercase;
    user-select: text;
}

.whisper .i-with-dot {
    position: relative;
    display: inline-block;
}

.whisper .dot-mark {
    position: absolute;
    top: -2px;
    left: 1px;
    width: 5px;
    height: 5px;
    background: var(--bleed-accent);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(168,66,60,0.5);
}

/* hide the natural dot of "i" in whisper */
.whisper .i-with-dot::before {
    content: 'ı';
    position: absolute;
    inset: 0;
}

.whisper .i-with-dot {
    color: transparent;
}

.whisper .i-with-dot::before {
    color: var(--stone-pale);
}

/* ============================================================
   FOOTER LEAF FRIEZE
   ============================================================ */
.frieze-wrap {
    position: relative;
    width: 100%;
    margin-top: 80px;
    z-index: 5;
}

.frieze {
    position: relative;
    width: 100vw;
    height: 110px;
    margin-left: calc(50% - 50vw);
    overflow: hidden;
    cursor: grab;
    background: linear-gradient(180deg, transparent 0%, rgba(14,13,17,0.0) 50%, rgba(14,13,17,0.4) 100%);
    border-top: 1px solid rgba(58,55,65,0.4);
    border-bottom: 1px solid rgba(58,55,65,0.4);
    transform: rotate(-1.2deg);
    transform-origin: 50% 50%;
}

.frieze.dragging {
    cursor: grabbing;
}

.frieze-track {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 26px;
    padding: 0 20px;
    will-change: transform;
}

.frieze-track .frieze-leaf {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    opacity: 0.55;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
    transform: rotate(var(--r, 0deg));
}

.frieze-meta {
    width: 100%;
    padding: 16px 80px 28px 80px;
    display: flex;
    justify-content: space-between;
    color: var(--stone-veined);
    font-family: 'Manrope', sans-serif;
    font-weight: 300;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: lowercase;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1099px) {
    .stage {
        padding: 50px 40px 200px 40px;
    }
    .anchor {
        width: 60vw;
        margin-left: 0;
    }
    .drift {
        position: relative;
        right: auto;
        top: auto;
        width: 100%;
        max-width: none;
        margin-top: 80px;
    }
    .pool {
        left: 5%;
        width: 50vw;
        height: 30vh;
    }
    .pool-label {
        left: 8%;
        top: 60%;
    }
    .wrist {
        left: 4vw;
        bottom: 8vh;
    }
    .whisper {
        position: relative;
        left: auto;
        top: auto;
        margin: 60px 0 0 0;
    }
    .frieze {
        height: 80px;
    }
    .frieze-track .frieze-leaf {
        width: 42px;
        height: 42px;
    }
}

@media (max-width: 639px) {
    .stage {
        padding: 36px 20px 160px 20px;
    }
    .anchor {
        width: 100%;
        text-align: left;
    }
    .monogram {
        font-size: clamp(56px, 18vw, 96px);
    }
    .drift {
        margin-top: 60px;
        gap: 18px;
    }
    .tab {
        transform: rotate(calc(var(--rest-rotate, 0deg) * 0.66));
    }
    .wrist {
        position: relative;
        left: auto;
        bottom: auto;
        margin-top: 40px;
        flex-wrap: wrap;
    }
    .charm {
        width: 44px;
        height: 44px;
    }
    .frieze-meta {
        padding: 12px 20px 22px 20px;
        font-size: 11px;
        flex-direction: column;
        gap: 6px;
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .charm-glyph,
    .anchor,
    .charm,
    .sticker,
    .subtitle,
    .whisper,
    .tab {
        animation: none !important;
        opacity: 1 !important;
        transform: rotate(var(--rest-rotate, 0deg)) !important;
    }
    .slab {
        opacity: 1;
    }
    .leaf-canvas .leaf {
        display: none;
    }
}
