/* Autoriix video tutorials (/tutorials, /fr/tutorials). Loaded after landing.css
   and uses its tokens. The page is light; only the watching area is a dark band
   with a fading grid, like the intro video on the landing page. Logical
   properties throughout for the Darija (RTL) page. */

/* The current page in the header, mobile menu and footer. */
.nav a[aria-current="page"] { color: var(--text); background: var(--border-soft); }
.sheet-nav a[aria-current="page"], .ftr ul a[aria-current="page"] { color: var(--red); }

.tut { position: relative; isolation: isolate; padding-top: clamp(20px, 3vw, 36px); }
.tut-bg {
    position: absolute; inset: 0 0 auto; height: 360px; z-index: -1; pointer-events: none;
    background:
        radial-gradient(560px 300px at 88% 0%, rgba(220, 38, 38, 0.08), transparent 70%),
        linear-gradient(to right, rgba(9, 9, 11, 0.04) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(to bottom, rgba(9, 9, 11, 0.04) 1px, transparent 1px) 0 0 / 44px 44px;
    -webkit-mask-image: linear-gradient(to bottom, #000 20%, transparent);
            mask-image: linear-gradient(to bottom, #000 20%, transparent);
}
[dir="rtl"] .tut-bg { transform: scaleX(-1); }

/* ---------- Page head (light) ---------- */
.tut-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 14px 32px; margin-bottom: clamp(20px, 2.6vw, 32px);
}
.tut-head-copy { display: grid; gap: 8px; max-width: 880px; justify-items: start; }
.tut-h1 { font-size: clamp(1.65rem, 1.15rem + 1.9vw, 2.45rem); letter-spacing: -0.03em; }
html[lang^="ar"] .tut-h1 { letter-spacing: 0; }
.tut-sub { color: var(--text-2); font-size: clamp(1rem, 0.96rem + 0.2vw, 1.075rem); }
.tut-note { color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.tut-count {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px;
    border: 1px solid var(--border); border-radius: 999px; background: #fff; box-shadow: var(--shadow-sm);
    color: var(--text-2); font-weight: 700; font-size: 0.875rem; white-space: nowrap;
}
.tut-count .ic { color: var(--red); }
.tut-count-sep { width: 1px; height: 14px; background: var(--border-2); margin-inline: 4px; }

/* ---------- Watching area: dark band, grid fading out at the edges ---------- */
.tut-theater {
    --d-bg: #09090b;
    --d-card: rgba(255, 255, 255, 0.035);
    --d-line: rgba(255, 255, 255, 0.09);
    --d-line-2: rgba(255, 255, 255, 0.16);
    --d-text: #fafafa;
    --d-text-2: #a1a1aa;
    --d-muted: #71717a;
    --d-red: #f87171;
    position: relative; isolation: isolate; overflow: hidden;
    padding-block: clamp(20px, 3vw, 40px) clamp(40px, 5vw, 72px);
    background: var(--d-bg); color: var(--d-text);
    color-scheme: dark; /* native video controls and scrollbars in their dark variant */
}
.tut-theater::before {
    content: ""; position: absolute; inset: 0; z-index: -2; pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 44px 44px; background-position: center top;
    -webkit-mask-image: radial-gradient(ellipse 80% 75% at 50% 40%, #000 10%, rgba(0, 0, 0, 0.35) 50%, transparent 85%);
            mask-image: radial-gradient(ellipse 80% 75% at 50% 40%, #000 10%, rgba(0, 0, 0, 0.35) 50%, transparent 85%);
}
.tut-theater::after { /* soft light from the top so the band does not look flat */
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: radial-gradient(60% 45% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 70%);
}
.tut-theater :focus-visible { outline-color: var(--d-red); }

/* ---------- Layout: player first in the markup, chapter list beside it on desktop ---------- */
.tut-lms { display: grid; gap: 20px; grid-template-areas: "main" "list"; }
.tut-main { grid-area: main; min-width: 0; container-type: inline-size; }
.tut-list { grid-area: list; min-width: 0; }

@media (min-width: 1024px) {
    /* The list takes the player's height (its own content does not size the row) and scrolls inside. */
    .tut-lms { grid-template-columns: 300px minmax(0, 1fr); grid-template-areas: "list main"; align-items: stretch; gap: 24px; }
    .tut-list { contain: size; display: flex; flex-direction: column; min-height: 420px; }
    .tut-scroll {
        flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
        scrollbar-width: thin; scrollbar-color: var(--d-line-2) transparent;
    }
}

/* ---------- Player card ---------- */
.tut-player {
    --stage-h: min(64svh, 560px);
    --stage-pad: 16px;
    display: grid; overflow: hidden; height: 100%;
    background: var(--d-card); border: 1px solid var(--d-line); border-radius: var(--r-xl);
    box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9), 0 0 0 6px rgba(255, 255, 255, 0.02);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
@media (min-width: 640px) { .tut-player { --stage-h: min(66svh, 580px); --stage-pad: 20px; } }
@media (min-width: 1024px) { .tut-player { --stage-h: clamp(440px, calc(100svh - var(--hdr-h) - 300px), 600px); } }

/* Every video gets the width of a 9:16 one at full stage height, so the columns never
   move when switching; the 4:5 ones are just shorter. A red glow sits behind the video. */
.tut-stage {
    position: relative; isolation: isolate;
    display: grid; place-items: center; padding: var(--stage-pad);
    border-bottom: 1px solid var(--d-line);
}
.tut-stage::before {
    content: ""; position: absolute; inset: 6% -10%; z-index: -1; pointer-events: none;
    background: radial-gradient(closest-side, rgba(220, 38, 38, 0.28), rgba(220, 38, 38, 0) 75%);
}
.tut-frame {
    --ar: 9 / 16;
    position: relative; width: min(100%, calc(var(--stage-h) * 9 / 16)); aspect-ratio: var(--ar);
    border-radius: 18px; overflow: hidden; background: #18181b;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.9), 0 0 0 6px rgba(255, 255, 255, 0.03);
    transition: opacity 0.35s var(--ease), transform 0.5s var(--ease);
}
.tut-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #18181b; }
html:not(.js) #tut-video { display: none; } /* the <noscript> copy plays instead */
.tut-player.is-switching .tut-frame { opacity: 0.35; transform: scale(0.985); }

.tut-info { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 20px; }
.tut-info.is-swap > :not(.tut-help) { animation: tut-swap 0.5s var(--ease) backwards; }
.tut-info.is-swap > :nth-child(2) { animation-delay: 40ms; }
.tut-info.is-swap > :nth-child(3) { animation-delay: 80ms; }
@keyframes tut-swap { from { opacity: 0; transform: translate3d(0, 8px, 0); } to { opacity: 1; transform: none; } }

.tut-label {
    display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px;
    background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.22);
    color: var(--d-red); font-weight: 700; font-size: 0.82rem;
}
.tut-title { font-size: clamp(1.3rem, 1.12rem + 0.7vw, 1.6rem); color: var(--d-text); }
.tut-text { color: var(--d-text-2); font-size: 1rem; max-width: 34em; }
.tut-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; color: var(--d-muted); font-size: 0.875rem; font-weight: 600; }
.tut-meta-time { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }

.tut-nav { display: flex; gap: 10px; width: 100%; margin-top: 6px; }
.tut-nav .btn { flex: 1; height: 44px; padding: 0 14px; }
.tut-theater .btn-ghost { background: rgba(255, 255, 255, 0.04); color: var(--d-text); border-color: var(--d-line-2); box-shadow: none; }
.tut-theater .btn-ghost:hover { border-color: rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.07); }
.tut-nav .ic-back { transform: scaleX(-1); }
[dir="rtl"] .tut-nav .ic-back { transform: none; }
.btn-ghost .ic-back { transition: transform 0.25s var(--ease); }
.tut-prev:hover .ic-back { transform: scaleX(-1) translateX(3px); }
[dir="rtl"] .tut-prev:hover .ic-back { transform: translateX(3px); }
.tut-nav .btn[aria-disabled="true"] { opacity: 0.4; pointer-events: none; box-shadow: none; }

/* Next video, only beside the player (the chapter list is right below it on phones). */
.tut-upnext {
    display: none; align-items: center; gap: 12px; width: 100%; margin-top: 10px; padding: 10px;
    border: 1px solid var(--d-line); border-radius: var(--r-md); background: rgba(255, 255, 255, 0.03);
    transition: border-color 0.2s, background-color 0.2s, transform 0.25s var(--ease);
}
.tut-upnext img { width: 46px; height: 64px; flex-shrink: 0; border-radius: 8px; object-fit: cover; object-position: top; background: #18181b; border: 1px solid var(--d-line); }
.tut-upnext-body { display: grid; gap: 1px; min-width: 0; flex: 1; }
.tut-upnext-k { color: var(--d-red); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
html[lang^="ar"] .tut-upnext-k { letter-spacing: 0; text-transform: none; font-size: 0.85rem; }
.tut-upnext-title { font-weight: 700; font-size: 0.95rem; line-height: 1.35; color: var(--d-text); }
.tut-upnext-sub { color: var(--d-muted); font-size: 0.8rem; line-height: 1.4; }
.tut-upnext-go {
    width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
    background: rgba(248, 113, 113, 0.14); color: var(--d-red); transition: background-color 0.2s, color 0.2s;
}
.tut-upnext-go .ic { margin-inline-start: 2px; }
[dir="rtl"] .tut-upnext-go .ic { margin-inline-start: 0; margin-inline-end: 2px; }
.tut-upnext:hover { border-color: var(--d-line-2); background: rgba(255, 255, 255, 0.06); transform: translateY(-1px); }
.tut-upnext:hover .tut-upnext-go { background: var(--red); color: #fff; }
.tut-upnext[hidden] { display: none !important; }

.tut-help {
    display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 8px; padding: 12px 14px;
    border: 1px solid var(--d-line); border-radius: var(--r-md); background: rgba(255, 255, 255, 0.03);
    font-size: 0.875rem; line-height: 1.45; transition: border-color 0.2s, background-color 0.2s;
}
.tut-help strong { display: block; font-weight: 700; color: var(--d-text); }
.tut-help span span { color: var(--d-text-2); }
.tut-help:hover { border-color: rgba(37, 211, 102, 0.55); background: rgba(37, 211, 102, 0.06); }
.tut-help-ic {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
    background: rgba(37, 211, 102, 0.12); color: #4ade80; font-size: 1.15rem;
}

/* Side by side once the player column is wide enough (tablet and large desktop). */
@container (min-width: 700px) {
    .tut-player { grid-template-columns: auto minmax(0, 1fr); }
    .tut-stage { width: calc(var(--stage-h) * 9 / 16 + var(--stage-pad) * 2); border-bottom: 0; border-inline-end: 1px solid var(--d-line); }
    .tut-info { padding: 26px 24px 22px; }
    .tut-upnext { display: flex; }
    .tut-help { margin-top: auto; }
}

/* ---------- Chapter list ---------- */
.tut-list {
    background: var(--d-card); border: 1px solid var(--d-line); border-radius: var(--r-xl); overflow: hidden;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.tut-list-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0;
    padding: 14px 18px; border-bottom: 1px solid var(--d-line); font-weight: 800; color: var(--d-text);
}
.tut-list-count { color: var(--d-muted); font-weight: 600; font-size: 0.85rem; }
.tut-scroll { position: relative; padding: 6px 8px 10px; }
@media (min-width: 640px) and (max-width: 1023.98px) {
    .tut-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; align-items: start; }
}

.tut-group-title {
    display: flex; align-items: center; gap: 8px; padding: 12px 10px 6px;
    color: var(--d-muted); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}
html[lang^="ar"] .tut-group-title { letter-spacing: 0; text-transform: none; font-size: 0.875rem; }
.tut-group-num { color: var(--d-red); font-family: 'Plus Jakarta Sans', var(--font); font-variant-numeric: tabular-nums; }

.tut-item {
    position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-md);
    transition: background-color 0.2s;
}
.tut-item::before {
    content: ""; position: absolute; inset-inline-start: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px;
    background: var(--red); transform: scaleY(0); transition: transform 0.35s var(--ease);
}
.tut-item:hover { background: rgba(255, 255, 255, 0.05); }
.tut-item[aria-current="true"] { background: rgba(220, 38, 38, 0.16); }
.tut-item[aria-current="true"]::before { transform: none; }
.tut-item:focus-visible { outline-offset: -2px; border-radius: var(--r-md); }

.tut-item-ic {
    position: relative; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%;
    display: grid; place-items: center; background: transparent; border: 1.5px solid var(--d-line-2);
    color: var(--d-text-2); font-size: 0.8rem; font-weight: 800; font-family: 'Plus Jakarta Sans', var(--font);
    transition: background-color 0.25s, border-color 0.25s, color 0.25s;
}
.tut-item-ic > * { grid-area: 1 / 1; }
.tut-item-done, .tut-eq { display: none; }
.tut-item.is-watched .tut-item-ic { border-color: rgba(52, 211, 153, 0.5); background: rgba(52, 211, 153, 0.12); color: #34d399; }
.tut-item.is-watched .tut-item-n { display: none; }
.tut-item.is-watched .tut-item-done { display: block; font-size: 1rem; }
.tut-item[aria-current="true"] .tut-item-ic { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 6px 16px -6px rgba(220, 38, 38, 0.8); }

/* "Now playing" bars on the current item while the video plays. */
.tut-eq { align-items: flex-end; gap: 2px; height: 12px; }
.tut-eq i { width: 3px; height: 100%; border-radius: 1px; background: currentColor; transform-origin: bottom; animation: tut-eq 0.9s ease-in-out infinite; }
.tut-eq i:nth-child(2) { animation-delay: -0.3s; }
.tut-eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes tut-eq { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }
.tut-lms.is-playing .tut-item[aria-current="true"] .tut-eq { display: flex; }
.tut-lms.is-playing .tut-item[aria-current="true"] .tut-item-n,
.tut-lms.is-playing .tut-item[aria-current="true"] .tut-item-done { display: none; }

.tut-item-body { display: grid; gap: 1px; min-width: 0; }
.tut-item-title { font-weight: 700; font-size: 0.925rem; line-height: 1.35; color: #e4e4e7; }
.tut-item[aria-current="true"] .tut-item-title { color: #fff; }
.tut-item-sub { display: flex; flex-wrap: wrap; gap: 0 8px; color: var(--d-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.tut-item[aria-current="true"] .tut-item-sub { color: #fca5a5; }
.tut-item-sub > * + *::before { content: "·"; margin-inline-end: 8px; }
.tut-item-seen { display: none; color: #34d399; font-weight: 600; }
.tut-item.is-watched .tut-item-seen { display: inline; }

/* Phones: the player and its controls fit on the first screen. The floating WhatsApp
   button would sit on the controls; the help card under the video replaces it. */
@media (max-width: 639.98px) {
    .tut-count { display: none; }
    .tut-h1 { font-size: 1.55rem; }
    .tut-sub { font-size: 0.95rem; }
    .tut-head { margin-bottom: 16px; }
    .tut-theater { padding-top: 16px; }
    .wa-float { display: none; }
}
@media (max-width: 380px) {
    .tut-info { padding: 16px; }
    .tut-nav .btn { padding: 0 10px; font-size: 0.875rem; }
}

@media (prefers-reduced-motion: reduce) {
    .tut-eq i { animation: none; transform: scaleY(0.7); }
    .tut-player.is-switching .tut-frame { transform: none; }
}
