@font-face {
  font-family: 'Andika Worksheet';
  src: url('/fonts/regular.woff') format('woff');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Andika Worksheet';
  src: url('/fonts/bold.woff') format('woff');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #fbf7ef;
  --surface: #ffffff;
  --ink: #232842;
  --muted: #5d6478;
  --primary: #3b4a8f;
  --primary-ink: #ffffff;
  --accent: #e0a526;
  --accent-soft: #fdf1d3;
  --border: #e6dfd0;
  --shadow: 0 1px 2px rgb(35 40 66 / 6%), 0 8px 24px rgb(35 40 66 / 8%);
  --radius: 14px;
  --font: 'Andika Worksheet', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); }
em { font-style: normal; color: var(--primary); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 20px; color: var(--ink); text-decoration: none;
}
.brand img { border-radius: 9px; }

/* Home hero */
.hero {
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 48px 16px 24px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(30px, 6vw, 48px);
  line-height: 1.15;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}
.accent {
  white-space: nowrap;
  background: linear-gradient(transparent 62%, var(--accent-soft) 62%);
  color: var(--primary);
}
.tagline { color: var(--muted); font-size: 19px; margin: 0 auto 32px; max-width: 34em; }

/* Search bar + Go */
.search {
  display: flex; gap: 8px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--primary); }
.search input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 19px; color: var(--ink);
  padding: 10px 18px;
}
.search button, .button, .toolbar button {
  font: inherit; font-weight: 700;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--primary); color: var(--primary-ink);
  padding: 10px 26px;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .1s, filter .15s;
}
.search button { font-size: 19px; min-width: 84px; }
.search button:hover, .button:hover, .toolbar button:hover { filter: brightness(1.12); }
.search button:active, .button:active { transform: translateY(1px); }
.search.compact { flex: 1; max-width: 460px; box-shadow: none; }
.search.compact input { font-size: 16px; padding: 6px 14px; }
.search.compact button { font-size: 16px; padding: 6px 20px; min-width: 0; }

.hint { color: var(--muted); font-size: 14px; margin: 10px 0 0; }

/* Suggestion bubbles */
.suggestions { margin-top: 36px; }
.suggestions h2, .popular h2 {
  font-size: 15px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 14px;
}
.bubbles { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.bubble {
  display: inline-flex; flex-direction: column; align-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 8px 20px;
  text-decoration: none; color: var(--ink);
  transition: border-color .15s, transform .15s, background .15s;
}
.bubble:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.bubble-label { font-weight: 700; font-size: 16px; line-height: 1.2; }
.bubble-ref { font-size: 13px; color: var(--muted); }

.popular { margin-top: 36px; }
.popular ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; }
.popular a { font-weight: 700; text-decoration: none; }
.popular a:hover { text-decoration: underline; }
.popular small { color: var(--muted); font-weight: 400; }

/* How it works */
.how {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
  max-width: 900px; margin: 40px auto 0; padding: 0 16px;
}
.how > div { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.how h3 { margin: 8px 0 4px; font-size: 18px; }
.how p { margin: 0; color: var(--muted); font-size: 15px; }
.step {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--primary); font-weight: 700;
}
.site-footer { margin-top: auto; padding: 40px 16px 24px; text-align: center; color: var(--muted); font-size: 13px; }

/* Worksheet page */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-block: 1px solid var(--border);
  position: sticky; top: 0; z-index: 2;
}
.options { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; font-size: 15px; }
.options select {
  font: inherit; font-size: 15px; margin-left: 6px;
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; background: var(--bg); color: var(--ink);
}
.options .check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.options input[type='checkbox'] { accent-color: var(--primary); width: 18px; height: 18px; }
.actions { display: flex; gap: 8px; }
.toolbar button.secondary { background: var(--accent-soft); color: var(--primary); }
.toolbar button:disabled, .button[aria-disabled='true'] { opacity: .45; pointer-events: none; }

.preview {
  display: flex; flex-direction: column; align-items: center; gap: 28px;
  padding: 32px 16px 56px;
}
.sheet {
  width: 100%; max-width: 816px; height: auto;
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: 4px;
  transition: opacity .2s;
}
.sheet.stale { opacity: .35; }
.sheet .ws-regular { font-family: 'Andika Worksheet', sans-serif; font-weight: 400; }
.sheet .ws-bold { font-family: 'Andika Worksheet', sans-serif; font-weight: 700; }

.status { text-align: center; color: var(--muted); padding: 40px 16px; max-width: 520px; }
.status.error p { color: #a33a2a; }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 12px;
  border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .how { grid-template-columns: 1fr; }
  .hero { padding-top: 24px; }
  .search input { font-size: 17px; padding: 8px 12px; }
  .search button { min-width: 64px; padding: 8px 18px; }
  .site-header, .toolbar { padding-inline: 16px; }
}

/* Printing: only the worksheet pages, one per sheet of paper. */
@page { size: letter; margin: 0; }
@media print {
  body { background: #fff; display: block; min-height: 0; }
  .no-print, .status { display: none !important; }
  .preview { padding: 0; gap: 0; display: block; }
  .sheet {
    display: block;
    width: 8.5in; height: 11in; max-width: none;
    box-shadow: none; border-radius: 0;
    break-after: page; page-break-after: always;
  }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
}
