@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --bg: #FFFCF3;
  --ink: #1B2358;
  --ink-soft: #4A5687;
  --muted: #7A82A6;
  --border: #ECE3CA;
  --card: #FFFFFF;
  --primary: #4A6CF7;
  --primary-ink: #FFFFFF;
  --accent: #FFC23C;
  --accent-ink: #1B2358;
  --warm: #FF6B6B;
  --leaf: #3DC97F;
  --sky: #6FC8FF;
  --berry: #E94B7C;
  --plum: #8462E0;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 8px 22px rgba(27, 35, 88, 0.08);
  --shadow-lg: 0 14px 38px rgba(27, 35, 88, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .brand-title, .btn { font-family: 'Fredoka', 'Nunito', sans-serif; letter-spacing: -0.01em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* Header */
.site-header {
  background: linear-gradient(180deg, #FFF6D6 0%, #FFFCF3 100%);
  border-bottom: 3px solid #F1E4B8;
  padding: 16px 0 0;
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(8px);
}
.header-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-size: 26px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.nav-primary { display: flex; gap: 22px; margin-left: auto; }
.nav-primary a { color: var(--ink); font-weight: 700; }
.search { display: flex; gap: 6px; }
.search input { padding: 10px 16px; border: 2px solid #F1E4B8; border-radius: 999px; min-width: 240px; background: #fff; font-family: inherit; font-size: 15px; }
.search input:focus { outline: none; border-color: var(--primary); }
.search button { padding: 10px 20px; border-radius: 999px; border: 0; background: var(--primary); color: #fff; font-weight: 800; cursor: pointer; font-family: inherit; }
.subnav { display: flex; gap: 18px; padding: 12px 24px; flex-wrap: wrap; border-top: 1px dashed #F1E4B8; margin-top: 14px; }
.subnav a { color: var(--ink-soft); font-size: 14px; font-weight: 700; }
.subnav a:hover { color: var(--primary); text-decoration: none; }

/* Hero */
.hero {
  background:
    radial-gradient(circle at 20% 20%, #FFE08A 0, transparent 45%),
    radial-gradient(circle at 80% 70%, #C4D6FF 0, transparent 50%),
    linear-gradient(135deg, #FFF1B5 0%, #FFD4B5 45%, #C8DAFF 100%);
  padding: 64px 0 72px;
  border-bottom: 4px solid #F1E4B8;
}
.hero-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(34px, 4.6vw, 56px); margin: 0 0 16px; line-height: 1.05; color: var(--ink); }
.hero p.lede { font-size: 20px; color: var(--ink-soft); margin: 0 0 24px; max-width: 56ch; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; background: rgba(255,255,255,0.7); border: 1.5px solid #F1E4B8; border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; }
.hero-pill .dot { width: 8px; height: 8px; background: var(--leaf); border-radius: 50%; }
.btn { display: inline-block; padding: 13px 26px; border-radius: 999px; font-weight: 700; border: 0; cursor: pointer; font-size: 16px; transition: transform .12s ease, box-shadow .12s ease; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: #fff; color: var(--ink); border: 2px solid var(--border); }
.hero-art img { width: 100%; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 5px solid #fff; transform: rotate(-1.5deg); }

.hero-stats { display: flex; gap: 32px; margin-top: 28px; flex-wrap: wrap; }
.hero-stats .stat .num { font-family: 'Fredoka', sans-serif; font-size: 30px; font-weight: 700; color: var(--ink); display: block; line-height: 1; }
.hero-stats .stat .lbl { font-size: 13px; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

/* Sections */
section { padding: 56px 0; }
section h2 { font-size: 34px; margin: 0 0 8px; }
section .section-sub { color: var(--muted); margin: 0 0 28px; font-size: 17px; }
.section-eyebrow { color: var(--berry); font-weight: 800; text-transform: uppercase; font-size: 13px; letter-spacing: 0.08em; margin: 0 0 6px; }

/* Cards */
.grid { display: grid; gap: 22px; }
.grid.cats { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.sheets { grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); }
.card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  text-decoration: none; color: inherit;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: #FFD27A; text-decoration: none; }
.card .thumb { aspect-ratio: 4 / 3; background: #F4EDD8; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 14px 18px 18px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.card .title { font-weight: 800; color: var(--ink); font-size: 16px; line-height: 1.3; font-family: 'Fredoka', sans-serif; }
.card .meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.tag { display: inline-block; padding: 3px 11px; background: #FFF1C2; color: #6A4F00; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag.subj { background: #DCE5FF; color: #2238A0; }
.tag.grade { background: #DDF7E6; color: #1E6A3E; }

.cat-tile {
  padding: 24px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 8px; min-height: 168px;
  text-decoration: none; color: inherit;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  position: relative; overflow: hidden;
}
.cat-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: #FFD27A; text-decoration: none; }
.cat-tile .icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: var(--ink); font-weight: 800; font-family: 'Fredoka', sans-serif; font-size: 20px; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.06); }
.cat-tile h3 { margin: 8px 0 0; font-size: 19px; }
.cat-tile p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.cat-tile .count { color: var(--muted); font-size: 12px; margin-top: auto; font-weight: 700; }

/* Color rotation for category tiles */
.cat-tile:nth-child(7n+1) .icon { background: #FFD27A; }
.cat-tile:nth-child(7n+2) .icon { background: #BDE0FF; color: #2238A0; }
.cat-tile:nth-child(7n+3) .icon { background: #FFCBD3; color: #B23254; }
.cat-tile:nth-child(7n+4) .icon { background: #C7F2D5; color: #1E6A3E; }
.cat-tile:nth-child(7n+5) .icon { background: #E4D6FF; color: #4D2FA9; }
.cat-tile:nth-child(7n+6) .icon { background: #FFE3B5; color: #6A4F00; }
.cat-tile:nth-child(7n+7) .icon { background: #B6F0EA; color: #0E5A52; }

/* Worksheet detail */
.sheet-detail { display: grid; grid-template-columns: 1.25fr .75fr; gap: 36px; align-items: start; }
.sheet-detail .preview { background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.sheet-detail .preview img { width: 100%; border-radius: 10px; }
.sheet-detail h1 { font-size: clamp(28px, 3.4vw, 40px); margin: 0 0 8px; line-height: 1.1; }
.sheet-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 18px; }
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 22px 0; }
.sheet-prose { color: var(--ink); }
.sheet-prose p { color: var(--ink-soft); margin: 12px 0; }
.sheet-prose h2 { font-size: 24px; margin-top: 32px; margin-bottom: 8px; color: var(--ink); }
.sheet-prose ul { padding-left: 22px; color: var(--ink-soft); }
.sheet-prose ul li { margin-bottom: 6px; }
.sheet-prose a { color: var(--primary); font-weight: 700; }
.sidebar-card { background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.sidebar-card h3 { margin: 0 0 12px; font-size: 18px; }
.sidebar-card ul { padding-left: 20px; margin: 0; }

/* Sidebar recommended block */
.sidebar-rec { background: linear-gradient(180deg, #FFF7E0 0%, #FFFCF3 100%); border: 1.5px solid #F1E4B8; }
.sidebar-rec ul.rec-list { padding-left: 0; list-style: none; margin: 0; }
.sidebar-rec ul.rec-list li { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed #F1E4B8; line-height: 1.4; }
.sidebar-rec ul.rec-list li:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.sidebar-rec a { color: var(--ink); font-weight: 700; }

/* Adsense placeholders */
.ad-slot { background: repeating-linear-gradient(45deg, #FFF6DD, #FFF6DD 10px, #FFEDB8 10px, #FFEDB8 20px); border: 1px dashed #C2A654; color: #6A4F00; padding: 18px; border-radius: 12px; text-align: center; font-size: 13px; margin: 18px 0; font-weight: 700; }

/* Breadcrumbs */
.crumbs { font-size: 13px; color: var(--muted); margin: 24px 0 12px; font-weight: 600; }
.crumbs a { color: var(--ink-soft); }

/* Featured background */
.bg-warm { background: linear-gradient(180deg, #FFF6DD 0%, #FFFCF3 100%); }
.bg-cool { background: linear-gradient(180deg, #ECF3FF 0%, #FFFCF3 100%); }

/* Footer */
.site-footer { background: #1B2358; color: #E5EAFF; margin-top: 64px; padding: 48px 0 20px; }
.site-footer .recommended { background: linear-gradient(180deg, #2A3573 0%, #1B2358 100%); border-radius: var(--radius-lg); padding: 28px; margin-bottom: 32px; }
.site-footer .rec-title { color: #FFF; margin: 0 0 6px; font-size: 22px; }
.site-footer .rec-sub { color: #B9C5FF; margin: 0 0 16px; font-size: 14px; }
.site-footer .rec-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px 24px; }
.site-footer .rec-list li { padding: 10px 14px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; line-height: 1.4; }
.site-footer .rec-list a { color: #FFE08A; font-weight: 700; }
.site-footer .wrap.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; }
.site-footer h3, .site-footer h4 { color: #FFF; margin: 0 0 12px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer ul li { margin-bottom: 6px; }
.site-footer a { color: #B9C5FF; }
.copyright { padding-top: 24px; margin-top: 24px; border-top: 1px solid #2E3B7A; font-size: 13px; color: #93A0D6; }

/* Responsive */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .sheet-detail { grid-template-columns: 1fr; }
  .site-footer .wrap.footer-grid { grid-template-columns: 1fr; }
  .nav-primary { order: 3; width: 100%; justify-content: space-between; }
  .search { width: 100%; }
  .search input { flex: 1; min-width: 0; }
  .hero { padding: 40px 0 48px; }
  section { padding: 40px 0; }
}

/* Print friendliness for worksheet pages */
@media print {
  .site-header, .site-footer, .ad-slot, .sheet-actions, .crumbs, .related, form, aside { display: none !important; }
  body { background: #fff; }
  .sheet-detail { grid-template-columns: 1fr; }
}
