:root {
    --primary: #ff5d22;
    --bg-dark: #0d0e14;
    --radius: 12px;

    --hero-img-1x: url('../img/background.png');
    /* default PNG */
}

@supports (background-image: url("../img/background.webp")) {
    :root {
        --hero-img-1x: url('../img/background.webp');
        --hero-img-2x: url('../img/background@2x.webp');
    }
}

/* override once more if AVIF is supported */
@supports (background-image: url("../img/background.avif")) {
    :root {
        --hero-img-1x: url('../img/background.avif');
        --hero-img-2x: url('../img/background@2x.avif');
    }
}

/* ---------- Base layout ---------- */
html,
body {
    height: 100%;
    margin: 0;
    font-family: 'Heebo', sans-serif;
    background: var(--bg-dark);
    /* solid fallback if JS never runs */
    color: #fff;
}

/* ---------- Mobile background (fixed hero) ---------- */
body.mobile-ready {
    /* transparent so the hero shows through */
    background: transparent;

    display: flex;
    align-items: flex-start;
    justify-content: center;
    text-align: center;
    padding: 50px 24px calc(24px + env(safe-area-inset-bottom));

    position: relative;
    /* establishes a stacking context           */
    z-index: 1;
    /* content above the ::before curtain        */
    overflow-x: hidden;
    /* prevent accidental sideways scroll         */

    /* (iOS Safari repaint quirk) */
    transform: translateZ(0);
}

/* ---------- Mobile hero curtain ---------- */
body.mobile-ready::before {
    content: '';
    position: fixed;
    inset: 0;

    /* layer 1 – artwork */
    background: var(--hero-img-1x) bottom center / cover no-repeat;

    /* layer 0 – solid colour behind it */
    background-color: var(--bg-dark);

    background-attachment: fixed;
    z-index: 0;
    pointer-events: none;
}

/* retina / 2× */
@media (min-resolution:192dpi),
(min-resolution:2dppx) {
    body.mobile-ready::before {
        background-image: var(--hero-img-2x);
        /* keep these for absolute clarity */
        background-size: cover;
        background-position: bottom center;
    }
}

/* performance hint for very old / low-end devices */
@media (prefers-reduced-motion: reduce) {
    body.mobile-ready::before {
        will-change: auto;
    }
}

a,
button,
input {
    font-family: inherit;
}

/* orange links used in consent screen & modal */
a.rules-link,
a.consent-link {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 700;
}

a.rules-link:hover,
a.consent-link:hover {
    filter: brightness(1.1);
}

#consent-next[aria-disabled="true"] {
    opacity: .45;
    filter: saturate(.4);
    cursor: pointer;
    /* stay clickable */
    pointer-events: auto;
    /* ensure click reaches JS */
}

/* ===== Rules-modal polish ===================================== */

/* A) gutter between text and the scrollbar */
.rules-scroll {
    padding-inline: .5rem .75rem;
    /* LTR→left | RTL→right */
}

/* B) hanging-indent & number column */
.rules-scroll p {
    position: relative;
    /* anchor the absolute number */
    margin: .8em 0 0;
    /* even vertical rhythm       */
    padding-inline-start: 3.2em;
    /* width of the number column */
    text-align: right;
    line-height: 1.6;
}

.rules-scroll p:first-child {
    margin-top: 0;
}

/* C) the number itself */
.rules-scroll p>strong:first-child {
    position: absolute;
    inset-inline-start: 0;
    /* RTL/LTR-aware “left”        */
    display: inline-block;
    min-width: 3.2em;
    /* fits 1- or 2-digit numbers  */
    margin-inline-end: .4em;
    /* tiny safety gap             */
    text-align: center;
    font-weight: 700;
    letter-spacing: .02em;
    /* keeps Hebrew crisp          */
}

/* D) modal heading */
#rules-modal .modal-content h3 {
    text-align: center;
}

/* ===== extra breathing-room in the rules modal ================= */

/* 1) wider gutter between the number (✓ RTL/LTR) and the text  */
.rules-scroll p>strong:first-child {
    display: inline-block;
    min-width: 3.2em;
    /* was 2.2em – tweak to taste */
    margin-inline-end: 0.4em;
    /* tiny safety gap              */
}

/* 2) vertical spacing before each new numbered section         */
.rules-scroll p {
    margin: .8em 0 0;
    /* top 0.8em   bottom 0   */
}

.rules-scroll p:first-child {
    margin-top: 0;
    /* keep the very first line snug */
}

/* ---------- Shared wrapper ---------- */
.wrapper {
    width: 100%;
    max-width: 360px;
    min-width: 320px;
    min-height: 100dvh;

    /* ADD ↓ */
    position: relative;
    /* new stacking context  */
    z-index: 2;
    /* above curtain (z-0)   */
}

/* Logo */
.logo {
    display: block;
    width: 160px;
    height: auto;
    margin: 0 auto 28px;
}

/* Footer logo inherits size from .logo but flips the margins */
.logo-footer {
    margin: 28px auto 0;
    /* 28 px top ‒ auto sides ‒ 0 bottom */
}

