/* Maths Tutorial: the catalog page's maths quizzes, in the Maths Tutorial
   design (colours, sizes and breakpoints taken from that design). Light or
   dark follows the device; nothing is kept in the browser. */

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/roboto-latin-400-normal-BqEyEoaF.woff2") format("woff2"),
       url("assets/roboto-latin-400-normal-D27F5sTu.woff") format("woff");
}
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/roboto-latin-500-normal-7RbcRiD8.woff2") format("woff2"),
       url("assets/roboto-latin-500-normal-fsTFPL3E.woff") format("woff");
}
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("assets/roboto-latin-700-normal-BZpUvMxY.woff2") format("woff2"),
       url("assets/roboto-latin-700-normal-YuyVweIx.woff") format("woff");
}

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #0f0f0f;
  --muted: #606060;
  --hover: #f2f2f2;
  --hover-strong: #e5e5e5;
  --border: #cccccc;
  --divider: #e5e5e5;
  --search-bg: #ffffff;
  --focus: #065fd4;
  --brand: #ff0000;
  --thumb-bg: #f2f2f2;
  --topbar-h: 56px;
  --sidebar-w: 240px;
  --rail-w: 72px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --text: #f1f1f1;
    --muted: #aaaaaa;
    --hover: #272727;
    --hover-strong: #3f3f3f;
    --border: #3f3f3f;
    --divider: #3f3f3f;
    --search-bg: #121212;
    --thumb-bg: #272727;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 Roboto, -apple-system, system-ui, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Top bar */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  height: var(--topbar-h);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  user-select: none;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 24px; height: 24px; }
.search-open svg, .search-submit svg { width: 20px; height: 20px; }
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}
.brand:hover { opacity: 0.9; }
.brand-mark {
  width: 32px;
  height: 22px;
  border-radius: 6px;
  background: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 13px; height: 13px; stroke: #ffffff; stroke-width: 2.4; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }

.topbar-center {
  display: none;
  flex: 1;
  max-width: 640px;
  margin: 0 16px;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.search { flex: 1; display: flex; align-items: center; }
.search-box {
  display: flex;
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--search-bg);
  overflow: hidden;
}
.search-box:focus-within { border-color: var(--focus); }
.search-box input {
  width: 100%;
  min-width: 0;
  padding: 0 8px 0 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.search-box input::placeholder { color: var(--muted); }
.search-box input:focus { outline: none; }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.search-submit {
  width: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--hover);
  border-left: 1px solid var(--divider);
  transition: background-color 0.15s;
}
.search-submit:hover { background: var(--hover-strong); }
.search-back { display: none; }

/* Phones: the search icon opens the search box in place of the top bar. */
.topbar.searching .topbar-left,
.topbar.searching .topbar-right { display: none; }
.topbar.searching .topbar-center { display: flex; margin: 0; max-width: none; }
.topbar.searching .search-back { display: inline-flex; flex-shrink: 0; }

/* Sidebar: 240px, a 72px rail when collapsed, a drawer on phones. */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  z-index: 50;
  width: var(--sidebar-w);
  background: var(--bg);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.2s ease, width 0.15s;
}
.sidebar-nav { height: 100%; display: flex; flex-direction: column; padding: 12px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 14px;
  flex-shrink: 0;
  transition: background-color 0.15s;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--hover); font-weight: 700; }
.nav-item svg { width: 24px; height: 24px; flex-shrink: 0; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-bottom { margin-top: auto; flex-shrink: 0; }
.divider { margin: 10px 0; border-top: 1px solid var(--divider); }
.privacy-link { display: block; padding: 12px 12px 4px; font-size: 12px; color: var(--muted); }
.privacy-link:hover { color: var(--text); text-decoration: underline; }

.backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 45; background: rgba(0, 0, 0, 0.5); }
body.drawer-open .sidebar { transform: none; }

/* Main area */
.main { padding-top: var(--topbar-h); min-height: 100vh; transition: padding 0.15s; }
.content { padding: 8px 16px 40px; }
.heading-row { margin-bottom: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.heading { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.5; font-variant-numeric: tabular-nums; }

.status { padding: 48px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.status[hidden] { display: none; }
.status strong { display: block; margin-bottom: 8px; color: var(--text); font-size: 20px; font-weight: 700; }
.status .retry {
  margin-top: 16px;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  column-gap: 16px;
  row-gap: 32px;
}

/* Quiz card */
.card { display: flex; flex-direction: column; gap: 12px; }
.card-link { display: flex; flex-direction: column; gap: 12px; border-radius: 12px; }
.thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: var(--thumb-bg);
}
.thumb img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform 0.3s ease-out; }
.card-link:hover .thumb img { transform: scale(1.02); }
.thumb-letter {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 700;
}
.tint-0 { background: #fde2e2; color: #b91c1c; }
.tint-1 { background: #dbeafe; color: #1d4ed8; }
.tint-2 { background: #dcfce7; color: #15803d; }
.tint-3 { background: #fef3c7; color: #b45309; }
.card-body { display: flex; align-items: flex-start; gap: 12px; }
.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-icon svg { width: 17px; height: 17px; stroke: #ffffff; stroke-width: 2.4; }
.card-text { min-width: 0; flex: 1; }
.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { margin-top: 4px; font-size: 13px; line-height: 18px; color: var(--muted); }
.card-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-description {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Breakpoints of the design: 640, 768, 1024 and 1280px. */
@media (min-width: 640px) {
  .topbar { padding: 0 16px; }
  .topbar-left, .topbar-right { gap: 8px; }
  .content { padding: 8px 24px 40px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .topbar-center { display: flex; }
  .search-open { display: none; }
  /* Keeps the search box centred where the design has it. */
  .topbar-right { min-width: 92px; }
  .sidebar { transform: none; }
  .backdrop { display: none; }
  .main { padding-left: var(--sidebar-w); }
  body.rail .sidebar { width: var(--rail-w); }
  body.rail .sidebar-nav { padding: 12px 4px; }
  body.rail .main { padding-left: var(--rail-w); }
  body.rail .nav-item {
    height: auto;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 12px 4px;
  }
  body.rail .nav-item svg { width: 20px; height: 20px; }
  body.rail .nav-label { font-size: 10px; line-height: 1.25; }
  body.rail .privacy-link { padding: 12px 4px 4px; text-align: center; }
}
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
