:root {
    --navy: #0d1b2a;
    --navy-mid: #162032;
    --navy-light: #1e3050;
    --gold: #c9a84c;
    --gold-light: #e8c97a;
    --cream: #f5f0e8;
    --text-light: #dde3ec;
    --accent: #4a7fa5;
    --parchment: #f4ead5;
    --parchment-dark: #e0ceaa;
    --ink: #2c1a0e;
    --nav-h: 68px; /* single source of truth for nav height */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: -webkit-fill-available;
}

body {
    font-family: 'Frank Ruhl Libre', serif;
    background: var(--navy);
    color: var(--text-light);
    overflow: hidden;
    /* 100dvh accounts for collapsing mobile browser chrome */
    height: 100dvh;
    height: -webkit-fill-available;
    width: 100vw;
    touch-action: none;
}

/* ─── SECTIONS ─── */
.section {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* default: vertically center (home) */
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
    /* generic safe padding; override per-section below */
    padding: clamp(1rem, 3vw, 2rem);
    padding-top: calc(clamp(1rem, 3vw, 2rem) + env(safe-area-inset-top));
    padding-bottom: calc(var(--nav-h) + 0.5rem + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.section.active {
    opacity: 1;
    pointer-events: all;
}

/* ─── HOME ─── */
#home {
    background: radial-gradient(ellipse at 50% 40%, #1e3a5f 0%, var(--navy) 70%);
    gap: clamp(1rem, 3vh, 1.8rem);
    /* home has no nav — reset padding-bottom */
    padding-bottom: clamp(1rem, 3vw, 2rem);
}

.idf-decoration {
    width: clamp(44px, 9vw, 80px);
    opacity: 0.7;
    flex-shrink: 0;
}

.home-title {
    font-family: 'Suez One', serif;
    font-size: clamp(2.4rem, 9vw, 5rem);
    color: var(--gold-light);
    text-align: center;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-shadow: 0 0 60px rgba(201, 168, 76, 0.3);
}

.home-subtitle {
    font-size: clamp(0.95rem, 2.5vw, 1.4rem);
    color: var(--text-light);
    opacity: 0.75;
    letter-spacing: 0.06em;
    text-align: center;
    padding: 0 1rem;
}

.divider-line {
    width: clamp(80px, 35vw, 180px);
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    flex-shrink: 0;
}

/* ─── BUTTONS ─── */
.btn-primary {
    font-family: 'Suez One', serif;
    font-size: clamp(0.95rem, 2.5vw, 1.2rem);
    padding: 0.85rem 2.5rem;
    background: transparent;
    border: 2px solid var(--gold);
    color: var(--gold-light);
    cursor: pointer;
    letter-spacing: 0.1em;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 48px;
    min-width: 130px;
    flex-shrink: 0;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gold);
    transform: translateX(101%);
    transition: transform 0.3s ease;
    z-index: -1;
}

.btn-primary:hover {
    color: var(--navy);
}

.btn-primary:hover::before {
    transform: translateX(0);
}

.btn-primary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: rgba(201, 168, 76, 0.3);
    color: rgba(232, 201, 122, 0.4);
}

/* prevent hover animation when disabled */
.btn-primary:disabled:hover {
    color: rgba(232, 201, 122, 0.4);
}

.btn-primary:disabled::before {
    transform: translateX(101%); /* keep background hidden */
}

#btn-continue:disabled {
    filter: grayscale(0.4);
}

/* ─── CONTENT SECTIONS (images + video share this base) ─── */
.content-section {
    background: radial-gradient(ellipse at 60% 30%, #1a2e48 0%, var(--navy) 70%);
    justify-content: flex-start;
    align-items: center;
    gap: 0.9rem;
    padding: clamp(1rem, 3vw, 2rem) clamp(0.8rem, 4vw, 3rem);
    padding-top: calc(clamp(1rem, 3vw, 2rem) + env(safe-area-inset-top));
    padding-bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom));
}

.section-label {
    font-size: clamp(0.6rem, 1.8vw, 0.75rem);
    letter-spacing: 0.22em;
    color: var(--gold);
    text-transform: uppercase;
    opacity: 0.8;
    text-align: center;
    flex-shrink: 0;
}