/* Headline */
h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0 0 18px;
    line-height: 1.45;
}

/* ---------- Form ---------- */
form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

input[type=text] {
    padding: 16px 20px;
    font-size: 1.25rem;
    border: 2px solid var(--primary);
    background: #ffffff08;
    color: #fff;
    border-radius: var(--radius);
    outline: none;
    text-align: center;
    direction: rtl;
}

input[type=text]::placeholder,
input[type=text]::-webkit-input-placeholder {
    font-size: 1.25rem;
    color: #fff;
    text-align: center;
    direction: rtl;
}

button {
    padding: 14px 16px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: filter .2s;
}

button:hover {
    filter: brightness(1.1);
}

/* ---------- Desktop warning ---------- */
#desktop-warning {
    display: none;
    height: 100%;
    width: 100%;
    background: var(--bg-dark);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 400;
    padding: 24px;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 20px;
}

#desktop-warning .dw-logo {
    width: 140px;
    height: auto;
    margin: 0 0 12px;
}

#desktop-warning p {
    max-width: 440px;
    margin: 0;
    line-height: 1.6;
}

/* ---------- Instructions screen ---------- */
#instructions-screen .title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 18px;
}

.instructions-list {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    text-align: right;
}

.instructions-list li {
    margin: 12px 0;
    font-size: 1rem;
    line-height: 1.6;
}

.instructions-list .number {
    color: var(--primary);
    font-weight: 700;
    margin-left: 4px;
}

/* ---------- Begin button ---------- */
#begin-btn {
    padding: 14px 16px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    width: 100%;
    margin-bottom: 12px;
}

/* ---------- Modal ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-dark);
    color: #fff;
    border-radius: var(--radius);
    padding: 24px 20px 32px;
    max-width: 320px;
    width: 90%;
    text-align: right;
    position: relative;
}

.modal-content h3 {
    margin: 0 0 12px;
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-content p {
    margin: 0;
    font-size: .95rem;
    line-height: 1.6;
}

.modal-close {
    position: absolute;
    top: 8px;
    left: 8px;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
}

/* keep feedback text away from the ✕ button */
#feedback-text {
    /* in RTL this pushes the text away from the left-hand (visual) edge
       where .modal-close is positioned */
    margin-left: 32px;
}

/* ---------- Quiz question ---------- */
.question-text {
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 12px;
    text-align: right;
}

.pw-item {
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 12px 14px 10px;
    margin: 0 0 14px;
}

.pw-label {
    margin: 0 0 10px;
    font-weight: 700;
    font-size: 1rem;
}

.pw-item label {
    margin-left: 12px;
    font-size: .95rem;
}

.attempts {
    font-size: .9rem;
    margin: -4px 0 12px;
    color: #ffb68f;
    text-align: center;
}

/* ---------- Fail screen tweaks ---------- */
.fail-box {
    padding: 28px 18px 26px;
    /* a bit roomier than regular pw-item */
    text-align: center;
}

.fail-label {
    font-size: 1.4rem;
    /* bigger “לא נורא!” */
}

.fail-text {
    font-size: 1.1rem;
    line-height: 1.7;
    margin: 0;
}

/* ---------- tidy radio list in Q2 ---------- */
#q2-form .pw-item label {
    direction: rtl;
    /* ← key: render children right-to-left  */
    display: flex;
    align-items: flex-start;
    /* keep bullet aligned with first line   */
    gap: 8px;
    /* space between bullet and text         */
    margin: 6px 0;
    line-height: 1.5;
}

#q2-form .pw-item input[type="radio"] {
    flex: 0 0 auto;
    /* bullet never shrinks                  */
    margin-top: 3px;
    /* nudge it down a touch                 */
}

/* ===== Q2 video toggle ===== */
#q2-video-box {
    position: relative;
    margin-bottom: 42px;
}

#q2-video-box video {
    width: 100%;
    border-radius: var(--radius);
}

/* arrow button (expanded-state position) */
#video-toggle {
    position: absolute;
    left: 50%;
    /* centre horizontally  */
    bottom: -70px;
    /* half-overlap video    */
    transform: translateX(-50%);
    width: 48px;
    height: 48px;
    font-size: 1.8rem;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .25s ease;
    z-index: 2;
    touch-action: manipulation;
}

/* keyboard focus style (only when an outline helps) */
#video-toggle:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

/* show the question ONLY after the video has been collapsed */
#q2-video-box:not(.collapsed)+p,
#q2-video-box:not(.collapsed)+p+form {
    display: none;
}

/* collapsed state */
#q2-video-box.collapsed video {
    display: none;
}

/* create a 48 px-high strip that only appears when the video is collapsed */
/* the arrow lives inside this strip, and the 24 px margin gives padding */
#q2-video-box.collapsed {
    height: 48px;
    /* = arrow size */
    margin-bottom: 0px;
    /* gap between arrow and the question */
}

/* park the arrow in the middle of that strip and flip it */
#q2-video-box.collapsed #video-toggle {
    top: -10px;
    /* sit at the top of the strip we just created */
    bottom: auto;
    transform: translateX(-50%) rotate(180deg);
}