/*
 * Academy theme. Plain CSS, loaded after the built-in stylesheet.
 *
 * Idea: a study notebook. Cool paper, deep ink, a cobalt pen for actions and a highlighter
 * swipe behind the page titles (the one loud element). Course cards without an image show
 * ruled notebook paper.
 *
 * The built-in site is dark and its views use Tailwind utilities that read CSS variables, so the
 * neutral scale, white, surface, raised and line are remapped here to a light scheme: the views
 * this theme does not replace (home blocks, blog, search) follow along. These tokens are set
 * after Site settings' design tags, so the theme's palette wins over colours chosen there.
 *
 * Direction-safe throughout: only logical properties (margin-inline, padding-inline,
 * inset-inline, border-inline, text-align: start/end), so Arabic mirrors without overrides.
 */

:root {
    color-scheme: light;

    /* Theme palette */
    --ac-ink: #14213d;
    --ac-ink-soft: #3b4763;
    --ac-muted: #4a5670;
    --ac-paper: #f6f7fb;
    --ac-sheet: #ffffff;
    --ac-rule: #d9deea;
    --ac-cobalt: #2448c8;
    --ac-cobalt-deep: #1b3799;
    --ac-marker: #ffd84d;
    --ac-radius: 0.875rem;
    --ac-radius-sm: 0.5rem;
    --ac-shadow: 0 10px 30px -12px rgb(20 33 61 / 0.18);

    /* Type */
    --ac-serif: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif;
    --ac-sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --ac-arabic: 'Cairo', 'Segoe UI', Tahoma, 'Noto Naskh Arabic', 'Noto Sans Arabic', system-ui, sans-serif;

    /* Built-in tokens, remapped to the light scheme */
    --color-brand: var(--ac-cobalt);
    --color-brand-soft: var(--ac-cobalt-deep);
    --color-on-brand: #ffffff;
    --color-surface: var(--ac-paper);
    --color-raised: var(--ac-sheet);
    --color-line: var(--ac-rule);
    --color-white: var(--ac-ink);
    --color-neutral-50: #0e1729;
    --color-neutral-100: var(--ac-ink);
    --color-neutral-200: #26324d;
    --color-neutral-300: var(--ac-ink-soft);
    --color-neutral-400: var(--ac-muted);
    --color-neutral-500: #566078;
    --color-neutral-600: #8a93a8;
    --color-neutral-700: #c3cad8;
    --color-neutral-800: #dde2ec;
    --color-neutral-900: #f8f9fc;
    --color-neutral-950: #ffffff;
    --font-sans: var(--ac-sans);
    --font-display: var(--ac-sans);
    --font-arabic: var(--ac-arabic);
    --heading-transform: none;
    --label-transform: none;
    --radius-btn: var(--ac-radius-sm);
    --radius-card: var(--ac-radius);
}

/* ---------- Base ---------- */

.academy-body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    margin: 0;
    background: var(--ac-paper);
    color: var(--ac-ink);
    font-family: var(--ac-sans);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
[dir='rtl'] .academy-body { font-family: var(--ac-arabic); }
.academy-body .eyebrow { letter-spacing: 0.01em; }
.academy-body :focus-visible { outline: 3px solid var(--ac-cobalt); outline-offset: 2px; border-radius: 4px; }
.academy-body ::selection { background: var(--ac-marker); color: var(--ac-ink); }
.ac-main { flex: 1 0 auto; }

.ac-wrap {
    width: 100%;
    max-width: 76rem;
    margin-inline: auto;
    padding-inline: 1rem;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .ac-wrap { padding-inline: 1.5rem; }
}

@media (min-width: 1024px) {
    .ac-wrap { padding-inline: 2rem; }
}

.ac-skip {
    position: absolute;
    inset-inline-start: 0.5rem;
    inset-block-start: -4rem;
    z-index: 60;
    padding: 0.6rem 1rem;
    border-radius: var(--ac-radius-sm);
    background: var(--ac-ink);
    color: #ffffff;
    font-weight: 600;
    text-decoration: none;
}
.ac-skip:focus { inset-block-start: 0.5rem; }

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

