/* Subject index pages (teoria/, problemas/ and extra-problems/ index.html): the compact look of the
   landing page. Linked as the last stylesheet of those pages, it lays their own markup out as a
   grid of short cards (number, title, arrow) and hides the long summaries and tag clouds, so a
   whole syllabus fits on one desktop screen. Colours and fonts are the page's own variables. */

/* ---------------------------------------------------------------- page width and header */
body .container { max-width: 1180px; }

:is(.page-header, .page-hero) {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 16px;
  margin: 0 auto 44px; padding: 34px 0 0; border: 0 !important; text-align: left;
}
:is(.page-header, .page-hero) > :is(.icon, .page-header-icon) {
  display: flex !important; align-items: center; justify-content: center; flex: none;
  width: 52px; height: 52px; margin: 0 !important; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--accent);
}
:is(.page-header, .page-hero) > :is(.icon, .page-header-icon) svg { width: 28px; height: 28px; color: inherit !important; }
:is(.page-header, .page-hero) h1 {
  margin: 0; font-size: clamp(1.6rem, 3vw, 2.3rem); line-height: 1.15; text-align: left;
}
:is(.page-header, .page-hero) h1 br { display: none; }
:is(.page-header, .page-hero) h1 br + span::before { content: " · "; }
/* the summaries under the title, the pills and counters, and the second copy of the tab strip */
:is(.page-header, .page-hero) > :is(p, .hero-badge-wrap, .hero-stats, .hero-pill),
body:has(.subject-tabs) :is(.view-switcher, .section-nav) { display: none !important; }
:is(.page-header, .page-hero) > .view-switcher { flex-basis: 100%; justify-content: center; margin: 10px 0 0; }

html:root body :is(header, section, div):is(.page-header, .page-hero) { border: 0 none transparent !important; }

/* ---------------------------------------------------------------- section titles */
.block-header { margin: 26px 0 16px; padding-bottom: 10px; justify-content: center; gap: 12px; text-align: center; }
.block-header h2, .exam-block-title { font-size: 1.15rem; margin: 0; }
.exam-block { margin-top: 18px; }
.exam-block-lead { display: none; }

/* ---------------------------------------------------------------- the cards: a grid, not a column */
:is(.topics-list, .topics-grid, .sets-list, .problem-sets-grid) {
  --idx-gap: 16px;
  display: flex !important; flex-direction: row !important; flex-wrap: wrap; justify-content: center; align-items: stretch;
  gap: var(--idx-gap); margin-top: 0; margin-bottom: 26px;
}
/* three cards per row; a last row with one or two cards is centred, as on the landing page */
:is(.topics-list, .topics-grid, .sets-list) > :is(.topic-card, .set-card) {
  flex: 0 1 calc((100% - 2 * var(--idx-gap)) / 3); width: auto; max-width: none; box-sizing: border-box;
}
@media (max-width: 1000px) {
  :is(.topics-list, .topics-grid, .sets-list) > :is(.topic-card, .set-card) { flex-basis: calc((100% - var(--idx-gap)) / 2); }
}
:is(.topic-card, .set-card) {
  position: relative; display: flex !important; flex-direction: row; align-items: center; gap: 12px;
  min-height: 104px; margin: 0 !important; padding: 20px 20px 20px 24px !important;
  border-radius: var(--radius-md, 14px); overflow: hidden;
}
:is(.topic-card, .set-card) :is(.topic-desc, .set-desc, .topic-tags, .content-badges, .topic-meta .meta-tag, .badge-status, .topic-badge.available, .set-badge) { display: none !important; }
:is(.topic-card, .set-card) :is(.topic-body, .topic-content, .set-content) {
  flex: 1; min-width: 0; padding: 0 !important; display: flex; flex-direction: column; gap: 3px;
}
:is(.topic-card, .set-card) :is(.topic-title, .set-title) {
  margin: 0 !important; font-size: 1.22rem; line-height: 1.25;
}
:is(.topic-card, .set-card) :is(.topic-number, .topic-code, .set-code, .topic-badge, .topic-num) {
  margin: 0 !important; font-family: var(--font-mono, "JetBrains Mono", monospace); font-size: .74rem; letter-spacing: .06em;
}
:is(.topic-card, .set-card) :is(.topic-meta, .set-meta, .topic-top) { margin: 0 !important; display: flex; align-items: center; gap: 8px; }
:is(.topic-card, .set-card) :is(.topic-arrow, .topic-action, .set-action) {
  flex: none; margin: 0 !important; padding: 0 !important; border: 0 !important; background: none !important;
  width: auto; font-size: 1.1rem; transition: transform .2s ease;
}
:is(.topic-card, .set-card):hover :is(.topic-arrow, .topic-action, .set-action) { transform: translateX(3px); }
/* accent strips become one thin bar on the left edge */
:is(.topic-card, .set-card) :is(.topic-accent, .topic-accent-bar, .topic-accent-strip, .set-accent-strip) {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px; height: auto; margin: 0;
}
/* Engineering Mechanics: the big number column becomes a small label */
.topic-card > .topic-num {
  flex: none; width: auto !important; min-width: 0 !important; padding: 0 !important; border: 0 !important; background: none !important;
  font-size: .95rem !important;
}
.topic-card.disabled { opacity: .55; }

