/* =====================================================================
   People Wall - design system
   Single source of truth for colour, type, spacing, radius and motion.
   Everything else (admin.css, join.css, display.css) builds on these tokens.
   ===================================================================== */

/* ---------------------------------------------------------------------
   Self-hosted faces
   Served from our own origin because the page CSP is `font-src 'self'`,
   which will not load a font from a CDN. Both are SIL Open Font License.
   The board picks one by key; Support\Fonts owns what a key resolves to.
   --------------------------------------------------------------------- */

@font-face {
    font-family: 'Tajawal';
    src: url('../fonts/tajawal-400.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Tajawal';
    src: url('../fonts/tajawal-500.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'Tajawal';
    src: url('../fonts/tajawal-700.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: 'Tajawal';
    src: url('../fonts/tajawal-800.woff2') format('woff2');
    font-weight: 800;
    font-display: swap;
}

/* Cairo is a variable font: one file covers 400–800, so every weight in that
   range is a real design rather than a synthesised bold. Split by script so a
   Latin-only wall does not download the Arabic glyphs and vice versa. */
@font-face {
    font-family: 'Cairo';
    src: url('../fonts/cairo-arabic.woff2') format('woff2');
    font-weight: 400 800;
    font-display: swap;
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
    font-family: 'Cairo';
    src: url('../fonts/cairo-latin.woff2') format('woff2');
    font-weight: 400 800;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

:root {
    /* ---- brand palette ---------------------------------------------- */
    --color-forest:        #0F4C3F;
    --color-forest-deep:   #0A3A30;
    --color-forest-dark:   #072620;
    --color-emerald:       #21A558;
    --color-emerald-soft:  #4FB286;
    --color-gold:          #D4A057;
    --color-gold-soft:     #E3BE86;
    --color-cream:         #EFE2D8;
    --color-cream-dim:     #DCCEC2;
    --color-ink:           #1F2A33;

    /* ---- semantic surfaces ------------------------------------------ */
    --color-primary:       var(--color-emerald);
    --color-secondary:     var(--color-gold);
    --color-background:    #F6F2ED;
    --color-surface:       #FFFFFF;
    --color-surface-alt:   #FBF8F4;
    --color-surface-sunk:  #F1ECE5;
    --color-border:        #E4DCD2;
    --color-border-strong: #CFC3B6;

    --color-text:          #22282C;
    --color-text-muted:    #6C7078;
    --color-text-faint:    #9AA0A6;
    --color-text-invert:   #FFFFFF;

    --color-success:       #1E9E5A;
    --color-success-bg:    #E4F5EB;
    --color-warning:       #B8791C;
    --color-warning-bg:    #FBF0DC;
    --color-danger:        #C0392B;
    --color-danger-bg:     #FBE9E7;
    --color-info:          #2E7FA5;
    --color-info-bg:       #E5F1F7;

    /* ---- radius ------------------------------------------------------ */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-pill: 999px;

    /* ---- shadow ------------------------------------------------------ */
    --shadow-xs: 0 1px 2px rgba(16, 32, 28, .06);
    --shadow-sm: 0 2px 8px rgba(16, 32, 28, .08);
    --shadow-md: 0 8px 24px rgba(16, 32, 28, .10);
    --shadow-lg: 0 18px 48px rgba(16, 32, 28, .14);
    --shadow-glow: 0 0 0 4px rgba(33, 165, 88, .16);

    /* ---- spacing scale ----------------------------------------------- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;

    /* ---- type -------------------------------------------------------- */
    --font-sans: "Segoe UI", "Tahoma", "Noto Sans Arabic", "Dubai", system-ui, -apple-system, sans-serif;
    --font-mono: "Cascadia Mono", "Consolas", "Courier New", monospace;

    --text-xs:   0.75rem;
    --text-sm:   0.8125rem;
    --text-base: 0.9375rem;
    --text-md:   1.0625rem;
    --text-lg:   1.25rem;
    --text-xl:   1.5rem;
    --text-2xl:  2rem;
    --text-3xl:  2.75rem;

    --leading-tight: 1.25;
    --leading-normal: 1.6;

    /* ---- motion ------------------------------------------------------ */
    --ease-out: cubic-bezier(.22, .8, .3, 1);
    --ease-in-out: cubic-bezier(.5, 0, .3, 1);
    --duration-fast: 140ms;
    --duration-base: 240ms;
    --duration-slow: 480ms;

    --header-height: 64px;
    --sidebar-width: 264px;
}

/* =====================================================================
   Reset
   ===================================================================== */

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

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

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 700;
    line-height: var(--leading-tight);
    color: var(--color-text);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p  { margin: 0 0 var(--space-3); }

a {
    color: var(--color-forest);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
}

a:hover { color: var(--color-emerald); }

img, svg, video, canvas {
    display: block;
    max-width: 100%;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

ul, ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

hr {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: var(--space-5) 0;
}

/* Focus is never removed, only restyled. */
:focus-visible {
    outline: 3px solid var(--color-emerald);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

::selection {
    background: rgba(33, 165, 88, .22);
}

/* =====================================================================
   Utilities
   ===================================================================== */

.u-hidden { display: none !important; }

.u-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.u-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.u-muted  { color: var(--color-text-muted); }
.u-faint  { color: var(--color-text-faint); }
.u-mono   { font-family: var(--font-mono); font-size: var(--text-sm); }
.u-center { text-align: center; }
.u-nowrap { white-space: nowrap; }

.u-stack       { display: flex; flex-direction: column; gap: var(--space-4); }
.u-stack-sm    { display: flex; flex-direction: column; gap: var(--space-2); }
.u-row         { display: flex; align-items: center; gap: var(--space-3); }
.u-row-tight   { display: flex; align-items: center; gap: var(--space-2); }
.u-row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.u-wrap        { flex-wrap: wrap; }
.u-grow        { flex: 1 1 auto; min-width: 0; }

.u-mt-0 { margin-top: 0; }
.u-mb-0 { margin-bottom: 0; }
.u-mt-4 { margin-top: var(--space-4); }
.u-mt-5 { margin-top: var(--space-5); }
.u-mb-4 { margin-bottom: var(--space-4); }
.u-mb-5 { margin-bottom: var(--space-5); }

/* =====================================================================
   Buttons
   ===================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 18px;
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
}

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

.btn:disabled,
.btn[aria-busy="true"] {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn--primary {
    background: var(--color-forest);
    border-color: var(--color-forest);
    color: var(--color-text-invert);
}

.btn--primary:hover {
    background: var(--color-forest-deep);
    border-color: var(--color-forest-deep);
    color: var(--color-text-invert);
}

.btn--accent {
    background: var(--color-emerald);
    border-color: var(--color-emerald);
    color: #06251C;
}

.btn--accent:hover { background: var(--color-emerald-soft); border-color: var(--color-emerald-soft); }

.btn--gold {
    background: var(--color-gold);
    border-color: var(--color-gold);
    color: #3A2708;
}

.btn--gold:hover { background: var(--color-gold-soft); border-color: var(--color-gold-soft); }

.btn--outline {
    background: transparent;
    border-color: var(--color-border-strong);
    color: var(--color-text);
}

.btn--outline:hover {
    border-color: var(--color-forest);
    color: var(--color-forest);
    background: rgba(15, 76, 63, .05);
}

.btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-text-muted);
}

.btn--ghost:hover { background: var(--color-surface-sunk); color: var(--color-text); }

.btn--danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}

.btn--danger:hover { filter: brightness(1.08); color: #fff; }

.btn--danger-outline {
    background: transparent;
    border-color: rgba(192, 57, 43, .4);
    color: var(--color-danger);
}

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

.btn--sm { min-height: 34px; padding: 6px 12px; font-size: var(--text-sm); }
.btn--lg { min-height: 54px; padding: 14px 28px; font-size: var(--text-md); border-radius: var(--radius-md); }
.btn--block { width: 100%; }
.btn--icon { padding: 8px; min-height: 36px; min-width: 36px; }

/* =====================================================================
   Forms
   ===================================================================== */

.field { display: flex; flex-direction: column; gap: 6px; }

.field__label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
}

.field__hint {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.field__error {
    font-size: var(--text-xs);
    color: var(--color-danger);
    font-weight: 600;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 10px 12px;
    min-height: 42px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
}

.textarea { min-height: 96px; resize: vertical; line-height: var(--leading-normal); }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--color-text-faint); }

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--color-emerald);
    box-shadow: var(--shadow-glow);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
    border-color: var(--color-danger);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
    background: var(--color-surface-sunk);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%),
                      linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
    background-position: left 14px top 50%, left 9px top 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-inline-start: 32px;
}

.input--color {
    padding: 4px;
    width: 52px;
    min-height: 42px;
    cursor: pointer;
}

.checkbox,
.radio {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-base);
}