.ac-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.6rem 1.15rem;
    border: 1px solid transparent;
    border-radius: var(--ac-radius-sm);
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.ac-btn--primary { background: var(--ac-cobalt); color: #ffffff; }
.ac-btn--primary:hover { background: var(--ac-cobalt-deep); }
.ac-btn--block { display: flex; width: 100%; white-space: normal; text-align: center; }

/* ---------- Header ---------- */

.ac-header {
    position: sticky;
    inset-block-start: 0;
    z-index: 40;
    border-block-start: 4px solid var(--ac-cobalt);
    border-block-end: 1px solid var(--ac-rule);
    background: rgb(255 255 255 / 0.94);
    backdrop-filter: saturate(1.4) blur(10px);
}
.ac-header__bar { display: flex; align-items: center; gap: 1rem; min-height: 4.5rem; }

/* The site name is never cut: the brand keeps its full width, and on a phone the name wraps
   (its longest word is the narrowest it gets) while the language button drops its label. */
.ac-brand {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.75rem;
    color: var(--ac-ink);
    text-decoration: none;
}
.ac-brand__mark { width: 2.5rem; height: 2.5rem; flex-shrink: 0; }
.ac-brand__logo { height: 2.75rem; width: auto; }
.ac-brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.ac-brand__name { font-family: var(--ac-serif); font-size: 1.2rem; font-weight: 700; white-space: nowrap; }
/* The tagline wraps under the name instead of widening the brand. */
.ac-brand__tagline { display: none; width: 0; min-width: 100%; font-size: 0.8rem; line-height: 1.25; color: var(--ac-muted); }

@media (max-width: 479px) {
    .ac-brand { flex: 0 1 auto; gap: 0.6rem; }
    .ac-brand__name { white-space: normal; font-size: 1.05rem; line-height: 1.15; }
    .ac-header__actions [aria-haspopup='listbox'] > span { display: none; }
}
.ac-nav { display: none; margin-inline-start: auto; }
.ac-nav ul { gap: 1.25rem; white-space: nowrap; }
.ac-nav a { font-size: 0.95rem; font-weight: 500; }
.ac-header__actions { display: flex; flex-shrink: 0; align-items: center; gap: 0.5rem; margin-inline-start: auto; }
.ac-header__actions [aria-haspopup='listbox'] { padding-inline: 0.75rem; }

.ac-header__search,
.ac-header__cta { display: none !important; }

.ac-menu-toggle {
    display: inline-grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--ac-rule);
    border-radius: var(--ac-radius-sm);
    background: var(--ac-sheet);
    color: var(--ac-ink);
    cursor: pointer;
}
.ac-menu-toggle svg { width: 1.4rem; height: 1.4rem; }
.ac-mobile-nav { border-block-start: 1px solid var(--ac-rule); background: var(--ac-sheet); }
.ac-mobile-nav__inner { display: grid; gap: 1.25rem; padding-block: 1.25rem; }
.ac-mobile-nav a { font-size: 1rem; }

@media (min-width: 768px) {
    .ac-header__cta { display: inline-flex !important; }
}

/* 1024-1279: everything is on one bar, so the nav tightens and the language button shows its flag only. */
@media (min-width: 1024px) and (max-width: 1279px) {
    .ac-nav ul { gap: 1rem; }
    .ac-nav a { font-size: 0.9rem; }
    .ac-header__actions [aria-haspopup='listbox'] > span { display: none; }
}

@media (min-width: 1024px) {
    .ac-nav { display: block; }
    .ac-header__actions { margin-inline-start: 0; }
    .ac-header__search { display: block !important; width: 8rem; }
    .ac-menu-toggle,
    .ac-mobile-nav { display: none !important; }
}

@media (min-width: 1280px) {
    .ac-header__bar { gap: 1.5rem; }
    .ac-brand__tagline { display: block; }
    .ac-nav ul { gap: 1.75rem; }
    .ac-header__actions { gap: 0.75rem; }
    .ac-header__search { width: 11rem; }
}

/* ---------- Page heads ---------- */

.ac-page-head { padding-block: 2.75rem 2.5rem; border-block-end: 1px solid var(--ac-rule); background: var(--ac-sheet); }

@media (min-width: 768px) {
    .ac-page-head { padding-block: 4rem 3.5rem; }
}

