#archive-stage { height: 100vh; height: 100svh; width: 100vw; display: flex; align-items: center; justify-content: center; overflow: hidden; }
body.grid-mode #archive-stage { height: auto; min-height: 100vh; min-height: 100svh; align-items: flex-start; padding-top: 25vh; padding-bottom: 12.5rem; }
#dashboard-wrapper { height: 60vh; margin-top: 10vh; }
#calendar-column, #magazine-column { flex-direction: column; align-self: center; height: 100%; }

body.grid-mode .side-column { opacity: 0; pointer-events: none; }
body.grid-mode #dashboard-wrapper { display: flex; justify-content: center; align-items: flex-start; height: auto; margin-top: 0; }

/* GRID MODE: 3 Equal columns, 80vw total width */
body.grid-mode #project-pile { width: 90vw; padding: 0 5vw; box-sizing: border-box; margin: 0 auto; max-width: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10rem 8vw; justify-items: center; align-items: center; }
body.grid-mode .side-column { display: none !important; }

/* Card wrappers: centered inside grid cells */
.card-wrapper { position: relative; filter: drop-shadow(0 0.2rem 0.8rem rgba(0,0,0,0.08)); transition: 0.5s; display: flex; justify-content: center; align-items: center; will-change: transform, top, left; backface-visibility: hidden; } 
body.grid-mode .card-wrapper { 
    filter: drop-shadow(0 0.5rem 1rem rgba(0,0,0,0.15));
    -webkit-clip-path: none !important;
    clip-path: none !important;
} 
body.grid-mode .mag-tube-wrapper {
    filter: drop-shadow(0 0.5rem 1rem rgba(0,0,0,0.15));
    -webkit-clip-path: none !important;
    clip-path: none !important; /* Prevent text cropping */
}

/* paper-card: padding is set dynamically by JS to 5% of image's shortest side */
.paper-card { 
    position: relative; display: inline-flex; flex-direction: column; cursor: pointer;
    width: fit-content; height: max-content;
    min-width: 12rem; 
}
.paper-card-bg {
    position: absolute; inset: 0; background: white; z-index: 0;
    /* Masks are now applied dynamically via JS in sizeCard() to perfectly center the holes in the variable frame */
}
.paper-card-bg::before {
    content: ""; position: absolute; inset: 0;
    background-image: url('../assets/textures/texture%20paper%203.jpg'); background-size: cover;
    opacity: 0.15; pointer-events: none;
}

/* NOTE: punhole cx is now 5% (= half of 10% left frame) so they stay centered in the left margin regardless of card width */

.card-inner-frame { position: relative; z-index: 1; }
.card-inner-frame img { display: block; object-fit: contain; }

/* Belly band: padding and font-size are dynamic via JS to maintain ratio */
.belly-band { z-index: 3; position: absolute; bottom: 15%; left: -0.2rem; width: calc(100% + 0.4rem); background-color: rgba(255, 255, 255, 0.25); backdrop-filter: blur(1.5rem); -webkit-backdrop-filter: blur(1.5rem); display: flex; justify-content: center; align-items: center; box-shadow: inset 0.6rem 0 0.6rem -0.4rem rgba(0,0,0,0.07), inset -0.6rem 0 0.6rem -0.4rem rgba(0,0,0,0.07); box-sizing: border-box; overflow: visible; }
.belly-band::before {
    content: ""; position: absolute; inset: 0;
    background-image: url('../assets/textures/texture%20paper%202.jpg'); background-size: cover;
    opacity: 0.15; z-index: 0; pointer-events: none;
}
/* Curved drop shadow below band — subtle, stronger in centre, fading at edges */
.belly-band::after {
    content: "";
    position: absolute;
    bottom: -0.7rem;
    left: 12%;
    width: 76%;
    height: 0.7rem;
    background: radial-gradient(ellipse at 50% 0%, rgba(0,0,0,0.07) 0%, rgba(0,0,0,0.02) 55%, transparent 100%);
    pointer-events: none;
    z-index: -1;
}
.belly-band > * { position: relative; z-index: 1; }

/* Belly band seam — vertical break line slightly left of centre */
.belly-seam {
    position: absolute;
    left: 43%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.12) 20%, rgba(0,0,0,0.18) 50%, rgba(0,0,0,0.12) 80%, transparent);
    pointer-events: none;
    z-index: 2;
}

/* Circular tape dot holding the seam */
.belly-tape {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    opacity: 0.88;
    box-shadow: 0 0.1rem 0.5rem rgba(0,0,0,0.18), inset 0 0 0 0.08rem rgba(255,255,255,0.15);
}
.belly-tape::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background-image: url('../assets/textures/cloth%20texture.jpg');
    background-size: cover;
    mix-blend-mode: multiply;
    opacity: 0.85;
    pointer-events: none;
}

