/* ── Glacial Indifference (not on Google Fonts — loaded via cdnfonts) ── */
@font-face {
    font-family: 'Glacial Indifference';
    src: url('https://fonts.cdnfonts.com/s/14935/GlacialIndifference-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Glacial Indifference';
    src: url('https://fonts.cdnfonts.com/s/14935/GlacialIndifference-Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ══════════════════════════════════════════
   RESET & TOKENS
══════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --paper:      #000000;
    --ink:        #f0ece0;
    --ink-muted:  rgba(255,255,255,0.8);
    --rule:       #2a2a2a;

    /* Category colours */
    --dynasty:    #BF3B3B;
    --both:       #D9814E;
    --contractor: #E0B04B;
    --no-ties:    #5897A6;

    --dim:        0.07;
}

html {
    scroll-behavior: auto;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: 'DM Sans', sans-serif;
    overflow-x: hidden;
}

/* ══════════════════════════════════════════
   PROGRESS BAR
══════════════════════════════════════════ */
#progressBar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: var(--dynasty);
    z-index: 300;
    pointer-events: none;
}

/* ══════════════════════════════════════════
   SCROLLY SECTION
══════════════════════════════════════════ */
#scrollySection {
    position: relative;
}

/* ══════════════════════════════════════════
   STICKY SCENE — fills 100vw × (100vh minus header)
══════════════════════════════════════════ */
#stickyScene {
    position: sticky;
    top: var(--header-h, 0px);
    width: 100vw;
    height: calc(100vh - var(--header-h, 0px));
    overflow: hidden;
    background: var(--paper);
}

/* ══════════════════════════════════════════
   PHOTO GRID — wall-to-wall, floor-to-ceiling
══════════════════════════════════════════ */
#photoGrid {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 0;
    width: 100%;
    height: 100%;
}

/* ── Card ── */
.rep-card {
    position: relative;
    overflow: hidden;
    opacity: 1;
    filter: none;
    transition:
        opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        filter  0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.rep-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 35%;
    display: block;
    pointer-events: none;
}

/* Dimmed */
.rep-card.dimmed {
    opacity: var(--dim);
    filter: grayscale(90%);
}

/* Highlighted */
.rep-card.highlighted {
    opacity: 1 !important;
    filter: none !important;
    z-index: 2;
}

/* ── Category corner square ── */
.rep-card .cat-square {
    position: absolute;
    top: 0;
    right: 0;
    width: clamp(10px, 1.6vw, 10px);
    height: clamp(10px, 1.6vw, 10px);
    opacity: 0;
    transition: opacity 0.35s;
    z-index: 4;
    pointer-events: none;
}

.rep-card[data-cat="Dynasty"] .cat-square            { background: var(--dynasty); }
.rep-card[data-cat="Both"] .cat-square               { background: var(--both); }
.rep-card[data-cat="Contractor-linked"] .cat-square,
.rep-card[data-cat="Franchisee-linked"] .cat-square  { background: var(--contractor); }
.rep-card[data-cat="none"] .cat-square               { background: var(--no-ties); }

/* ── Hover name tag (explore mode) — shows on bottom of card ── */
.rep-card .name-tag {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 6px 6px;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
    z-index: 5;
}

.name-tag .nt-name {
    font-family: 'Glacial Indifference', 'DM Sans', sans-serif;
    font-size: clamp(7px, 0.58vw, 9px);
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    display: block;
    margin-bottom: 1px;
}

.name-tag .nt-pl {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(5.5px, 0.45vw, 7px);
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
    display: block;
    margin-bottom: 3px;
}

.name-tag .nt-cat {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(5.5px, 0.44vw, 6.5px);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    display: block;
}

/* Explore mode */
body.explore-mode .rep-card {
    cursor: pointer;
}

body.explore-mode .rep-card:hover {
    z-index: 10;
}

body.explore-mode .rep-card:hover .name-tag {
    opacity: 1;
}

/* ── Floating annotation tooltip ── */
#annTooltip {
    position: fixed;
    z-index: 200;
    width: clamp(220px, 20vw, 300px);
    background: rgba(8, 8, 8, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 16px 16px 14px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
}

#annTooltip.visible {
    opacity: 1;
    pointer-events: auto;
}

#annTooltip.stuck {
    border-color: rgba(255,255,255,0.22);
}

.att-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 8px;
}

.att-meta { flex: 1; min-width: 0; }

.att-name {
    font-family: 'Glacial Indifference', 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    display: block;
    margin-bottom: 2px;
    line-height: 1.2;
}

.att-pl {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    display: block;
    margin-bottom: 4px;
}

.att-cat {
    font-family: 'DM Sans', sans-serif;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    display: block;
}

#annClose {
    background: none;
    border: none;
    color: rgba(255,255,255,0.35);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    display: none;
    transition: color 0.15s;
}

#annClose:hover { color: rgba(255,255,255,0.8); }

#annTooltip.stuck #annClose { display: block; }

.att-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin-bottom: 10px;
}

.att-body {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 300;
    line-height: 1.65;
    color: rgba(240, 236, 224, 0.8);
    white-space: pre-wrap;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.att-body.is-scrollable {
    mask-image: linear-gradient(to bottom, black 60%, transparent 95%);
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 95%);
}

.att-body::-webkit-scrollbar { width: 3px; }
.att-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.att-body::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
}

.att-no-ties {
    font-style: italic;
    color: rgba(240, 236, 224, 0.3);
}

/* click-to-stick hint */
.att-hint {
    margin-top: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 8px;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.25);
    text-align: right;
}