.checkbox input,
.radio input {
    width: 18px;
    height: 18px;
    accent-color: var(--color-emerald);
    cursor: pointer;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch__track {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: var(--radius-pill);
    background: var(--color-border-strong);
    transition: background var(--duration-base) var(--ease-out);
    flex: none;
}

.switch__track::after {
    content: "";
    position: absolute;
    inset-inline-start: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-xs);
    transition: transform var(--duration-base) var(--ease-out);
}

.switch input:checked + .switch__track { background: var(--color-emerald); }

[dir="rtl"] .switch input:checked + .switch__track::after { transform: translateX(-20px); }
[dir="ltr"] .switch input:checked + .switch__track::after { transform: translateX(20px); }

.switch input:focus-visible + .switch__track { box-shadow: var(--shadow-glow); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
}

.form-grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* =====================================================================
   Cards, panels, tables
   ===================================================================== */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
}

.card__title { font-size: var(--text-md); font-weight: 700; margin: 0; }
.card__body  { padding: var(--space-5); }
.card__footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-alt);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-base);
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: start;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.table th {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-text-muted);
    background: var(--color-surface-alt);
    white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-surface-alt); }

/* =====================================================================
   Badges & pills
   ===================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 1.6;
    white-space: nowrap;
}

.badge--neutral { background: var(--color-surface-sunk); color: var(--color-text-muted); }
.badge--success { background: var(--color-success-bg); color: var(--color-success); }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge--info    { background: var(--color-info-bg);    color: var(--color-info); }

.badge__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.dot-live {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success);
    box-shadow: 0 0 0 0 rgba(30, 158, 90, .6);
    animation: pulse-ring 2s var(--ease-out) infinite;
}

@keyframes pulse-ring {
    70%  { box-shadow: 0 0 0 8px rgba(30, 158, 90, 0); }
    100% { box-shadow: 0 0 0 0 rgba(30, 158, 90, 0); }
}

/* =====================================================================
   Alerts / flash
   ===================================================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: var(--text-base);
}

.alert--success { background: var(--color-success-bg); border-color: rgba(30, 158, 90, .25);  color: #14603a; }
.alert--error   { background: var(--color-danger-bg);  border-color: rgba(192, 57, 43, .25);  color: #8c2419; }
.alert--warning { background: var(--color-warning-bg); border-color: rgba(184, 121, 28, .25); color: #7a5111; }
.alert--info    { background: var(--color-info-bg);    border-color: rgba(46, 127, 165, .25); color: #1d566f; }

/* =====================================================================
   Toasts (JS-driven)
   ===================================================================== */

