/* ==========================================================================
   Tunivisions ISSAT Kairouan — layout.css
   Container, sticky header, navigation, language switch, sections, grids,
   footer. Uses logical properties throughout.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Container
   -------------------------------------------------------------------------- */
.container {
    width: min(var(--max), calc(100% - 40px));
    margin-inline: auto;
}

/* --------------------------------------------------------------------------
   2. Sticky header
   -------------------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(0, 0, 0, .72);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-bottom: 1px solid transparent;
    transition: background var(--ease), border-color var(--ease), box-shadow var(--ease);
}
.site-header.is-scrolled {
    background: rgba(0, 0, 0, .93);
    border-bottom-color: var(--line);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}

.nav-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: var(--nav-h);
    transition: min-height var(--ease);
}
.site-header.is-scrolled .nav-wrap { min-height: var(--nav-h-sm); }

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-shrink: 0;
}
.brand-mark {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 16px;
    background: #000;
    display: grid;
    place-items: center;
    overflow: hidden;
    box-shadow: 0 7px 20px rgba(0, 0, 0, .4);
    transition: width var(--ease), height var(--ease), border-radius var(--ease);
}
.site-header.is-scrolled .brand-text { font-size: 17px; }
    .brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
/* The header chip wears the brand red; the footer one stays plain. */
.site-header .brand-mark {
    border: 2px solid var(--red);
    box-shadow: 0 8px 22px rgba(237, 23, 76, .32);
}

.brand-text {
    font-family: var(--font-head);
    font-weight: 900;
    font-size: 19px;
    line-height: 1.1;
    letter-spacing: -.7px;
    white-space: nowrap;
}
.brand-text span {
    display: block;
    margin-top: 3px;
    color: var(--red);
    font-family: var(--font-script);
    font-size: 13px;
    font-style: italic;
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: .3px;
    text-transform: none;
}

/* Primary navigation */
.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}
.nav-links a {
    position: relative;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    color: var(--muted-strong);
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: color var(--ease), background var(--ease);
}
.nav-links a::after {
    content: '';
    position: absolute;
    inset-block-end: 4px;
    inset-inline: 12px;
    height: 2px;
    border-radius: 2px;
    background: var(--red);
    transform: scaleX(0);
    transform-origin: inline-start center;
    transition: transform .32s var(--ease-out);
}
.nav-links a:hover { color: var(--ink); background: rgba(255, 255, 255, .05); }
.nav-links a:hover::after,
.nav-links a.active::after { transform: scaleX(1); }
.nav-links a.active { color: var(--ink); }

/* Header actions */
.nav-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Profile circle — a single button for both states */
.account-menu { position: relative; }

.account-btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--ink);
    cursor: pointer;
    transition: border-color var(--ease), background var(--ease), transform var(--ease), box-shadow var(--ease);
}
.account-btn:hover {
    border-color: var(--red);
    transform: translateY(-2px);
    box-shadow: 0 10px 26px -14px rgba(237, 23, 76, .95);
}
.account-menu.is-open .account-btn {
    border-color: var(--red);
    background: rgba(237, 23, 76, .14);
}