#annTooltip.stuck .att-hint { display: none; }

/* ══════════════════════════════════════════
   FLOATING TEXT CARD — bottom-left, frosted
══════════════════════════════════════════ */
#textCard {
    position: absolute;
    bottom: 30%;
    left: 50%;
    transform: translateX(-50%);
    width: clamp(300px, 34vw, 520px);
    z-index: 20;
    /* panels position themselves via JS translateY */
}

/* Individual panels — fixed size, JS sets position + opacity each tick */
.card-panel {
    position: absolute;
    bottom: 30%;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-bottom: none;
    padding: 28px 28px 26px;

    /* JS drives transform + opacity directly — no CSS transition needed */
    opacity: 0;
    transform: translateY(0px);
    will-change: transform, opacity;
    pointer-events: none;
}

.card-panel.active {
    pointer-events: auto;
}

/* Eyebrow */
.p-eye {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 10px;
}

/* Headline */
.p-head {
    font-family: 'Glacial Indifference', 'DM Sans', sans-serif;
    font-size: clamp(26px, 2.4vw, 38px);
    font-weight: 700;
    line-height: 1.1;
    color: var(--ink);
    margin-bottom: 14px;
    letter-spacing: -0.01em;
}

/* Body copy */
.p-body {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(16px, 1vw, 18px);
    font-weight: 300;
    line-height: 1.75;
    color: var(--ink-muted);
}

/* Big stat number inline */
.p-num {
    font-family: 'Glacial Indifference', 'DM Sans', sans-serif;
    font-size: clamp(15px, 1.3vw, 20px);
    font-weight: 700;
    display: inline;
    margin-right: 3px;
}

/* ── Scroll hint (frame 0 only) ── */
.scroll-hint {
    margin-top: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.scroll-hint span {
    font-family: 'DM Sans', sans-serif;
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(240, 236, 224, 0.3);
}

.scroll-arrow {
    width: 14px;
    height: 24px;
    border: 1px solid rgba(240, 236, 224, 0.25);
    border-radius: 7px;
    position: relative;
    flex-shrink: 0;
}

.scroll-arrow::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 6px;
    background: rgba(240, 236, 224, 0.3);
    border-radius: 2px;
    animation: scrollBob 1.6s ease-in-out infinite;
}

@keyframes scrollBob {
    0%, 100% { transform: translateX(-50%) translateY(0);    opacity: 0.8; }
    65%       { transform: translateX(-50%) translateY(8px);  opacity: 0;   }
}

/* ── Panel colour accents ── */
#p2 .p-eye {
    color: #000;
    background: var(--dynasty);
    display: inline-block;
    padding: 2px 7px;
    opacity: 1;
}

#p3 .p-eye {
    color: #000;
    background: var(--contractor);
    display: inline-block;
    padding: 2px 7px;
    opacity: 1;
}

#p4 .p-eye {
    color: #000;
    background: var(--both);
    display: inline-block;
    padding: 2px 7px;
    opacity: 1;
}

/* ── Legend (inside frame 5 panel) ── */
#exploreLegend {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.leg {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--ink-muted);
}

.leg-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Scroll triggers ── */
.scroll-trigger {
    height: 100vh;
}

/* ── Tablet (up to ~1024px) ── */
@media (max-width: 1024px) {
    #photoGrid {
        grid-template-columns: repeat(8, 1fr);
        grid-template-rows: repeat(8, 1fr);
    }

    #textCard {
        width: clamp(260px, 60vw, 480px);
        bottom: 35%;
    }

    .card-panel {
        bottom: 35%;
        padding: 22px 22px 20px;
    }

    .p-head {
        font-size: clamp(18px, 2.5vw, 28px);
    }

    .p-body {
        font-size: clamp(15px, 3.5vw, 18px);
    }
}

/* ── Mobile (up to ~600px) ── */
@media (max-width: 600px) {
    #photoGrid {
        grid-template-columns: repeat(8, 1fr);
        grid-template-rows: repeat(8, 1fr);
        height: 100%;
    }

    #textCard {
        width: 92vw;
        bottom: 35%;
    }

    .card-panel {
        bottom: 35%;
        padding: 14px 16px 12px;
    }

    .p-eye {
        font-size: 10px;
        padding: 1px 5px;
        margin-bottom: 7px;
    }

    .p-head {
        font-size: clamp(16px, 4.5vw, 22px);
        margin-bottom: 8px;
    }

    .p-body {
        font-size: clamp(15px, 3.5vw, 18px);
        line-height: 1.6;
    }

    .p-num {
        font-size: clamp(13px, 3.5vw, 16px);
    }

    /* Always show close button on mobile tooltips */
    #annClose {
        display: block !important;
        color: rgba(255,255,255,0.6);
        font-size: 20px;
        padding: 2px 4px;
    }

    /* Tooltip full-width on mobile */
    #annTooltip {
        width: 92vw;
        left: 4vw !important;
        right: 4vw;
    }

    /* Tooltip: make it feel like a sheet from bottom */
    #annTooltip.visible {
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        border-radius: 12px 12px 0 0;
        border: 1px solid rgba(255,255,255,0.12);
        padding: 20px 20px 32px;
        max-height: 60vh;
    }

    .att-body {
        max-height: 35vh;
    }

    /* Name tags too small to be useful at this size — hide them */
    .rep-card .name-tag {
        display: none;
    }

    /* Slightly larger tap targets */
    .rep-card {
        cursor: pointer;
    }
}