.ac-title {
    margin: 0;
    max-width: 22ch;
    font-family: var(--ac-serif);
    font-size: clamp(2rem, 1.35rem + 2.6vw, 3.25rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: var(--ac-ink);
    text-wrap: balance;
}
.ac-title--xl { max-width: 24ch; font-size: clamp(2.15rem, 1.4rem + 3vw, 3.75rem); }

/* The highlighter: a marker swipe across the lower part of the words, following line wraps. */
.ac-mark {
    padding-inline: 0.12em;
    margin-inline: -0.12em;
    background-image: linear-gradient(transparent 56%, var(--ac-marker) 56%, var(--ac-marker) 90%, transparent 90%);
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

.ac-lede {
    margin: 1rem 0 0;
    max-width: 60ch;
    font-size: clamp(1.05rem, 1rem + 0.35vw, 1.25rem);
    line-height: 1.55;
    color: var(--ac-muted);
    text-wrap: pretty;
}
.ac-crumb { margin: 0 0 0.75rem; font-size: 0.9rem; }
.ac-crumb a { color: var(--ac-cobalt); font-weight: 600; text-decoration: none; }
.ac-crumb a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Arabic has no serif face here, sits taller, and must never be letter-spaced. */
[dir='rtl'] .ac-title,
[dir='rtl'] .ac-heading,
[dir='rtl'] .ac-brand__name,
[dir='rtl'] .ac-course-card__title,
[dir='rtl'] .ac-person-card__name,
[dir='rtl'] .ac-footer__name,
[dir='rtl'] .ac-enquiry h2 { font-family: var(--ac-arabic); letter-spacing: 0; line-height: 1.4; }

/* ---------- Sections and grids ---------- */

.ac-section { padding-block: 2.5rem 4rem; }
/* Narrow reading column that keeps the page head's start edge. */
.ac-narrow > * { max-width: 52rem; }
.ac-grid { display: grid; gap: 1.25rem; }

@media (min-width: 640px) {
    .ac-grid { gap: 1.5rem; }
    .ac-grid--2,
    .ac-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
    .ac-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.ac-block { margin-block-start: 3rem; padding-block-start: 2rem; border-block-start: 1px solid var(--ac-rule); }
.ac-block:first-child { margin-block-start: 0; padding-block-start: 0; border-block-start: 0; }

.ac-heading {
    margin: 0 0 1.25rem;
    font-family: var(--ac-serif);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
}

.ac-empty {
    margin: 0;
    padding: 2rem 1.5rem;
    border: 1px dashed var(--ac-rule);
    border-radius: var(--ac-radius);
    background: var(--ac-sheet);
    color: var(--ac-muted);
}

/* A card's title link covers the whole card. */
.ac-stretched { color: inherit; text-decoration: none; }
.ac-stretched::after { content: ''; position: absolute; inset: 0; z-index: 1; }

.ac-stretched:hover,
.ac-stretched:focus-visible {
    text-decoration: underline;
    text-decoration-color: var(--ac-cobalt);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

/* ---------- Course card ---------- */

.ac-course-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--ac-rule);
    border-radius: var(--ac-radius);
    background: var(--ac-sheet);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ac-course-card:hover,
.ac-course-card:focus-within { border-color: var(--ac-cobalt); box-shadow: var(--ac-shadow); }
.ac-course-card__media { aspect-ratio: 16 / 10; background: #edf0f7; }
.ac-course-card__img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* No image: ruled notebook paper with a margin line at the start. */
.ac-course-card__placeholder {
    display: block;
    height: 100%;
    background:
        linear-gradient(to right, transparent 2.25rem, rgb(36 72 200 / 0.35) 2.25rem, rgb(36 72 200 / 0.35) calc(2.25rem + 2px), transparent calc(2.25rem + 2px)),
        repeating-linear-gradient(to bottom, #f3f5fa 0 1.45rem, #d5dcea 1.45rem calc(1.45rem + 1px));
}

[dir='rtl'] .ac-course-card__placeholder {
    background:
        linear-gradient(to left, transparent 2.25rem, rgb(36 72 200 / 0.35) 2.25rem, rgb(36 72 200 / 0.35) calc(2.25rem + 2px), transparent calc(2.25rem + 2px)),
        repeating-linear-gradient(to bottom, #f3f5fa 0 1.45rem, #d5dcea 1.45rem calc(1.45rem + 1px));
}

.ac-course-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.25rem;
}

.ac-course-card__title {
    margin: 0;
    font-family: var(--ac-serif);
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.25;
    text-wrap: balance;
}
.ac-course-card__excerpt { margin: 0; font-size: 0.95rem; color: var(--ac-muted); text-wrap: pretty; }

/* ---------- Course details (specs) ---------- */

.ac-specs { margin: 0; }

.ac-specs__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 0.7rem;
    border-block-end: 1px solid var(--ac-rule);
}
.ac-specs dt { font-size: 0.9rem; color: var(--ac-muted); }
.ac-specs dd { margin: 0; font-weight: 600; text-align: end; }

.ac-specs--compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin-block-start: auto;
    padding-block-start: 0.9rem;
    border-block-start: 1px dashed var(--ac-rule);
}

.ac-specs--compact .ac-specs__row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 0;
    border: 0;
}
.ac-specs--compact dt { font-size: 0.75rem; }
.ac-specs--compact dd { font-size: 0.9rem; text-align: start; }

/* ---------- Course page ---------- */

.ac-course { display: grid; gap: 2.5rem; padding-block: 2.5rem 4rem; }

@media (min-width: 1024px) {
    .ac-course { grid-template-columns: minmax(0, 1fr) 20rem; gap: 3.5rem; align-items: start; }
    .ac-course__facts { grid-column: 2; grid-row: 1; position: sticky; inset-block-start: 6.5rem; }
    .ac-course__main { grid-column: 1; grid-row: 1; }
}

.ac-facts {
    display: grid;
    gap: 1.25rem;
    padding: 1.25rem;
    border: 1px solid var(--ac-rule);
    border-block-start: 6px solid var(--ac-marker);
    border-radius: var(--ac-radius);
    background: var(--ac-sheet);
}
.ac-facts .ac-specs__row:last-child { border-block-end: 0; }

.ac-gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0 0 2.5rem;
    padding: 0;
    list-style: none;
}

.ac-gallery__img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--ac-radius-sm);
}
.ac-gallery__item--lead { grid-column: 1 / -1; }
.ac-gallery__item--lead .ac-gallery__img { aspect-ratio: 16 / 9; border-radius: var(--ac-radius); }
.ac-prose { max-width: 68ch; font-size: 1.0625rem; line-height: 1.75; }