.account-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--ink);
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    transition: background var(--ease), color var(--ease);
}
.account-avatar .account-plus {
    width: 18px; height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
.account-avatar .account-initial { display: none; }

/* Signed in: the circle carries the member's own initial */
.account-avatar.has-user { background: linear-gradient(145deg, var(--red), #a20f36); color: #fff; }
.account-avatar.has-user .account-plus { display: none; }
.account-avatar.has-user .account-initial { display: block; }

/* A member whose account is still waiting for approval: the circle stays
   visible but turns amber, so nobody mistakes it for an active membership. */
.account-menu.is-pending .account-avatar {
    background: linear-gradient(145deg, #f7c948, #d99a06);
    color: #1a1400;
    box-shadow: 0 0 0 2px rgba(247, 201, 72, .28), 0 8px 20px rgba(217, 154, 6, .32);
    animation: pendingPulse 2.6s var(--ease) infinite;
}
.account-menu.is-pending .account-avatar.is-solid { animation: none; }
@keyframes pendingPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(247, 201, 72, .28), 0 8px 20px rgba(217, 154, 6, .32); }
    50% { box-shadow: 0 0 0 6px rgba(247, 201, 72, .12), 0 8px 22px rgba(217, 154, 6, .4); }
}

/* The small amber note inside the account popup. */
.account-pop-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 10px 6px;
    padding: 9px 11px;
    border: 1px solid rgba(247, 201, 72, .34);
    border-radius: var(--r-sm);
    background: rgba(247, 201, 72, .1);
    color: #f0cf7a;
    font-size: 11.5px;
    line-height: 1.5;
}

/* The quick account popup */
.account-pop {
    position: absolute;
    inset-block-start: calc(100% + 10px);
    inset-inline-end: 0;
    z-index: 40;
    width: min(262px, calc(100vw - 32px));
    padding: 8px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: 0 26px 54px -20px rgba(0, 0, 0, .9);
    animation: account-pop-in .18s var(--ease-out) backwards;
}
@keyframes account-pop-in {
    from { opacity: 0; transform: translateY(-6px) scale(.97); }
    to { opacity: 1; transform: none; }
}
.account-pop-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 12px;
    margin-bottom: 6px;
    border-block-end: 1px solid var(--line);
}
.account-pop-id { display: grid; gap: 2px; min-width: 0; }
.account-pop-id strong {
    font-family: var(--font-head);
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-pop-id span {
    color: var(--muted);
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: var(--r-xs);
    background: transparent;
    color: var(--muted-strong);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: start;
    cursor: pointer;
    transition: background var(--ease), color var(--ease);
}
.account-item svg {
    width: 16px; height: 16px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.account-item:hover { background: var(--surface-2); color: var(--ink); }
.account-item.is-danger:hover { background: rgba(237, 23, 76, .16); color: var(--red-soft); }

/* Language switch */
.lang-switch {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
}
.lang-switch button {
    padding: 6px 9px;
    border-radius: 8px;
    color: var(--faint);
    font-family: var(--font-head);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .4px;
    line-height: 1;
    transition: var(--ease);
}
.lang-switch button:hover { color: var(--ink); }
.lang-switch button.active { background: var(--red); color: #fff; }

/* Burger */
.menu-toggle {
    display: none;
    width: 44px; height: 44px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
}
.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    margin: 4px auto;
    border-radius: 2px;
    background: var(--ink);
    transition: transform var(--ease), opacity var(--ease);
}
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* --------------------------------------------------------------------------
   3. Sections
   -------------------------------------------------------------------------- */
.section { padding: 86px 0; }
.section-soft {
    /* Slightly translucent, so the page gradient keeps flowing through. */
    background: rgba(19, 19, 24, .58);
    border-block: 1px solid rgba(255, 255, 255, .04);
}

.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 34px;
}
.section-head h2 {
    font-size: clamp(29px, 3.8vw, 44px);
    letter-spacing: -1.6px;
    line-height: 1.12;
    margin: 12px 0 0;
}
.section-head > p { max-width: 500px; color: var(--muted); margin: 0; }

/* --------------------------------------------------------------------------
   4. Grids
   -------------------------------------------------------------------------- */
.card-grid,
.gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.gallery-grid { gap: 16px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 46px; align-items: center; }
.form-layout { display: grid; grid-template-columns: .72fr 1.28fr; gap: 28px; align-items: start; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

/* --------------------------------------------------------------------------
   5. Footer
   -------------------------------------------------------------------------- */
.site-footer {
    position: relative;
    margin-top: 44px;
    background: #000;
    border-top: 1px solid var(--line);
    overflow: hidden;
}

/* --- Closing call to action --------------------------------------------- */
.footer-cta {
    padding: 56px 0 52px;
    border-bottom: 1px solid var(--line);
    background:
        radial-gradient(ellipse at 12% 0%, rgba(237, 23, 76, .2) 0, transparent 55%),
        radial-gradient(ellipse at 92% 100%, rgba(237, 23, 76, .13) 0, transparent 50%);
}
.footer-cta-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 34px;
    flex-wrap: wrap;
}
.footer-cta-copy { max-width: 620px; }
.footer-cta-copy h2 { margin: 10px 0 12px; font-size: clamp(24px, 3vw, 34px); line-height: 1.15; letter-spacing: -1px; }
.footer-cta-copy p { color: var(--muted-strong); font-size: 14.5px; }
.footer-cta-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* --- Columns ------------------------------------------------------------ */
.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr .85fr .85fr 1.3fr;
    gap: 40px;
    padding: 54px 0 0;
}
.footer-col h4 {
    margin: 0 0 16px;
    color: var(--ink);
    font-family: var(--font-head);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
}
.footer-col h4::after {
    content: '';
    display: block;
    width: 26px;
    height: 2px;
    margin-top: 9px;
    border-radius: 2px;
    background: var(--red);
}
.footer-about p { color: var(--muted); font-size: 13px; line-height: 1.7; }

.footer-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.footer-brand .brand-mark { width: 46px; height: 46px; border-radius: 13px; }
.footer-brand strong { font-family: var(--font-head); font-size: 16px; line-height: 1.2; }
.footer-brand strong span {
    display: block;
    margin-top: 4px;
    color: var(--red);
    font-size: 10.5px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

/* Social buttons — the real logo of each app, in that app's colour */
.footer-social { display: flex; gap: 9px; margin-top: 20px; }
.social-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--brand, var(--muted-strong));
    transition: transform var(--ease), color var(--ease), border-color var(--ease), background var(--ease), box-shadow var(--ease);
}
.social-btn svg { width: 18px; height: 18px; }
.social-btn:hover {
    transform: translateY(-3px);
    border-color: var(--brand, var(--red));
    background: var(--brand, var(--red));
    color: #fff;
    box-shadow: 0 12px 24px -10px color-mix(in srgb, var(--brand, var(--red)) 85%, transparent);
}

