:root {
  --cream: #fbf6ea;
  --cream-deep: #f4ecd9;
  --card: #ffffff;
  --gray-soft: #f1f2f4;
  --gray-line: #e3e5e8;
  --ink: #1f2933;
  --ink-soft: #52606d;
  --blue: #2b6cb0;
  --blue-dark: #1f548f;
  --blue-soft: #e6f0fa;
  --green: #2f855a;
  --green-dark: #276749;
  --green-soft: #e3f4ea;
  --red: #c53030;
  --red-soft: #fdecec;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 4px rgba(31, 41, 51, .05), 0 8px 24px rgba(31, 41, 51, .07);
  --shadow-hover: 0 4px 8px rgba(31, 41, 51, .07), 0 14px 32px rgba(31, 41, 51, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 88px; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.55;
  background-color: var(--cream);
  /* Subtle education doodles: book, pencil, ruler-ish lines, circles */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220' fill='none' stroke='%23c9b98f' stroke-opacity='.28' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 40h24a8 8 0 0 1 8 8v26H30a8 8 0 0 1-8-8V40Zm32 8a8 8 0 0 1 8-8h24v26a8 8 0 0 1-8 8H54V48Z'/%3E%3Cpath d='M150 28l22 22-40 40-26 4 4-26 40-40Z'/%3E%3Ccircle cx='60' cy='150' r='14'/%3E%3Cpath d='M130 140h50M130 156h36M130 172h44'/%3E%3Cpath d='M180 90l8 8m0-8-8 8'/%3E%3Cpath d='M20 196h40M20 206h24'/%3E%3Cpath d='M98 112l10-12 10 12z'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
a { color: var(--blue); }
img { max-width: 100%; }

.container { width: min(1120px, 100% - 32px); margin-inline: auto; }

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

:focus-visible {
  outline: 3px solid #f6a609;
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute; left: 12px; top: -60px;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 100;
}
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251, 246, 234, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--gray-line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand img { border-radius: 14px; box-shadow: var(--shadow); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.brand-sub { font-size: .8rem; color: var(--ink-soft); }

.site-nav ul { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: 8px 14px; border-radius: 999px;
  text-decoration: none; color: var(--ink); font-weight: 600; font-size: .95rem;
  transition: background .2s, color .2s;
}
.site-nav a:hover, .site-nav a.active { background: var(--blue-soft); color: var(--blue-dark); }

.nav-toggle {
  display: none; width: 44px; height: 44px; border: 1px solid var(--gray-line);
  background: var(--card); border-radius: 12px; cursor: pointer; position: relative;
}
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
  content: ""; position: absolute; left: 12px; right: 12px; height: 2px; background: var(--ink); border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.nav-toggle-bars { top: 21px; }
.nav-toggle-bars::before { left: 0; right: 0; top: -7px; }
.nav-toggle-bars::after { left: 0; right: 0; top: 7px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::before { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::after { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero { padding: 56px 0 28px; text-align: center; }
.eyebrow { margin: 0 0 8px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .8rem; color: var(--green-dark); }
.hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); letter-spacing: -.02em; }
.hero-text { max-width: 640px; margin: 16px auto 28px; color: var(--ink-soft); font-size: 1.08rem; }

.search-form {
  display: flex; align-items: center; gap: 8px; max-width: 700px; margin: 0 auto;
  background: var(--card); border-radius: 999px; padding: 8px 8px 8px 20px;
  box-shadow: var(--shadow); border: 1px solid var(--gray-line);
}
.search-form:focus-within { border-color: var(--blue); }
.search-icon { width: 22px; height: 22px; color: var(--ink-soft); flex: none; }
.search-form input {
  flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--ink); padding: 10px 4px;
}
.search-form input:focus-visible { outline: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: .93rem; text-decoration: none; cursor: pointer;
  border-radius: 999px; padding: 10px 18px; border: 1px solid transparent;
  transition: background .2s, transform .15s, box-shadow .2s, color .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-download { background: var(--green); color: #fff; }
.btn-download:hover { background: var(--green-dark); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--gray-line); }
.btn-ghost:hover { background: var(--gray-soft); }
.btn-outline { background: var(--card); color: var(--blue-dark); border-color: var(--blue); }
.btn-outline:hover { background: var(--blue-soft); }
.btn[aria-disabled="true"] { background: var(--gray-soft); color: #6b7280; border-color: var(--gray-line); cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Stats ---------- */
.stats { margin-top: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 0; }
.stat { background: var(--card); border-radius: var(--radius); padding: 18px 12px; text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column-reverse; }
.stat dd { margin: 0; font-size: 2rem; font-weight: 800; color: var(--blue-dark); line-height: 1.1; }
.stat dt { color: var(--ink-soft); font-size: .88rem; margin-top: 4px; }

/* ---------- Sections ---------- */
.section { padding: 40px 0 8px; }
.section[hidden] { display: none; }
.section-head { margin-bottom: 18px; }
.section-head h2 { font-size: 1.6rem; }
.section-head p { margin: 6px 0 0; color: var(--ink-soft); }

.notice {
  margin-top: 22px; padding: 14px 18px; border-radius: var(--radius-sm);
  background: #fff7e0; border: 1px solid #f0d98a; color: #5c4400;
}
.notice strong { color: #3f2f00; }

/* ---------- Categories ---------- */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.category-card {
  text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--card); border: 1px solid transparent; border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s, border-color .2s;
  display: flex; flex-direction: column; gap: 6px;
}
.category-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--blue-soft); }
.category-card[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); }
.category-card h3 { font-size: 1.05rem; }
.category-card p { margin: 0; font-size: .9rem; color: var(--ink-soft); }
.category-count { align-self: flex-start; margin-top: 4px; font-size: .8rem; font-weight: 700; color: var(--green-dark); background: var(--green-soft); padding: 3px 10px; border-radius: 999px; }
.category-count.is-empty { color: #6b7280; background: var(--gray-soft); }

/* ---------- Filters ---------- */
.filters {
  display: grid; grid-template-columns: 2fr 1.3fr 1fr 1fr auto auto; gap: 12px; align-items: end;
  background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label:not(.check) { font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.field input[type="search"], .field select {
  font: inherit; color: var(--ink); background: var(--gray-soft);
  border: 1px solid var(--gray-line); border-radius: 12px; padding: 10px 12px; width: 100%;
}
.field input:focus-visible, .field select:focus-visible { outline-offset: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; padding-bottom: 10px; cursor: pointer; white-space: nowrap; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }

/* ---------- Cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.resource-card {
  background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px; transition: transform .2s, box-shadow .2s;
}
.resource-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.resource-card.is-unavailable { opacity: .82; }
.card-top { display: flex; gap: 14px; align-items: flex-start; }
.file-icon { width: 52px; height: 60px; flex: none; }
.card-title { font-size: 1.05rem; font-weight: 700; overflow-wrap: anywhere; }
.card-desc { margin: 4px 0 0; font-size: .92rem; color: var(--ink-soft); }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-dark); }
.badge-featured { background: #fff0c2; color: #6b4b00; }
.badge-missing { background: var(--red-soft); color: var(--red); }

.file-info {
  background: var(--gray-soft); border-radius: var(--radius-sm); padding: 10px 12px;
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: .85rem; margin: 0;
}
.file-info dt { color: var(--ink-soft); }
.file-info dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

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

/* ---------- Empty state / about / footer ---------- */
.empty-state {
  text-align: center; background: var(--card); border-radius: var(--radius); padding: 40px 20px; box-shadow: var(--shadow);
}
.empty-state[hidden] { display: none; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: 6px; }
.empty-state p { color: var(--ink-soft); margin: 6px auto 16px; max-width: 520px; }
.empty-state code { background: var(--gray-soft); padding: 2px 6px; border-radius: 6px; }

.about-card { background: var(--card); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.about-card h2 { margin-bottom: 10px; }
.about-card p { color: var(--ink-soft); max-width: 760px; }

.site-footer { margin-top: 48px; padding: 24px 0 36px; border-top: 1px solid var(--gray-line); color: var(--ink-soft); font-size: .9rem; text-align: center; }
.site-footer p { margin: 4px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .field-search { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .nav-toggle { display: inline-block; }
  .site-nav {
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--cream); border-bottom: 1px solid var(--gray-line);
    padding: 8px 16px 14px; display: none;
  }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; }
  .site-nav a { padding: 12px 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .brand-sub { display: none; }
}

@media (max-width: 560px) {
  .hero { padding-top: 36px; }
  .search-form { flex-direction: column; align-items: stretch; border-radius: var(--radius); padding: 12px; }
  .search-icon { display: none; }
  .search-form input { background: var(--gray-soft); border-radius: 12px; padding: 12px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* ---------- Learning path and ordering ---------- */
.badge-step { background: #fff0c2; color: #6b4b00; }
.badge-order { background: var(--green-soft); color: var(--green-dark); }
.next-hint { margin: 8px 0 0; font-size: .85rem; color: var(--ink-soft); }
.next-hint strong { color: var(--ink); }

.category-step { align-self: flex-start; font-size: .75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #6b4b00; background: #fff0c2; padding: 2px 10px; border-radius: 999px; }

.path-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.path-step { background: var(--card); border: 1px solid var(--gray-line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.path-head { display: flex; gap: 14px; align-items: flex-start; }
.path-num { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 800; display: grid; place-items: center; }
.path-heading h3 { font-size: 1.2rem; }
.path-heading p { margin: 4px 0 0; color: var(--ink-soft); font-size: .92rem; }
.path-files { list-style: none; margin: 16px 0 0 54px; padding: 0; display: grid; gap: 10px; }
.path-file { display: flex; gap: 12px; align-items: flex-start; background: var(--cream); border-radius: var(--radius-sm); padding: 12px 14px; }
.path-file-num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--green); color: #fff; font-size: .85rem; font-weight: 800; display: grid; place-items: center; }
.path-file-body { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; flex: 1; }
.path-links { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-small { padding: 6px 12px; font-size: .85rem; }

@media (max-width: 560px) {
  .path-files { margin-left: 0; }
}
