/* Emirati Traditional Games – Maritime Heritage Festival 2026.
   Colours come from the logo (deep brown) with sand and a sea teal for the festival. */

:root {
    color-scheme: light;

    --brown: #3D2214;
    --brown-soft: #6B4A36;
    --sand: #F6EFE6;
    --sand-deep: #EADCC8;
    --card: #FFFFFF;
    --field: #FBF8F4;
    --line: #E3D6C5;
    --line-strong: #B9A58E;
    --text: #2A1A10;
    --muted: #6B5A4C;
    --gold: #B8862F;
    --sea: #2F6F7E;
    --sea-soft: #E4F0F1;
    --error: #B42318;
    --error-bg: #FEF3F2;
    --success: #1F7A4D;

    --font-ar: 'Cairo', system-ui, sans-serif;
    --font-en: 'Outfit', system-ui, sans-serif;

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 22px;
    --shadow: 0 1px 2px rgba(61, 34, 20, 0.06), 0 12px 32px rgba(61, 34, 20, 0.08);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-ar);
    background: var(--sand);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

img { display: block; max-width: 100%; height: auto; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.en {
    font-family: var(--font-en);
    color: var(--muted);
    font-weight: 500;
    unicode-bidi: isolate;
}

/* An English sentence on its own line inside Arabic text: keep its punctuation at the
   end and line it up with the Arabic above it. */
.terms-intro .en, .agree-text .en, .result .en, .hint .en {
    direction: ltr;
}
.terms-intro .en, .agree-text .en { text-align: right; }

:focus-visible {
    outline: 3px solid var(--sea);
    outline-offset: 2px;
}

/* ---------- Hero ---------- */

.hero {
    position: relative;
    background:
        radial-gradient(120% 80% at 50% 0%, #FFFDF9 0%, var(--sand) 70%);
    padding: 40px 16px 32px;
    text-align: center;
}

.hero-inner {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.hero-logo {
    width: min(360px, 82vw);
    mix-blend-mode: multiply; /* drops the logo's white background onto the sand */
}

.festival {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 6px;
}

.festival-ar {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--brown);
    line-height: 1.4;
}

.festival-en {
    font-family: var(--font-en);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--sea);
}

.dates {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px 8px;
    padding: 6px 16px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--line);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--brown);
}

.dates span[dir="ltr"] {
    font-family: var(--font-en);
    font-weight: 600;
}

.dates-sep { color: var(--gold); }

/* ---------- Card ---------- */

.page {
    flex: 1;
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 16px 40px;
    position: relative;
}

.card {
    background: var(--card);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
    padding: 28px;
}

.card-head {
    padding-bottom: 20px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.card-head h1 {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--brown);
    line-height: 1.35;
}

.card-head h1 .h-en {
    font-family: var(--font-en);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--muted);
}

/* ---------- Form ---------- */

/* Clipped, not pushed off-screen: a large left offset on an RTL page adds sideways scroll. */
.hp-field {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    opacity: 0;
}

.section {
    border: 0;
    padding: 0;
    margin: 0;
    padding-top: 24px;
    min-width: 0;
}

.section + .section {
    margin-top: 8px;
    border-top: 1px dashed var(--line);
}

.section-title {
    float: left; /* lets the legend sit inside the fieldset like a normal heading */
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--brown);
}

.section-title .en { font-size: 0.92rem; margin-inline-start: 4px; }

.step {
    flex: none;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brown);
    color: #FFF;
    font-family: var(--font-en);
    font-size: 0.9rem;
    font-weight: 700;
}

.section-title + * { clear: both; }

.field + .field { margin-top: 16px; }

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: 0.98rem;
}

.field label .en { font-size: 0.88rem; margin-inline-start: 4px; }

.req { color: var(--error); font-weight: 700; }

.field input {
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--field);
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.field input::placeholder { color: #8F7F72; }

.field input:hover { border-color: var(--brown-soft); }

.field input:focus {
    outline: none;
    border-color: var(--sea);
    background: #FFF;
    box-shadow: 0 0 0 3px rgba(47, 111, 126, 0.22);
}

.field input[aria-invalid="true"] {
    border-color: var(--error);
    background: var(--error-bg);
}

.field input[dir="ltr"] { text-align: right; }
.field input[dir="ltr"]:placeholder-shown { text-align: right; }

.field-age input { max-width: 160px; }

.hint {
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}

.hint .en { font-size: 0.8rem; margin-inline-start: 4px; }

.error {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--error);
}

.error:not(:empty) { margin-top: 6px; }

/* ---------- Terms ---------- */

.terms-intro {
    font-weight: 600;
    margin-bottom: 12px;
}

.terms-intro .en { display: block; font-size: 0.88rem; }

