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

:root {
    --bg: #000000;
    --ink: #ffffff;
    --muted: rgba(255, 255, 255, 0.55);
    --line: rgba(255, 255, 255, 0.12);
    --cream: #f2e8d5;
    --accent: #ffffff;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.back-link {
    position: fixed;
    bottom: 0.75rem;
    left: 0.75rem;
    z-index: 1000;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    padding: 0.45rem 0.9rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    opacity: 0.85;
    transition: opacity 0.3s, transform 0.3s;
}
.back-link:hover { opacity: 1; transform: translateY(-2px); }

/* =========================================================
   LOADER — audio waveform bars
   ========================================================= */
.loader {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
}

.loader__wave {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 120px;
}
.loader__wave span {
    display: block;
    width: 5px;
    min-height: 5px;
    background: var(--ink);
    border-radius: 3px;
    transform-origin: center;
    will-change: transform, height;
}

.loader__meta {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.25em;
    color: var(--muted);
}
.loader__counter {
    color: var(--ink);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 3ch;
    text-align: right;
}

/* =========================================================
   MEDIA GRID SECTION
   ========================================================= */
.mediagrid {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 780px;
    overflow: hidden;
    background: var(--bg);
}

.mediagrid__topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 84px;
    background: linear-gradient(90deg,
        #c9bf98 0%,
        #6c6450 25%,
        #1a1a18 55%,
        #000 100%);
    opacity: 0.9;
    pointer-events: none;
    transform-origin: left;
}

/* ---------- Top nav ---------- */
.topnav {
    position: relative;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.2rem 2rem;
}

.topnav__logo {
    display: inline-flex;
    align-items: center;
    color: var(--ink);
    text-decoration: none;
    will-change: transform;
}
.topnav__logo-mark {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}
.topnav__logo-mark span {
    width: 2px;
    background: var(--ink);
    border-radius: 2px;
    will-change: transform;
}
.topnav__logo-mark span:nth-child(1) { height: 30%; }
.topnav__logo-mark span:nth-child(2) { height: 80%; }
.topnav__logo-mark span:nth-child(3) { height: 45%; }
.topnav__logo-mark span:nth-child(4) { height: 95%; }
.topnav__logo-mark span:nth-child(5) { height: 55%; }
.topnav__logo-mark span:nth-child(6) { height: 25%; }

.topnav__links {
    display: flex;
    gap: 2rem;
    margin-left: 2rem;
}
.topnav__links a {
    position: relative;
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.3rem 0;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    will-change: transform;
}
.caret {
    font-size: 0.65em;
    opacity: 0.7;
    transition: transform 0.3s ease;
}
.topnav__links a:hover .caret { transform: translateY(2px); }
.topnav__links a::after {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    width: 100%; height: 1px;
    background: var(--ink);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.topnav__links a:hover::after { transform: scaleX(1); transform-origin: left; }

.topnav__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.topnav__action {
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    will-change: transform;
    position: relative;
    padding: 0.3rem 0;
}
.topnav__action::after {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    width: 100%; height: 1px;
    background: var(--ink);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}
.topnav__action:hover::after { transform: scaleX(1); transform-origin: left; }

.topnav__cta {
    background: var(--ink);
    color: var(--bg);
    text-decoration: none;
    padding: 0.7rem 1.3rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-block;
    will-change: transform;
    transition: background 0.3s;
}
.topnav__cta:hover { background: #e5e5e5; }

.topnav__mark {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #ff3b3b, #c22020);
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    will-change: transform;
}
.topnav__mark svg { width: 20px; height: 20px; }

/* ---------- Image grid ---------- */
.grid {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}
.tile {
    position: absolute;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.55);
    pointer-events: auto;
    cursor: pointer;
    will-change: transform, filter;
    background: #1a1a1a;
}
.tile img {
    width: 100%; height: 100%;
    object-fit: cover;
    user-select: none;
    display: block;
    transition: transform 0.6s cubic-bezier(0.65, 0, 0.35, 1), filter 0.4s ease;
    filter: saturate(1.05);
}
.tile:hover img { transform: scale(1.08); filter: saturate(1.2) brightness(1.05); }

/* Positions (mimic the Frame.io-style scatter) */
.tile--tl-1 { top: 8%;  left: -2%;  width: 260px; height: 190px; transform: rotate(-1deg); }
.tile--tl-2 { top: 38%; left: -3%;  width: 280px; height: 210px; transform: rotate(1deg); }
.tile--tc   { top: 2%;  left: 25%;  width: 260px; height: 150px; transform: rotate(1deg); }
.tile--tr-1 { top: 0%;  left: 60%;  width: 230px; height: 170px; transform: rotate(-1.5deg); }
.tile--tr-2 { top: 10%; right: -2%; width: 280px; height: 190px; transform: rotate(1deg); }

.tile--r-1 { top: 40%; right: -1%; width: 240px; height: 210px; transform: rotate(-1deg); }
.tile--r-2 { top: 68%; right: 4%;  width: 280px; height: 200px; transform: rotate(1deg); }

.tile--l-1 { top: 5%;  left: 2%;   width: 250px; height: 160px; display: none; }
.tile--l-2 { top: 68%; left: 4%;   width: 280px; height: 200px; transform: rotate(-1deg); }

.tile--bl   { bottom: 10%; left: -2%;   width: 280px; height: 200px; transform: rotate(1deg); }
.tile--bc-1 { bottom: 2%;  left: 28%;   width: 240px; height: 140px; transform: rotate(-1deg); }
.tile--bc-2 { bottom: 6%;  left: 46%;   width: 220px; height: 140px; transform: rotate(1deg); }
.tile--bc-3 { bottom: 4%;  left: 62%;   width: 240px; height: 160px; transform: rotate(-1deg); }
.tile--br   { bottom: 14%; right: -2%;  width: 280px; height: 200px; transform: rotate(1deg); display: none; }

/* ---------- Center content ---------- */
.center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    text-align: center;
    max-width: 560px;
    padding: 0 1.5rem;
    pointer-events: none;
}
.center > * { pointer-events: auto; }

