/* Layout: the page frame, the header (with the player HUD from game.css), the footer and the phone tab bar. */

.wrap {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 16px;
}

.main { flex: 1; padding-top: 24px; padding-bottom: 40px; }
.main:focus { outline: none; }

.skip-link {
    position: absolute;
    inset-inline-start: 12px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 700;
}
.skip-link:focus { top: 12px; }

/* ---------- Header: a dark "console" bar in both themes ---------- */
.site-header {
    position: relative;
    z-index: 40;
    background: var(--console);
    color: var(--on-console);
    border-bottom: 2px solid rgba(32, 184, 166, .35);
    box-shadow: 0 8px 24px -16px rgba(0, 0, 0, .6);
}
.header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    min-height: 64px;
    padding-top: 8px;
    padding-bottom: 8px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 44px;
    min-height: 44px;
    color: var(--on-console);
    text-decoration: none;
}
.brand-mark { transition: transform .25s var(--ease-spring); }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.08); }
.brand-name { font-family: var(--font-title); font-size: 1.4rem; line-height: 1; }

.top-nav { display: none; align-items: center; gap: 4px; }
.top-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 4px 14px;
    border-radius: var(--radius-pill);
    color: var(--on-console-muted);
    font-family: var(--font-title);
    font-size: 1.05rem;
    text-decoration: none;
}
.top-nav a:hover { color: var(--on-console); background: rgba(255, 255, 255, .08); }
.top-nav a.active { color: var(--navy); background: var(--primary); }

.header-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.header-actions .btn { min-height: 44px; padding: 6px 16px; font-size: 1rem; border-radius: 14px; }
.header-actions .btn-icon { padding-inline: 10px; }
.header-action-label { display: none; }
.header-login {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 6px 12px;
    color: var(--on-console);
    font-family: var(--font-title);
    text-decoration: none;
    white-space: nowrap;
}
.header-login:hover { color: var(--amber); }
.header-login:focus-visible { outline: none; border-radius: 14px; box-shadow: var(--focus-ring); }
.header-menu { display: none; position: relative; }
.header-menu summary {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 14px;
    color: var(--on-console);
    font-family: var(--font-title);
    cursor: pointer;
    list-style: none;
}
.header-menu summary::-webkit-details-marker { display: none; }
.header-menu summary:hover { background: rgba(255, 255, 255, .08); }
.header-menu summary:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.header-menu nav {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 12px);
    width: 220px;
    padding: 8px;
    border: 1px solid rgba(32, 184, 166, .35);
    border-radius: 14px;
    background: var(--console);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.header-menu nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--on-console);
    text-decoration: none;
}
.header-menu nav a:hover { background: rgba(255, 255, 255, .08); }
/* «نزّل التطبيق»: icon and text, small on phones (the icon over a short line), a pill on wide screens. */
.header-install {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-width: 44px;
    min-height: 44px;
    padding: 2px 6px;
    border-radius: 14px;
    color: var(--amber);
    font: 700 .72rem/1.1 var(--font-title);
    text-decoration: none;
    white-space: nowrap;
}
.site-header:has(.hud) .header-install-verb { display: none; }
.header-install:hover { background: rgba(255, 255, 255, .08); }
.header-install:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* Light or dark (js/theme.js): the bell's size, the moon while light, the sun while dark (the page's theme, so no
   script is needed for the right icon). */
.header-theme-wrap { display: contents; }
.header-theme {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: none;
    color: var(--amber);
    cursor: pointer;
}
.header-theme:hover { background: rgba(255, 255, 255, .08); }
.header-theme:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.header-theme .icon { transition: transform .3s var(--ease-spring); }
.header-theme:active .icon { transform: rotate(-30deg) scale(.9); }
.header-theme-sun { display: none; }
:root[data-theme="dark"] .header-theme-moon { display: none; }
:root[data-theme="dark"] .header-theme-sun { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .header-theme-moon { display: none; }
    :root:not([data-theme="light"]) .header-theme-sun { display: block; }
}
.header-logout { margin: 0; }
.header-logout .btn[type="submit"] { width: auto; }

