/* =================================================================
   CodeIslander — shared design system
   Tokens, base type, buttons, the floating top navigation, footer,
   flash messages, form cards, page headers, legal pages and the
   site-wide motion. Page stylesheets build on these tokens.
   ================================================================= */

:root {
    /* Surfaces and ink */
    --paper: #FFFFFF;
    --canvas: #F6F8FA;
    --surface: #F1F4F7;
    --line: #E3E8ED;
    --line-2: #D3DAE1;
    --ink: #0E1A26;
    --ink-2: #33414F;
    --mute: #5B6875;
    --night: #0C1722;
    --night-2: #142331;
    --night-3: #1C2E40;

    /* Actions and meaning: ocean = action, green = success, red = errors, gold = Premium */
    --brand: #0A6FA3;
    --brand-hover: #085B86;
    --brand-soft: #E7F2F8;
    --sea: #EAF4F9;
    --sea-2: #D6EAF4;
    --ok: #13805B;
    --ok-soft: #E6F4EE;
    --warn: #A86A0C;
    --warn-soft: #FCF5E7;
    --danger: #C2413A;
    --danger-soft: #FCEEED;
    --gold: #B9851B;
    --gold-soft: #FBF3E1;

    /* Type */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: 'Schibsted Grotesk', var(--font-main);
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Depth, shape, motion */
    --shadow-card: 0 1px 2px rgba(14, 26, 38, 0.05), 0 10px 28px -12px rgba(14, 26, 38, 0.18);
    --shadow-frame: 0 1px 2px rgba(14, 26, 38, 0.06), 0 12px 32px -8px rgba(14, 26, 38, 0.16), 0 40px 80px -24px rgba(14, 26, 38, 0.22);
    --shadow-pop: 0 1px 2px rgba(14, 26, 38, 0.08), 0 18px 48px -16px rgba(14, 26, 38, 0.32);
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-io: cubic-bezier(0.65, 0, 0.35, 1);

    /* Layout */
    --nav-h: 64px;
    --header-h: 64px;               /* the top bar: what fixed and sticky things clear */
    --gutter: clamp(20px, 4vw, 56px);
    --page-max: 1200px;

    /* Names the page stylesheets already use, mapped onto the system above */
    --color-bg: var(--canvas);
    --color-card: var(--paper);
    --color-border: var(--line);
    --color-text: var(--ink);
    --color-text-light: var(--mute);
    --color-ocean: var(--brand);
    --color-ocean-hover: var(--brand-hover);
    --color-palm: var(--ok);
    --color-sunset: var(--danger);
    --color-gold: var(--gold);
    --color-ink-900: var(--night);
    --color-ink-800: var(--night-2);
    --color-ink-700: var(--night-3);
    --shadow-xs: 0 1px 2px rgba(14, 26, 38, 0.06);
    --shadow-sm: var(--shadow-card);
    --shadow-md: 0 1px 2px rgba(14, 26, 38, 0.06), 0 14px 36px -14px rgba(14, 26, 38, 0.22);
    --shadow-lg: var(--shadow-frame);
    --shadow-glow-ocean: 0 8px 18px -8px rgba(14, 26, 38, 0.32);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --card-radius: 14px;
    --glass-bg: rgba(255, 255, 255, 0.86);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-blur: 16px;
    --ease-out: var(--ease);
    --sidebar-width: 0px;
    --sidebar-collapsed-width: 0px;
}

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

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

body {
    margin: 0;
    font: 400 16px/1.6 var(--font-main);
    background-color: var(--canvas);
    color: var(--ink);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
    text-wrap: balance;
}

p { text-wrap: pretty; }

::selection { background: rgba(10, 111, 163, 0.18); color: var(--ink); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }

a { color: inherit; }

img { max-width: 100%; height: auto; }