.section-title {
    font-family: 'Suez One', serif;
    font-size: clamp(1.3rem, 4.5vw, 2.8rem);
    color: var(--cream);
    text-align: center;
    line-height: 1.3;
    flex-shrink: 0;
}

/* Image frame: fills available space but never overwhelms */
.placeholder-frame {
    width: min(700px, 94vw);
    /* grow to fill leftover space; hard caps prevent overflow */
    flex: 1 1 auto;
    min-height: 140px;
    max-height: min(420px, calc(100dvh - var(--nav-h) - 120px));
    border: 2px dashed rgba(201, 168, 76, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    position: relative;
    overflow: hidden;
}

.placeholder-frame .ph-icon {
    font-size: 2.5rem;
    opacity: 0.3;
}

.placeholder-frame .ph-text {
    font-size: clamp(0.75rem, 2vw, 1rem);
    opacity: 0.45;
    letter-spacing: 0.05em;
    text-align: center;
    padding: 0 1.5rem;
}

/* ─── NAV BAR ─── */
.nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    z-index: 100;
    padding: 0.75rem 1.2rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    background: linear-gradient(to top,
    rgba(13, 27, 42, 0.98) 0%,
    rgba(13, 27, 42, 0.88) 75%,
    transparent 100%);
    min-height: var(--nav-h);
}

.step-indicator {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.step-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(201, 168, 76, 0.3);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.step-dot.active {
    background: var(--gold);
    transform: scale(1.4);
}

/* ─── BEN-GURION ─── */
#section-bengurion {
    justify-content: flex-start;
    align-items: center;
    padding: clamp(1rem, 3vw, 2rem) clamp(0.8rem, 4vw, 2.5rem);
    padding-top: calc(clamp(1rem, 3vw, 2rem) + env(safe-area-inset-top));
    padding-bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom));
    gap: 0;
}

.antique-frame {
    width: min(720px, 96vw);
    padding: clamp(1.2rem, 3.5vw, 3.5rem) clamp(1rem, 3.5vw, 4rem);
    background: var(--parchment);
    position: relative;
    margin: 0;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.8),
    inset 0 0 30px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.antique-frame::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid var(--parchment-dark);
    pointer-events: none;
}

.antique-frame::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

.antique-frame > * {
    position: relative;
    z-index: 1;
}

.antique-byline {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: clamp(0.8rem, 2vw, 1rem);
    color: var(--ink);
    text-align: center;
    opacity: 0.55;
    margin-bottom: clamp(0.7rem, 2vw, 1.5rem);
}

.antique-quote {
    color: var(--ink);
    font-family: 'Frank Ruhl Libre', serif;
    font-size: clamp(0.88rem, 2.2vw, 1.15rem);
    font-style: italic;
    /* Reduced line-height from 2 → 1.85 saves vertical space on mobile */
    line-height: 1.85;
    text-align: justify;
    word-spacing: 0.05em;
    margin: 0;
    padding: 0;
    opacity: 0.85;
}

.antique-signature {
    color: var(--ink);
    font-family: 'Frank Ruhl Libre', serif;
    font-size: clamp(0.75rem, 1.8vw, 0.95rem);
    font-style: italic;
    text-align: end;
    opacity: 0.6;
    margin-top: clamp(0.8rem, 2vw, 1.4rem);
}

/* ─── VIDEO SECTION ─── */
#section-video {
    background: radial-gradient(ellipse at 50% 60%, #0f2340 0%, var(--navy) 70%);
    justify-content: flex-start;
    align-items: center;
    gap: 0.9rem;
    padding: clamp(1rem, 3vw, 2rem) clamp(0.8rem, 4vw, 3rem);
    padding-top: calc(clamp(1rem, 3vw, 2rem) + env(safe-area-inset-top));
    padding-bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom));
}

/* Reliable 16:9 wrapper that respects short screens */
.video-wrapper {
    width: min(720px, 96vw);
    /* padding-bottom trick: 56.25% = 9/16 */
    height: 0;
    padding-bottom: min(
            calc(min(720px, 96vw) * 0.5625),
            40vh
    );
    background: #000;
    position: relative;
    border: 1px solid rgba(201, 168, 76, 0.25);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
    flex-shrink: 0;
}