.toast-stack {
    position: fixed;
    inset-block-end: var(--space-5);
    inset-inline-start: var(--space-5);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-ink);
    color: #fff;
    box-shadow: var(--shadow-lg);
    font-size: var(--text-base);
    animation: toast-in var(--duration-base) var(--ease-out);
}

.toast--success { background: #15653C; }
.toast--error   { background: #8C2419; }
.toast--warning { background: #7A5111; }

.toast.is-leaving { animation: toast-out var(--duration-base) var(--ease-out) forwards; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(8px) scale(.98); }
}

/* =====================================================================
   Modal
   ===================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(12, 24, 20, .58);
    backdrop-filter: blur(3px);
    animation: fade-in var(--duration-fast) var(--ease-out);
}

.modal {
    width: min(560px, 100%);
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-in var(--duration-base) var(--ease-out);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

/* =====================================================================
   Progress / spinner
   ===================================================================== */

.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex: none;
}

.spinner--lg { width: 40px; height: 40px; border-width: 3.5px; }

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

.progress-track {
    height: 6px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-sunk);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: inherit;
    background: var(--color-emerald);
    transition: width var(--duration-base) var(--ease-out);
}

/* =====================================================================
   Empty state
   ===================================================================== */

.empty {
    padding: var(--space-8) var(--space-5);
    text-align: center;
    color: var(--color-text-muted);
}

.empty__title {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-2);
}

/* =====================================================================
   Reduced motion
   ===================================================================== */

/*
 * Honour the viewer's motion preference everywhere a person is actually
 * browsing: the join flow on their own phone, and the admin.
 *
 * `html.display` — the big-screen wall — is deliberately exempt. It is signage
 * on a dedicated screen with no reader to make dizzy, and its motion is
 * configured per event (`floating_animation_enabled`, `bubble_pulse_enabled`).
 * Media players and Windows Server images very commonly report "reduce" by
 * default, and this blanket !important rule silently flattened every
 * animation an event had switched on, including the arrival and hand-over
 * transitions. The wall's own opt-out lives in display.css, keyed on
 * `.wall[data-motion="system"]`.
 */
@media (prefers-reduced-motion: reduce) {
    html:not(.display) *,
    html:not(.display) *::before,
    html:not(.display) *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
