/* ==========================================================
   TABLET / MOBILE STORY MODE
========================================================== */

@media (max-width: 1024px) {

    .story-nav {
        display: none;
    }

    .hero {
        min-height: 100svh;
    }

    .hero-content {

        display: flex;

        flex-direction: column;

        align-items: center;

        gap: var(--space-5);

        min-height: 200vh;

    }

    .device {

        position: absolute;

        top: 0;

        left: 50%;

        width:
            min(330px,
                calc(100vw - 28px));

        margin: 0;

        transform:
            translateX(-50%) rotate(var(--device-rotation, 0deg));

        z-index: 20;

    }

    .device-stage {

        min-height: 640px;

    }

    .device-screen {

        height:
            min(640px,
                calc((100vw - 28px) * 1.94),
                calc(100svh - var(--navbar-height) - 86px));

        border-radius: 30px;
    }

    .device-frame {

        border-radius: 38px;

        padding: 8px;

    }

    .device.mobile-stage-fixed {

        position: fixed;

        left: 50%;

        top:
            calc(var(--navbar-height) + 6px);

        margin: 0;

        transform:
            translateX(-50%) rotate(var(--device-rotation, 0deg));

        z-index: 20;
    }

    /*
     * The narrative is no longer part of the layout.
     * It becomes a transient overlay.
     */

    .hero .story-overlay {

        position: fixed;

        inset: 0;

        display: block;

        padding: 0;

        pointer-events: none;

        z-index: 900;

    }

    /*
     * "Meet Emily" uses the same snackbar treatment
     * as the later narrative beats.
     */

    .hero .story-caption {

        position: fixed;

        top:
            calc(var(--navbar-height) + 14px);

        left: 12px;

        right: auto;

        width:
            min(calc(100vw - 24px),
                340px);

        padding:
            12px 18px 14px;

        border-radius: 14px;

        text-align: left;

        background:
            rgba(255, 255, 255, .94);

        box-shadow:
            0 14px 36px rgba(0, 0, 0, .12);

        backdrop-filter:
            blur(14px);

        opacity: 0;

        transform:
            translateX(-115%);

        transition:
            opacity .55s ease,
            transform .7s cubic-bezier(.22,
                1,
                .36,
                1);

    }

    .hero .story-caption.visible {

        opacity: 1;

        transform:
            translateX(0);

    }

    .hero .story-kicker {

        font-size: .72rem;

        letter-spacing: .2em;

        margin-bottom: 4px;

        color:
            var(--color-text-light);

    }

    .hero .story-person {

        font-size:
            clamp(1.6rem,
                8vw,
                2.5rem);

        line-height: 1;

        color:
            var(--color-text);

    }

    /*
     * All narrative beats use the same snackbar.
     *
     * They enter from the opposite side so the user
     * immediately understands that this is a new story beat.
     */

    .hero .story-narrative {

        position: fixed;

        top:
            calc(var(--navbar-height) + 14px);

        left: auto;

        right: 12px;

        width:
            min(calc(100vw - 24px),
                360px);

        padding:
            13px 17px;

        border-radius: 14px;

        text-align: left;

        background:
            rgba(255, 255, 255, .94);

        box-shadow:
            0 14px 36px rgba(0, 0, 0, .12);

        backdrop-filter:
            blur(14px);

        opacity: 0;

        transform:
            translateX(115%);

        transition:
            opacity .5s ease,
            transform .65s cubic-bezier(.22,
                1,
                .36,
                1);

    }

    .hero .story-narrative.visible {

        opacity: 1;

        transform:
            translateX(0);

    }

    .story-narrative-text {

        font-size:
            clamp(1rem,
                4.5vw,
                1.35rem);

        line-height: 1.22;

        font-weight: 600;

        letter-spacing: -.015em;

    }

    /*
     * Action buttons remain comfortable to tap.
     */

    .reject-btn,
    .accept-btn {

        width: 58px;

        height: 58px;

        font-size: 1.3rem;

    }

}


/* ==========================================================
   SHORT MOBILE SCREENS
========================================================== */




/* ==========================================================
   VERY NARROW PHONES
========================================================== */

