/*
 * Theme: ليالي الفاينل (Finals nights).
 * By day the platform is an exam sheet on a study desk: squared paper, blue ink, a red margin
 * and a yellow highlighter. After dark it is the night before the exam: midnight blue, the
 * amber glow of a desk lamp, a moon and stars over the home page.
 * The ideas, all in plain CSS:
 * - a band on top whose words change by themselves (ركّز… / فاضل القليل / كوباية شاي وكمّل),
 * - headings struck with a highlighter, the eyebrows are sticky notes,
 * - course cards are exam papers with a red margin and a paper clip,
 * - the doctor's photo is a polaroid taped to the desk,
 * - stars twinkle on the home page, and a row of books and a mug closes every page.
 * A theme cannot load anything from other sites, so every picture is drawn inside this file.
 */

/* ---------- Colours ---------- */

html:root, html:root[data-palette] {
    --bg: #f6f4ee;
    --bg-elevated: #fffefb;
    --surface: #fffefb;
    --surface-2: #eef0f8;
    --surface-3: #dfe3f3;
    --border: rgb(38 52 140 / 0.14);
    --border-strong: rgb(38 52 140 / 0.3);
    --fg: #141733;
    --fg-muted: #4b5072;
    --fg-subtle: #7c8099;
    --accent: #2b3cc4;
    --accent-strong: #1f2c99;
    --accent-fg: #ffffff;
    --accent-soft: rgb(43 60 196 / 0.1);
    --glow: rgb(43 60 196 / 0.25);
    --pink: #e0565b;
    --orange: #f4b400;
    --cyan: #2b3cc4;
    --brand: linear-gradient(135deg, #10163d 0%, #2b3cc4 60%, #f4b400 100%);
    --ink: #2b3cc4;
    --marker: rgb(255 214 10 / 0.55);
    --margin-red: #e0565b;
    --shadow-sm: 0 1px 2px rgb(20 23 51 / 0.07);
    --shadow-md: 0 2px 4px rgb(20 23 51 / 0.05), 0 12px 28px -10px rgb(20 23 51 / 0.2);
    --shadow-lg: 0 4px 8px rgb(20 23 51 / 0.06), 0 28px 56px -18px rgb(20 23 51 / 0.32);
}

html.dark, html.dark[data-palette] {
    --bg: #0a0f26;
    --bg-elevated: #10173a;
    --surface: #10173a;
    --surface-2: #161f4a;
    --surface-3: #1e295c;
    --border: rgb(255 200 87 / 0.14);
    --border-strong: rgb(255 200 87 / 0.3);
    --fg: #eef0ff;
    --fg-muted: #b5bad8;
    --fg-subtle: #8187ad;
    --accent: #ffc857;
    --accent-strong: #ffd98a;
    --accent-fg: #14122a;
    --accent-soft: rgb(255 200 87 / 0.13);
    --glow: rgb(255 200 87 / 0.3);
    --pink: #ff8a7a;
    --orange: #ffc857;
    --cyan: #8fa8ff;
    --brand: linear-gradient(135deg, #0a0f26 0%, #26338a 55%, #ffc857 100%);
    --ink: #8fa8ff;
    --marker: rgb(255 200 87 / 0.32);
    --margin-red: #ff8a7a;
}

html { color-scheme: light; }
html.dark { color-scheme: dark; }

/* Squared exam paper by day */
body {
    background-color: var(--bg);
    background-image:
        linear-gradient(rgb(43 60 196 / 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgb(43 60 196 / 0.07) 1px, transparent 1px);
    background-size: 26px 26px;
}
/* The study lamp at night: an amber pool of light at the top, the rest is midnight */
html.dark body {
    background-image:
        radial-gradient(60rem 28rem at 50% -6rem, rgb(255 200 87 / 0.13), transparent 70%),
        linear-gradient(rgb(143 168 255 / 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgb(143 168 255 / 0.04) 1px, transparent 1px);
    background-size: auto, 26px 26px, 26px 26px;
}

.text-gradient {
    background-image: linear-gradient(120deg, #2b3cc4 0%, #6a4cff 50%, #e0565b 100%);
    animation: none;
}
html.dark .text-gradient { background-image: linear-gradient(120deg, #ffc857 0%, #fff1c9 50%, #ff9f6e 100%); }

/* ---------- The band on top: its words change by themselves ---------- */

@keyframes fn-words {
    0%, 24%   { content: '\1F319\00a0 ليالي الفاينل… ركّز، الليلة دي هتفرق'; }
    25%, 49%  { content: '\270F\FE0F\00a0 محاضرة كمان وراجع اللي فات… فاضل القليل'; }
    50%, 74%  { content: '\2615\00a0 كوباية شاي، نفس عميق، وكمّل'; }
    75%, 100% { content: '\1F4AA\00a0 دكتور محمد الفار معاك لآخر ليلة'; }
}

body::before {
    content: '\1F319\00a0 ليالي الفاينل… ركّز، الليلة دي هتفرق';
    display: block;
    height: 2.8rem;
    line-height: 2.8rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding-inline: 1rem;
    text-align: center;
    font-weight: 800;
    font-size: clamp(.85rem, 3.4vw, 1.05rem);
    color: #fff3cf;
    background:
        radial-gradient(1px 1px at 12% 30%, #fff 50%, transparent 51%),
        radial-gradient(1px 1px at 27% 70%, #fff 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 44% 25%, #fff 50%, transparent 51%),
        radial-gradient(1px 1px at 63% 65%, #fff 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 81% 35%, #fff 50%, transparent 51%),
        radial-gradient(1px 1px at 93% 72%, #fff 50%, transparent 51%),
        linear-gradient(90deg, #0a0f26, #1b2466 50%, #0a0f26);
    border-bottom: 2px solid #ffc857;
    animation: fn-words 24s steps(1, end) infinite;
}

/* ---------- Writing: highlighter headings, sticky-note eyebrows ---------- */

h1, h2 { letter-spacing: normal !important; }

/* The key word of a heading is marked with a highlighter, as on a revision sheet */
h1 .text-gradient, h2 .text-gradient, .text-center > h2 {
    background-image: linear-gradient(transparent 58%, var(--marker) 58%, var(--marker) 92%, transparent 92%);
    -webkit-background-clip: border-box;
    background-clip: border-box;
    -webkit-text-fill-color: currentColor;
    color: var(--fg);
    padding-inline: .15em;
    border-radius: .15em;
}

/* Eyebrows: a little yellow sticky note, slightly crooked */
.eyebrow {
    background: #ffe66d;
    color: #3b2f00;
    border-radius: 2px 2px 10px 2px;
    padding: .3rem .8rem;
    font-weight: 800;
    transform: rotate(-1.5deg);
    box-shadow: 0 6px 12px -6px rgb(0 0 0 / 0.35);
}
.eyebrow svg { color: #3b2f00; }
html.dark .eyebrow { background: #ffc857; color: #2a2100; }

/* A pencil underline under centred section titles */
.text-center > h2::after {
    content: '';
    display: block;
    width: 9rem;
    height: 14px;
    margin: .8rem auto 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='144' height='14' viewBox='0 0 144 14'%3E%3Cpath d='M3 9c20-5 40-6 62-4s44 3 76-3' fill='none' stroke='%23e0565b' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- Cards: exam papers ---------- */

.card, .university-card {
    border-color: var(--border-strong);
}

/* Course cards: a sheet with a red margin and a paper clip on top */
a.card[data-accent] {
    position: relative;
    overflow: visible;
    border-radius: .5rem;
    /* the red margin of an exam sheet, on the side the writing starts from */
    border-inline-start: 4px double var(--margin-red);
    box-shadow: 4px 4px 0 -1px var(--surface), 4px 4px 0 0 var(--border-strong), var(--shadow-sm);
    transition: transform .25s ease, box-shadow .25s ease;
}
a.card[data-accent]:hover { transform: rotate(-.6deg) translateY(-3px); }
a.card[data-accent]::after {
    content: '';
    position: absolute;
    top: -12px;
    left: 1.4rem;
    width: 16px;
    height: 40px;
    pointer-events: none;
    z-index: 2;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='40' viewBox='0 0 16 40'%3E%3Cpath d='M5 30V8a3 3 0 0 1 6 0v24a5 5 0 0 1-10 0V6a7 7 0 0 1 14 0v20' fill='none' stroke='%239aa3b5' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
a.card[data-accent] > div:first-child { border-radius: .35rem; }

.faculty-card, .free-card { border-radius: .6rem; }
.faculty-card { box-shadow: 4px 4px 0 -1px var(--surface), 4px 4px 0 0 var(--border-strong), var(--shadow-sm); }

/* Buttons: written in ink */
.btn-primary, button[type=submit].bg-accent { box-shadow: 0 3px 0 var(--accent-strong); }

/* ---------- The doctor: a polaroid taped to the desk ---------- */

.portrait-ring, .portrait-dots { display: none; }
.portrait-disc {
    border-radius: .4rem;
    background: #fff;
    box-shadow: 0 0 0 10px #fff, 0 0 0 11px rgb(0 0 0 / 0.08), 0 30px 60px -25px rgb(0 0 0 / 0.5);
    transform: rotate(-2.5deg);
}
html.dark .portrait-disc { background: #f3f1ea; box-shadow: 0 0 0 10px #f3f1ea, 0 30px 70px -20px rgb(0 0 0 / 0.8), 0 0 80px -10px var(--glow); }
.portrait-glow { border-radius: .6rem; }
.portrait-img { clip-path: inset(-50% 0 0 0 round 0 0 .4rem .4rem); }
[data-portrait] { position: relative; }
[data-portrait]::before {
    content: '';
    position: absolute;
    top: 1%;
    left: 50%;
    width: 7rem;
    height: 1.7rem;
    transform: translateX(-50%) rotate(-4deg);
    background: rgb(255 230 109 / 0.75);
    box-shadow: 0 2px 4px rgb(0 0 0 / 0.12);
    z-index: 5;
    pointer-events: none;
}

/* ---------- The home page: a night sky with a moon ---------- */

@keyframes fn-twinkle { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

#main > section:has([data-portrait]) { position: relative; isolation: isolate; }
#main > section:has([data-portrait])::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .0;
}
html.dark #main > section:has([data-portrait])::before {
    opacity: 1;
    background:
        radial-gradient(2px 2px at 8% 18%, #fff 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 18% 62%, #fff 50%, transparent 51%),
        radial-gradient(2px 2px at 31% 12%, #ffe9b0 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 46% 40%, #fff 50%, transparent 51%),
        radial-gradient(2px 2px at 58% 8%, #fff 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 72% 52%, #ffe9b0 50%, transparent 51%),
        radial-gradient(2px 2px at 86% 22%, #fff 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 94% 70%, #fff 50%, transparent 51%);
    animation: fn-twinkle 4s ease-in-out infinite;
}
/* The crescent moon over the home page */
#main > section:has([data-portrait])::after {
    content: '';
    position: absolute;
    top: 1.2rem;
    left: 6%;
    width: 64px;
    height: 64px;
    z-index: -1;
    pointer-events: none;
    opacity: .9;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cpath d='M40 6a26 26 0 1 0 18 44A22 22 0 0 1 40 6z' fill='%23ffc857'/%3E%3C/svg%3E") center / contain no-repeat;
    filter: drop-shadow(0 0 18px rgb(255 200 87 / 0.6));
}
html:not(.dark) #main > section:has([data-portrait])::after { opacity: .55; filter: none; }

/* ---------- Books, a pencil and a mug close every page ---------- */

#main + footer, footer.border-t { position: relative; }
footer.border-t::before {
    content: '';
    display: block;
    height: 58px;
    margin-top: -58px;
    pointer-events: none;
    opacity: .5;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='58' viewBox='0 0 360 58'%3E%3Cg%3E%3Crect x='0' y='54' width='360' height='4' fill='%238187ad'/%3E%3Crect x='20' y='14' width='14' height='40' rx='2' fill='%232b3cc4'/%3E%3Crect x='35' y='22' width='12' height='32' rx='2' fill='%23e0565b'/%3E%3Crect x='48' y='8' width='16' height='46' rx='2' fill='%23f4b400'/%3E%3Crect x='65' y='18' width='11' height='36' rx='2' fill='%236a4cff'/%3E%3Crect x='96' y='44' width='70' height='10' rx='2' fill='%232b3cc4'/%3E%3Crect x='100' y='34' width='62' height='10' rx='2' fill='%23e0565b'/%3E%3Crect x='212' y='48' width='48' height='4' rx='2' fill='%23f4b400' transform='rotate(-8 236 50)'/%3E%3Cpath d='M290 30h28v20a6 6 0 0 1-6 6h-16a6 6 0 0 1-6-6z' fill='%238187ad'/%3E%3Cpath d='M318 35h5a5 5 0 0 1 0 10h-5' fill='none' stroke='%238187ad' stroke-width='3'/%3E%3Cpath d='M298 24c-3-4 3-6 0-10M308 24c-3-4 3-6 0-10' fill='none' stroke='%238187ad' stroke-width='2' stroke-linecap='round'/%3E%3C/g%3E%3C/svg%3E") center bottom / 360px 58px repeat-x;
}

/* ---------- Progress bars: a pen filling the line ---------- */

progress { accent-color: var(--accent); }

/* ---------- Small screens and calm ---------- */

@media (max-width: 640px) {
    #main > section:has([data-portrait])::after { width: 44px; height: 44px; top: .6rem; }
    a.card[data-accent]:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    body::before, #main > section:has([data-portrait])::before { animation: none !important; }
}

/* The theme sets the colours, so the colour picker would change nothing: it is hidden
   while the theme is on and comes back with the platform's own look. */
.palette, [data-palette-switcher] { display: none !important; }

a[aria-label] > .bg-brand { box-shadow: inset 0 0 0 1.5px #ffc857; }

@media print {
    body::before, footer.border-t::before, #main > section:has([data-portrait])::before, #main > section:has([data-portrait])::after, a.card[data-accent]::after, [data-portrait]::before { display: none; }
    body { background-image: none; }
}
