:root {
  --accent: #287A64;
  --accent-rgb: 40, 122, 100;
  --accent-dark: #173D36;
  --accent-warm: #F4A261;
  --accent-warm-rgb: 244, 162, 97;
  --text: #26332F;
  --text-muted: #5c6f68;
  --border: #173D36;
  --bg: #FFF9F1;
  --bg-rgb: 169, 205, 191;
  --card-bg: #ffffff;
  --header-bg: #FFF9F1;
  --radius: 10px;
  --radius-lg: 18px;
  --shadow-card: 0 1px 2px rgba(23, 61, 54, 0.06), 0 10px 24px rgba(23, 61, 54, 0.07);
  --shadow-card-hover: 0 4px 10px rgba(23, 61, 54, 0.08), 0 18px 34px rgba(23, 61, 54, 0.13);
}

* { box-sizing: border-box; }

html {
  overflow-x: hidden;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
}

.wrap {
  max-width: none;
  margin: 0;
  padding: 0 24px;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--accent-dark);
  padding: 12px 0;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-btn {
  display: inline-flex;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.site-header .logo {
  height: 46px;
  width: auto;
  flex: none;
  display: block;
}

.header-contact-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--header-bg);
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 9px 22px;
  border: 2px solid var(--accent-dark);
  border-radius: 999px;
  text-decoration: none;
  box-shadow: -2px 2px 0 rgba(var(--bg-rgb), 0.9);
  transition: transform 0.12s ease;
}

.header-contact-btn:hover {
  transform: translate(-1px, 1px);
}

/* Filters */

.filters {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  margin: 22px 0;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.filter-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  align-items: start;
}

select, .combobox input[type="text"] {
  width: 100%;
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}

select:focus, .combobox input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.filter-actions {
  margin-top: 14px;
  text-align: right;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.88rem;
  cursor: pointer;
  padding: 4px;
}

.btn-text:hover { text-decoration: underline; }

/* Combobox */

.combobox {
  position: relative;
}

.combobox input[type="text"] {
  padding-right: 34px;
}

.combobox-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.combobox-clear:hover { color: var(--text); }

.combobox-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(20, 24, 33, 0.12);
}

.combobox-list.hidden { display: none; }

.combobox-list li {
  border-radius: 6px;
  font-size: 0.92rem;
}

.combobox-list li.active,
.combobox-list li:hover {
  background: rgba(var(--accent-rgb), 0.09);
}

.combobox-list li label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  cursor: pointer;
}

.combobox-list li input[type="checkbox"] {
  flex: none;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.combobox-list li.all-option {
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  margin-bottom: 4px;
  cursor: pointer;
  padding: 9px 10px 10px;
}

.combobox-list .no-match {
  color: var(--text-muted);
  cursor: default;
  padding: 10px;
}

.combobox-list .no-match:hover { background: none; }

/* Selected topic chips */

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.topic-chips[hidden] { display: none; }

.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--accent-dark);
  background: rgba(var(--accent-rgb), 0.09);
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
}

.topic-chip button {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.topic-chip button:hover { background: rgba(var(--accent-rgb), 0.18); }

/* Results */

.results-count {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 14px;
}

.results-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  padding-bottom: 40px;
}

@media (max-width: 1500px) {
  .results-list { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 1150px) {
  .results-list { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
  .results-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .results-list { grid-template-columns: 1fr; }
}

.status {
  color: var(--text-muted);
  padding: 30px 0;
  text-align: center;
  grid-column: 1 / -1;
}

/* Tile */

.tile {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border);
}

.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}

.tile-qnum {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.tile-marks {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-dark);
  background: rgba(var(--accent-rgb), 0.12);
  border-radius: 999px;
  padding: 2px 9px;
}

.tile-thumb {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  height: 190px;
  overflow: hidden;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: zoom-in;
}

.tile-thumb img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tile-thumb img.loaded {
  opacity: 1;
}

.tile-zoom-hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  color: #fff;
  background: rgba(20, 24, 33, 0.55);
  border-radius: 6px;
  pointer-events: none;
}

