/* The look follows the website of the authors' faculty, finki.ukim.mk: its navy-to-blue
   gradient, yellow buttons, square white cards on a light grey page, and wide-spaced
   capital titles. Only colours, shapes and type treatment are borrowed; no logo or image.

   Layout: a header with the title, authors and the Python loader; the ten lessons as a
   row of tiles; lesson text on the left, editor and result on the right; one column on
   narrow screens. The page is light only, as the faculty's site is. */

/* Fira Sans, the font of the faculty's site, served from this site (see fonts/LICENSE.txt). */
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/fira-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/fira-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/fira-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/fira-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 800; font-display: swap; src: url("fonts/fira-sans-latin-800-normal.woff2") format("woff2"); }

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --raised: #f6f6f6;
  --ink: #1b1b1b;
  --muted: #5b6270;
  --line: #e6e6e6;
  --navy: #2c3179;
  --navy-deep: #1f2360;
  --blue: #2b92d0;
  --link: #1c74ae;                 /* the blue, darkened until text in it is readable on white */
  --hairline: rgba(44, 49, 121, 0.14);
  --yellow: #f1cc16;
  --yellow-deep: #e0bc0d;
  --bad: #b42318;
  --bad-soft: #fdeceb;
  --good: #136b48;
  --good-soft: #e6f4ec;
  --blue-soft: #eaf4fb;
  --grad: linear-gradient(90deg, #2c3179 0%, #2b92d0 100%);
  /* Behind white text the gradient stops short of its lightest blue, so the text stays readable. */
  --grad-text-right: linear-gradient(270deg, #2b92d0 -35%, #2c3179 100%);
  --grad-text-left: linear-gradient(90deg, #2b92d0 -35%, #2c3179 100%);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
  --shadow-hero: 0 8px 24px rgba(21, 26, 70, 0.16);
  --font-body: "Fira Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --code-size: 13.5px;
  --code-line: 21px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* the rules below set "display", which would otherwise win */
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font-body); }
.wrap { max-width: 1440px; margin-inline: auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
@media (min-width: 900px) { .wrap { width: min(90vw, 1440px); padding-inline: 0; } }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--navy); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); font-weight: 800; letter-spacing: 0.01em; text-transform: uppercase; color: var(--navy); }
h2 { font-size: 1.5rem; font-weight: 600; }
/* Section labels: capitals, wide spacing, a short blue rule under the words. */
h3 { width: fit-content; font-size: 0.875rem; font-weight: 500; line-height: 1.4; letter-spacing: 0.18em; text-transform: uppercase; color: #111111; margin-top: 26px; margin-bottom: 10px; padding-bottom: 7px; border-bottom: 3px solid var(--blue); }
p { margin: 0; }
.small { font-size: 13px; color: var(--muted); }
.eyebrow { font-size: 11px; line-height: 1.5; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.section-title { font-size: 1.125rem; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; color: #000000; }

/* ---------- header ---------- */
.top { position: relative; }
/* Part of a ring in the top left corner. Its size follows the width of the window, so that it
   stays inside the page margin and clear of the title beside it. */
@media (min-width: 900px) {
  .top::before { content: ""; position: absolute; left: -29vw; top: -29vw; width: 36vw; height: 36vw; border-radius: 50%; background: linear-gradient(90deg, #2c3179 82%, #2b92d0 90%); -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 2vw), #000 calc(100% - 2vw + 1px)); mask: radial-gradient(closest-side, transparent calc(100% - 2vw), #000 calc(100% - 2vw + 1px)); pointer-events: none; }
}
/* The top of the page is a grid. On wide screens the title stands on the same line as the
   blue strip, with the status card under the strip; on narrow screens they stack. */
.top-grid { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "brand" "card"; padding-bottom: 30px; }
@media (min-width: 900px) {
  .top-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "brand bar" "brand card"; column-gap: 32px; }
}
.topbar { grid-area: bar; position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 28px; min-height: 45px; padding: 8px 20px; background: var(--grad-text-left); color: #ffffff; font-size: 13px; letter-spacing: 0.05em; }
.topbar a { color: #ffffff; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.topbar :focus-visible, .foot :focus-visible { outline-color: #ffffff; }

.brand { grid-area: brand; align-self: start; display: flex; flex-direction: column; gap: 10px; min-width: 0; margin-top: 30px; }
@media (min-width: 900px) {
  .brand { margin-top: 0; }
  .brand h1 { display: flex; align-items: center; min-height: 45px; line-height: 1.1; }   /* as tall as the strip, so the two share a centre line */
}
.tagline { max-width: 60ch; font-size: 1.05rem; color: #333333; }
.byline { margin-top: 4px; font-size: 14px; }
.byline strong { font-weight: 600; color: var(--navy); }

/* The loader is the page's one "hero card": white, a gradient band on top, a navy-tinted shadow.
   It says what the page is, then whether Python is ready. */
.loader { grid-area: card; align-self: start; position: relative; display: flex; flex-direction: column; gap: 10px; margin-top: 26px; padding: 24px 26px 20px; background: var(--surface); box-shadow: var(--shadow-hero); }
@media (min-width: 900px) { .loader { justify-self: end; width: min(390px, 100%); } }
.loader::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--grad); }
.loader-label { padding-bottom: 10px; border-bottom: 1px solid var(--hairline); font-size: 11px; line-height: 1.5; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.status { font-size: 1rem; font-weight: 600; line-height: 1.35; color: var(--navy); }
.status.ok { color: var(--good); }
.status.fail { color: var(--bad); }
progress { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 6px; border: 0; border-radius: 0; background: var(--hairline); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--hairline); }
progress::-webkit-progress-value { background: var(--grad); transition: width 0.25s ease; }
progress::-moz-progress-bar { background: var(--grad); }
@media (prefers-reduced-motion: reduce) { progress::-webkit-progress-value { transition: none; } }
.loader .small { margin-top: -4px; }

.load-error { margin-bottom: 24px; padding: 18px 22px 20px; border-top: 6px solid var(--bad); background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.load-error-title { font-weight: 700; color: var(--bad); }
.load-error ul { font-size: 14.5px; }

/* Small navy squares mark list items. */
.lesson ul, .load-error ul { list-style: none; margin: 8px 0 0; padding: 0; }
.lesson li, .load-error li { position: relative; margin-bottom: 6px; padding-left: 18px; }
.lesson li::before, .load-error li::before { content: ""; position: absolute; left: 1px; top: 0.62em; width: 6px; height: 6px; background: var(--navy); }

/* ---------- the ten lessons ---------- */
.lessons { padding-bottom: 6px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; margin-bottom: 14px; }
.solved { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
/* A tile: the category number in a block of its own, the name beside it. */
.tab { display: grid; grid-template-columns: 62px minmax(0, 1fr); align-items: center; column-gap: 12px; min-height: 62px; padding: 0 12px 0 0; border: 0; border-radius: 0; background: var(--surface); color: #222222; font: 400 13.5px/1.25 var(--font-body); text-align: left; cursor: pointer; box-shadow: inset 0 -3px 0 transparent; }
.tab .tab-id { align-self: stretch; display: grid; place-items: center; border-right: 3px solid var(--bg); font-size: 17px; font-weight: 700; color: var(--navy); white-space: nowrap; }
.tab:hover { box-shadow: inset 0 -3px 0 var(--blue); }
.tab[aria-current="true"] { box-shadow: inset 0 -3px 0 var(--blue); font-weight: 600; color: #000000; }
.tab[aria-current="true"] .tab-id { background: var(--navy); color: #ffffff; }
.tab.done .tab-id { font-size: 14px; color: var(--good); }
.tab[aria-current="true"].done .tab-id { color: #ffffff; }
/* Narrower screens: number tiles only; the open lesson's name is its heading just below. */
@media (max-width: 1099px) {
  .tabs { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; }
  .tab { display: flex; align-items: stretch; min-height: 46px; padding: 0; font-size: 0; }
  .tab .tab-id { flex: 1; border-right: 0; font-size: 15px; }
  .tab.done .tab-id { font-size: 12.5px; }
}
@media (max-width: 619px) { .tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* ---------- lesson and exercise ---------- */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 28px; padding-block: 28px 36px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }
.lesson { min-width: 0; background: var(--surface); padding: 34px 32px 32px; box-shadow: var(--shadow); }
@media (max-width: 619px) { .lesson { padding: 24px 18px; } }
.lesson h2 { margin-top: 8px; }
.lesson .summary { font-size: 1.08rem; margin-top: 12px; color: #222222; }
details { margin-top: 14px; border: 1px solid var(--line); background: var(--raised); }
details > summary { cursor: pointer; padding: 10px 14px; font-size: 14px; font-weight: 500; color: var(--navy); }
details[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface); }
details > p { padding: 12px 14px; }
.after { margin-top: 26px; padding: 0 18px 16px; background: var(--blue-soft); }
.after h3 { margin-top: 0; padding-top: 16px; }
.after .small { margin-top: 8px; }

.work { min-width: 0; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 12px; }
@media (max-width: 900px) { .work { position: static; } }
/* The three steps, set like a row of figures: a heavy navy number, a small spaced label. */
.steps { display: flex; flex-wrap: wrap; gap: 6px 34px; margin: 0; padding: 0 0 12px; list-style: none; border-bottom: 1px solid var(--hairline); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.steps li { display: flex; align-items: baseline; gap: 9px; }
.steps b { font-size: 22px; font-weight: 800; line-height: 1; letter-spacing: 0; color: var(--navy); }

.card { background: var(--surface); overflow: hidden; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; padding: 14px 20px 12px; border-bottom: 1px solid var(--line); }
.card-head label, .card-head > span:first-child { font-size: 0.875rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: #111111; }

/* ---------- code: the colours of VS Code's default dark theme ----------
   Every place that shows code uses the same dark surface and token colours,
   as an embedded editor would. */
.ide, pre.code, .printed {
  --vsc-bg: #1f1f1f;          /* editor.background */
  --vsc-bar: #181818;         /* title and status bars */
  --vsc-fg: #cccccc;          /* editor.foreground */
  --vsc-border: #2b2b2b;
  --vsc-line-number: #6e7681;
  --vsc-selection: #264f78;
  --vsc-cursor: #aeafad;
  --vsc-error: #f85149;
  --vsc-warning: #cca700;
  --vsc-ok: #73c991;
}
.tk-c { color: #6a9955; }     /* comment */
.tk-s { color: #ce9178; }     /* string */
.tk-e { color: #d7ba7d; }     /* escape sequence */
.tk-n { color: #b5cea8; }     /* number */
.tk-k { color: #569cd6; }     /* def, class, True, None, and, self */
.tk-f { color: #c586c0; }     /* if, for, return, import */
.tk-d { color: #dcdcaa; }     /* function name, decorator */
.tk-t { color: #4ec9b0; }     /* class, type, module */
.tk-v { color: #9cdcfe; }     /* variable, parameter */
.tk-o { color: #4fc1ff; }     /* CONSTANT */

.ide { background: var(--vsc-bg); color-scheme: dark; box-shadow: var(--shadow-hero); }
.ide-bar { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: space-between; gap: 0 12px; background: var(--vsc-bar); border-bottom: 1px solid var(--vsc-border); }
.ide-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--vsc-bg); color: var(--vsc-fg); border-top: 1px solid #0078d4; border-right: 1px solid var(--vsc-border); font: 13px/1.4 var(--font-body); }
.ide-dot { width: 9px; height: 9px; border-radius: 2px; background: #3572a5; }   /* the Python file colour */
.ide-hint { align-self: center; padding: 4px 14px; color: #9d9d9d; font-size: 12.5px; }

.editor-box { display: flex; align-items: stretch; background: var(--vsc-bg); height: 380px; }
.gutter { flex: none; width: 48px; overflow: hidden; padding: 14px 0; text-align: right; color: var(--vsc-line-number); font: var(--code-size)/var(--code-line) var(--font-mono); user-select: none; }
.gutter span { display: block; padding-right: 12px; height: var(--code-line); }
.gutter span.err { background: var(--vsc-error); color: #1f1f1f; font-weight: 700; }
.code-area { position: relative; flex: 1; min-width: 0; }
/* The coloured copy lies under a transparent text box of exactly the same metrics. */
.highlight, #editor { position: absolute; inset: 0; margin: 0; padding: 14px 16px 14px 4px; border: 0; font: var(--code-size)/var(--code-line) var(--font-mono); letter-spacing: 0; tab-size: 4; white-space: pre; word-wrap: normal; overflow-wrap: normal; }
.highlight { overflow: hidden; color: var(--vsc-fg); pointer-events: none; padding-right: 48px; }
#editor { width: 100%; height: 100%; resize: none; overflow: auto; background: transparent; color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--vsc-cursor); outline: none; }
#editor::selection { background: var(--vsc-selection); }
#editor:focus-visible { outline: 1px solid #0078d4; outline-offset: -1px; }
.lint { min-height: 30px; margin: 0; padding: 5px 14px; background: var(--vsc-bar); border-top: 1px solid var(--vsc-border); font: 12.5px/1.55 var(--font-mono); color: #9d9d9d; overflow-wrap: anywhere; }
.lint.err { color: var(--vsc-error); }
.lint.warn { color: var(--vsc-warning); }
.lint.ok { color: var(--vsc-ok); }

pre.code { margin: 0; padding: 12px 14px; overflow-x: auto; background: var(--vsc-bg); color: var(--vsc-fg); font: 13px/1.6 var(--font-mono); color-scheme: dark; }

/* ---------- buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.btn { font: 500 14.4px/1 var(--font-body); padding: 11.5px 22px; border-radius: 4px; border: 1px solid var(--navy); background: var(--surface); color: var(--navy); cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease; }
.btn:hover:not(:disabled) { background: var(--navy); color: #ffffff; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.navy { background: var(--navy); color: #ffffff; }
.btn.navy:hover:not(:disabled) { background: var(--navy-deep); border-color: var(--navy-deep); }
.btn.cta { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.btn.cta:hover:not(:disabled) { background: var(--yellow-deep); border-color: var(--yellow-deep); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

/* ---------- result ---------- */
.result { padding: 16px 20px 18px; min-height: 96px; display: flex; flex-direction: column; gap: 8px; }
.verdict { font-weight: 600; font-size: 1.02rem; padding: 10px 14px; }
.verdict.pass { color: var(--good); background: var(--good-soft); }
.verdict.fail { color: var(--bad); background: var(--bad-soft); }
.line { font: 13px/1.55 var(--font-mono); overflow-wrap: anywhere; }
.line b.bad { color: var(--bad); }
.line b.good { color: var(--good); }
.printed { margin: 0; padding: 10px 12px; background: var(--vsc-bg); color: var(--vsc-fg); font: 12.5px/1.55 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- compatibility check ---------- */
.compat { padding-block: 34px 44px; border-top: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 14px; }
.compat > p { max-width: 80ch; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--surface); box-shadow: var(--shadow); }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; font-weight: 500; line-height: 1.4; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--navy); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.ok { color: var(--good); font-weight: 600; }
td.no { color: var(--bad); font-weight: 600; }
td.detail { font: 12.5px/1.5 var(--font-mono); overflow-wrap: anywhere; }

/* ---------- footer ---------- */
.foot { padding-block: 44px 22px; background: var(--grad-text-right); color: #ffffff; font-size: 14px; line-height: 1.5; }
.foot-grid { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: 26px 56px; }
@media (max-width: 760px) { .foot-grid { grid-template-columns: minmax(0, 1fr); } }
.foot-grid > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.foot-title { margin-bottom: 6px; font-size: 1rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; }
.foot-names { font-weight: 600; }
.foot a { color: #ffffff; }
.foot a:hover { color: #ffffff; text-decoration-thickness: 2px; }
.foot .small { color: rgba(255, 255, 255, 0.88); }
.foot-bottom { margin-top: 30px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.25); text-align: center; font-size: 13px; }