.ac-prose h2,
.ac-prose h3 { font-family: var(--ac-serif); line-height: 1.25; }

[dir='rtl'] .ac-prose h2,
[dir='rtl'] .ac-prose h3 { font-family: var(--ac-arabic); }
.ac-prose a { color: var(--ac-cobalt); }

/* ---------- Enquiry form (built-in component, restyled) ---------- */

.ac-enquiry > div {
    padding: 1.5rem;
    border: 1px solid var(--ac-rule);
    border-radius: var(--ac-radius);
    background: var(--ac-sheet);
}

@media (min-width: 640px) {
    .ac-enquiry > div { padding: 2rem; }
}
.ac-enquiry h2 { font-family: var(--ac-serif); font-size: 1.6rem; line-height: 1.2; }

.ac-enquiry input:not([type='hidden']),
.ac-enquiry textarea {
    box-sizing: border-box;
    padding: 0.7rem 0.85rem;
    border-color: #b9c1d1;
    border-radius: var(--ac-radius-sm);
    background: #ffffff;
    color: var(--ac-ink);
    font-size: 1rem;
}

.ac-enquiry input:focus,
.ac-enquiry textarea:focus { border-color: var(--ac-cobalt); box-shadow: 0 0 0 3px rgb(36 72 200 / 0.2); }
.ac-enquiry [role='status'] { border-color: #9fd2b2; background: #eaf7ef; color: #14532d; font-size: 1rem; }

/* ---------- Instructor card and profile ---------- */

.ac-person-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--ac-rule);
    border-radius: var(--ac-radius);
    background: var(--ac-sheet);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ac-person-card:hover,
.ac-person-card:focus-within { border-color: var(--ac-cobalt); box-shadow: var(--ac-shadow); }

.ac-person-card__photo {
    width: 5.5rem;
    height: 5.5rem;
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
}

.ac-person-card__initial {
    display: grid;
    place-items: center;
    background: var(--ac-marker);
    color: var(--ac-ink);
    font-family: var(--ac-serif);
    font-size: 2.25rem;
    font-weight: 700;
}
.ac-person-card__body { min-width: 0; text-align: start; }

.ac-person-card__name {
    margin: 0;
    font-family: var(--ac-serif);
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.25;
}
.ac-person-card__headline { margin: 0.25rem 0 0; font-size: 0.925rem; color: var(--ac-muted); }
.ac-profile { display: flex; flex-direction: column; gap: 1.5rem; }

@media (min-width: 640px) {
    .ac-profile { flex-direction: row; align-items: center; gap: 2.5rem; }
}

