/* Storybook look: warm paper, crayon palette, wobbly hand-cut card shapes. */
@font-face {
  font-family: 'Baloo 2';
  src: url('fonts/baloo2-latin-ext.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0;
}
@font-face {
  font-family: 'Baloo 2';
  src: url('fonts/baloo2-latin.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC;
}

:root {
  --paper: #FAF1DE;
  --card: #FFFBF2;
  --ink: #46392E;
  --ink-soft: #8A7A69;
  --terracotta: #E0684B;
  --mustard: #EFAF3C;
  --sage: #7FA05C;
  --sky: #6FAEC4;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: 'Baloo 2', -apple-system, sans-serif;
  background: var(--paper);
  min-height: 100vh;
  padding-bottom: 170px; /* room for sticky player */
  color: var(--ink);
}

header {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 0;
  overflow: hidden;
}
.sun {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 52px;
  height: 52px;
  transform: rotate(8deg);
}
.masthead {
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.mascot { width: 148px; flex: none; margin-bottom: -3px; }
.title-block { padding-bottom: 22px; min-width: 0; }
.eyebrow {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  transform: rotate(-2deg);
  margin-left: 4px;
}
h1 {
  font-size: 40px;
  font-weight: 800;
  line-height: 0.9;
  margin: 0;
  transform: rotate(-2deg);
  letter-spacing: 0.01em;
}

main { max-width: 560px; margin: 0 auto; padding: 10px 18px; }

h2.section {
  display: inline-block;
  font-size: 21px;
  font-weight: 800;
  margin: 26px 2px 12px;
  transform: rotate(-1deg);
  padding-bottom: 7px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='7'%3E%3Cpath d='M2 4.5 Q 9 1 16 4.5 T 30 4.5 T 44 4.5' fill='none' stroke='%23E0684B' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x bottom left;
}
h2.section:nth-of-type(2) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='7'%3E%3Cpath d='M2 4.5 Q 9 1 16 4.5 T 30 4.5 T 44 4.5' fill='none' stroke='%236FAEC4' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}

.view-toggle {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.vt {
  border: 3px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 14px 18px 12px 16px / 16px 12px 18px 14px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(70, 57, 46, 0.25);
}
.vt.on { background: var(--mustard); }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* book mode: swipe through episodes like pages of a picture book */
.book {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 16px;
  padding: 18px 2px 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.book::-webkit-scrollbar { display: none; }
.page { flex: 0 0 86%; scroll-snap-align: center; }
.page .title { font-size: 20px; }
.page .meta { font-size: 14px; }
.page .sec {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.page .row { padding: 10px 14px 12px; }
.page .play .badge { width: 50px; height: 50px; }
.page .play .badge svg { width: 24px; height: 24px; }

/* picture-first tiles: the artwork is the play button */
.card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 18px 22px 16px 24px / 22px 16px 24px 18px;
  overflow: hidden;
  box-shadow: 3px 4px 0 rgba(70, 57, 46, 0.18);
}
.card:nth-child(odd) { transform: rotate(-0.5deg); }
.card:nth-child(even) { transform: rotate(0.45deg); border-radius: 24px 16px 22px 18px / 16px 24px 18px 22px; }
.card.playing { border-color: var(--terracotta); box-shadow: 3px 4px 0 rgba(224, 104, 75, 0.45); }

.card .play {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 320 / 220;
  padding: 0;
  border: none;
  border-bottom: 3px solid var(--ink);
  background-size: cover;
  background-position: center;
  cursor: pointer;
}
.card .play .badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 40px;
  height: 40px;
  border-radius: 50% 46% 48% 52% / 48% 52% 46% 50%;
  border: 3px solid var(--ink);
  color: var(--card);
  background: var(--sage);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 rgba(70, 57, 46, 0.35);
}
.card .play .badge svg { width: 20px; height: 20px; margin-left: 1px; }
.card.playing .play .badge { background: var(--terracotta); }
.card.playing .play .badge svg { margin-left: 0; }

/* crayon-coloured episode numbers */
.card .num {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 30px;
  height: 30px;
  border-radius: 48% 52% 46% 54% / 52% 46% 54% 48%;
  border: 2.5px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: var(--card);
  transform: rotate(-4deg);
}
.num.c0 { background: var(--terracotta); }
.num.c1 { background: var(--mustard); transform: rotate(3deg); }
.num.c2 { background: var(--sky); transform: rotate(-2deg); }
.num.c3 { background: var(--sage); transform: rotate(4deg); }

.card .row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 9px;
}
.card .info { flex: 1; min-width: 0; }
.card .title { font-weight: 700; font-size: 15px; line-height: 1.1; }
.card .meta { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-top: 2px; }
.card .resume { color: var(--terracotta); }

.card .dl {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 46% 54% 48% 52% / 54% 48% 52% 46%;
  border: 3px solid var(--ink-soft);
  background: transparent;
  font-family: inherit;
  font-weight: 800;
  font-size: 11px;
  cursor: pointer;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card .dl svg { width: 18px; height: 18px; }
.card .dl.done { border-color: var(--sage); color: var(--sage); border-style: solid; }
.card .dl.busy { border-style: dashed; color: var(--terracotta); border-color: var(--terracotta); }

#player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--card);
  border: 3px solid var(--ink);
  border-bottom: none;
  border-radius: 26px 20px 0 0 / 22px 26px 0 0;
  box-shadow: 0 -4px 0 rgba(70, 57, 46, 0.12);
  padding: 12px 22px calc(14px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}
#player.hidden { display: none; }

.player-title {
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-bar { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.player-bar input[type=range] { flex: 1; accent-color: var(--terracotta); height: 30px; }

.player-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  margin-top: 4px;
}
.ctrl {
  border: 3px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  border-radius: 52% 48% 50% 50% / 48% 52% 48% 52%;
  width: 56px;
  height: 56px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 rgba(70, 57, 46, 0.3);
}
.ctrl:active { transform: translateY(2px); box-shadow: none; }
.ctrl.big {
  width: 76px;
  height: 76px;
  background: var(--terracotta);
  color: var(--card);
}
.ctrl.big svg { margin-left: 3px; }
.ctrl.big.is-pause svg { margin-left: 0; }

.offline-note {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 22px 0;
  transform: rotate(-0.5deg);
}