/* ---------- Footer ---------- */
.site-footer {
    margin-top: auto;
    padding: 24px 0 calc(24px + var(--tabbar-h) + env(safe-area-inset-bottom));
    border-top: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: var(--fs-sm);
}
.footer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.footer-brand { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.footer-name { font-family: var(--font-title); font-size: 1.15rem; color: var(--text); }
.footer-tagline { color: var(--text-muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--text-muted); }
.footer-links a:hover { color: var(--link); }
/* The company row: the legal pages, the contact lines (ContactLinks.razor) and the company line. */
.footer-legal { display: grid; gap: 4px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.footer-legal .footer-links { margin-inline: -8px; }
/* The contact list of the footer (every page) and of /contact. */
.contact-links { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0; padding: 0; list-style: none; }
.contact-links li { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.contact-links .icon { flex: none; color: var(--link); }
.footer-contact { gap: 0 20px; }
.footer-company { margin: 4px 0 0; font-size: .85rem; }

/* Channel links (SocialLinks.razor): round 44 px buttons. */
.social { --social-cut: var(--surface); display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.social a {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-muted);
    transition: transform .15s var(--ease-spring);
}
.social a:hover { transform: translateY(-2px) rotate(-6deg); border-color: var(--primary); color: var(--link); }
.social a:active { transform: scale(.92); }

/* ---------- Tab bar: phones only ---------- */
.tabbar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    justify-content: space-around;
    gap: 4px;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    background: var(--console);
    border-top: 2px solid rgba(32, 184, 166, .35);
    box-shadow: 0 -10px 30px -18px rgba(0, 0, 0, .7);
}
.tab {
    position: relative;
    flex: 1;
    max-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    border-radius: 14px;
    color: var(--on-console-muted);
    font-family: var(--font-title);
    font-size: .85rem;
    line-height: 1.1;
    text-decoration: none;
    transition: transform .15s var(--ease-out);
}
.tab:active { transform: scale(.92); }
.tab.active { color: var(--amber); }
.tab.active::before {
    content: "";
    position: absolute;
    top: -8px;
    width: 32px;
    height: 4px;
    border-radius: 0 0 4px 4px;
    background: var(--amber);
    box-shadow: 0 0 12px var(--amber);
}
.tab.active .icon { transform: translateY(-1px) scale(1.1); }

/* ---------- WhatsApp button (SupportButton.razor): the sign-up and visitor pages ----------
   Phones: a slim bar on top of the tab bar, from edge to edge, so it never sits on half a field or on the video. Wide
   screens: a pill in the left corner (the end side in RTL). Under the toasts. The footer gets the button's height as
   more padding, so the end of the page can scroll clear of it. */
.support-fab {
    position: fixed;
    inset-inline: 0;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    z-index: 55;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 6px 16px;
    background: var(--success);
    color: var(--surface);
    font-family: var(--font-title);
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
}
.support-fab:hover { background: color-mix(in srgb, var(--success) 88%, #000); }
.support-fab:focus-visible { box-shadow: var(--focus-ring); }
body:has(.support-fab) .site-footer { padding-bottom: calc(68px + var(--tabbar-h) + env(safe-area-inset-bottom)); }
body:has(.support-fab) .toast-stack { bottom: calc(var(--tabbar-h) + 60px + env(safe-area-inset-bottom)); }

/* ---------- Wider screens: nav in the header, no tab bar ---------- */
@media (min-width: 56.25em) {
    .site-header-guest .header-row { flex-wrap: nowrap; gap: 24px; }
    .site-header-guest .top-nav { flex: 1; justify-content: center; }
    .site-header-guest .top-nav a { padding-inline: 10px; white-space: nowrap; }
    .site-header-guest .header-actions { margin-inline-start: auto; gap: 12px; flex-shrink: 0; }
    .top-nav { display: flex; }
    .tabbar { display: none; }
    .site-footer { padding-bottom: 24px; }
    .header-action-label { display: inline; }
    .site-header:not(:has(.hud)) .header-install { flex-direction: row; gap: 6px; padding: 4px 14px; border: 2px solid color-mix(in srgb, var(--amber) 45%, transparent); border-radius: var(--radius-pill); font-size: 1rem; }
    .toast-stack { bottom: 24px; }
    .support-fab { inset-inline: auto 16px; bottom: 24px; min-height: 48px; padding: 8px 18px; border-radius: var(--radius-pill); box-shadow: var(--shadow-float); }
    .support-fab:focus-visible { box-shadow: var(--shadow-float), var(--focus-ring); }
    body:has(.support-fab) .site-footer { padding-bottom: 96px; }
    body:has(.support-fab) .toast-stack { bottom: 24px; }
    .main { padding-top: 32px; padding-bottom: 56px; }
}

/* A student's header on a laptop: the brand, the nav, the HUD and the actions need about 1240 px, more than the page's
   1080, so the header is wider than the page. Below 1200 px the nav goes to the tab bar and the row keeps the HUD;
   below 1360 px the brand keeps only its logo. One row at every width. */
@media (min-width: 56.25em) {
    .site-header:has(.hud) .wrap { max-width: 1320px; }
}
@media (min-width: 56.25em) and (max-width: 74.9375em) {
    .site-header:has(.hud) .top-nav { display: none; }
    body:has(.site-header .hud) .tabbar { display: flex; }
    body:has(.site-header .hud) .site-footer { padding-bottom: calc(var(--tabbar-h) + 24px); }
    body:has(.site-header .hud) .toast-stack { bottom: calc(var(--tabbar-h) + 16px); }
    body:has(.site-header .hud) .support-fab { bottom: calc(var(--tabbar-h) + 16px); }
    body:has(.site-header .hud):has(.support-fab) .site-footer { padding-bottom: calc(var(--tabbar-h) + 88px); }
}
@media (min-width: 56.25em) and (max-width: 84.9375em) {
    .site-header:has(.hud) .brand-name { display: none; }
}

/* A visitor's header with «المساعد»: the brand, the four links and the actions need about 1130 px, more than the page's
   1080. From 1200 px the header is a little wider than the page (as the student header). From 900 to 1199 px the brand
   keeps only its logo and the gaps get smaller; below 1000 px the nav links too. One row at every width. */
@media (min-width: 75em) {
    .site-header-guest .wrap { max-width: 1180px; }
}
@media (min-width: 56.25em) and (max-width: 74.9375em) {
    .site-header-guest .header-row { gap: 12px; }
    .site-header-guest .brand-name { display: none; }
    .site-header-guest .top-nav a { padding-inline: 8px; }
    .site-header-guest .header-actions { gap: 8px; }
    .site-header-guest .header-login { padding-inline: 8px; }
}
@media (min-width: 56.25em) and (max-width: 62.4375em) {
    .site-header-guest .header-row { gap: 8px; }
    .site-header-guest .top-nav { gap: 0; }
    .site-header-guest .top-nav a { padding-inline: 6px; font-size: .95rem; }
}

@media (max-width: 56.1875em) {
    .site-header-guest .header-row { flex-wrap: nowrap; gap: 8px; }
    .site-header-guest .header-actions { gap: 8px; }
    .site-header-guest .header-actions > .header-install,
    .site-header-guest .header-login { display: none; }
    .header-menu { display: block; }
    .site-header-guest .brand-name { font-size: 1.2rem; }
    .site-header-guest .header-actions .btn { padding-inline: 12px; white-space: nowrap; }
}

/* Phones with the player HUD: one header row, the logo without the name, and «التطبيق» under its icon. */
@media (max-width: 43.6875em) {
    .site-header:has(.hud) .brand-name { display: none; }
    .site-header:has(.hud) .header-row { flex-wrap: nowrap; gap: 8px; }
}

/* Very small phones: keep the brand short. */
@media (max-width: 23.75em) {
    .site-header-guest .brand { gap: 6px; }
    .site-header-guest .brand-name { font-size: 1rem; }
    .site-header-guest .header-actions { gap: 4px; }
    .site-header-guest .header-actions .btn { padding-inline: 8px; }
    .brand-name { font-size: 1.2rem; }
    .header-actions .btn { padding-inline: 12px; }
}
@media (max-width: 21.25em) {
    .site-header-guest .brand-name { display: none; }
}
