/* Contes.cat — hand-written, no build step. Paper-cut storybook look: warm paper,
   ink outlines, solid offset shadows that press down when tapped. */

@font-face { font-family: Fredoka; src: url(/assets/fonts/fredoka.woff2) format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: Impremta; src: url(/assets/fonts/impremta.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: Lligada; src: url(/assets/fonts/lligada.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: Pal; src: url(/assets/fonts/carrois-sc.woff2) format("woff2"); font-display: swap; }

:root {
  --paper: #fff8ec;
  --card: #fff;
  --ink: #2b2a4c;
  --soft: #5d5b7c;
  --line: #2b2a4c;
  --tomato: #cf3f27; --tomato-t: #ffe3da;
  --sun: #f6b62c; --sun-t: #fff0c7;
  --leaf: #23804f; --leaf-t: #dcf4e3;
  --sky: #1b76b5; --sky-t: #d9f0fd;
  --plum: #7445c8; --plum-t: #ece3fc;
  --pine: #17674d; --pine-t: #d6efe5;
  --c: var(--tomato); --t: var(--tomato-t);
  --display: Fredoka, ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  --radius: 18px;
  --reader-size: 1.4rem;
}

.c-tomato { --c: var(--tomato); --t: var(--tomato-t); }
.c-sun { --c: #a86f00; --t: var(--sun-t); }
.c-leaf { --c: var(--leaf); --t: var(--leaf-t); }
.c-sky { --c: var(--sky); --t: var(--sky-t); }
.c-plum { --c: var(--plum); --t: var(--plum-t); }
.c-pine { --c: var(--pine); --t: var(--pine-t); }
.c-ink { --c: var(--ink); --t: #e4e3f0; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 6vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2rem); margin-top: 1.75em; }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
a { color: var(--sky); }
img { max-width: 100%; height: auto; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--plum); outline-offset: 2px; border-radius: 6px; }

.wrap { width: min(1120px, 100% - 2rem); margin-inline: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 50; background: #fff; padding: .5rem 1rem; }

/* Header */
.top { background: var(--card); border-bottom: 3px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 1.25rem; min-height: 68px; }
.logo { display: flex; align-items: center; gap: .4rem; text-decoration: none; font: 700 1.7rem/1 var(--display); color: var(--ink); }
.logo b { font-weight: 700; }
.logo b:nth-child(1) { color: var(--tomato); }
.logo b:nth-child(2) { color: #d98a00; }
.logo b:nth-child(3) { color: var(--leaf); }
.logo b:nth-child(4) { color: var(--sky); }
.logo b:nth-child(5) { color: var(--plum); }
.logo b:nth-child(6) { color: var(--tomato); }
.logo i { font-style: normal; font-size: .75em; color: var(--soft); }
.nav { display: flex; gap: .15rem; margin-left: auto; }
.nav a { padding: .4rem .7rem; border-radius: 12px; color: var(--ink); text-decoration: none; font: 500 1.05rem var(--display); }
.nav a:hover { background: var(--sun-t); }
.nav a[aria-current] { background: var(--ink); color: #fff; }
.top-search { display: flex; border: 2.5px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.top-search input { border: 0; padding: .35rem .6rem; width: 8.5rem; background: none; outline: 0; }
.top-search button { border: 0; background: var(--sun-t); padding: 0 .6rem; cursor: pointer; }

.crumbs { font-size: .95rem; color: var(--soft); padding-block: .6rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.crumbs a { color: var(--soft); }

/* Buttons and chips */
.btn {
  display: inline-block; padding: .65rem 1.25rem; min-height: 48px;
  border: 2.5px solid var(--line); border-radius: 16px;
  background: var(--tomato); color: #fff;
  font: 600 1.1rem/1.4 var(--display); text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 0 var(--line); transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--line); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }
.btn-sun { background: var(--sun); color: var(--ink); }
.btn-leaf { background: var(--leaf); }
.btn-ghost { background: var(--card); color: var(--ink); }

.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .4rem .85rem; min-height: 44px;
  background: var(--card); color: var(--ink); text-decoration: none;
  border: 2.5px solid var(--line); border-radius: 999px; font: 500 1rem var(--display);
}
.chip small { color: var(--soft); font-size: .8em; }
.chip:hover { background: var(--sun-t); }
.chip[aria-current] { background: var(--ink); color: #fff; }
.chip[aria-current] small { color: #fff; }
.chip-all { background: var(--sun); }
.chips-wide, .filters { display: flex; flex-wrap: wrap; gap: .5rem; }
.filters { margin-top: 1.25rem; }
.pill { display: inline-block; font: 500 .9rem var(--display); padding: .1rem .6rem; border-radius: 999px; background: var(--t); color: var(--ink); }

/* Hero */
.hero { position: relative; background: var(--sky-t); border-bottom: 3px solid var(--line); overflow: hidden; }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: #fff; opacity: .75; }
.hero::before { width: 240px; height: 70px; top: 12%; right: 30%; box-shadow: 90px 30px 0 -14px #fff; }
.hero::after { width: 480px; height: 480px; right: -80px; bottom: -350px; background: #8fd6a8; opacity: 1; border: 3px solid var(--line); }
.hero-row { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding-block: clamp(1.5rem, 5vw, 3.5rem); }
.hero-copy { max-width: 640px; }
.hero h1 { margin-bottom: .25em; }
.hero-owl { flex: none; width: clamp(150px, 22vw, 240px); }
.big-search { display: flex; gap: .5rem; margin-block: 1rem .9rem; }
.big-search input {
  flex: 1; min-width: 0; min-height: 52px; padding: .5rem 1rem;
  border: 2.5px solid var(--line); border-radius: 16px; background: #fff; font-size: 1.1rem;
}

/* Today's picks */
.today-grid { display: grid; gap: 1.1rem; align-items: start; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.today-btn { margin-top: .9rem; }
.today-card, .card {
  display: flex; flex-direction: column; align-items: flex-start;
  background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: 5px 5px 0 var(--c);
}
.today-card { background: var(--t); }
.today-card .tag { font: 600 .95rem var(--display); color: var(--c); margin-bottom: .4rem; }
.today-card h3 { font-size: 1.5rem; }
.today-card h3 a, .card h3 a { color: var(--ink); text-decoration: none; }
.today-card h3 a:hover, .card h3 a:hover { color: var(--c); }
.verse { font: 500 1.15rem/1.45 var(--display); margin-bottom: .75rem; }
.more { color: var(--c); font: 600 1rem var(--display); margin-top: auto; }

.answer { margin-bottom: .6rem; width: 100%; }
.answer summary {
  display: inline-block; cursor: pointer; list-style: none; padding: .35rem .9rem; min-height: 40px;
  background: var(--sun); border: 2.5px solid var(--line); border-radius: 12px; font: 600 1rem var(--display);
}
.answer summary::-webkit-details-marker { display: none; }
.answer[open] summary { display: none; }
.answer p { font: 600 1.25rem var(--display); color: var(--c); margin: 0; animation: pop .3s; }
.answer p::before { content: "🎉 "; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

/* Section tiles */
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.tiles-small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .15rem;
  padding: 1rem .6rem; background: var(--t); color: var(--ink); text-decoration: none;
  border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 0 var(--line);
  transition: transform .1s, box-shadow .1s;
}
.tile:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: 0 8px 0 var(--line); }
.tile:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.tile-emoji { font-size: 2.6rem; line-height: 1.2; }
.tile strong { font: 600 1.12rem/1.2 var(--display); }
.tile small { color: var(--soft); }

/* Bedtime band */
.night { margin-top: 2.5rem; padding-block: .5rem 2.25rem; background: #2b2a4c; color: #fff; }
.night .card { color: var(--ink); }
.night .card { box-shadow: 5px 5px 0 var(--sun); }

/* Lists */
.band { background: var(--t); border-block: 3px solid var(--line); padding-block: 1.5rem; }
.band h1 { margin-bottom: .2em; }
.band p { margin-bottom: .8rem; max-width: 60ch; }
.count { color: var(--soft); margin-block: 1rem .75rem; }
.grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.card h3 { margin-bottom: .2em; }
.card small { color: var(--soft); margin-bottom: .3rem; }
.card p { color: var(--soft); margin-bottom: .6rem; }
.card .pill { margin-top: auto; }
.card-short p.verse { color: var(--ink); }
.grid-break { grid-column: 1 / -1; }

/* Videos */
.videos { display: grid; gap: 1.1rem; margin-top: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.video { display: block; color: var(--ink); text-decoration: none; background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 5px 0 var(--line); transition: transform .1s; }
.video:hover { transform: translateY(-3px); }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--t); border-bottom: 2.5px solid var(--line); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.play { position: absolute; inset: 50% auto auto 50%; width: 56px; height: 56px; margin: -28px; background: var(--tomato); border: 2.5px solid var(--line); border-radius: 50%; }
.play::after { content: ""; position: absolute; left: 21px; top: 14px; border: 11px solid transparent; border-left: 17px solid #fff; border-right: 0; }
.video-title { display: block; padding: .6rem .8rem; font: 500 1.05rem/1.25 var(--display); }
.player { width: min(1000px, 96vw); padding: 0; border: 3px solid var(--line); border-radius: var(--radius); background: #000; overflow: visible; }
.player::backdrop { background: rgb(43 42 76 / .85); }
.player iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 15px; }
.player button { position: absolute; top: -18px; right: -10px; width: 48px; height: 48px; font-size: 1.3rem; background: var(--sun); border: 2.5px solid var(--line); border-radius: 50%; cursor: pointer; }

/* Pagination */
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin-block: 2rem .5rem; }
.pager a, .pager .current { display: grid; place-items: center; min-width: 46px; height: 46px; padding-inline: .5rem; border: 2.5px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); text-decoration: none; font: 600 1.05rem var(--display); }
.pager .current { background: var(--ink); color: #fff; }
.pager .gap { align-self: center; }

/* Reader */
.progress { position: sticky; top: 0; z-index: 12; height: 6px; background: transparent; }
.progress span { display: block; height: 100%; width: 100%; background: var(--c); transform: scaleX(0); transform-origin: left; }
.reader { width: min(760px, 100% - 2rem); margin: .5rem auto 0; }
.reader-head { text-align: center; }
.reader-head h1 { margin-bottom: .15em; }
.subtitle { color: var(--soft); font: 500 1.15rem var(--display); margin-bottom: .4rem; }
.meta { margin-bottom: 1rem; }

.tools {
  position: sticky; top: 10px; z-index: 10;
  display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem .6rem;
  padding: .4rem; margin-bottom: 1.5rem;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--line);
}
.tool-group { display: flex; gap: .2rem; }
.tools button, .tool-link {
  display: inline-grid; grid-auto-flow: column; gap: .25rem; place-items: center;
  min-width: 44px; height: 44px; padding-inline: .45rem;
  border: 0; border-radius: 10px; background: none; color: var(--ink); cursor: pointer;
  font: 600 1.1rem var(--display); text-decoration: none;
}
.tools button:hover, .tool-link:hover { background: var(--sun-t); }
.tools button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.tools button[data-fav][aria-pressed="true"] { background: var(--tomato-t); }
.f-lligada { font-family: Lligada, cursive !important; }
.f-impremta { font-family: Impremta, sans-serif; }
.f-pal { font-family: Pal, sans-serif !important; }

.story-text { font: var(--reader-size)/1.7 Impremta, Georgia, serif; overflow-wrap: anywhere; }
.story-text p { margin-bottom: 1.1em; }
.story-text.is-verse { text-align: center; font-size: calc(var(--reader-size) * 1.12); }
.story-text .speaking { background: var(--sun-t); box-shadow: 0 0 0 .3em var(--sun-t); border-radius: 4px; }
html[data-lletra="lligada"] .story-text { font-family: Lligada, cursive; font-size: calc(var(--reader-size) * 1.45); line-height: 1.75; }
html[data-lletra="pal"] .story-text { font-family: Pal, sans-serif; letter-spacing: .03em; }
html[data-mida="1"] { --reader-size: 1.1rem; }
html[data-mida="2"] { --reader-size: 1.25rem; }
html[data-mida="4"] { --reader-size: 1.65rem; }
html[data-mida="5"] { --reader-size: 2rem; }
html[data-mida="6"] { --reader-size: 2.5rem; }
html[data-mida="7"] { --reader-size: 3.2rem; }
html[data-mida="8"] { --reader-size: 4rem; }

.answer-big { text-align: center; margin-block: 1rem; }
.answer-big summary { font-size: 1.25rem; padding: .6rem 1.4rem; }
.answer-big p { font-size: 2rem; }
.the-end { text-align: center; font: 500 1.2rem var(--display); color: var(--c); }
.after { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem; margin-block: 1.5rem; }
.more-reading { margin-bottom: 1rem; }

.reader:fullscreen { width: 100%; margin: 0; padding: 2rem max(1rem, 8vw); overflow: auto; background: var(--paper); }
.reader:fullscreen .after { display: none; }

html[data-nit="1"] {
  --paper: #1d1c3a; --card: #2b2a4c; --ink: #f4eedd; --soft: #bbb7d8; --line: #4b4977;
  --sun-t: #4b4977; --tomato-t: #5a3048; color-scheme: dark;
}
html[data-nit="1"] .top-search { background: var(--card); }
html[data-nit="1"] .pill { color: #2b2a4c; }
html[data-nit="1"] a { color: #9fd2f5; }
html[data-nit="1"] .answer summary { color: #2b2a4c; }
html[data-nit="1"] .btn-ghost { color: var(--ink); }
html[data-nit="1"] .btn-sun { color: #2b2a4c; }
html[data-nit="1"] .btn { color: #fff; }
html[data-nit="1"] .btn-sun, html[data-nit="1"] .chip-all { color: #2b2a4c; }

/* Ads: reserved height so the page does not jump; hidden when nothing fills them. */
.ad { width: min(970px, 100% - 2rem); min-height: 280px; margin: 2rem auto; text-align: center; }
.ad small { display: block; color: var(--soft); font-size: .75rem; }
.grid-break .ad, .videos .ad { width: 100%; margin-block: .5rem; }
.ad:has(ins[data-ad-status="unfilled"]) { display: none; }

/* Grown-ups */
.adults {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  margin-block: 2.5rem 1rem; padding: 1.25rem 1.5rem;
  background: var(--leaf-t); border: 2.5px solid var(--line); border-radius: var(--radius);
}
.adults h2 { margin-top: 0; }
.adults p { margin: 0; max-width: 60ch; }
.prose-grid { display: grid; gap: 1.1rem; margin-top: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.how { background: var(--t); border: 2.5px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.how h2 { margin-top: 0; font-size: 1.35rem; }
.how p:last-child { margin: 0; }
.how-tip { font-size: 1.05rem; }
.note { color: var(--soft); margin-top: .9rem; font-size: .95rem; }
.ideas { padding-left: 1.2rem; max-width: 70ch; }
.ideas li { margin-bottom: .5rem; }
.prose { max-width: 70ch; padding-block: 1.5rem; }
.prose h2 { font-size: 1.4rem; margin-top: 1.4em; }

.empty { text-align: center; padding-block: 2.5rem; }
.empty h1, .empty h2 { margin-top: 0; }
.empty-icon { font-size: 4.5rem; line-height: 1; margin-bottom: .5rem; }

/* Footer and mobile tab bar */
.foot { margin-top: 3rem; padding-block: 1.25rem; background: var(--card); border-top: 3px solid var(--line); color: var(--soft); font-size: .95rem; }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; }
.foot p { margin: 0; }
.foot nav { display: flex; flex-wrap: wrap; gap: 1rem; }
.foot a { color: var(--soft); }

.tabs { display: none; }

@media (max-width: 1000px) {
  .nav { display: none; }
  .top-search { margin-left: auto; }
}
@media (max-width: 720px) {
  body { padding-bottom: 76px; }
  .top-row { min-height: 58px; }
  .logo { font-size: 1.45rem; }
  .logo img { width: 36px; height: 36px; }
  .top-search { display: none; }
  .hero-owl { display: none; }
  .hero::after { display: none; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .big-search .btn { padding-inline: .9rem; }
  .tools { top: 8px; gap: .1rem .3rem; padding: .25rem; }
  .tools button, .tool-link { min-width: 40px; }
  .tabs {
    position: fixed; inset: auto 0 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--card); border-top: 3px solid var(--line);
  }
  .tabs a { display: flex; flex-direction: column; align-items: center; padding: .35rem 0; color: var(--ink); text-decoration: none; font: 500 .8rem var(--display); }
  .tabs a span { font-size: 1.35rem; line-height: 1.25; }
  .tabs a[aria-current] { background: var(--sun-t); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
@media print {
  .top, .crumbs, .tools, .after, .ad, .foot, .tabs, .more-reading, .progress { display: none !important; }
  body { padding: 0; background: #fff; color: #000; }
}