@media (max-width: 390px) {

    .device-stage {

        min-height: 590px;

    }

    :root {
        --navbar-height: 56px;
    }

    .navbar .container {
        width: calc(100% - 20px);
    }

    .logo {

        font-size:
            .9rem;

        gap: 6px;

    }

    .navbar .btn {

        padding:
            9px 15px;

        font-size:
            .76rem;

    }

}

@media (max-width: 1024px) {

    :root {
        --navbar-height: 64px;
    }

    .navbar .container {
        width: calc(100% - 28px);
    }

    .navbar .btn {
        padding: 10px 20px;
        font-size: .84rem;
        line-height: 1;
    }

    .logo {
        font-size: 1rem;
        gap: 8px;
    }

    .btn {
        margin: auto;
    }

}

@media (max-width: 600px) {

    :root {
        --navbar-height: 54px;
    }

    .navbar .container {
        width: calc(100% - 20px);
    }

    .navbar .btn {
        padding: 8px 14px;
        font-size: .78rem;
        line-height: 1;
    }

    .logo {
        font-size: .9rem;
        gap: 6px;
    }

}

@media (max-width: 390px) {

    :root {
        --navbar-height: 52px;
    }

    .navbar .container {
        width: calc(100% - 16px);
    }

    .navbar .btn {
        padding: 7px 12px;
        font-size: .74rem;
        line-height: 1;
    }

    .logo {
        font-size: .86rem;
        gap: 5px;
    }

}

/* ==========================================================
   DESKTOP STORY PHONE
========================================================== */

@media (min-width: 1025px) {

    .device-stage {

        position: sticky;

        top:
            calc(var(--navbar-height) + 14px);

        z-index: 20;

    }

    /*
     * On shorter desktop/laptop screens the default
     * 640px screen plus the frame/notch is taller than
     * the available viewport.
     *
     * Keep the entire physical device inside the viewport.
     */
    .device-screen {

        height:
            min(640px,
                calc(100dvh - var(--navbar-height) - 100px));

    }

}

/* Keep desktop narrative between the phone and navigator. */
@media (min-width: 1025px) {

    :root {
        --story-phone-width: 330px;
        --story-nav-width: 128px;
        --story-nav-right: 40px;
        --story-text-gap: 24px;
    }

    .device {
        width: var(--story-phone-width);
    }

    .story-nav {
        width: var(--story-nav-width);
        right: var(--story-nav-right);
    }

    .hero .story-narrative {
        /* Start just after the centered phone. */
        left: calc(50% + var(--story-phone-width) / 2 + var(--story-text-gap));

        /* Stop before the navigator, including its active shift. */
        right: calc(var(--story-nav-right) + var(--story-nav-width) + var(--story-text-gap) + 6px);

        width: auto;
        max-width: 460px;
        min-width: 0;
    }

    .hero .story-narrative-text {
        white-space: normal;
        overflow-wrap: anywhere;
        text-wrap: balance;

        font-size: clamp(1.25rem, 2.3vw, 2.35rem);
        line-height: 1.25;
    }

}

/* ==========================================================
   CENTRAL STORY — AFTER THE PHONE
========================================================== */

.device.story-device-exit {
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.1s ease;
}

.device.story-device-hidden {
    visibility: hidden;
}

/* Hide earlier overlays once the central story takes over. */
body.central-story-active .story-overlay,
body.central-story-active .scroll-indicator {
    visibility: hidden;
    pointer-events: none;
}

.central-story {
    position: fixed;

    top: var(--navbar-height);
    right: 0;
    bottom: 0;
    left: 0;

    z-index: 900;

    display: grid;
    place-items: center;

    padding: 28px 20px;
    overflow-y: auto;

    pointer-events: none;
    text-align: center;
}

.central-story[hidden] {
    display: none;
}

.central-story-content {
    width: min(760px, 100%);
    margin: auto;

    opacity: 0;

    transition: opacity .7s ease;
}

.central-story.visible .central-story-content {
    opacity: 1;
}