.video-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.time-badge {
    display: inline-block;
    background: rgba(201, 168, 76, 0.15);
    border: 1px solid rgba(201, 168, 76, 0.4);
    color: var(--gold);
    padding: 0.2rem 0.8rem;
    font-size: clamp(0.65rem, 2vw, 0.8rem);
    letter-spacing: 0.1em;
    flex-shrink: 0;
}

/* ─── DRAG GAME ─── */
#section-drag {
    background: radial-gradient(ellipse at 40% 50%, #122038 0%, var(--navy) 70%);
    justify-content: flex-start;
    align-items: center;
    gap: 0.7rem;
    padding: clamp(0.8rem, 2vw, 1.5rem) clamp(0.6rem, 2.5vw, 2rem);
    padding-top: calc(clamp(0.8rem, 2vw, 1.5rem) + env(safe-area-inset-top));
    padding-bottom: calc(var(--nav-h) + 0.8rem + env(safe-area-inset-bottom));
    overflow-y: auto;
}

.game-header {
    text-align: center;
    flex-shrink: 0;
}

.game-round {
    font-size: clamp(0.6rem, 2vw, 0.75rem);
    letter-spacing: 0.2em;
    color: var(--gold);
    opacity: 0.8;
}

.game-instruction {
    font-size: clamp(0.78rem, 2.2vw, 0.95rem);
    color: var(--text-light);
    opacity: 0.7;
    margin-top: 0.25rem;
}

.drag-area {
    width: min(760px, 99vw);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
}

.drag-card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.drag-card-desc {
    font-size: clamp(0.72rem, 2.2vw, 0.9rem);
    color: var(--gold-light);
    opacity: 0.8;
    text-align: center;
    max-width: clamp(180px, 60vw, 380px);
    line-height: 1.5;
    letter-spacing: 0.03em;
    min-height: 1.4em;
}

.image-placeholder-box {
    /* More compact on mobile */
    width: clamp(100px, 28vw, 200px);
    height: clamp(75px, 20vw, 145px);
    border: 2px dashed rgba(201, 168, 76, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    cursor: grab;
    user-select: none;
    position: relative;
    flex-shrink: 0;
    touch-action: none;
}

.image-placeholder-box:active {
    cursor: grabbing;
}

.image-placeholder-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    display: none;
}

.image-placeholder-box .img-ph {
    color: rgba(255, 255, 255, 0.3);
    font-size: clamp(0.65rem, 1.8vw, 0.85rem);
    text-align: center;
    padding: 0.5rem;
}

/* ─── SPECTRUM ─── */
.spectrum-container {
    width: 100%;
    position: relative;
    padding-top: 0.5rem;
    flex-shrink: 0;
}

.spectrum-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    padding: 0 0.2rem;
}

.spectrum-label {
    font-family: 'Suez One', serif;
    /* Tighter on narrow screens */
    font-size: clamp(0.55rem, 2.2vw, 1rem);
    color: var(--gold-light);
    text-align: center;
    flex: 1;
    opacity: 0.9;
}

.spectrum-track {
    height: clamp(50px, 11vw, 80px);
    background: linear-gradient(90deg,
    rgba(74, 127, 165, 0.2) 0%,
    rgba(74, 127, 165, 0.3) 33%,
    rgba(201, 168, 76, 0.25) 66%,
    rgba(201, 168, 76, 0.45) 100%);
    border: 1px solid rgba(201, 168, 76, 0.25);
    position: relative;
    border-radius: 2px;
    overflow: visible;
    touch-action: none;
}

.spectrum-divisions {
    position: absolute;
    inset: 0;
    display: flex;
    pointer-events: none;
}

