:root {
  --purple-900: #2d2165;
  --purple-800: #463691;
  --purple-700: #684dac;
  --purple-100: #eee9fa;
  --ink: #242331;
  --muted: #625f6f;
  --line: #dedce6;
  --surface: #f6f7fc;
  --white: #ffffff;
  --gold: #e9ad2f;
  --teal: #167a75;
  --secondary-action-text: #0f5f5a;
  --secondary-action-text-hover: #0b4c48;
  --secondary-action-border: #91c5c1;
  --secondary-action-bg: #f1f9f8;
  --secondary-action-bg-hover: #e5f5f3;
  --secondary-action-bg-active: #d8eeec;
  --input-line: #8f8a9d;
  --danger-bg: #fff5df;
  --danger-line: #d59022;
  --danger-text: #5d3c00;
  --shadow: 0 3px 8px rgba(37, 29, 72, 0.12);
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --content: 1180px;
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--white);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0;
}

img { display: block; max-width: 100%; }
a { color: var(--purple-800); text-underline-offset: 3px; }
button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }

:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--purple-900);
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--white);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.site-header { border-bottom: 1px solid var(--line); background: var(--white); }
.nav-shell, .catalogue-heading, .catalogue-shell, .footer-shell, .breadcrumb, .course-intro, .detail-shell, .plain-shell {
  width: min(calc(100% - 40px), var(--content));
  margin-inline: auto;
}
.nav-shell { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 14px; color: var(--purple-900); font-weight: 750; text-decoration: none; }
.brand img { width: 112px; height: 50px; object-fit: contain; }
.brand span { padding-left: 14px; border-left: 1px solid var(--line); }
nav { display: flex; align-items: center; gap: 24px; }
nav a { min-height: 44px; display: inline-flex; align-items: center; color: var(--ink); font-size: 0.94rem; font-weight: 650; text-decoration: none; }
nav a:hover { color: var(--purple-700); }
nav a:active { color: var(--purple-900); }

.catalogue-band {
  position: relative;
  min-height: 184px;
  display: grid;
  align-items: center;
  color: var(--white);
  background-color: var(--purple-800);
  background-image: linear-gradient(90deg, rgba(45, 33, 101, 0.93), rgba(70, 54, 145, 0.72)), url("images/hero.jpg");
  background-size: cover;
  background-position: center;
}
.catalogue-heading { padding-block: var(--space-lg); }
.catalogue-heading h1, .course-intro h1, .plain-shell h1 {
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 5vw, 4.6rem);
  line-height: 1.02;
  font-weight: 700;
  letter-spacing: 0;
}
.catalogue-heading h1 { margin-bottom: var(--space-xs); font-size: 3.4rem; line-height: 1; }
.catalogue-heading p:last-child { max-width: 58ch; margin: 0; font-size: 1rem; line-height: 1.5; }
.eyebrow { margin: 0 0 var(--space-2xs); color: var(--gold); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }

.catalogue-shell { padding-block: var(--space-xl) var(--space-2xl); }
.catalogue-tools { display: flex; align-items: end; justify-content: space-between; gap: var(--space-lg); margin-bottom: var(--space-lg); }
.catalogue-tools h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.7rem; line-height: 1.2; }
.catalogue-tools p { margin: 4px 0 0; color: var(--muted); }
.filters { display: grid; grid-template-columns: minmax(230px, 330px) auto; align-items: end; gap: var(--space-xs) var(--space-md); }
.filters label { grid-column: 1; font-size: 0.82rem; font-weight: 750; }
.filters input { grid-column: 1; min-height: 44px; padding: 9px 12px; border: 1px solid var(--input-line); border-radius: 4px; color: var(--ink); background: var(--white); }
.filters input::placeholder { color: var(--muted); opacity: 1; }
.segment { grid-column: 2; grid-row: 1 / span 2; display: inline-flex; align-self: end; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.segment button { min-height: 44px; padding: 6px 12px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; cursor: pointer; transition: color 180ms var(--ease-out), background-color 180ms var(--ease-out); }
.segment button:not(.active):hover { color: var(--ink); background: var(--white); }
.segment button:not(.active):active { background: var(--purple-100); }
.segment button.active { color: var(--white); background: var(--purple-800); }

.course-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-md); }
.course-card { min-width: 0; display: flex; overflow: hidden; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; background: var(--white); box-shadow: var(--shadow); }
.course-card[hidden] { display: none; }
.course-image { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface); }
.course-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 180ms var(--ease-out); }
.course-card-body { min-height: 0; display: flex; flex: 1; flex-direction: column; padding: var(--space-md); }
.course-meta { min-height: 24px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); color: var(--muted); font-size: 0.78rem; font-weight: 650; }
.status-tag { padding: 2px 7px; border: 1px solid #99cbc7; border-radius: 3px; color: #0f5f5a; background: #eaf7f6; }
.course-card h2 { margin: var(--space-xs) 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.25rem; line-height: 1.24; }
.course-card h2 a { color: var(--purple-900); text-decoration: none; }
.course-card h2 a:hover { text-decoration: underline; }
.course-card h2 a:active { color: var(--purple-700); }
.course-card-body > p { display: -webkit-box; overflow: hidden; margin: 0 0 var(--space-sm); color: var(--muted); font-size: 0.875rem; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.text-link { min-height: 44px; display: inline-flex; align-items: center; gap: 4px; font-weight: 750; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.text-link:active { color: var(--purple-900); }
.course-card-actions { display: flex; flex-direction: column; align-items: stretch; gap: var(--space-xs); margin-top: auto; }
.course-card-actions > .text-link { align-self: flex-start; }
.moodle-downloads { padding-top: 12px; border-top: 1px solid var(--line); }
.moodle-downloads-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.moodle-download-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.moodle-download {
  min-width: 0;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--secondary-action-border);
  border-radius: 5px;
  color: var(--secondary-action-text);
  background: var(--secondary-action-bg);
  font-size: 0.78rem;
  line-height: 1.2;
  text-decoration: none;
  transition: color 180ms var(--ease-out), border-color 180ms var(--ease-out), background-color 180ms var(--ease-out);
}
.moodle-download:hover { color: var(--secondary-action-text-hover); border-color: var(--teal); background: var(--secondary-action-bg-hover); }
.moodle-download:active { background: var(--secondary-action-bg-active); }
.download-icon { width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; border-radius: 50%; color: var(--white); background: var(--teal); font-size: 0.92rem; font-weight: 800; }
.moodle-download strong, .moodle-download small { display: block; }
.moodle-download strong { font-weight: 750; }
.moodle-download small { margin-top: 2px; color: var(--secondary-action-text); font-size: 0.75rem; }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); background: var(--surface); }