.ac-profile__photo {
    width: 9rem;
    height: 9rem;
    flex-shrink: 0;
    border: 6px solid var(--ac-sheet);
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--ac-rule), 0 0 0 10px var(--ac-marker);
    object-fit: cover;
}

@media (min-width: 640px) {
    .ac-profile__photo { width: 11rem; height: 11rem; }
}
.ac-profile__text { min-width: 0; text-align: start; }

/* ---------- Footer (ink; the dark tokens come back inside it) ---------- */

/*
 * Built-in blocks that put light text on a photo or a dark fade mark that wrapper with
 * data-surface="dark" (hero_media, the cta_banner band, icon_panels image tiles, feature_grid
 * cover media, the video_embed media box). Inside it the original dark-site tokens come back,
 * with a lighter cobalt so accents stay readable on dark.
 */
[data-surface='dark'] {
    --color-white: #ffffff;
    --color-neutral-50: oklch(98.5% 0 none);
    --color-neutral-100: oklch(97% 0 none);
    --color-neutral-200: oklch(92.2% 0 none);
    --color-neutral-300: oklch(87% 0 none);
    --color-neutral-400: oklch(70.8% 0 none);
    --color-neutral-500: oklch(55.6% 0 none);
    --color-neutral-600: oklch(43.9% 0 none);
    --color-neutral-700: oklch(37.1% 0 none);
    --color-neutral-800: oklch(26.9% 0 none);
    --color-neutral-900: oklch(20.5% 0 none);
    --color-neutral-950: oklch(14.5% 0 none);
    --color-surface: #0f1a30;
    --color-raised: #16233f;
    --color-line: rgb(255 255 255 / 0.16);
    --color-brand: #9db4ff;
    --color-brand-soft: #c3d1ff;
    --color-on-brand: var(--ac-ink);

    color: var(--color-neutral-100);
    color-scheme: dark;
}

/*
 * A brand-coloured section (the "accent" tone, e.g. the filled call-to-action band) holds the
 * built-in dark-site buttons: bg-neutral-950 text-white, with .text-white rewritten to on-brand.
 * The light remap above turns neutral-950 white, which left a white button with white text. Inside
 * the band the neutral scale and white come back to their dark-site values; the brand colours stay,
 * so the band itself is still cobalt.
 */
section.bg-brand {
    --color-white: #ffffff;
    --color-neutral-50: oklch(98.5% 0 none);
    --color-neutral-100: oklch(97% 0 none);
    --color-neutral-200: oklch(92.2% 0 none);
    --color-neutral-300: oklch(87% 0 none);
    --color-neutral-400: oklch(70.8% 0 none);
    --color-neutral-500: oklch(55.6% 0 none);
    --color-neutral-600: oklch(43.9% 0 none);
    --color-neutral-700: oklch(37.1% 0 none);
    --color-neutral-800: oklch(26.9% 0 none);
    --color-neutral-900: oklch(20.5% 0 none);
    --color-neutral-950: oklch(14.5% 0 none);
}

.ac-footer {
    --color-white: #ffffff;
    --color-neutral-100: #f1f4fa;
    --color-neutral-300: #c9d1e3;
    --color-neutral-400: #b3bdd3;
    --color-line: rgb(255 255 255 / 0.14);

    margin-block-start: 4rem;
    background: var(--ac-ink);
    color: #dfe5f2;
}
.ac-footer a { color: #ffffff; }
.ac-footer :focus-visible { outline-color: var(--ac-marker); }
.ac-footer__grid { display: grid; gap: 2rem; padding-block: 3rem 2.5rem; }

@media (min-width: 768px) {
    .ac-footer__grid { grid-template-columns: minmax(0, 1fr) auto; gap: 4rem; }
}

.ac-footer__name {
    margin: 0;
    font-family: var(--ac-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
}
.ac-footer__tagline { margin: 0.4rem 0 0; max-width: 40ch; color: #b8c2d9; }
.ac-footer__social { margin-block-start: 1.25rem; }

.ac-footer__legal {
    padding-block: 1.25rem;
    border-block-start: 1px solid rgb(255 255 255 / 0.14);
    font-size: 0.875rem;
    color: #b8c2d9;
}
.ac-footer__legal p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
    .academy-body *,
    .academy-body *::before,
    .academy-body *::after { transition: none !important; scroll-behavior: auto !important; }
}