/* POST-IT NOTE: width and min-width are set dynamically by JS to 28% of image shortest side */
.bookmark-note {
    position: absolute; bottom: 5%; right: 2%; z-index: 2; 
    height: 85%; 
    background-color: #F1EED7; 
    backdrop-filter: none; -webkit-backdrop-filter: none; 
    border: none; 
    box-shadow: 0.2rem 0.5rem 1.5rem rgba(0,0,0,0.06); 
    padding: 1.2rem; 
    line-height: 1.5; transform: rotate(0deg); overflow: hidden;
    transition: transform 0s, box-shadow 0s, z-index 0s;
    display: flex; flex-direction: column; box-sizing: border-box;
}
.bookmark-note::before {
    content: ""; position: absolute; inset: 0;
    background-image: url('../assets/textures/texture%20paper.jpg'); background-size: cover;
    opacity: 0.25; z-index: 0; pointer-events: none;
}
.bookmark-note > * { position: relative; z-index: 1; }

body.grid-mode .bookmark-note { width: 6vw; min-width: 10rem; font-size: 0.8rem; padding: 1rem; }
.bookmark-note:hover { transform: scale(1.15) translateX(-15%) translateY(-5%); box-shadow: 0 1.5rem 3.5rem rgba(0,0,0,0.15); max-height: none; overflow: visible; z-index: 10 !important; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), z-index 0s; }

/* POST-IT TYPOGRAPHY (Dossier/Receipt Style) */
.calendar-separator { width: 100%; transition: opacity 0.4s; }
.note-ref-code { width: 100%; text-align: right; font-family: monospace; font-size: 0.8em; opacity: 1; margin-bottom: 0.4rem; letter-spacing: 0.05em; }
.note-divider { width: 100%; height: 1px; background: rgba(0,0,0,0.3); margin: 0.4rem 0; flex-shrink: 0; }
.note-title { font-size: 1.2em; font-weight: bold; margin: 0.4rem 0; text-transform: capitalize; position: relative; z-index: 2; line-height: 1.2; flex-shrink: 0; }
.note-meta-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 0.2rem 1rem; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 0.75em; opacity: 1; margin: 0.4rem 0; max-height: 8rem; overflow-y: auto; scrollbar-width: none; flex-shrink: 0; }
.note-meta-grid::-webkit-scrollbar { display: none; }
.note-meta-grid > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-meta-grid > div:nth-child(odd) { text-transform: uppercase; }
.note-text-content { position: relative; font-size: 0.8em; display: -webkit-box; -webkit-line-clamp: 10; -webkit-box-orient: vertical; overflow: hidden; flex-grow: 1; flex-shrink: 1; min-height: 0; margin-top: 0.4rem; pointer-events: auto; scrollbar-width: none; }
.note-text-content::-webkit-scrollbar { display: none; }
.bookmark-note:hover .note-text-content { display: block; -webkit-line-clamp: unset; overflow-y: auto; }

.stamp-logo { 
    position: absolute; top: 1rem; right: 5%; width: 90%; 
    opacity: 0.15; 
    transform: rotate(-15deg); 
    z-index: 0; 
    pointer-events: none;
    mix-blend-mode: multiply;
    /* Dark embossing: subtle dark shadow top-left, crisp white highlight bottom-right */
    filter: drop-shadow(-1px -1px 1px rgba(0,0,0,0.3)) 
            drop-shadow(1px 1px 1px rgba(255,255,255,0.9)); 
}

/* ----------------------------------------------------
   THE EDITORIAL SPREAD PHYSICS 
   ---------------------------------------------------- */

#calendar-column { display: flex; flex-direction: column; justify-content: center; }
#calendar-text::-webkit-scrollbar { display: none; }
#calendar-text { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; font-size: 0.9rem; line-height: 1.4; gap: 2.5rem; padding: 2rem 0; max-height: 50vh; scroll-snap-type: y mandatory; }
.calendar-event-group { width: 100%; display: flex; flex-direction: column; align-items: center; scroll-snap-align: center; position: relative; z-index: 1; }

.calendar-event-item { 
    width: 100%; position: relative; display: flex; flex-direction: column; gap: 0.5rem;
    padding: 1.5rem; box-sizing: border-box; border-radius: 2px;
    background-color: transparent; 
    box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), background-color 0.4s, box-shadow 0.4s;
    transform-origin: center center;
}
.calendar-event-item::before {
    content: ""; position: absolute; inset: 0;
    background-image: url('../assets/textures/texture%20paper.jpg'); background-size: cover;
    opacity: 0; z-index: 0; pointer-events: none;
    transition: opacity 0.4s;
}
.calendar-event-item > * { position: relative; z-index: 1; }

.calendar-stack-piece-img {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 75%; 
    height: auto;
    object-fit: contain;
    box-sizing: border-box;
    border: 0.8rem solid rgba(255, 255, 255, 0.95);
    opacity: 0; pointer-events: none;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.4s;
    box-shadow: 0 0.2rem 0.8rem rgba(0,0,0,0.08);
    border-radius: 2px;
    z-index: 0;
}