/* cards that list exercises (Business problems, Extra problems, Maths problem sets) */
.problem-card { padding: 16px 18px !important; margin: 0 !important; }
.problem-card :is(.card-desc, .topic-meta) { display: none !important; }
.problem-card .card-title { margin: 0 0 8px !important; font-size: 1.1rem; }
.problem-card .exercise-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 14px; margin: 0; }
.problem-card .exercise-item { padding: 5px 0 !important; }
.problem-sets-grid { display: grid !important; grid-template-columns: 1fr; gap: 16px; }
/* the exercise names of a problem sheet are listed on its own page */
.set-card .exercise-pills-list { display: none !important; }

/* exercise lists: body font, two lines at most */
.problem-card .ex-title {
  font-family: var(--font-body, "Newsreader", Georgia, serif) !important; font-weight: 500 !important; letter-spacing: 0;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; line-height: 1.35;
}

/* ---------------------------------------------------------------- Extra problems hub: one chip per item
   The generators (build_problem_bank, build_mechanics_bank, build_maths_bank) write every item as a
   link with its code and its full title; only the code is shown, the title stays as the tooltip and
   for screen readers. Chips are centred, so a short last row sits in the middle. */
.problem-sets-grid:has(.ex-link) { display: flex !important; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 16px; }
.problem-sets-grid:has(.ex-link) > .problem-card {
  flex: 1 1 420px; max-width: 580px; box-sizing: border-box; padding: 20px 22px 22px !important; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px; transform: none !important;
}
.problem-sets-grid:has(.ex-link) > .problem-card:only-child { max-width: 760px; }
.exam-block:has(.ex-link) { margin-top: 10px; }
.exam-block:has(.ex-link) .exam-block-title { text-align: center; margin: 0 0 10px; }
.problem-card:has(.ex-link) .card-badge { margin: 0; }
.problem-sets-grid:has(.ex-link) > .problem-card:only-child { padding: 16px 22px 18px !important; gap: 10px; }
.problem-sets-grid:has(.ex-link) > .problem-card:only-child .card-badge { display: none; }
.problem-card:has(.ex-link) .card-title { margin: 0 !important; }
.problem-card .card-title a { color: inherit; text-decoration: none; }
.problem-card .card-title a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }
.problem-card .exercise-list:has(.ex-link) {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; margin: 0; padding: 0; list-style: none;
}
.problem-card .exercise-list:has(.ex-link) .exercise-item { padding: 0 !important; margin: 0; border: 0; display: block; }
.ex-link {
  display: flex; align-items: center; justify-content: center; min-width: 68px; min-height: 44px; padding: 0 12px; box-sizing: border-box;
  border: 1px solid var(--border-card, rgba(127, 127, 127, .3)); border-radius: var(--radius-sm, 10px);
  background: var(--bg-input, transparent); color: var(--text-primary, inherit) !important; text-decoration: none;
  transition: border-color .2s ease, transform .2s ease;
}
.ex-link:hover, .ex-link:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.ex-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ex-link .ex-num {
  font-family: var(--font-mono, "JetBrains Mono", monospace); font-size: .92rem; font-weight: 600; letter-spacing: .04em;
  color: inherit !important; min-width: 0; margin: 0;
}
.ex-link .ex-title {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; display: block !important;
}

/* ---------------------------------------------------------------- no neon: flat title, plain shadows */
:is(.page-header, .page-hero)::before, :is(.page-header, .page-hero)::after { display: none !important; }
:is(.page-header, .page-hero), :is(.page-header, .page-hero) * { text-shadow: none !important; filter: none !important; }
:is(.page-header, .page-hero) > :is(.icon, .page-header-icon) { box-shadow: none; }
:is(.topic-card, .set-card, .problem-card),
:is(.topic-card, .set-card, .problem-card):hover { box-shadow: var(--shadow-card, 0 4px 24px rgba(0, 0, 0, .35)) !important; }
:is(.topic-card, .set-card):hover { border-color: var(--accent) !important; transform: translateY(-2px); }