.central-story .central-story-text {
    margin: 0;

    color: var(--color-text);

    font-size: clamp(1.65rem, 3.2vw, 3rem);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -.035em;

    white-space: normal;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

.central-story-mark {
    margin-bottom: 18px;

    font-size: clamp(3rem, 6vw, 4.5rem);
    line-height: 1.2;
}

.central-story.is-brand .central-story-text {
    color: var(--color-primary);
    font-weight: 700;
}

/*
 * Reserve equal space on both sides on desktop.
 * This keeps the text centred while clearing the navigator.
 */
@media (min-width: 1025px) {

    .central-story {
        padding-inline: calc(var(--story-nav-right, 40px) + var(--story-nav-width, 128px) + var(--story-text-gap, 24px) + 6px);
    }

}

@media (prefers-reduced-motion: reduce) {

    .device.story-device-exit,
    .central-story-content {
        transition: none;
    }

}

/* ==========================================================
   SINGLETOWN WALKTHROUGH
========================================================== */

.town-walkthrough {
    position: fixed;

    top: var(--navbar-height);
    right: 0;
    bottom: 0;
    left: 0;

    z-index: 900;

    padding: 20px;

    background: var(--color-bg);
    text-align: left;
}

.town-walkthrough[hidden] {
    display: none;
}

.town-walkthrough-shell {
    display: flex;
    flex-direction: column;

    width: min(1080px, 100%);
    height: 100%;
    margin: auto;

    overflow-y: auto;
    overscroll-behavior: contain;

    border: 1px solid #e9e2f3;
    border-radius: 24px;
    background: white;
}

.town-walkthrough-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    flex-shrink: 0;
    padding: 18px 24px;

    border-bottom: 1px solid #f0ebf5;
    color: #766b87;
    font-size: .8rem;
}

.town-slide-counter {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.town-slide {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 28px;

    flex: 1 0 auto;
    padding: 28px;

    touch-action: pan-y pinch-zoom;
}

.town-slide-art {
    min-width: 0;
}

.town-slide-image {
    display: block;

    width: 100%;
    max-height: 430px;
    max-height: min(430px, 48dvh);

    object-fit: contain;
    user-select: none;
}

.town-slide-copy {
    min-width: 0;
}

.town-slide-label {
    margin-bottom: 12px;

    color: var(--color-primary);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.town-slide-title {
    margin: 0 0 18px;

    font-size: clamp(1.6rem, 2.6vw, 2.5rem);
    line-height: 1.15;
    letter-spacing: -.035em;
    text-wrap: balance;
    overflow-wrap: anywhere;
}

.town-slide-title:focus {
    outline: none;
}

.town-slide-description {
    color: #665e70;
    font-size: 1rem;
    line-height: 1.65;
}

.town-slide-note {
    margin-top: 18px;

    color: #81758f;
    font-size: .78rem;
    line-height: 1.5;
}

.town-example-label {
    margin-top: 20px;

    color: #81758f;
    font-size: .7rem;
}

.town-example {
    margin: 8px 0 0;
    padding: 16px;

    border-left: 3px solid var(--color-primary);
    border-radius: 0 12px 12px 0;

    background: #f6f2ff;
    color: #514465;

    font-size: .9rem;
    line-height: 1.6;
}

.town-photo-options {
    display: grid;
    gap: 9px;

    margin: 20px 0 0;
    padding-left: 24px;

    color: #514465;
    font-size: .85rem;
    line-height: 1.5;
}

.town-photo-options li {
    padding: 8px;
    border-radius: 8px;
    background: #f6f2ff;
}

.town-walkthrough-controls {
    position: sticky;
    bottom: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    flex-shrink: 0;
    margin-top: auto;
    padding: 14px 24px;

    border-top: 1px solid #f0ebf5;
    background: white;
}

.town-carousel-button {
    min-height: 44px;
    padding: 10px 18px;

    border: 1px solid #ddd3ec;
    border-radius: 999px;

    background: white;
    color: #594a6c;

    font-size: .85rem;
    font-weight: 600;
}

.town-carousel-button.primary {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: white;
}

.town-carousel-button:disabled {
    opacity: .4;
    cursor: default;
}

.town-carousel-button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
}

.town-carousel-hint {
    color: #93889f;
    font-size: .72rem;
}

/* Clear the existing desktop story navigator. */
@media (min-width: 1025px) {

    .town-walkthrough {
        padding-inline: calc(var(--story-nav-right, 40px) + var(--story-nav-width, 128px) + 24px);
    }

}

@media (max-width: 700px) {

    .town-walkthrough {
        padding: 10px;
    }

    .town-walkthrough-shell {
        border-radius: 18px;
    }

    .town-walkthrough-header {
        padding: 12px 16px;
        font-size: .72rem;
    }

    .town-slide {
        grid-template-columns: minmax(0, 1fr);
        align-content: start;
        gap: 18px;
        padding: 18px;
    }

    .town-slide-image {
        max-height: 210px;
        max-height: min(210px, 28dvh);
    }

    .town-slide-title {
        font-size: 1.6rem;
        margin-bottom: 12px;
    }

    .town-slide-description {
        font-size: .9rem;
    }

    .town-walkthrough-controls {
        padding: 12px;
    }

    .town-carousel-hint {
        display: none;
    }

}

/* Header logo */
.logo-image {
    display: block;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    object-fit: contain;
}

/* Castle above the welcome text */
.central-story-mark {
    display: block;

    width: clamp(140px, 22vw, 260px);
    height: auto;
    max-height: 32dvh;

    margin: 0 auto 20px;

    object-fit: contain;
}

@media (max-width: 1024px) {

    .logo-image {
        width: 34px;
        height: 34px;
    }

}

@media (max-width: 600px) {

    .logo-image {
        width: 30px;
        height: 30px;
    }

}

/* ==========================================================
   WAITLIST DIALOG
========================================================== */

.waitlist-dialog {
    width: min(480px, calc(100vw - 24px));

    max-height: 90vh;
    max-height: calc(100dvh - 32px);

    margin: auto;
    padding: 0;

    border: 1px solid #e9e0f4;
    border-radius: 24px;

    background: #fff;
    color: var(--color-text);

    overflow-y: auto;
    overscroll-behavior: contain;

    box-shadow: 0 24px 100px rgba(35, 15, 65, .25);
}

.waitlist-dialog::backdrop {
    background: rgba(25, 15, 40, .5);
    backdrop-filter: blur(5px);
}

.waitlist-dialog-content {
    position: relative;
    padding: 28px;
}

.waitlist-close {
    position: absolute;
    top: 10px;
    right: 10px;

    width: 44px;
    height: 44px;

    border-radius: 50%;
    background: #f5f1fa;
    color: #6e5d82;

    font-size: 1.7rem;
    line-height: 1;
}

.waitlist-castle {
    width: 76px;
    height: 76px;

    margin: 0 auto 14px;

    object-fit: contain;
}

.waitlist-dialog h2 {
    margin: 0 0 12px;

    text-align: center;
    font-size: 1.6rem;
    line-height: 1.2;
    letter-spacing: -.03em;
}

#waitlist-description {
    margin-bottom: 24px;

    text-align: center;
    color: #786c84;
    font-size: .88rem;
    line-height: 1.6;
}