.tile-meta {
  padding: 10px 12px 12px;
}

.tile-info {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.tile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.tag-chip {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: 999px;
  padding: 2px 9px;
}

/* Practice view (lightbox with Question / Mark Scheme / Video tabs) */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(10, 12, 16, 0.92);
}

.lightbox.hidden { display: none; }

.practice-panel {
  position: relative;
  width: 96vw;
  height: 94vh;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.practice-nav-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.practice-position {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 4.5em;
  text-align: center;
}

.practice-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.practice-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.practice-print-btn {
  flex: none;
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.practice-print-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
}

.practice-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: none;
}

.practice-tab {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.practice-tab:hover { color: var(--text); background: var(--bg); }

.practice-tab.active {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.22);
}

.lightbox-close {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover { background: #eaecf0; }

.practice-nav-btn {
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.practice-nav-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg);
}

.practice-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.practice-meta {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.practice-meta.has-tags {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.practice-meta .tile-tags {
  margin-bottom: 0;
}

.practice-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.info-chip {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.lightbox-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: #fff;
}

.lightbox-body.align-top {
  align-items: flex-start;
}

.lightbox-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 4px;
  background: #fff;
  transition: transform 0.15s ease;
}

.zoom-controls {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.zoom-controls[hidden] {
  display: none;
}

.zoom-btn {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg);
}

.zoom-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.zoom-level {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 3.2em;
  text-align: center;
}

.video-tab-content {
  width: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.video-embed {
  position: relative;
  width: min(92vw, 44vh, 420px);
  aspect-ratio: 9 / 16;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  margin: 0 auto;
}

.video-embed iframe,
.video-embed video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* "Coming soon" states + promo CTA */

.coming-soon-cta {
  max-width: 560px;
  margin: auto;
  text-align: center;
  padding: 10px 16px;
}

.coming-soon-cta strong {
  display: block;
  color: var(--text);
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.coming-soon-cta p {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.cta-strip {
  width: 100%;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.cta-strip p {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.cta-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.cta-btn {
  display: inline-block;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 11px 18px;
  border-radius: 8px;
  text-decoration: none;
  color: #fff;
}

.cta-youtube { background: #c81e1e; }
.cta-youtube:hover { background: #a01717; }

.cta-live { background: var(--accent-warm); }
.cta-live:hover { background: #e08b3f; }

@media (max-width: 640px) {
  .practice-panel { width: 100vw; height: 100vh; border-radius: 0; }
  .practice-tab { padding: 8px 10px; font-size: 0.82rem; }
  .practice-position { display: none; }
  .zoom-controls { display: none !important; }
}

/* Footer */

.site-footer {
  background: var(--accent-dark);
  padding: 26px 0;
  margin-top: 20px;
}

.site-footer p {
  margin: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85rem;
  text-align: center;
}

/* Responsive */

@media (max-width: 640px) {
  .filter-row {
    grid-template-columns: 1fr;
  }
  .filters { padding: 16px; }
  .tile-thumb { height: 140px; }
}

/* Print — just the question/mark-scheme image, no chrome, no background.
   Note: the browser paginates the tall image at plain fixed-height
   intervals; it has no way to know where the original source PDF's page
   boundaries fell inside a stitched multi-page question, since that
   position isn't recorded anywhere in the crop pipeline today. */

@page {
  margin: 15mm;
}

@media print {
  html, body {
    background: #fff !important;
  }

  .site-header,
  main,
  .site-footer {
    display: none !important;
  }

  .lightbox {
    position: static;
    background: #fff;
    padding: 0;
  }

  .practice-panel {
    position: static;
    width: auto;
    height: auto;
    max-width: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }

  .practice-head,
  .practice-meta {
    display: none !important;
  }

  .lightbox-body {
    position: static;
    display: block;
    padding: 0;
    overflow: visible;
    background: #fff;
  }

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

  .video-embed,
  .coming-soon-cta,
  .cta-strip {
    display: none !important;
  }
}