.spectrum-division {
    flex: 1;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.spectrum-division:last-child {
    border-right: none;
}

.drop-indicator {
    position: absolute;
    top: -8px;
    width: 3px;
    height: calc(100% + 16px);
    background: var(--gold);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    transform: translateX(-1.5px);
    box-shadow: 0 0 8px var(--gold);
}

.placed-image {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: clamp(42px, 10vw, 70px);
    height: clamp(34px, 8vw, 55px);
    background: rgba(201, 168, 76, 0.15);
    border: 2px solid var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(201, 168, 76, 0.3);
    z-index: 10;
    border-radius: 1px;
}

.placed-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drag-controls {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.placement-result {
    background: rgba(201, 168, 76, 0.1);
    border: 1px solid rgba(201, 168, 76, 0.3);
    padding: 0.4rem 0.8rem;
    font-size: clamp(0.75rem, 2.2vw, 0.9rem);
    color: var(--gold-light);
    text-align: center;
    min-width: clamp(110px, 35vw, 200px);
    min-height: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary {
    font-family: 'Suez One', serif;
    font-size: clamp(0.78rem, 2.2vw, 0.9rem);
    padding: 0.55rem 1.3rem;
    background: transparent;
    border: 1px solid rgba(201, 168, 76, 0.5);
    color: var(--gold);
    cursor: pointer;
    letter-spacing: 0.08em;
    transition: all 0.25s ease;
    min-height: 44px;
    min-width: 90px;
}

.btn-secondary:hover {
    background: rgba(201, 168, 76, 0.1);
}

.btn-secondary:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ─── DRAG GHOST ─── */
.dragging-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.85;
    transform: translate(-50%, -50%);
    border: 2px solid var(--gold);
    background: rgba(13, 27, 42, 0.9);
    width: clamp(60px, 15vw, 100px);
    height: clamp(48px, 12vw, 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--gold);
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(201, 168, 76, 0.2);
}

.dragging-ghost img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ─── CORNER ORNAMENTS ─── */
.corner-ornament {
    position: fixed;
    width: clamp(32px, 5.5vw, 60px);
    height: clamp(32px, 5.5vw, 60px);
    opacity: 0.18;
    pointer-events: none;
    z-index: 50;
}

.corner-ornament.tl {
    top: 1rem;
    right: 1rem;
}

.corner-ornament.tr {
    top: 1rem;
    left: 1rem;
    transform: scaleX(-1);
}

.corner-ornament.bl {
    bottom: 1rem;
    right: 1rem;
    transform: scaleY(-1);
}

.corner-ornament.br {
    bottom: 1rem;
    left: 1rem;
    transform: scale(-1);
}

/* ─── ANIMATIONS ─── */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.active .anim-1 {
    animation: fadeUp 0.5s ease 0.10s both;
}

.active .anim-2 {
    animation: fadeUp 0.5s ease 0.25s both;
}

.active .anim-3 {
    animation: fadeUp 0.5s ease 0.40s both;
}

.active .anim-4 {
    animation: fadeUp 0.5s ease 0.55s both;
}

/* ─── FULLSCREEN OVERLAY ─── */
.fullscreen-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

.fullscreen-overlay.open {
    display: flex;
}

.fullscreen-overlay img {
    max-width: 96vw;
    max-height: 82vh;
    object-fit: contain;
}

.close-btn {
    color: var(--gold);
    background: none;
    border: 1px solid var(--gold);
    padding: 0.6rem 2rem;
    cursor: pointer;
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 1rem;
    min-height: 48px;
    min-width: 100px;
}

/* ─── MOBILE ≤ 480 px ─── */
@media (max-width: 480px) {
    :root {
        --nav-h: 60px;
    }

    .corner-ornament {
        display: none;
    }

    #home {
        gap: 1.1rem;
    }

    .antique-frame {
        padding: 1rem 0.9rem;
    }

    .antique-byline {
        margin-bottom: 0.6rem;
    }

    .antique-quote {
        font-size: 0.88rem;
        line-height: 1.8;
    }

    .spectrum-label {
        font-size: 0.58rem;
    }

    .drag-area {
        gap: 0.5rem;
    }
}

/* ─── SHORT SCREENS (landscape phone etc.) ─── */
@media (max-height: 600px) {
    :root {
        --nav-h: 54px;
    }

    .section {
        justify-content: flex-start;
        padding-top: 0.7rem;
    }

    #home {
        justify-content: center;
    }

    .antique-quote {
        line-height: 1.7;
    }

    .image-placeholder-box {
        height: clamp(60px, 17vw, 110px);
    }

    .spectrum-track {
        height: clamp(42px, 10vw, 60px);
    }

    .placeholder-frame {
        max-height: calc(100dvh - var(--nav-h) - 110px);
    }

    .video-wrapper {
        padding-bottom: min(calc(96vw * 0.5625), 36vh);
    }
}