/* Link columns */
.footer-links { display: grid; gap: 10px; }
.footer-links a {
    position: relative;
    display: inline-block;
    width: fit-content;
    color: #b9b4be;
    font-size: 13.5px;
    transition: color var(--ease), transform var(--ease);
}
.footer-links a::after {
    content: '';
    position: absolute;
    inset-block-end: -2px;
    inset-inline-start: 0;
    width: 0;
    height: 1px;
    background: var(--red);
    transition: width var(--ease);
}
.footer-links a:hover { color: var(--ink); transform: translateX(3px); }
.footer-links a:hover::after { width: 100%; }

/* Contact list */
.footer-contact { display: grid; gap: 11px; margin: 0; padding: 0; list-style: none; }
.footer-contact li { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.footer-contact a { color: var(--muted); transition: color var(--ease); }
.footer-contact a:hover { color: var(--red); }
.contact-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: var(--r-xs);
    background: var(--surface-2);
    color: var(--red);
}
.contact-icon svg { width: 15px; height: 15px; }
.footer-note { margin-top: 14px; color: var(--faint); font-size: 11.5px; line-height: 1.6; }

/* --- Bottom bar --------------------------------------------------------- */
.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 46px;
    padding: 20px 0 26px;
    border-top: 1px solid var(--line);
    color: #a7a1ac;
    font-size: 12px;
}
.footer-bottom-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.footer-lang { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase; }
.footer-lang .lang-switch { background: var(--surface); }
.to-top {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--muted-strong);
    cursor: pointer;
    transition: transform var(--ease), color var(--ease), border-color var(--ease), background var(--ease), box-shadow var(--ease);
}
.to-top svg { width: 17px; height: 17px; }
.to-top:hover {
    transform: translateY(-3px);
    border-color: var(--red);
    background: var(--red);
    color: #fff;
    box-shadow: 0 12px 24px -10px rgba(237, 23, 76, .9);
}

/* --- Oversized wordmark ------------------------------------------------- */
.footer-wordmark { padding-bottom: 4px; line-height: .78; text-align: center; pointer-events: none; user-select: none; }
.footer-wordmark span {
    display: block;
    font-family: var(--font-head);
    font-size: clamp(46px, 15.5vw, 230px);
    font-weight: 800;
    letter-spacing: -.04em;
    white-space: nowrap;
    color: transparent;
    background: linear-gradient(180deg, rgba(237, 23, 76, .3), transparent 76%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-stroke: 1px rgba(255, 255, 255, .08);
}

/* --------------------------------------------------------------------------
   6. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1120px) {
    .nav-links a { padding: 10px 9px; font-size: 12.5px; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 36px; }
    .footer-about { grid-column: 1 / -1; }
}

@media (max-width: 980px) {
    .nav-wrap { min-height: var(--nav-h-sm); gap: 12px; }
    .brand-mark { width: 46px; height: 46px; border-radius: 13px; }
    .brand-text { font-size: 16px; }
    .brand-text span { font-size: 10px; }

    .menu-toggle { display: block; }

    .nav-links {
        position: fixed;
        inset-block-start: var(--nav-h-sm);
        inset-inline: 0;
        z-index: 99;
        display: block;
        max-height: calc(100vh - var(--nav-h-sm));
        padding: 16px 20px 26px;
        background: #0b0b0b;
        border-block-end: 1px solid var(--line);
        box-shadow: 0 26px 50px rgba(0, 0, 0, .6);
        overflow-y: auto;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: opacity var(--ease), transform var(--ease), visibility var(--ease);
    }
    .nav-links.open { opacity: 1; visibility: visible; transform: none; }

    .nav-links a {
        display: block;
        padding: 14px 14px;
        border-radius: var(--r-sm);
        font-size: 15px;
        border-bottom: 1px solid rgba(255, 255, 255, .05);
    }
    .nav-links a::after { display: none; }
    .nav-links a.active { color: var(--red); background: rgba(237, 23, 76, .1); }

    .split,
    .form-layout { grid-template-columns: 1fr; }

    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }

    .section { padding: 68px 0; }

    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-grid > div:first-child { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
    .container { width: min(var(--max), calc(100% - 28px)); }

    .lang-switch button { padding: 6px 7px; font-size: 10.5px; }

    .section-head { display: block; }
    .section-head .text-link { margin-top: 14px; }

    .card-grid,
    .gallery-grid { grid-template-columns: 1fr; }

    .footer-cta { padding: 42px 0; }
    .footer-cta-inner { gap: 22px; }
    .footer-cta-actions { width: 100%; }
    .footer-cta-actions .btn { flex: 1 1 auto; }
    .footer-grid { grid-template-columns: 1fr; gap: 30px; padding-top: 40px; }
    .footer-grid > div:first-child { grid-column: auto; }
    .footer-bottom { flex-direction: column; align-items: flex-start; gap: 16px; margin-top: 34px; }
    .footer-bottom-right { width: 100%; justify-content: space-between; }

    .section { padding: 56px 0; }
}

@media (max-width: 420px) {
    .brand-text { font-size: 14px; }
    .brand-text span { font-size: 9px; }
}