code, kbd, pre, samp {
    font-family: var(--font-mono);
    font-variant-ligatures: none;
    font-feature-settings: "calt" 0, "liga" 0;   /* beginners must see >= and !=, not merged glyphs */
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(14, 26, 38, 0.18); border-radius: 999px; border: 2px solid var(--canvas); }
::-webkit-scrollbar-thumb:hover { background: rgba(14, 26, 38, 0.3); }

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 200;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--ink);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 20px;
    border-radius: 11px;
    border: 1px solid transparent;
    font: 600 15px/1 var(--font-main);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s, color 0.25s, transform 0.5s var(--ease);
}
.btn i, .btn svg { font-size: 0.92em; transition: transform 0.35s var(--ease); }
.btn:hover .fa-arrow-right, .btn:hover .btn__arrow { transform: translateX(3px); }
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn.is-disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(14, 26, 38, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.btn--primary:hover { background: var(--brand-hover); box-shadow: 0 8px 18px -8px rgba(14, 26, 38, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.btn--secondary { background: var(--paper); color: var(--ink); border-color: var(--line-2); }
.btn--secondary:hover { background: #FAFBFC; border-color: #B6C1CB; }
.btn--dark { background: var(--ink); color: #fff; }
.btn--dark:hover { background: #1B2B3B; }
.btn--white { background: #fff; color: var(--ink); }
.btn--white:hover { background: #EEF4F8; }
.btn--ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.btn--ghost:hover { border-color: rgba(255, 255, 255, 0.5); }
.btn--quiet { background: transparent; color: var(--ink-2); }
.btn--quiet:hover { background: rgba(14, 26, 38, 0.05); color: var(--ink); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #A8352F; }
.btn--sm { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 9px; }
.btn--lg { height: 52px; padding: 0 24px; font-size: 16px; }
.btn--block { width: 100%; }

.link-arrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--brand);
    text-decoration: none;
}
.link-arrow i { font-size: 0.85em; transition: transform 0.35s var(--ease); }
.link-arrow:hover i { transform: translateX(4px); }

/* --------------------------------- */
/* Top navigation                    */
/* --------------------------------- */

/* A full-width bar; its content lines up with the page (--page-max). */
.topnav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--nav-h);
    background: rgba(255, 255, 255, 0.86);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    box-shadow: 0 1px 0 rgba(14, 26, 38, 0.06);
    color: var(--ink);
    transition: background-color 0.3s, box-shadow 0.3s, color 0.3s;
}
.topnav.is-scrolled { background: rgba(255, 255, 255, 0.94); box-shadow: 0 1px 0 var(--line), 0 8px 24px -18px rgba(14, 26, 38, 0.3); }
.topnav.is-dark { background: rgba(12, 23, 34, 0.8); color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08); }

.topnav__in {
    width: min(var(--page-max), calc(100% - 2 * var(--gutter)));
    height: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    color: inherit;
    text-decoration: none;
}
.brand__mark { width: auto; height: 38px; flex: none; }
.brand__word {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--ink);
    white-space: nowrap;
}
.topnav.is-dark .brand__word { color: #fff; }
.site-footer .brand__mark { height: 48px; }
.site-footer .brand__word { font-size: 22px; }
/* A hairline between the name and the links */
.topnav .brand::after {
    content: "";
    width: 1px;
    height: 22px;
    margin-left: 20px;
    background: var(--line);
}
.topnav.is-dark .brand::after { background: rgba(255, 255, 255, 0.14); }

.topnav__links {
    position: relative;
    display: flex;
    align-self: stretch;
    gap: 2px;
    margin-right: auto;
}
.topnav__links a {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 12px;
    color: var(--ink-2);
    font-size: 14.5px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.25s;
}
.topnav__links a i { font-size: 0.78rem; opacity: 0.7; }
.topnav.is-dark .topnav__links a { color: #9FB0BF; }
.topnav__links a:hover,
.topnav__links a.is-active,
.topnav__links a[aria-current="page"] { color: var(--ink); }
.topnav.is-dark .topnav__links a:hover,
.topnav.is-dark .topnav__links a.is-active,
.topnav.is-dark .topnav__links a[aria-current="page"] { color: #fff; }
/* The page you're on: a line along the bottom edge of the bar */
.topnav__links a.is-active::after,
.topnav__links a[aria-current="page"]::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--brand);
}
.topnav.is-dark .topnav__links a.is-active::after,
.topnav.is-dark .topnav__links a[aria-current="page"]::after { background: #7CC3E6; }
.topnav__ink {
    position: absolute;
    top: 50%;
    left: 0;
    width: 0;
    height: 36px;
    margin-top: -18px;
    border-radius: 9px;
    background: rgba(14, 26, 38, 0.06);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.45s var(--ease), width 0.45s var(--ease), opacity 0.3s;
}
.topnav.is-dark .topnav__ink { background: rgba(255, 255, 255, 0.08); }

.topnav__end { display: flex; align-items: center; gap: 6px; flex: none; }

.topnav__login {
    padding: 9px 12px;
    border-radius: 9px;
    font-size: 14.5px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s;
}
.topnav__login:hover { background: rgba(14, 26, 38, 0.05); }
.topnav.is-dark .topnav__login:hover { background: rgba(255, 255, 255, 0.08); }

/* EN / FR */
.lang-switch {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
}
.lang-switch__opt {
    padding: 6px 7px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--mute);
    font: 600 12.5px/1.2 var(--font-main);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}
.topnav.is-dark .lang-switch__opt { color: #9FB0BF; }
.lang-switch__opt:hover { color: var(--ink); }
.lang-switch__opt.is-active { color: var(--ink); font-weight: 700; }
.lang-switch__opt + .lang-switch__opt { border-left: 1px solid var(--line-2); border-radius: 0; }
.topnav.is-dark .lang-switch__opt + .lang-switch__opt { border-left-color: rgba(255, 255, 255, 0.2); }
.topnav.is-dark .lang-switch__opt.is-active,
.topnav.is-dark .lang-switch__opt:hover { color: #fff; }

/* Signed in: streak, Premium and the account menu */
.topnav__streak {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 11px 0 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
    text-decoration: none;
    transition: background-color 0.2s, border-color 0.2s;
}
.topnav.is-dark .topnav__streak { border-color: rgba(255, 255, 255, 0.16); }
.topnav__streak i { color: #E4572E; }
.topnav__streak:hover { background: rgba(14, 26, 38, 0.05); }
.topnav.is-dark .topnav__streak { color: #DCE4EA; }

.topnav__premium {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 12px;
    border-radius: 9px;
    background: var(--gold-soft);
    color: #7A5610;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s;
}
.topnav__premium i { color: var(--gold); }
.topnav__premium:hover { background: #F6E8C6; }

.account { position: relative; }
.account__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 8px 0 4px;
    border: 0;
    border-radius: 11px;
    background: none;
    color: inherit;
    font: 600 14px/1 var(--font-main);
    cursor: pointer;
    transition: background-color 0.2s;
}
.account__btn:hover, .account.is-open .account__btn { background: rgba(14, 26, 38, 0.06); }
.topnav.is-dark .account__btn:hover, .topnav.is-dark .account.is-open .account__btn { background: rgba(255, 255, 255, 0.1); }
.account__btn > i { font-size: 0.7rem; opacity: 0.6; transition: transform 0.35s var(--ease); }
.account.is-open .account__btn > i { transform: rotate(180deg); }
.avatar {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font: 700 13px/1 var(--font-display);
}
.account__menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    padding: 8px;
    border-radius: 16px;
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow-pop), 0 0 0 1px rgba(14, 26, 38, 0.06);
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    visibility: hidden;
    transition: opacity 0.25s var(--ease), transform 0.35s var(--ease), visibility 0s 0.35s;
}
.account.is-open .account__menu { opacity: 1; transform: none; visibility: visible; transition: opacity 0.25s var(--ease), transform 0.35s var(--ease); }
.account__who {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 14px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
}
.account__who b { display: block; font-size: 15px; }
.account__who small { display: block; color: var(--mute); font-size: 13px; }
.account__menu a, .account__menu button.account__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 9px;
    background: none;
    color: var(--ink-2);
    font: 500 14.5px/1.3 var(--font-main);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.account__menu a i, .account__menu button.account__item i { width: 18px; text-align: center; color: var(--mute); }
.account__menu a:hover, .account__menu button.account__item:hover { background: var(--surface); color: var(--ink); }
.account__menu .account__nudge { color: #4C5BD4; }
.account__menu .account__nudge i { color: #5865F2; }
.account__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    margin-top: 6px;
    border-top: 1px solid var(--line);
    color: var(--mute);
    font-size: 13.5px;
}
.account__menu form { margin: 0; }

/* Menu button and the phone sheet */
.topnav__menu {
    display: none;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: none;
    color: inherit;
    cursor: pointer;
}
.topnav__menu i, .topnav__menu i::before, .topnav__menu i::after {
    display: block;
    position: relative;
    width: 18px;
    height: 1.8px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.4s var(--ease), background-color 0.2s;
}
.topnav__menu i::before, .topnav__menu i::after { content: ""; position: absolute; left: 0; }
.topnav__menu i::before { top: -6px; }
.topnav__menu i::after { top: 6px; }
.topnav.is-open .topnav__menu i { background: transparent; }
.topnav.is-open .topnav__menu i::before { transform: translateY(6px) rotate(45deg); }
.topnav.is-open .topnav__menu i::after { transform: translateY(-6px) rotate(-45deg); }

.sheet {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: calc(100svh - var(--nav-h));
    display: flex;
    flex-direction: column;
    padding: 8px var(--gutter) 20px;
    overflow-y: auto;
    background: var(--paper);
    color: var(--ink);
    box-shadow: inset 0 1px 0 var(--line);
    clip-path: inset(0 0 100% 0);
    visibility: hidden;
    transition: clip-path 0.6s var(--ease), visibility 0s 0.6s;
}
.topnav.is-open .sheet { clip-path: inset(0 0 0 0); visibility: visible; transition: clip-path 0.6s var(--ease); }
.sheet__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    font: 600 22px/1.2 var(--font-display);
    letter-spacing: -0.02em;
    text-decoration: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s, transform 0.6s var(--ease);
}
.sheet__link i { font-size: 0.8rem; color: var(--mute); }
.topnav.is-open .sheet__link { opacity: 1; transform: none; transition-delay: calc(var(--i, 0) * 40ms + 120ms); }
.sheet__group { margin: 18px 0 6px; color: var(--mute); font-size: 13px; font-weight: 600; }
.sheet__end { display: grid; gap: 10px; margin-top: auto; padding-top: 20px; }
.sheet__end .lang-switch { justify-self: start; }

body.nav-open { overflow: hidden; }

@media (max-width: 1040px) {
    .topnav__links, .topnav__end .topnav__login, .topnav__end .lang-switch,
    .topnav__end .btn, .topnav__end .topnav__premium { display: none; }
    .topnav__menu { display: grid; }
    .topnav__end { margin-left: auto; }
}
@media (max-width: 1040px) {
    .account__btn .account__name { display: none; }
    .topnav .brand::after { display: none; }  /* the links it separated are in the menu */
}
@media (max-width: 420px) {
    .topnav__in { gap: 12px; }
    .brand__mark { height: 30px; }
    .brand__word { font-size: 17px; }
    .topnav__end { gap: 2px; }
}

/* --------------------------------- */
/* Main content                      */
/* --------------------------------- */

main {
    position: relative;
    display: block;
    min-height: calc(100vh - 200px);
    padding: calc(var(--header-h) + clamp(28px, 5vh, 56px)) var(--gutter) clamp(56px, 9vh, 96px);
}

.page {
    width: min(var(--page-max), 100%);
    margin: 0 auto;
}
.page--narrow { width: min(760px, 100%); }
.page--read { width: min(920px, 100%); }

/* Page header: title, one line of context, optional actions */
.page-hero {
    width: min(var(--page-max), 100%);
    margin: 0 auto clamp(28px, 5vh, 44px);
}
.page-title {
    margin: 0 0 10px;
    font-family: var(--font-display);
    font-size: clamp(28px, min(2.6vw, 4.6vh), 38px);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.03em;
    color: var(--ink);
}
.page-subtitle {
    margin: 0;
    max-width: 640px;
    color: var(--mute);
    font-size: clamp(16px, 1.25vw, 18px);
    line-height: 1.6;
}
/* Level pages (lessons, quizzes): a banner in the chapter's colour (--hero-accent)
   with its island floating on the right */
.level-hero {
    position: relative;
    padding: clamp(22px, 16px + 1.6vw, 36px) clamp(22px, 16px + 2.4vw, 48px);
    padding-right: clamp(22px, 26%, 272px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background:
        radial-gradient(60% 90% at 88% 30%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%),
        linear-gradient(120deg, color-mix(in srgb, var(--hero-accent, var(--brand)) 9%, #fff) 0%, #EEF7FB 55%, #D9EDF6 100%);
}
.level-hero__isle {
    position: absolute;
    right: clamp(-16px, 2%, 32px);
    top: 50%;
    width: clamp(144px, 22%, 224px);
    height: auto;
    translate: 0 -50%;
    filter: drop-shadow(0 22px 22px rgba(14, 26, 38, 0.18));
    pointer-events: none;
}
.motion .level-hero__isle { animation: levelIsleIn 1.2s var(--ease) 0.15s both, levelIsleBob 6s var(--ease-io) 1.4s infinite; }
@keyframes levelIsleIn { from { opacity: 0; transform: translateY(30px) scale(0.9); } }
@keyframes levelIsleBob { 50% { transform: translateY(-8px) rotate(-1.5deg); } }
@media (max-width: 640px) {
    .level-hero { padding-right: clamp(22px, 16px + 2.4vw, 48px); }
    .level-hero__isle { top: 12px; right: -12px; width: 104px; translate: none; opacity: 0.9; }
    .level-hero > a:first-of-type { margin-right: 80px; }
}

/* Small context above a page title (a breadcrumb or date, never a decorative label) */
.page-eyebrow, .small-page-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    color: var(--mute);
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

/* --------------------------------- */
/* Flash messages                    */
/* --------------------------------- */

.flash-messages {
    display: grid;
    gap: 8px;
    width: min(720px, 100%);
    margin: 0 auto 20px;
}
.flash-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--paper);
    box-shadow: var(--shadow-card);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.5;
    animation: flashIn 0.6s var(--ease) both;
    transition: opacity 0.4s ease, transform 0.4s ease;
}
@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } }
.flash-message.is-leaving { opacity: 0; transform: translateY(-6px); }
.flash-message__icon { flex-shrink: 0; margin-top: 3px; font-size: 15px; color: var(--brand); }
.flash-message__text { flex: 1; }
.flash-message__close {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    margin: -1px 0 -1px 4px;
    border: 0;
    border-radius: 7px;
    background: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
}
.flash-message__close:hover, .flash-message__close:focus-visible { opacity: 1; background: rgba(14, 26, 38, 0.06); }
.flash-message--success { border-color: rgba(19, 128, 91, 0.25); background: #F3FAF6; }
.flash-message--success .flash-message__icon { color: var(--ok); }
.flash-message--error { border-color: rgba(194, 65, 58, 0.3); background: #FDF5F4; }
.flash-message--error .flash-message__icon { color: var(--danger); }
.flash-message--warning { border-color: rgba(168, 106, 12, 0.3); background: #FFFAF0; }
.flash-message--warning .flash-message__icon { color: var(--warn); }
.flash-message--info { border-color: rgba(10, 111, 163, 0.22); background: #F3F9FC; }

/* --------------------------------- */
/* Footer                            */
/* --------------------------------- */

/* Light, like the rest of the site: the logo never sits on a dark block. */
.site-footer {
    border-top: 1px solid var(--line);
    background: var(--canvas);
    color: var(--mute);
    font-size: 14.5px;
    padding: clamp(48px, 8vh, 72px) var(--gutter) 32px;
}
.site-footer__in { width: min(var(--page-max), 100%); margin: 0 auto; }
.site-footer__grid { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: 40px; }
.site-footer .brand { color: var(--ink); }
.site-footer__tag { margin: 14px 0 0; max-width: 300px; line-height: 1.6; }
.site-footer h3 { margin: 0 0 14px; color: var(--ink); font: 600 13px/1.2 var(--font-main); letter-spacing: 0; }
.site-footer ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.site-footer ul a { text-decoration: none; transition: color 0.2s; }
.site-footer ul a:hover { color: var(--ink); }
.site-footer__social { display: flex; gap: 8px; margin-top: 20px; }
.site-footer__social a {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    outline: 1px solid var(--line-2);
    background: var(--paper);
    text-decoration: none;
    transition: outline-color 0.2s, color 0.2s;
}
.site-footer__social a:hover { outline-color: #B6C1CB; color: var(--ink); }
.site-footer__bottom {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
    color: var(--mute);
    font-size: 13.5px;
}
.site-footer__bottom p { margin: 0; }

@media (max-width: 900px) {
    .site-footer__grid { grid-template-columns: 1fr 1fr; }
    .site-footer__grid > div:first-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
    /* Product beside Legal; Help (with the long email address) gets its own row */
    .site-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: row dense; gap: 32px 20px; }
    .site-footer__grid > div:nth-child(3) { grid-column: 1 / -1; }
    .site-footer__bottom { flex-direction: column; gap: 8px; }
}

/* --------------------------------- */
/* Cards and forms                   */
/* --------------------------------- */

.card {
    border-radius: 20px;
    border: 1px solid var(--line);
    background: var(--paper);
    box-shadow: var(--shadow-xs);
}

.small-page-shell { width: min(640px, 100%); margin: 0 auto; }
.small-page-card {
    padding: clamp(24px, 4vh, 36px);
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--paper);
    box-shadow: var(--shadow-card);
}
.small-page-title { margin: 0; font-size: clamp(24px, 2.4vw, 30px); line-height: 1.15; letter-spacing: -0.025em; }
.small-page-copy { margin: 8px 0 22px; color: var(--mute); line-height: 1.6; }
.small-page-form { display: grid; gap: 16px; }
.small-page-field label,
.field label,
.field__label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
}

.small-page-form input[type="text"],
.small-page-form input[type="email"],
.small-page-form input[type="password"],
.small-page-form input[type="number"],
.input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line-2);
    border-radius: 11px;
    background: var(--paper);
    color: var(--ink);
    font: 400 15.5px/1.2 var(--font-main);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.small-page-form input:hover, .input:hover { border-color: #B6C1CB; }
.small-page-form input:focus, .input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(10, 111, 163, 0.14); }
.small-page-form input::placeholder, .input::placeholder { color: #8C98A4; }

.small-page-form .errorlist, .errorlist { margin: 6px 0 0; padding: 0; list-style: none; }
.small-page-form .errorlist li, .errorlist li { margin-top: 2px; color: var(--danger); font-size: 13.5px; }

.small-page-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.small-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: var(--brand);
    color: #fff;
    font: 600 15px/1 var(--font-main);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.25s var(--ease), box-shadow 0.25s;
}
.small-page-btn:hover { background: var(--brand-hover); box-shadow: 0 8px 18px -8px rgba(14, 26, 38, 0.35); }
.small-page-btn--secondary { background: var(--paper); color: var(--ink); border-color: var(--line-2); }
.small-page-btn--secondary:hover { background: #FAFBFC; border-color: #B6C1CB; box-shadow: none; }
.small-page-btn--danger { background: var(--danger); }
.small-page-btn--danger:hover { background: #A8352F; }
.small-page-note { margin-top: 16px; color: var(--mute); font-size: 14px; }
.small-page-link-row { margin-top: 18px; }
.small-page-link { color: var(--brand); font-size: 14.5px; font-weight: 600; text-decoration: none; }
.small-page-link:hover { color: var(--brand-hover); }

@media (max-width: 640px) {
    .small-page-actions { flex-direction: column; }
    .small-page-btn { width: 100%; }
}

/* Password show/hide toggle */
.password-field { position: relative; }
.password-field input { padding-right: 46px !important; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--mute);
    font-size: 14px;
    cursor: pointer;
    transform: translateY(-50%);
    transition: color 0.2s, background-color 0.2s;
}
.password-toggle:hover { color: var(--brand); background: var(--brand-soft); }
.password-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Tags */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 6px;
    background: var(--ok-soft);
    color: var(--ok);
    font: 600 11.5px/1 var(--font-main);
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.tag--brand { background: var(--brand-soft); color: var(--brand-hover); }
.tag--gold { background: var(--gold-soft); color: #7A5610; }
.tag--mute { background: var(--surface); color: var(--mute); }
.tag--new { background: #FDE9DA; color: #A84A16; font-style: normal; }  /* a new world or feature, in Java orange */

/* --------------------------------- */
/* Legal and long-form pages         */
/* --------------------------------- */

.legal-shell { width: min(var(--page-max), 100%); margin: 0 auto; }
.legal-updated {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    color: var(--mute);
    font-size: 14px;
}
.legal-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: clamp(24px, 4vw, 56px);
    align-items: start;
    margin-top: clamp(24px, 4vh, 40px);
}
.legal-toc {
    position: sticky;
    top: calc(var(--header-h) + 16px);
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: calc(100vh - var(--header-h) - 40px);
    overflow-y: auto;
    counter-reset: legal-toc;
}
.legal-toc p { margin: 0 0 10px; color: var(--ink); font-size: 13.5px; font-weight: 600; }
.legal-toc a {
    counter-increment: legal-toc;
    display: flex;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--mute);
    font-size: 14px;
    line-height: 1.4;
    text-decoration: none;
    transition: color 0.2s, background-color 0.2s;
}
.legal-toc a::before { content: counter(legal-toc); min-width: 1.2em; color: #9AA6B2; font-variant-numeric: tabular-nums; }
.legal-toc a:hover, .legal-toc a.is-active { color: var(--ink); background: var(--paper); }
.legal-content {
    counter-reset: legal-section;
    padding: clamp(28px, 4vw, 48px);
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--paper);
}
.legal-content > section { counter-increment: legal-section; margin-top: 36px; padding-top: 36px; border-top: 1px solid var(--line); }
.legal-content > section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.legal-content h2 {
    display: flex;
    gap: 12px;
    margin: 0 0 14px;
    font-size: clamp(20px, 1.8vw, 24px);
    letter-spacing: -0.02em;
    scroll-margin-top: calc(var(--header-h) + 16px);
}
.legal-content h2::before { content: counter(legal-section) "."; color: var(--brand); font-variant-numeric: tabular-nums; }
.legal-content h3 { margin: 24px 0 8px; font-size: 17px; }
.legal-content p, .legal-content ul, .legal-content ol { max-width: 72ch; }
.legal-content p { margin: 0 0 14px; color: var(--ink-2); line-height: 1.75; }
.legal-content ul, .legal-content ol { display: grid; gap: 8px; margin: 10px 0 18px; padding-left: 1.3rem; }
.legal-content li { color: var(--ink-2); line-height: 1.7; }
.legal-content li::marker { color: var(--brand); }
.legal-content a { color: var(--brand); font-weight: 600; text-underline-offset: 3px; }
.legal-content a:hover { color: var(--brand-hover); }
.legal-content strong { color: var(--ink); }
.legal-content code { padding: 1px 6px; border-radius: 5px; background: var(--brand-soft); color: var(--brand-hover); font-size: 0.88em; }
.legal-note {
    display: flex;
    gap: 12px;
    margin: 28px 0 0;
    padding: 16px 18px;
    border-radius: 14px;
    background: var(--warn-soft);
    border: 1px solid rgba(168, 106, 12, 0.22);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.65;
}
.legal-note i { flex-shrink: 0; margin-top: 3px; color: var(--warn); }
.legal-placeholder { padding: 1px 6px; border-radius: 5px; background: var(--danger-soft); color: var(--danger); font-weight: 700; font-style: normal; }

@media (max-width: 860px) {
    .legal-layout { grid-template-columns: 1fr; }
    .legal-toc { position: static; max-height: none; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
}

/* --------------------------------- */
/* Motion                            */
/* --------------------------------- */

/* Groups of cards arrive one after the other (theory, quizzes, docs). */
.rise-in > * { animation: riseIn 0.8s var(--ease) both; }
.rise-in > :nth-child(2) { animation-delay: 0.06s; }
.rise-in > :nth-child(3) { animation-delay: 0.12s; }
.rise-in > :nth-child(4) { animation-delay: 0.18s; }
.rise-in > :nth-child(5) { animation-delay: 0.24s; }
.rise-in > :nth-child(n+6) { animation-delay: 0.3s; }
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Page titles rise out of a mask word by word; marked blocks fade up when they first come into view
   (static/js/site.js adds .motion to <html> unless reduced motion is asked for). */
.motion [data-words] .wm { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.motion [data-words] .wm > span { display: inline-block; transform: translateY(105%); transition: transform 1s var(--ease); transition-delay: calc(var(--i) * 45ms); }
.motion [data-words].in .wm > span { transform: none; }
.motion [data-fade] { opacity: 0; transform: translateY(18px); transition: opacity 0.9s var(--ease), transform 1.1s var(--ease); transition-delay: var(--d, 0s); }
.motion [data-fade].in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
        scroll-behavior: auto !important;
    }
}
