:root {
    /* Modal open/close fade — this one only lives in CSS, tweak here. */
    --modal-fade-duration: 1.0s;

    /* Modal background crossfade duration — fallback value only.
       At runtime this is overwritten by modalConfig.crossfadeDuration
       in index.js, which is the single source of truth. */
    --modal-crossfade-duration: 2.0s;
}

html, body {
    /* Stops iOS/Android from hijacking finger-drags for scroll, pull-to-refresh,
       or pinch-zoom, so a drag always drives the grid instead. */
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: Helvetica, Arial, sans-serif;
    text-align: center;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #426fa6;
}

#bkaux {
    z-index: 1;
    position: fixed;
    padding: 0;
    margin: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 1;
    transition: opacity 9s ease-in-out; /* overridden per-image at runtime by index.js */
}

.bk {
    background-color: #426fa6;
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
}

#gridCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2;
    pointer-events: none;
}

.grid-link {
    position: fixed;
    z-index: 3;
    color: transparent;
    text-decoration: none;
    font-size: 23px;
    letter-spacing: 2.5px;
    opacity: 0;
    pointer-events: none;
    user-select: none;
    font-weight: 300;
    white-space: nowrap;
}

.top-center {
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.bottom-left {
    top: 75%;
    left: 25%;
    transform: translate(-50%, -50%);
}

.bottom-right {
    top: 75%;
    left: 75%;
    transform: translate(-50%, -50%);
}

/* Touch-only onboarding hint (removed entirely on non-touch devices by JS).
   Sits in a corner so the center stays free for the flashlight demo. */
#dragHint {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    z-index: 4; /* above the grid canvas, doesn't matter re: links since pointer-events is none */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.85);
    pointer-events: none;
    user-select: none;
    opacity: 1;
    transition: opacity var(--hint-fade-duration, 0.5s) ease;
}

#dragHint.is-hidden {
    opacity: 0;
}

.drag-hint-icon {
    font-size: 28px;
    animation: dragHintMotion 1.6s ease-in-out infinite;
    /* Emoji glyphs ignore `color`; this flattens it to a silhouette, then
       inverts that silhouette to pure white. */
    filter: brightness(0) invert(1);
}

.drag-hint-label {
    font-size: 13px;
    letter-spacing: 1.5px;
    text-transform: lowercase;
    opacity: 0.8;
}

/* Static fallback for prefers-reduced-motion: no orbiting icon, just the label */
#dragHint.is-static .drag-hint-icon {
    animation: none;
}

@keyframes dragHintMotion {
    0%, 100% { transform: translate(-10px, -6px); }
    50%      { transform: translate(10px, 6px); }
}

/* Info popup modal */
.modal {
    display: flex;
    position: fixed;
    z-index: 10;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--modal-fade-duration) ease, visibility var(--modal-fade-duration) ease;
}

.modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    position: relative;
    margin: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 90vw;
    max-width: 900px;
    height: 60vh;
    border-radius: 4px;
    box-shadow: 0 0 35px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    color: #ffffff;
}

/* Dual background layers for the modal's image crossfade */
.modal-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity var(--modal-crossfade-duration) ease-in-out;
    z-index: 1;
}

.modal-bg.active {
    opacity: 1;
}

.popup-text-block {
    position: absolute;
    bottom: 25px;
    right: 25px;
    text-align: right;
    opacity: 0.6;
    font-size: 16px;
    letter-spacing: 1px;
    line-height: 1.8;
    z-index: 2;
}

.popup-text-block p {
    margin: 5px 0;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 28px;
    cursor: pointer;
    z-index: 3;
}

.close-btn:hover {
    color: #fff;
}

.noTransition {
    transition: none !important;
}