/* ---------------------------------------------------------------- less air around the page */
body :is(.page-footer, .site-footer) { margin-top: 18px; padding: 14px 0 18px; }
section.container:has(#quoteContainer), section:has(> #quoteContainer) { display: none; }

@media (max-width: 700px) {
  :is(.page-header, .page-hero) { padding-top: 18px; margin-bottom: 24px; }
  :is(.page-header, .page-hero) > :is(.icon, .page-header-icon) { width: 44px; height: 44px; }
  :is(.topics-list, .topics-grid, .sets-list) > :is(.topic-card, .set-card) { flex-basis: 100%; min-height: 84px; }
}
@media print {
  :is(.topic-card, .set-card) :is(.topic-desc, .set-desc) { display: block !important; }
}

/* ---------------------------------------------------------------- syllabuses split in three parts
   (Engineering Mechanics and Advanced Maths theory): tighter part titles and lower cards, so the
   three groups still fit on one 1440 x 900 screen. Other indexes are not matched. */
@media (min-width: 1001px) {
  body:has(.block-header ~ .topics-list ~ .block-header ~ .topics-list ~ .block-header) {
    & :is(.page-header, .page-hero) { margin-bottom: 18px; padding-top: 22px; }
    & .block-header { margin: 12px 0 10px; padding-bottom: 0; border-bottom: 0 !important; }
    & .block-header h2 { font-size: 1.05rem; }
    & :is(.topics-list, .topics-grid) { --idx-gap: 12px; margin-bottom: 12px; }
    & .topic-card { min-height: 78px; padding-top: 12px !important; padding-bottom: 12px !important; }
    & .topic-card .topic-title { font-size: 1.12rem; }
    & :is(.page-footer, .site-footer) { margin-top: 8px; padding: 8px 0 10px; }
  }
}

/* ---------------------------------------------------------------- starry sky behind the page
   A quiet, slowly drifting night sky in the colours of the subject: two layers of a tiled SVG of dust
   and four-point stars (assets/img/sky/<subject>-<polarity>.svg) over two faint nebulae. The layers
   move at different speeds and in opposite directions, so the stars shimmer past each other. The
   drift is one registered custom property (--sky-x) animated on the root, so the loop is seamless
   and the !important background of the reading palettes does not stop it. It sits on the body's own
   colour: every reading palette keeps its background and its AAA text (cards stay opaque). */
@property --sky-x { syntax: '<length>'; inherits: true; initial-value: 0px; }
@keyframes sky-drift { to { --sky-x: 1280px; } }
html[data-celestial-subject] { animation: sky-drift 420s linear infinite; }
@media (prefers-reduced-motion: reduce) { html[data-celestial-subject] { animation: none; } }
html[data-celestial-subject="fluid-mechanics"]       { --sky-a: 6 182 212;   --sky-b: 139 92 246; }
html[data-celestial-subject="aerospace-materials-1"] { --sky-a: 245 158 11;  --sky-b: 244 114 182; }
html[data-celestial-subject="engineering-mechanics"] { --sky-a: 16 185 129;  --sky-b: 34 211 238; }
html[data-celestial-subject="advanced-maths"]        { --sky-a: 99 102 241;  --sky-b: 217 70 239; }
html[data-celestial-subject="business-management"]   { --sky-a: 239 68 68;   --sky-b: 251 146 60; }
html[data-theme="dark"]  { --sky-n1: .15; --sky-n2: .10; }
html[data-theme="light"] { --sky-n1: .08; --sky-n2: .06; }
html[data-celestial-subject="fluid-mechanics"][data-theme="dark"] body {
  background-image: url(../img/sky/fluid-mechanics-dark.svg), url(../img/sky/fluid-mechanics-dark.svg),
    radial-gradient(ellipse 60% 46% at 12% 6%, rgb(var(--sky-a) / var(--sky-n1)), transparent 72%),
    radial-gradient(ellipse 54% 42% at 92% 90%, rgb(var(--sky-b) / var(--sky-n2)), transparent 72%) !important;
  background-size: 1280px 960px, 768px 576px, auto, auto !important;
  background-repeat: repeat, repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed, fixed !important;
  background-position: var(--sky-x) calc(var(--sky-x) * .75), calc(var(--sky-x) * -.6) calc(var(--sky-x) * .45), 0 0, 0 0 !important;
}
html[data-celestial-subject="fluid-mechanics"][data-theme="light"] body {
  background-image: url(../img/sky/fluid-mechanics-light.svg), url(../img/sky/fluid-mechanics-light.svg),
    radial-gradient(ellipse 60% 46% at 12% 6%, rgb(var(--sky-a) / var(--sky-n1)), transparent 72%),
    radial-gradient(ellipse 54% 42% at 92% 90%, rgb(var(--sky-b) / var(--sky-n2)), transparent 72%) !important;
  background-size: 1280px 960px, 768px 576px, auto, auto !important;
  background-repeat: repeat, repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed, fixed !important;
  background-position: var(--sky-x) calc(var(--sky-x) * .75), calc(var(--sky-x) * -.6) calc(var(--sky-x) * .45), 0 0, 0 0 !important;
}
html[data-celestial-subject="aerospace-materials-1"][data-theme="dark"] body {
  background-image: url(../img/sky/aerospace-materials-1-dark.svg), url(../img/sky/aerospace-materials-1-dark.svg),
    radial-gradient(ellipse 60% 46% at 12% 6%, rgb(var(--sky-a) / var(--sky-n1)), transparent 72%),
    radial-gradient(ellipse 54% 42% at 92% 90%, rgb(var(--sky-b) / var(--sky-n2)), transparent 72%) !important;
  background-size: 1280px 960px, 768px 576px, auto, auto !important;
  background-repeat: repeat, repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed, fixed !important;
  background-position: var(--sky-x) calc(var(--sky-x) * .75), calc(var(--sky-x) * -.6) calc(var(--sky-x) * .45), 0 0, 0 0 !important;
}
html[data-celestial-subject="aerospace-materials-1"][data-theme="light"] body {
  background-image: url(../img/sky/aerospace-materials-1-light.svg), url(../img/sky/aerospace-materials-1-light.svg),
    radial-gradient(ellipse 60% 46% at 12% 6%, rgb(var(--sky-a) / var(--sky-n1)), transparent 72%),
    radial-gradient(ellipse 54% 42% at 92% 90%, rgb(var(--sky-b) / var(--sky-n2)), transparent 72%) !important;
  background-size: 1280px 960px, 768px 576px, auto, auto !important;
  background-repeat: repeat, repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed, fixed !important;
  background-position: var(--sky-x) calc(var(--sky-x) * .75), calc(var(--sky-x) * -.6) calc(var(--sky-x) * .45), 0 0, 0 0 !important;
}
html[data-celestial-subject="engineering-mechanics"][data-theme="dark"] body {
  background-image: url(../img/sky/engineering-mechanics-dark.svg), url(../img/sky/engineering-mechanics-dark.svg),
    radial-gradient(ellipse 60% 46% at 12% 6%, rgb(var(--sky-a) / var(--sky-n1)), transparent 72%),
    radial-gradient(ellipse 54% 42% at 92% 90%, rgb(var(--sky-b) / var(--sky-n2)), transparent 72%) !important;
  background-size: 1280px 960px, 768px 576px, auto, auto !important;
  background-repeat: repeat, repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed, fixed !important;
  background-position: var(--sky-x) calc(var(--sky-x) * .75), calc(var(--sky-x) * -.6) calc(var(--sky-x) * .45), 0 0, 0 0 !important;
}
html[data-celestial-subject="engineering-mechanics"][data-theme="light"] body {
  background-image: url(../img/sky/engineering-mechanics-light.svg), url(../img/sky/engineering-mechanics-light.svg),
    radial-gradient(ellipse 60% 46% at 12% 6%, rgb(var(--sky-a) / var(--sky-n1)), transparent 72%),
    radial-gradient(ellipse 54% 42% at 92% 90%, rgb(var(--sky-b) / var(--sky-n2)), transparent 72%) !important;
  background-size: 1280px 960px, 768px 576px, auto, auto !important;
  background-repeat: repeat, repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed, fixed !important;
  background-position: var(--sky-x) calc(var(--sky-x) * .75), calc(var(--sky-x) * -.6) calc(var(--sky-x) * .45), 0 0, 0 0 !important;
}
html[data-celestial-subject="advanced-maths"][data-theme="dark"] body {
  background-image: url(../img/sky/advanced-maths-dark.svg), url(../img/sky/advanced-maths-dark.svg),
    radial-gradient(ellipse 60% 46% at 12% 6%, rgb(var(--sky-a) / var(--sky-n1)), transparent 72%),
    radial-gradient(ellipse 54% 42% at 92% 90%, rgb(var(--sky-b) / var(--sky-n2)), transparent 72%) !important;
  background-size: 1280px 960px, 768px 576px, auto, auto !important;
  background-repeat: repeat, repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed, fixed !important;
  background-position: var(--sky-x) calc(var(--sky-x) * .75), calc(var(--sky-x) * -.6) calc(var(--sky-x) * .45), 0 0, 0 0 !important;
}
html[data-celestial-subject="advanced-maths"][data-theme="light"] body {
  background-image: url(../img/sky/advanced-maths-light.svg), url(../img/sky/advanced-maths-light.svg),
    radial-gradient(ellipse 60% 46% at 12% 6%, rgb(var(--sky-a) / var(--sky-n1)), transparent 72%),
    radial-gradient(ellipse 54% 42% at 92% 90%, rgb(var(--sky-b) / var(--sky-n2)), transparent 72%) !important;
  background-size: 1280px 960px, 768px 576px, auto, auto !important;
  background-repeat: repeat, repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed, fixed !important;
  background-position: var(--sky-x) calc(var(--sky-x) * .75), calc(var(--sky-x) * -.6) calc(var(--sky-x) * .45), 0 0, 0 0 !important;
}
html[data-celestial-subject="business-management"][data-theme="dark"] body {
  background-image: url(../img/sky/business-management-dark.svg), url(../img/sky/business-management-dark.svg),
    radial-gradient(ellipse 60% 46% at 12% 6%, rgb(var(--sky-a) / var(--sky-n1)), transparent 72%),
    radial-gradient(ellipse 54% 42% at 92% 90%, rgb(var(--sky-b) / var(--sky-n2)), transparent 72%) !important;
  background-size: 1280px 960px, 768px 576px, auto, auto !important;
  background-repeat: repeat, repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed, fixed !important;
  background-position: var(--sky-x) calc(var(--sky-x) * .75), calc(var(--sky-x) * -.6) calc(var(--sky-x) * .45), 0 0, 0 0 !important;
}
html[data-celestial-subject="business-management"][data-theme="light"] body {
  background-image: url(../img/sky/business-management-light.svg), url(../img/sky/business-management-light.svg),
    radial-gradient(ellipse 60% 46% at 12% 6%, rgb(var(--sky-a) / var(--sky-n1)), transparent 72%),
    radial-gradient(ellipse 54% 42% at 92% 90%, rgb(var(--sky-b) / var(--sky-n2)), transparent 72%) !important;
  background-size: 1280px 960px, 768px 576px, auto, auto !important;
  background-repeat: repeat, repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed, fixed !important;
  background-position: var(--sky-x) calc(var(--sky-x) * .75), calc(var(--sky-x) * -.6) calc(var(--sky-x) * .45), 0 0, 0 0 !important;
}
@media print { html body { background-image: none !important; } }

/* the page header, the top bar and the footer let the sky through (no dark bands) */
html[data-theme] :is(header.page-header, .page-hero) { background: transparent !important; }
html[data-theme="dark"][data-celestial-subject] :is(.back-bar, .site-header, .top-nav, .sticky-nav, .pdf-library .site-header) {
  background: color-mix(in srgb, var(--study-bg-dark, #0a0e17) 38%, transparent) !important;
  border-bottom-color: rgba(255, 255, 255, 0.06) !important;
  -webkit-backdrop-filter: blur(10px) !important; backdrop-filter: blur(10px) !important;
}
html[data-theme="light"][data-celestial-subject] :is(.back-bar, .site-header, .top-nav, .sticky-nav, .pdf-library .site-header) {
  background: color-mix(in srgb, var(--study-bg-light, #f6f8fa) 55%, transparent) !important;
  border-bottom-color: rgba(15, 23, 42, 0.08) !important;
  -webkit-backdrop-filter: blur(10px) !important; backdrop-filter: blur(10px) !important;
}
html[data-celestial-subject] :is(footer, .site-footer, .page-footer) { background: transparent !important; border-top-color: rgba(128, 140, 160, 0.18) !important; }

/* short pages: the sky reaches the bottom of the window (no plain band under the footer) */
html[data-celestial-subject] body { min-height: 100vh; min-height: 100dvh; }
