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

:root {
    --bg: #f4f2ee;
    --ink: #1a1a1a;
    --ink-soft: #6b6b6b;
    --line: rgba(26, 26, 26, 0.12);
    --accent: #d94a2f;
    --sidebar-w: 52px;
    --gutter: 0px;
}

html {
    /* Always reserve space for the vertical scrollbar so hiding overflow
       (when the lightbox opens) doesn't cause the layout to shift. */
    scrollbar-gutter: stable;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Manrope', -apple-system, sans-serif;
    font-size: 12px;
    background: var(--bg);
    color: var(--ink);
    letter-spacing: 0.02em;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ---------- Sidebars ---------- */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 22px 0;
    z-index: 20;
    background: #fff;
}

.sidebar--left {
    left: 0;
}

/* ---------- Logo (left, rotated -90°) ---------- */
.logo {
    display: block;
    position: relative;
    width: 77px;
    height: 90px;
    color: var(--ink);
}

.logo__svg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 110px;         /* pre-rotation width */
    height: auto;         /* keeps SVG aspect from viewBox */
    transform: translate(-50%, -50%) rotate(-90deg);
    display: block;
}

/* ---------- Vertical nav (centered in left sidebar) ---------- */
.nav {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.nav a {
    position: relative;
    display: block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 10px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--ink-soft);
    padding: 4px 0;
    transition: color 0.35s ease;
}

.nav a:hover,
.nav a.active {
    color: var(--ink);
}

/* underline that fades in on hover / active — placed on the visual RIGHT
   of the vertical text (i.e. BELOW the word in tilted-head reading) */
.nav a::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -8px;                  /* becomes visual RIGHT after 180° rotation */
    width: 1px;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.nav a:hover::after,
.nav a.active::after {
    opacity: 1;
}

/* ---------- Stage & Masonry ---------- */
.stage {
    padding: 0 0 0 var(--sidebar-w);
    min-height: 100vh;
}

.masonry {
    column-count: 4;
    column-gap: var(--gutter);
}

.masonry__item {
    break-inside: avoid;
    margin-bottom: var(--gutter);
    position: relative;
    overflow: hidden;
    background: #e6e2dc;
    cursor: pointer;
    opacity: 0;
    transform: translateY(18px);
    animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
    transition: box-shadow 0.5s ease, transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes rise {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.masonry__item img,
.masonry__item video {
    width: 100%;
    height: auto;
    display: block;
}

/* tiny expand indicator in the corner (not applied to the photo) */
.masonry__item::after {
    content: '';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bg);
    z-index: 2;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
    background-image:
        linear-gradient(var(--ink), var(--ink)),
        linear-gradient(var(--ink), var(--ink));
    background-size: 10px 1px, 1px 10px;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
}

.masonry__item:hover::after {
    opacity: 1;
    transform: scale(1);
}

/* while the lightbox is animating this item, freeze it completely:
   - hide the thumbnail so the flying copy owns the space
   - kill hover so the rect we measure never drifts from the resting layout
   - block pointer events so cursor movement can't retrigger hover */
.masonry__item.is-source {
    transform: none !important;
    box-shadow: none !important;
    pointer-events: none;
}
.masonry__item.is-source img,
.masonry__item.is-source video {
    opacity: 0;
}
.masonry__item.is-source::after {
    opacity: 0 !important;
}

/* used briefly after removing .is-source so the thumbnail can't snap into hover */
.masonry__item.no-transition,
.masonry__item.no-transition img,
.masonry__item.no-transition video,
.masonry__item.no-transition::after {
    transition: none !important;
}

/* ---------- Lightbox ---------- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0);
    transition: background 0.55s ease;
    pointer-events: none;
}

.lightbox.is-open {
    pointer-events: auto;
    background: #000;
}

.lightbox__frame {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform, width, height, left, top, opacity;
    display: block;
    background: #000;
    overflow: hidden;
}

.lightbox__frame img,
.lightbox__frame video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lightbox__frame img[hidden],
.lightbox__frame video[hidden] {
    display: none;
}

/* nav buttons */
.lightbox__btn {
    position: absolute;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: 'Manrope', sans-serif;
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
    opacity: 0;
    z-index: 5;
}

.lightbox.is-open .lightbox__btn {
    opacity: 1;
    transition-delay: 0.35s;
}

.lightbox__btn:hover {
    background: #fff;
    color: #000;
    border-color: #fff;
}

.lightbox__close {
    top: 26px;
    right: 26px;
    font-size: 20px;
}

.lightbox__prev {
    left: max(24px, calc(var(--sidebar-w) + 18px));
    top: 50%;
    margin-top: -23px;
}

.lightbox__next {
    right: 24px;
    top: 50%;
    margin-top: -23px;
}

.lightbox__prev:hover,
.lightbox__next:hover {
    transform: scale(1.08);
}

.lightbox__meta {
    position: absolute;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 22px;
    align-items: center;
    font-size: 10px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    opacity: 0;
    transition: opacity 0.5s ease 0.4s;
}

.lightbox.is-open .lightbox__meta {
    opacity: 1;
}

.lightbox__counter {
    font-variant-numeric: tabular-nums;
    color: #fff;
}

body.lightbox-open {
    overflow: hidden;
}

/* ---------- Contact panel ---------- */
.contact-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--sidebar-w);
    background: #fff;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0s linear 0.5s;
}

.contact-panel.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0s linear 0s;
}

.contact-panel__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 110px;
    padding: 40px;
    max-width: 820px;
    width: 100%;
    transform: translateY(18px);
    opacity: 0;
    transition:
        transform 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.1s,
        opacity 0.55s ease 0.1s;
}

.contact-panel.is-open .contact-panel__grid {
    transform: translateY(0);
    opacity: 1;
}

.contact-card {
    display: flex;
    flex-direction: column;
    gap: 22px;
    align-items: flex-start;
}

.contact-card__name {
    font-family: 'Manrope', sans-serif;
    font-weight: 500;
    font-size: 16px;
    letter-spacing: -0.01em;
    line-height: 1.15;
    color: var(--ink);
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.contact-card__link {
    font-family: 'Manrope', sans-serif;
    font-size: 11px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--ink-soft);
    text-decoration: none;
    transition: color 0.25s ease;
}

.contact-card__link:hover {
    color: var(--ink);
}

@media (max-width: 640px) {
    .contact-panel__grid {
        grid-template-columns: 1fr;
        gap: 60px;
        text-align: left;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .masonry {
        column-count: 3;
    }
}

@media (max-width: 800px) {
    :root {
        --sidebar-w: 44px;
    }
    .masonry {
        column-count: 2;
    }
    .stage {
        padding: 0 0 0 var(--sidebar-w);
    }
}

@media (max-width: 520px) {
    .masonry {
        column-count: 1;
    }
}