.cal-row { display: flex; width: 100%; gap: 1rem; justify-content: flex-start; }
.cal-date { flex: 0 0 35%; text-align: left; font-size: 1.4em; font-weight: normal; padding-left: 3ch; box-sizing: border-box; }
#today-event .cal-date { font-weight: bold; padding-left: 0; }
.cal-details { flex: 0 0 60%; text-align: left; word-break: break-word; overflow-wrap: break-word; box-sizing: border-box; }
.cal-details::first-line { font-size: 1.4em; font-weight: bold; }
.calendar-event-item.has-invite { cursor: pointer; transition: opacity 0.2s; }
.calendar-event-item.has-invite:hover { opacity: 0.8; }
.calendar-event-item.is-past .invite-indicator { opacity: 0.8; }

/* ----------------------------------------------------
   CHAOTIC CALENDAR STACK (DESKTOP)
   ---------------------------------------------------- */
@media (min-width: 901px) {
    #calendar-text.is-stacked {
        overflow: hidden !important;
        scroll-snap-type: none !important;
    }
    
    #calendar-text.is-stacked .calendar-event-item {
        width: 80%;
        margin: 0 auto;
        background-color: rgba(255, 255, 255, 0.12); 
        backdrop-filter: blur(1.5rem); -webkit-backdrop-filter: blur(1.5rem); 
        box-shadow: 0 0.2rem 0.8rem rgba(0,0,0,0.08); 
    }
    #calendar-text.is-stacked .calendar-event-item::before {
        opacity: 0.08;
    }
    
    #calendar-text.is-stacked .calendar-stack-piece-img {
        opacity: 1;
    }

    #calendar-text.is-stacked .cal-date {
        display: none;
    }
    #calendar-text.is-stacked .cal-details {
        flex: 1 1 100%;
        font-size: 1.1em; /* Slight bump to fill space better */
    }
    
    #calendar-text.is-stacked .invite-indicator {
        display: none !important;
    }

    /* When NOT stacked (i.e. hovered), return to normal */
    #calendar-text:not(.is-stacked) .calendar-event-item {
        transform: translate(0, 0) rotate(0deg) !important;
    }
    #calendar-text:not(.is-stacked) .calendar-stack-piece-img {
        transform: translate(-50%, -50%) rotate(0deg) !important;
    }
}


/* FIX: Changed calendar plus indicator to solid black */
.invite-indicator { color: black; font-weight: bold; font-size: 1em; }

.calendar-inline-img { max-height: 0; opacity: 0; overflow: hidden; transition: all 0.4s ease; width: 90%; margin-top: 0; }
.calendar-inline-img.expanded { max-height: 50rem; opacity: 1; margin-top: 1.5rem; }
.calendar-inline-img img { width: 100%; display: block; box-shadow: 0 0.5rem 2rem rgba(0,0,0,0.1); border-radius: 0.2rem; }

#passcode-overlay, .glass-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; height: 100svh; background: rgba(232, 228, 217, 0.5); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); z-index: 1000; display: flex; align-items: center; justify-content: center; }

/* ----------------------------------------------------
   MAGAZINE GRID & 3D TUBES
   ---------------------------------------------------- */
body.grid-mode.magazine-grid #project-pile {
    grid-template-columns: repeat(5, 1fr);
    gap: 5rem 4vw;
}

.mag-tube-wrapper {
    position: relative;
    width: 25.3rem; /* Increased 15% to make the thing scale a bit bigger */
    height: 25.3rem;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), z-index 0s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flat-cover-img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30rem; /* Scaled 15% larger */
    height: auto;
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 2rem 4rem rgba(0,0,0,0.35);
    -webkit-clip-path: inset(-20rem -20rem 0 -20rem);
    clip-path: inset(-20rem -20rem 0 -20rem); /* Cut shadow perfectly flush at floor */
}

.spiral-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 25.3rem;
    height: 25.3rem;
    transform: translate(-50%, -50%);
    opacity: 1;
    transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Simulate the dark hollow core of the page-stack */
.spiral-shadow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem; /* Shrunk to match the crushed core */
    height: 2rem;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
    pointer-events: none;
    transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.mag-tube-title {
    position: absolute;
    bottom: -2.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Ufficio', sans-serif;
    font-size: 1rem;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.3s;
}

/* Unroll Animation */
.mag-tube-wrapper.is-active {
    /* Translates to exact center calculated by JS */
    transform: translate(var(--tx, 0), var(--ty, 0)) scale(1.4);
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), z-index 0s;
    filter: none !important; /* Remove wrapper drop-shadow to prevent double shadow */
}

.mag-tube-wrapper.is-active .spiral-canvas,
.mag-tube-wrapper.is-active .spiral-shadow {
    opacity: 0;
    pointer-events: none;
}

.mag-tube-wrapper.is-active .flat-cover-img {
    opacity: 1;
    pointer-events: auto;
}

.mag-tube-wrapper.is-active .mag-tube-title {
    opacity: 0;
}