.site-footer { color: var(--white); background: var(--purple-900); }
.footer-shell { display: grid; grid-template-columns: 150px 1fr 1.2fr; gap: 36px; align-items: start; padding-block: 48px; }
.footer-shell img { width: 118px; }
.footer-shell p { margin: 4px 0 0; color: #e5e0f2; font-size: 0.88rem; }
.footer-shell a { color: var(--white); }

.breadcrumb { display: flex; gap: 10px; padding-block: 22px; color: var(--muted); font-size: 0.88rem; }
.course-intro { display: grid; grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.35fr); gap: 54px; align-items: center; padding-block: 22px 58px; }
.course-intro-media { overflow: hidden; aspect-ratio: 4 / 3; border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); }
.course-intro-media img { width: 100%; height: 100%; object-fit: cover; }
.course-intro h1 { max-width: 790px; font-size: clamp(2.2rem, 4.4vw, 4.15rem); color: var(--purple-900); }
.lead { max-width: 820px; color: #4e4a59; font-size: 1.08rem; }
.facts { display: flex; flex-wrap: wrap; gap: 14px 34px; margin: 24px 0 28px; }
.facts div { min-width: 110px; }
.facts dt { color: var(--muted); font-size: 0.75rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.07em; }
.facts dd { margin: 2px 0 0; font-weight: 700; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.primary-button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; padding: 10px 22px; border-radius: 5px; color: var(--white); background: var(--purple-800); font-weight: 750; text-decoration: none; transition: background-color 180ms var(--ease-out); }
.primary-button:hover { background: var(--purple-900); }
.primary-button:active { background: var(--purple-700); }
.source-link { min-height: 44px; display: inline-flex; align-items: center; font-size: 0.9rem; }
.detail-shell { max-width: 880px; padding-bottom: 72px; }
.detail-section { padding-block: 32px; border-top: 1px solid var(--line); }
.detail-section h2 { margin: 0 0 14px; color: var(--purple-900); font-family: Georgia, "Times New Roman", serif; font-size: 1.75rem; }
.detail-section ul { margin: 0; padding-left: 22px; }
.detail-section li + li { margin-top: 9px; }
.topic-list { columns: 2; column-gap: 46px; }
.topic-list li { break-inside: avoid; margin-bottom: 9px; }
.archive-note p { color: var(--muted); }
.package-warning { margin: 0 0 20px; padding: 16px 18px; border: 1px solid var(--danger-line); border-radius: 6px; color: var(--danger-text); background: var(--danger-bg); }
.package-warning p { margin: 4px 0 0; }

.plain-shell { max-width: 880px; min-height: 62vh; padding-block: 58px 82px; }
.plain-shell h1 { color: var(--purple-900); }
.plain-shell code { padding: 2px 5px; background: var(--surface); }

.player-page { height: 100dvh; overflow: hidden; background: #15141c; }
.player-app { height: 100dvh; display: grid; grid-template-rows: 62px auto minmax(0, 1fr); }
.player-bar { z-index: 2; grid-row: 1; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center; min-width: 0; padding: 8px 18px; color: var(--white); background: var(--purple-900); }
.icon-link { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 4px; color: var(--white); font-size: 1.55rem; text-decoration: none; }
.icon-link:hover { background: rgba(255,255,255,0.12); }
.player-title { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.player-title span { color: #cfc7e8; font-size: 0.72rem; }
.player-title strong { overflow: hidden; font-size: 0.92rem; text-overflow: ellipsis; white-space: nowrap; }
.progress-summary { display: flex; align-items: center; gap: 14px; color: #e8e3f4; font-size: 0.78rem; }
.progress-summary button { min-height: 44px; padding: 5px 10px; border: 1px solid rgba(255,255,255,0.48); border-radius: 4px; color: var(--white); background: transparent; cursor: pointer; transition: background-color 180ms var(--ease-out); }
.progress-summary button:hover { background: rgba(255,255,255,0.1); }
.progress-summary button:active { background: rgba(255,255,255,0.18); }
.player-notice { grid-row: 2; padding: 8px 16px; color: var(--danger-text); background: #fff0c7; text-align: center; font-size: 0.84rem; }
#course-frame { grid-row: 3; width: 100%; height: 100%; border: 0; background: var(--white); }

@media (hover: hover) {
  .course-card:hover .course-image img { transform: scale(1.025); }
}

@media (max-width: 900px) {
  .course-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalogue-tools { align-items: stretch; flex-direction: column; gap: var(--space-md); }
  .filters { grid-template-columns: minmax(0, 1fr) auto; }
  .course-intro { grid-template-columns: 0.8fr 1.2fr; gap: 32px; }
  .footer-shell { grid-template-columns: 120px 1fr; }
  .footer-shell > p { grid-column: 2; }
}

@media (max-width: 680px) {
  .nav-shell, .catalogue-heading, .catalogue-shell, .footer-shell, .breadcrumb, .course-intro, .detail-shell, .plain-shell { width: min(calc(100% - 28px), var(--content)); }
  .nav-shell { min-height: 68px; }
  .brand img { width: 92px; height: 42px; }
  .brand span { display: none; }
  nav { gap: 13px; }
  nav a { font-size: 0.875rem; }
  .catalogue-band { min-height: 160px; }
  .catalogue-heading { padding-block: var(--space-md); }
  .catalogue-heading h1 { font-size: 2.2rem; }
  .course-intro h1, .plain-shell h1 { font-size: 2.35rem; }
  .catalogue-shell { padding-block: var(--space-lg) var(--space-2xl); }
  .filters { grid-template-columns: 1fr; }
  .segment { grid-column: 1; grid-row: auto; width: 100%; }
  .segment button { flex: 1; padding-inline: 7px; }
  .course-grid { grid-template-columns: 1fr; }
  .course-meta, .moodle-downloads-label, .moodle-download, .moodle-download small { font-size: 0.875rem; }
  .course-intro { grid-template-columns: 1fr; gap: 28px; padding-block: 8px 48px; }
  .course-intro-media { aspect-ratio: 16 / 9; }
  .topic-list { columns: 1; }
  .footer-shell { grid-template-columns: 1fr; gap: 22px; }
  .footer-shell > p { grid-column: 1; }
  .player-app { grid-template-rows: 104px auto minmax(0, 1fr); }
  .player-bar { grid-template-columns: 44px minmax(0, 1fr); gap: 4px 8px; padding: 6px 8px; }
  .progress-summary { grid-column: 2; display: flex; justify-content: space-between; gap: 8px; }
  .progress-summary { font-size: 0.875rem; }
  .progress-summary button { min-height: 44px; padding: 5px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
  .course-image img { transform: none !important; }
}