.waitlist-fields {
    display: grid;
    gap: 9px;

    min-width: 0;
    border: 0;
}

.waitlist-fields label {
    margin-top: 8px;

    font-size: .82rem;
    font-weight: 600;
}

.waitlist-fields input,
.waitlist-fields select {
    width: 100%;
    min-width: 0;
    min-height: 46px;

    padding: 11px 12px;

    border: 1px solid #dcd3e8;
    border-radius: 10px;

    background: white;
    color: var(--color-text);

    font: inherit;
    font-size: 16px;
}

.waitlist-fields input:focus-visible,
.waitlist-fields select:focus-visible,
.waitlist-dialog button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
}

.waitlist-data-note {
    margin: 12px 0 6px;

    color: #83768f;
    font-size: .72rem;
    line-height: 1.5;
}

.waitlist-submit {
    width: 100%;
    min-height: 46px;

    padding: 12px 18px;
    border-radius: 999px;

    background: var(--color-primary);
    color: white;

    font-size: .9rem;
    font-weight: 600;
}

.waitlist-fields:disabled {
    opacity: .65;
}

.waitlist-fields:disabled .waitlist-submit {
    cursor: wait;
}

.waitlist-error {
    margin-top: 12px;

    color: #a5304c;
    font-size: .8rem;
    line-height: 1.5;
}

.waitlist-error:empty {
    display: none;
}

.waitlist-success p {
    margin-bottom: 20px;

    text-align: center;
    color: #506c59;
    line-height: 1.6;
}

.waitlist-dialog [hidden] {
    display: none;
}

@media (max-width: 600px) {

    .waitlist-dialog-content {
        padding: 24px 20px;
    }

    .waitlist-dialog h2 {
        font-size: 1.4rem;
    }

}