.center__title {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4.2rem);
    line-height: 1.05;
    letter-spacing: -0.025em;
    color: var(--ink);
    margin-bottom: 1.5rem;
}
.center__line {
    display: block;
    overflow: hidden;
    padding-bottom: 0.05em;
}
.center__char {
    display: inline-block;
    will-change: transform, color;
    transition: color 0.3s ease;
}
.center__char.is-space { width: 0.25em; }

.center__desc {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--muted);
    font-weight: 400;
}

/* ---------- Initial hidden states ---------- */
[data-magnetic], [data-link], [data-tile], [data-desc], [data-topbar] { opacity: 0; }
[data-title-line] .center__char { opacity: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .topnav__links { display: none; }
    .topnav__action { display: none; }
    .topnav { gap: 1rem; }
    .tile--tc, .tile--tr-1, .tile--r-2 { display: none; }
}
@media (max-width: 768px) {
    .tile {
        transform: none !important;
    }
    .tile--tl-2, .tile--r-2, .tile--bl, .tile--bc-3 { display: none; }
    .tile--tl-1 { width: 40vw; height: 28vw; left: -8%; }
    .tile--tr-2 { width: 42vw; height: 30vw; right: -6%; }
    .tile--r-1 { width: 40vw; height: 30vw; right: -10%; top: 42%; }
    .tile--l-2 { width: 40vw; height: 28vw; left: -8%; top: 62%; }
    .tile--bc-1 { width: 40vw; height: 26vw; left: 8%; bottom: 4%; }
    .tile--bc-2 { width: 40vw; height: 26vw; right: 8%; left: auto; bottom: 4%; }
    .center { max-width: 90%; }
    .center__desc { font-size: 0.9rem; }
}
@media (max-width: 480px) {
    .tile--r-1, .tile--l-2 { display: none; }
    .tile--tl-1 { top: 6rem; left: -8%; width: 45vw; height: 32vw; }
    .tile--tr-2 { top: 6rem; right: -8%; width: 45vw; height: 32vw; }
    .tile--bc-1, .tile--bc-2 { top: auto; bottom: 1rem; width: 45vw; height: 28vw; }
    .tile--bc-1 { left: -5%; }
    .tile--bc-2 { right: -5%; left: auto; }
    .topnav { padding: 1rem; }
    .topnav__cta { padding: 0.5rem 1rem; font-size: 0.8rem; }
    .topnav__mark { width: 30px; height: 30px; }
}
