/* Persian UI. Tahoma is the one face that ships everywhere and renders Persian
 * correctly; the Latin stack in front of it only ever sees digits and the odd
 * ASCII string, so the mix stays consistent. */

*, *::before, *::after { box-sizing: border-box; }

/* .card sets display:flex, which outranks the browser's own [hidden] rule — so
 * every section rendered at once, stacked down the page. This has to win. */
[hidden] { display: none !important; }

:root {
    --ink: #eaf1ff;
    --ink-dim: #9fb3d4;
    --line: rgba(255, 255, 255, 0.14);
    --card: rgba(10, 22, 46, 0.55);
    --blue: #2a7cf5;
    --blue-deep: #1450a8;
    --bad: #ef8080;
    --radius: 18px;
}

html, body { height: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Tahoma, sans-serif;
    color: var(--ink);
    background: #050b18;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
}

#bg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    display: block;
    /* The canvas is ~260px wide and stretched over the window; that upscale is
     * most of the softness. This filter finishes it off. */
    filter: blur(46px) saturate(1.15);
    transform: scale(1.15);
}

main {
    width: min(560px, 100% - 32px);
    margin: 0 auto;
    padding: clamp(24px, 6vh, 56px) 0 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

h1 {
    margin: 0;
    text-align: center;
    font-size: clamp(1.9rem, 7vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    /* The animated gradient behind this is busy; without the blur the text
     * sits on moving colour and gets hard to read. */
    backdrop-filter: blur(22px) saturate(1.3);
    -webkit-backdrop-filter: blur(22px) saturate(1.3);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---------------------------------------------------------------- drop zone */
.drop {
    border: 1.5px dashed rgba(255, 255, 255, 0.28);
    border-radius: 14px;
    padding: clamp(28px, 8vw, 48px) 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.drop:hover, .drop:focus-visible { border-color: rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.04); }
.drop.over { border-color: var(--blue); background: rgba(42, 124, 245, 0.14); transform: scale(1.01); }
.drop:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

.drop-icon { width: 34px; height: 34px; fill: none; stroke: var(--ink-dim); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.drop-main { margin: 4px 0 0; font-size: 1.06rem; font-weight: 600; }


/* ------------------------------------------------------------------ buttons */
.row { display: flex; gap: 10px; }

.btn {
    flex: 1;
    appearance: none;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.07);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    font-size: 0.98rem;
    padding: 13px 18px;
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--blue); border-color: transparent; }
.btn-primary:hover { background: #3d8bff; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

/* ------------------------------------------------------------------- images */
.frame {
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 58vh;
}

.frame img { max-width: 100%; max-height: 58vh; display: block; object-fit: contain; }

.frame-busy img { filter: saturate(0.5) brightness(0.72); transition: filter 0.4s; }

/* ------------------------------------------------------------------ working */
.working { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.working-text { margin: 0; font-weight: 600; }

.pulse { display: flex; gap: 7px; }
.pulse span {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--blue);
    animation: bounce 1.25s ease-in-out infinite;
}
.pulse span:nth-child(2) { animation-delay: 0.16s; }
.pulse span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
    0%, 70%, 100% { transform: translateY(0); opacity: 0.45; }
    35%           { transform: translateY(-7px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .pulse span { animation: none; opacity: 0.8; }
}

/* ----------------------------------------------------------------- messages */
.msg { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; }
.msg h2 { margin: 0; font-size: 1.2rem; font-weight: 700; }
.msg p { margin: 0; color: var(--ink-dim); line-height: 1.8; }

.msg-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; background: rgba(255, 255, 255, 0.1); }
.msg-icon.bad { background: rgba(239, 128, 128, 0.16); }

/* -------------------------------------------------------------------- pills */
.pills {
    display: flex;
    gap: 6px;
    padding: 5px;
    border-radius: 999px;
    background: rgba(10, 22, 46, 0.55);
    border: 1px solid var(--line);
    backdrop-filter: blur(22px) saturate(1.3);
    -webkit-backdrop-filter: blur(22px) saturate(1.3);
}

.pill {
    flex: 1;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--ink-dim);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 10px 8px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s, color 0.18s;
}

.pill:hover { color: var(--ink); }
.pill.is-on { background: var(--blue); color: #fff; }
.pill:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* -------------------------------------------------------------------- queue */
.queue {
    margin: 0;
    text-align: center;
    color: var(--ink-dim);
    font-size: 0.85rem;
    min-height: 1.2em;
}

/* ------------------------------------------------------------------- footer */
.foot {
    padding: 26px 16px 30px;
    text-align: center;
    color: var(--ink-dim);
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    opacity: 0.75;
}

/* ------------------------------------------------------------ close button */
.frame { position: relative; }

.x {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.15s;
}

.x:hover { background: rgba(0, 0, 0, 0.75); }
.x:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ------------------------------------------------------------ intro dialog */
.intro-back {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(3, 8, 18, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fade 0.25s ease;
}

.intro {
    width: min(460px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    color: #11203a;
    border-radius: 22px;
    padding: 26px 22px 22px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
    animation: rise 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.intro h2 { margin: 0; font-size: 1.4rem; font-weight: 800; text-align: center; }

.intro-sub {
    margin: 8px 0 20px;
    text-align: center;
    color: #5b6b86;
    font-size: 0.92rem;
}

.modes { list-style: none; margin: 0 0 22px; padding: 0; display: flex; flex-direction: column; gap: 14px; }

.modes li { display: flex; align-items: center; gap: 14px; }

.ex {
    width: 76px;
    height: 76px;
    flex: none;
    border-radius: 14px;
    background: #dbe4f2 center / cover no-repeat;
}

.ex[data-ex="screen"] { background-image: url("ex-screen.jpg"); }
.ex[data-ex="solid"]  { background-image: url("ex-solid.jpg"); }
.ex[data-ex="full"]   { background-image: url("ex-full.jpg"); }

.modes strong { display: block; font-size: 1rem; font-weight: 700; margin-bottom: 3px; }
.modes span { color: #5b6b86; font-size: 0.87rem; line-height: 1.6; }

/* The one button on a white sheet, so it keeps the page's blue rather than
 * inheriting the dark-panel button styling. */
.intro .btn-primary { width: 100%; background: var(--blue); color: #fff; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

@media (prefers-reduced-motion: reduce) {
    .intro-back, .intro { animation: none; }
}