.terms-box {
    padding: 16px 20px;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.terms {
    margin-top: 4px;
    padding-inline-start: 20px;
    display: grid;
    gap: 12px;
}

.terms li::marker { color: var(--gold); }

.terms strong { color: var(--brown); font-weight: 700; }
.terms .en strong { color: var(--muted); font-weight: 700; }

.terms p { font-size: 0.93rem; }

.terms p.en {
    margin-top: 2px;
    font-size: 0.85rem;
    line-height: 1.5;
    text-align: right;
}

.agree {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 16px;
    padding: 14px 16px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.agree:hover { border-color: var(--brown-soft); }

.agree:has(input:checked) {
    border-color: var(--sea);
    background: var(--sea-soft);
}

.agree:has(input[aria-invalid="true"]) {
    border-color: var(--error);
    background: var(--error-bg);
}

.agree input {
    flex: none;
    width: 22px;
    height: 22px;
    margin-top: 3px;
    accent-color: var(--sea);
    cursor: pointer;
}

.agree-text { font-weight: 700; }
.agree-text .en { display: block; font-size: 0.88rem; }

/* ---------- Buttons ---------- */

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 12px 24px;
    border-radius: var(--r-md);
    border: 1.5px solid transparent;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn .en { color: inherit; opacity: 0.85; margin-inline-start: 6px; }

.btn-primary {
    width: 100%;
    margin-top: 24px;
    background: var(--brown);
    color: #FFF;
}

.btn-primary:hover:not(:disabled) { background: #55301C; }
.btn-primary:disabled { cursor: progress; opacity: 0.8; }

.btn-ghost {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--brown);
}

.btn-ghost:hover { background: var(--sand); }

.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #FFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn.loading .spinner { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

.form-error {
    font-weight: 600;
    color: var(--error);
    text-align: center;
}

.form-error:not(:empty) {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--error-bg);
    border-radius: var(--r-sm);
}

/* ---------- Results ---------- */

.result {
    text-align: center;
    padding: 24px 0 8px;
    outline: none;
}

.result-icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: #E7F4EC;
    color: var(--success);
    font-size: 2.2rem;
    font-weight: 700;
    animation: pop 0.4s ease both;
}

.result-closed .result-icon { background: var(--error-bg); color: var(--error); }

@keyframes pop {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.result h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--brown);
}

.result h2 .en { display: block; font-size: 1rem; }

.result p { margin-top: 10px; color: var(--muted); }

.result-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text) !important;
}

.result-actions {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

.result-actions .btn-primary { margin-top: 0; }

.confetti {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

/* ---------- Footer ---------- */

.footer {
    padding: 8px 16px 32px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
}

.footer .en { margin-inline: 4px; }

/* ---------- Small screens ---------- */

@media (max-width: 560px) {
    .hero { padding: 28px 16px 24px; }
    .festival-ar { font-size: 1.3rem; }
    .card { padding: 20px 16px; border-radius: 18px; }
    .card-head h1 { font-size: 1.3rem; }
    .terms-box { padding: 14px 16px; }
    .field-age input { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ======================================================
   Admin
====================================================== */

.admin-body { background: var(--sand); }

.admin {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

.login {
    max-width: 420px;
    margin: 48px auto;
}

.login .hero-logo { width: 220px; margin: 0 auto 16px; }

.login h1 {
    font-size: 1.15rem;
    text-align: center;
    color: var(--brown);
    margin-bottom: 16px;
}

.login .btn-primary { margin-top: 20px; }

.admin-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 24px;
    margin-bottom: 20px;
}

.admin-head .hero-logo { width: 150px; }

.admin-head h1 { font-size: 1.25rem; color: var(--brown); line-height: 1.4; }
.admin-head p { color: var(--muted); font-size: 0.92rem; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px;
}

.stat-label { font-size: 0.88rem; color: var(--muted); font-weight: 600; }

.stat-value {
    font-family: var(--font-en);
    font-size: 2rem;
    font-weight: 700;
    color: var(--brown);
    line-height: 1.2;
}

.stat-value small { font-size: 1rem; color: var(--muted); font-weight: 500; }

.bar {
    height: 8px;
    margin-top: 10px;
    border-radius: 999px;
    background: var(--sand-deep);
    overflow: hidden;
}

.bar-fill { height: 100%; background: var(--sea); border-radius: inherit; }
.stat.warn .bar-fill { background: var(--gold); }
.stat.full .bar-fill { background: var(--error); }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.toolbar input[type="search"] {
    flex: 1 1 260px;
    min-height: 44px;
    padding: 8px 14px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--card);
}

.toolbar input[type="search"]:focus {
    outline: none;
    border-color: var(--sea);
    box-shadow: 0 0 0 3px rgba(47, 111, 126, 0.22);
}

.btn-sm {
    min-height: 44px;
    padding: 8px 16px;
    font-size: 0.92rem;
    width: auto;
    margin: 0;
}

.btn-danger {
    min-height: 36px;
    padding: 4px 12px;
    font-size: 0.85rem;
    background: transparent;
    border-color: #E4B4AE;
    color: var(--error);
}

.btn-danger:hover { background: var(--error-bg); }

.table-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }

th, td {
    padding: 10px 14px;
    text-align: start;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    background: var(--field);
    font-weight: 700;
    color: var(--brown);
    font-size: 0.85rem;
}

tbody tr:hover { background: #FDFBF8; }
tbody tr:last-child td { border-bottom: 0; }

.empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--muted);
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    border-top: 1px solid var(--line);
    font-family: var(--font-en);
}

.login-error {
    color: var(--error);
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

.login-error:not(:empty) { margin-top: 12px; }

.admin-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.88rem;
}

.admin-footer a { color: var(--sea); font-weight: 600; }
