/* Wonder Why — playful, friendly styling for young readers. */

/* Baloo 2 — self-hosted variable font (weights 400–800), SIL Open Font License.
   Licence + copyright: /static/fonts/OFL.txt. One face per subset: latin covers
   English; latin-ext adds the accents German and Galician need. */
@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/static/fonts/baloo2-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/static/fonts/baloo2-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #fff8ef;
  --ink: #2d2a4a;
  --muted: #6b6885;
  --sun: #ffd23f;
  --sky: #6cc4f5;
  --grass: #7bd389;
  --berry: #ff6f91;
  --card: #ffffff;
  --shadow: 0 8px 24px rgba(45, 42, 74, 0.12);
  --radius: 22px;
  --font: "Baloo 2", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(108, 196, 245, 0.18), transparent 40%),
    radial-gradient(circle at 88% 4%, rgba(255, 111, 145, 0.16), transparent 38%),
    var(--bg);
  line-height: 1.6;
  font-size: 18px;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

main { max-width: 1040px; margin: 0 auto; padding: 0 20px 64px; }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  max-width: 1040px; margin: 0 auto; padding: 18px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.4rem; }
.brand-mark { width: 30px; height: 30px; }
.brand-name { color: var(--ink); }
.site-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.site-nav a {
  text-decoration: none; padding: 8px 14px; border-radius: 999px;
  font-weight: 700; color: var(--ink); transition: background .15s, transform .15s;
}
.site-nav a:hover { background: #fff; box-shadow: var(--shadow); transform: translateY(-1px); }
.lang-switch { position: relative; margin-left: 6px; }
.lang-current {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .85rem; font-weight: 800; letter-spacing: .03em;
  padding: 8px 12px; border-radius: 999px; color: var(--ink);
  transition: background .15s, box-shadow .15s;
}
.lang-current::-webkit-details-marker { display: none; }
.lang-current::after {
  content: ""; width: 8px; height: 8px; border: 2px solid currentColor;
  border-left: 0; border-top: 0; transform: rotate(45deg) translateY(-2px);
  opacity: .5; transition: transform .15s;
}
.lang-switch[open] .lang-current,
.lang-current:hover { background: #fff; box-shadow: var(--shadow); }
.lang-switch[open] .lang-current::after { transform: rotate(225deg) translateY(-2px); }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  margin: 0; padding: 6px; list-style: none; min-width: 160px;
  background: #fff; border-radius: 14px; box-shadow: var(--shadow);
}
.lang-menu li { margin: 0; }
.lang-option {
  display: block; padding: 9px 12px; border-radius: 9px;
  text-decoration: none; font-weight: 700; color: var(--ink); white-space: nowrap;
}
.lang-option:hover { background: var(--bg); }
.lang-option.lang-active { color: var(--berry); }
.lang-option.lang-active::after { content: " ✓"; }
.btn-icon { width: 20px; height: 20px; flex: none; }

/* Hero */
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 24px;
  background: linear-gradient(135deg, #fff, #fffdf6);
  border-radius: 32px; padding: 36px; box-shadow: var(--shadow); margin: 8px 0 40px;
}
.hero h1 { font-size: 2.8rem; margin: 0 0 8px; line-height: 1.1; }
.lede { font-size: 1.25rem; color: var(--muted); margin: 0 0 20px; }
.hero-art img { margin: 0 auto; max-height: 260px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  text-decoration: none; font-weight: 800;
  background: var(--berry); color: #fff; padding: 12px 22px; border-radius: 999px;
  box-shadow: var(--shadow); transition: transform .15s;
}
.btn:hover { transform: translateY(-2px) scale(1.02); }

/* Sections */
.section { margin: 40px 0; }
.section h2, .search-heading { font-size: 1.7rem; margin: 0 0 18px; }

/* Category tiles */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.category-tile {
  position: relative; text-decoration: none; text-align: center;
  background: color-mix(in srgb, var(--tile) 22%, #fff);
  border: 3px solid color-mix(in srgb, var(--tile) 55%, #fff);
  border-radius: var(--radius); padding: 22px 12px; transition: transform .15s;
}
.category-tile:hover { transform: translateY(-3px) rotate(-1deg); }
.category-icon { width: 56px; height: 56px; display: block; margin: 0 auto; }
.category-name { display: block; font-weight: 800; margin-top: 8px; }
.category-count {
  position: absolute; top: 10px; right: 12px; background: #fff; color: var(--muted);
  border-radius: 999px; font-size: .8rem; font-weight: 700; padding: 2px 9px; box-shadow: var(--shadow);
}

/* Story cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column; text-decoration: none;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .15s;
}
.card:hover { transform: translateY(-4px); }
.card-art { background: linear-gradient(135deg, #eef7ff, #fff0f5); padding: 18px; }
.card-art img { height: 140px; margin: 0 auto; object-fit: contain; }
.card-body { padding: 16px 18px 20px; }
.card-body h3 { margin: 0 0 6px; font-size: 1.2rem; }
.card-body p { margin: 0 0 12px; color: var(--muted); font-size: .98rem; }
.card-read { font-weight: 800; color: var(--berry); }

/* Page heads */
.page-head {
  display: flex; align-items: center; gap: 14px; margin: 12px 0 28px;
  background: color-mix(in srgb, var(--tile, #fff) 22%, #fff);
  border-radius: var(--radius); padding: 22px 26px;
}
.page-head-plain { background: #fff; box-shadow: var(--shadow); }
.page-icon { width: 46px; height: 46px; }
.page-head h1 { margin: 0; font-size: 1.9rem; }

/* About page — two friendly notes side by side: one for kids, one for grown-ups. */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin: 4px 0 28px; }
.about-note { border-radius: var(--radius); padding: 26px 28px; box-shadow: var(--shadow); }
.about-note h2 { margin: 0 0 12px; font-size: 1.5rem; }
.about-note p { margin: 0; font-size: 1.12rem; line-height: 1.55; }
.about-kids { background: #eaf7ff; border: 3px solid var(--sky); }
.about-kids h2 { color: #1f86c4; }
.about-grown { background: #fff6e6; border: 3px solid var(--sun); }
.about-grown h2 { color: #d98a00; }
.about-cta { text-align: center; margin: 4px 0 40px; }

/* Story article */
.story { max-width: 720px; margin: 0 auto; }
.crumbs { margin: 8px 0 4px; }
.crumbs a { text-decoration: none; font-weight: 700; color: var(--muted); }
.crumb-icon { width: 22px; height: 22px; vertical-align: -6px; }
.story h1 { font-size: 2.2rem; margin: 6px 0 18px; }
.story-art {
  margin: 0 0 24px; background: linear-gradient(135deg, #eef7ff, #fff0f5);
  border-radius: var(--radius); padding: 28px;
}
.story-art img { max-height: 320px; margin: 0 auto; }

.prose { font-size: 1.12rem; }
.prose p { margin: 0 0 16px; }
.prose h2 { font-size: 1.4rem; margin: 28px 0 10px; }
.prose strong { color: var(--berry); }
.prose ul { padding-left: 1.2em; }

/* "Wonder fact" callout — Markdown blockquotes become a friendly idea box. */
.prose blockquote {
  position: relative;
  margin: 30px 0 8px;
  padding: 20px 24px 20px 70px;
  background: linear-gradient(135deg, #fff7e0, #fff0f5);
  border: 3px solid #ffe08a;
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.prose blockquote::before {
  content: "";
  position: absolute;
  left: 18px; top: 18px;
  width: 38px; height: 38px;
  background: url("/static/img/icons/ui-idea.svg") center / contain no-repeat;
}
.prose blockquote p { margin: 0; }
.prose blockquote strong { color: #e8930c; }

.story-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 36px 0 12px;
}
.story-nav a {
  text-decoration: none; background: #fff; border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow); color: var(--muted); font-size: .95rem;
}
.story-nav a strong { color: var(--ink); display: block; margin-top: 2px; }
.story-nav-next { text-align: right; }

.back { margin-top: 28px; }
.back a { text-decoration: none; font-weight: 700; color: var(--muted); }

/* Newsletter */
.newsletter {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 22px;
  background: linear-gradient(135deg, #fffbe9, #ffeef5);
  border-radius: 32px; padding: 30px 34px; margin: 48px 0 0; box-shadow: var(--shadow);
}
.newsletter-art { width: 62px; height: 62px; }
.newsletter h2 { margin: 0 0 6px; }
.newsletter p { margin: 0 0 14px; color: var(--muted); }
.newsletter-form { display: flex; gap: 10px; flex-wrap: wrap; }
.newsletter-form input {
  flex: 1; min-width: 220px; border: 3px solid #ffd9e6; border-radius: 999px;
  padding: 12px 18px; font-family: inherit; font-size: 1rem;
}
.newsletter-form button, .search-form button {
  border: none; background: var(--berry); color: #fff; font-weight: 800; font-family: inherit;
  padding: 12px 24px; border-radius: 999px; cursor: pointer; transition: transform .15s;
}
.newsletter-form button:hover, .search-form button:hover { transform: translateY(-2px); }
.note { font-weight: 700; }
.note-ok { color: #2f9e44; }
.note-bad { color: #e03131; }

/* Search */
.search-form { display: flex; gap: 10px; margin: 0 0 28px; flex-wrap: wrap; }
.search-form input {
  flex: 1; min-width: 240px; border: 3px solid #d6ecff; border-radius: 999px;
  padding: 12px 20px; font-family: inherit; font-size: 1.05rem;
}
.empty { font-size: 1.15rem; color: var(--muted); }

/* The Big Book — download landing page */
.bookshelf {
  display: flex; gap: 48px; align-items: center; flex-wrap: wrap;
  justify-content: center; padding: 32px 0 16px;
}
.bookshelf-text { flex: 1; min-width: 280px; max-width: 460px; }
.bookshelf-text h1 { font-size: 2.4rem; margin: 0 0 12px; }
.bookshelf-text .lede { font-size: 1.2rem; color: var(--muted); }
.book-stat { font-size: 1.05rem; color: var(--muted); margin: 18px 0 24px; }
.book-stat strong { color: var(--berry); font-size: 1.4rem; }
.btn-big { font-size: 1.2rem; padding: 16px 28px; }

/* A little 3-D book cover that mirrors the printed cover. */
.book-3d { perspective: 1400px; flex-shrink: 0; }
.book-3d-cover {
  width: 260px; height: 348px; border-radius: 8px 16px 16px 8px;
  background: linear-gradient(150deg, var(--c1), var(--c2));
  box-shadow: var(--shadow), inset 6px 0 0 rgba(255,255,255,.45), inset 10px 0 14px rgba(45,42,74,.08);
  border-left: 8px solid rgba(45,42,74,.12);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 28px; text-align: center;
  transform: rotateY(-18deg) rotateX(3deg); transition: transform .35s ease;
}
.book-3d-cover:hover { transform: rotateY(-6deg) rotateX(1deg); }
.book-3d-cover img { width: 70%; }
.book-3d-title { font-weight: 800; font-size: 1.5rem; color: #27314f; line-height: 1.2; }

/* Footer */
.site-footer { text-align: center; color: var(--muted); padding: 30px 20px 50px; }

/* Responsive */
@media (max-width: 720px) {
  body { font-size: 17px; }
  .hero { grid-template-columns: 1fr; text-align: center; padding: 26px; }
  .hero-art { order: -1; }
  .hero h1 { font-size: 2.2rem; }
  .newsletter { grid-template-columns: 1fr; text-align: center; }
  .newsletter-form { justify-content: center; }
  .story-nav { grid-template-columns: 1fr; }
  .story-nav-next { text-align: left; }
  .about-grid { grid-template-columns: 1fr; }
}
