:root {
  --paper: #fbf8f1;
  --ink: #222;
  --muted: #5b5b5b;
  --card: #fff;
  --line: #e4ded2;
  --yellow: #ffcf3f;
  --colouring: #ff8a65;
  --draw: #f06292;
  --dots: #4fc3f7;
  --colour-by-number: #ffd54f;
  --mazes: #81c784;
  --tracing: #ba68c8;
  --games: #ffb300;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}

a { color: inherit; }

/* Top bar: logo and tagline, then a row of activity tabs, on a white band that ends
   in a stripe of the activity colours */

.topbar {
  background: var(--card);
  box-shadow: 0 1px 0 var(--line);
}

.topbar::after {
  content: "";
  display: block;
  height: 6px;
  background: linear-gradient(90deg,
    var(--colouring) 0 14.3%, var(--draw) 0 28.6%, var(--dots) 0 42.9%,
    var(--colour-by-number) 0 57.1%, var(--mazes) 0 71.4%, var(--tracing) 0 85.7%,
    var(--games) 0);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 16px 12px;
}

.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 24px;
}

.topbar .logo { line-height: 0; }
.topbar .logo img { width: min(300px, 76vw); height: auto; }

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.menu { margin-top: 12px; }

.menu ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px 6px 8px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--paper);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.menu a::before {
  content: "";
  flex: none;
  width: 11px;
  height: 11px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--accent, var(--yellow));
}

.menu a:hover { border-color: var(--line); background: #f2eee4; }
.menu a[aria-current="page"] { border-color: var(--ink); background: var(--accent, var(--yellow)); }
.menu a[aria-current="page"]::before { background: var(--card); }
.menu-colouring { --accent: var(--colouring); }
.menu-draw { --accent: var(--draw); }
.menu-dots { --accent: var(--dots); }
.menu-colour-by-number { --accent: var(--colour-by-number); }
.menu-mazes { --accent: var(--mazes); }
.menu-tracing { --accent: var(--tracing); }
.menu-games { --accent: var(--games); }

/* On phones the tabs stay on one line and scroll sideways, fading out at the edges */
@media (max-width: 700px) {
  .tagline { display: none; }
  .menu { margin-top: 8px; }
  .menu ul {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -16px;
    padding: 2px 16px;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 32px), transparent);
  }
  .menu ul::-webkit-scrollbar { display: none; }
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* Breadcrumbs */

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.breadcrumbs li + li::before { content: "›"; margin-right: 4px; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }

/* Page intro */

.hero {
  text-align: center;
  padding: 32px 0 16px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  line-height: 1.2;
}

.hero p {
  max-width: 40rem;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.1rem;
}

.hero-left { text-align: left; }
.hero-left p { margin: 0; }

/* Chips (links to categories and themes) */

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 8px;
}

.chip {
  --accent: var(--yellow);
  font-weight: 600;
  padding: 6px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  text-decoration: none;
}

.chip .count { color: var(--muted); font-weight: 400; }
.chip:hover { background: #f2eee4; }
.chip[aria-current="page"] { background: var(--accent); }
.chip[aria-current="page"] .count { color: var(--ink); }
.chip-colouring { --accent: var(--colouring); }
.chip-draw { --accent: var(--draw); }
.chip-dots { --accent: var(--dots); }
.chip-colour-by-number { --accent: var(--colour-by-number); }
.chip-mazes { --accent: var(--mazes); }
.chip-tracing { --accent: var(--tracing); }
.chip-games { --accent: var(--games); }

/* Shelves: a heading plus a grid of cards */

.shelf { margin-top: 48px; }

.shelf-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 8px;
}

.shelf h2 { margin: 0; font-size: 1.5rem; }
.shelf h2 a { text-decoration: none; }
.shelf h2 a:hover { text-decoration: underline; }
.shelf-intro { margin: 0 0 16px; max-width: 48rem; color: var(--muted); }

.more {
  font-weight: 600;
  white-space: nowrap;
}

.hero + .grid,
.chips + .grid { margin-top: 24px; }

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 24px;
}

.card {
  --accent: var(--yellow);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 6px solid var(--accent);
  border-radius: 14px;
  overflow: hidden;
}

.card-colouring { --accent: var(--colouring); }
.card-draw { --accent: var(--draw); }
.card-dots { --accent: var(--dots); }
.card-colour-by-number { --accent: var(--colour-by-number); }
.card-mazes { --accent: var(--mazes); }
.card-tracing { --accent: var(--tracing); }
.card-games { --accent: var(--games); }

.thumb {
  display: block;
  padding: 16px 16px 0;
}

.thumb img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 210 / 297;
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: transform 0.15s ease;
}

.thumb:hover img { transform: scale(1.02) rotate(-0.5deg); }

.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 12px 16px 16px;
}

.card h2,
.card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.card h2 a,
.card h3 a { text-decoration: none; }
.card h2 a:hover,
.card h3 a:hover { text-decoration: underline; }

.meta {
  margin: 2px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.tag { font-weight: 600; }
a.tag { text-decoration: none; }
a.tag:hover { text-decoration: underline; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.button {
  flex: 1;
  font: inherit;
  text-align: center;
  padding: 7px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.button:hover { background: #f2eee4; }
.button.primary { background: var(--yellow); }
.button.primary:hover { background: #ffc107; }

/* A single sheet's page */

.sheet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  margin-top: 24px;
}

.sheet-preview img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.08);
}

.sheet-info h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.2;
}

.sheet-info .meta { font-size: 1rem; }
.sheet-info .lead { font-size: 1.1rem; margin: 0 0 24px; }
.sheet-info .actions { margin: 0 0 16px; }
.sheet-info .button { flex: 0 1 auto; padding: 10px 20px; }
.small { color: var(--muted); font-size: 0.9rem; }

.print-sheet { display: none; }

@media (max-width: 700px) {
  .sheet { grid-template-columns: 1fr; gap: 20px; }
}

/* About, more activities, footer */

.about {
  max-width: 44rem;
  margin: 64px auto 0;
  color: var(--muted);
}

.about h2,
.more-activities h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.3rem;
}

.about strong { color: var(--ink); }

.terms { margin-top: 16px; }
.terms h2 { margin-top: 24px; }
.terms ul { padding-left: 1.2rem; }

.more-activities {
  margin-top: 56px;
  text-align: center;
}

.chip:focus-visible,
.button:focus-visible,
.logo:focus-visible,
.menu a:focus-visible,
.card a:focus-visible {
  outline: 3px solid #1e88e5;
  outline-offset: 2px;
}

.site-footer {
  text-align: center;
  padding: 24px 16px 40px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p { margin: 4px 0; }
.site-footer strong { color: var(--ink); }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  margin: 8px 0;
  padding: 0;
  list-style: none;
}

/* Printing a sheet page prints just the sheet, filling the paper */

@media print {
  @page { margin: 0; }
  .sheet-page > * { display: none !important; }
  .sheet-page { background: #fff; }
  .sheet-page > main { display: block !important; padding: 0; max-width: none; }
  .sheet-page > main > * { display: none !important; }
  .sheet-page > main > .print-sheet {
    display: block !important;
    width: 100%;
    height: 100vh;
    object-fit: contain;
  }
}
