/* AniwehKids site styles. Sunny storybook. No dark mode in v1. */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + var(--space-4));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.6;
  overflow-x: hidden;
}

img,
picture,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--title-blue);
  font-family: var(--font-heading);
  line-height: 1.15;
  text-wrap: balance;
}

h1 { font-size: var(--text-h1); font-weight: 800; }
h2 { font-size: var(--text-h2); font-weight: 800; }
h3 { font-size: var(--text-h3); font-weight: 700; }

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: var(--roof-dark);
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--title-blue);
}

:focus-visible {
  outline: 4px solid var(--title-blue);
  outline-offset: 3px;
  border-radius: var(--radius-s);
}

.container {
  width: min(100% - 2rem, var(--container));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -6rem;
  z-index: 100;
  padding: var(--space-3) var(--space-6);
  background: var(--title-blue);
  color: var(--white);
  font-weight: 700;
  border-radius: var(--radius-pill);
}

.skip-link:focus {
  top: var(--space-4);
  color: var(--white);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 3.25rem;
  min-width: 3rem;
  padding: var(--space-3) var(--space-6);
  border: 3px solid var(--roof-dark);
  border-radius: var(--radius-pill);
  background: var(--roof-dark);
  color: var(--white);
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-warm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgb(181 98 25 / 26%);
}

.btn--ghost {
  background: var(--white);
  color: var(--roof-dark);
  box-shadow: var(--shadow-s);
}

.btn--ghost:hover {
  color: var(--roof-dark);
  background: var(--cream);
}

.btn--small {
  min-height: 3rem;
  padding: var(--space-2) var(--space-4);
  font-size: 1.05rem;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgb(255 248 236 / 94%);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 14px rgb(46 84 160 / 10%);
}

.header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  min-height: var(--header-height);
  padding-block: var(--space-2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 3rem;
  text-decoration: none;
}

.brand:hover {
  color: var(--title-blue);
}

/* The logo is a wide wordmark on white: show it at its natural ratio and let white melt into the page colour. */
.brand img,
.preloader__logo {
  width: auto;
  height: 3.5rem;
  mix-blend-mode: multiply;
}

.site-nav {
  flex-basis: 100%;
  order: 3;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list a {
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  color: var(--title-blue);
  font-weight: 700;
  text-decoration: none;
}

.nav-list a:hover {
  background: var(--sky-soft);
  color: var(--title-blue);
}

.header-cta {
  display: none;
}

.menu-button {
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 3rem;
  min-height: 3rem;
  padding: 0 var(--space-4);
  border: 3px solid var(--title-blue);
  border-radius: var(--radius-pill);
  background: var(--white);
  color: var(--title-blue);
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.menu-button__bars {
  display: grid;
  gap: 4px;
}

.menu-button__bars span {
  display: block;
  width: 20px;
  height: 3px;
  border-radius: 2px;
  background: currentcolor;
}

/* With JS the nav becomes a toggled menu on small screens. */
.js .menu-button {
  display: inline-flex;
}

.js .site-nav {
  display: none;
}

.js .site-nav.is-open {
  display: block;
  padding-bottom: var(--space-4);
}

.js .nav-list {
  flex-direction: column;
}

.js .nav-list a {
  min-height: 3.5rem;
  width: 100%;
  font-size: 1.2rem;
}

.header-cta--menu {
  margin-top: var(--space-2);
  width: 100%;
}

@media (min-width: 60rem) {
  .header-bar {
    flex-wrap: nowrap;
  }

  .site-nav,
  .js .site-nav {
    display: block;
    flex-basis: auto;
    order: 0;
    margin-inline: auto;
    padding: 0;
  }

  .js .nav-list {
    flex-direction: row;
  }

  .js .nav-list a {
    width: auto;
    min-height: 3rem;
    font-size: inherit;
  }

  .header-cta {
    display: inline-flex;
  }

  .header-cta--menu,
  .js .menu-button {
    display: none;
  }
}

/* ---------- Sections ---------- */

.section {
  position: relative;
  padding-block: var(--space-12) calc(var(--space-12) + var(--wave-h));
}

.section-head {
  max-width: 44rem;
  margin-bottom: var(--space-8);
}

.section-head p {
  margin-top: var(--space-3);
  font-size: var(--text-lead);
}

.section--cream { background: var(--cream); }
.section--sky { background: var(--sky-soft); }
.section--sun { background: #fff0d0; }

/* Each section ends in a gentle wave painted in the colour of the next section. */
.wave {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: var(--wave-h);
  pointer-events: none;
}

.wave path {
  fill: currentcolor;
}

.wave--cream { color: var(--cream); }
.wave--sky { color: var(--sky-soft); }
.wave--sun { color: #fff0d0; }
.wave--wall { color: var(--wall); }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky-soft) 0%, #eef7ff 70%, #fff7ea 100%);
  padding-block: var(--space-8) calc(var(--space-12) + var(--wave-h));
}

.hero__grid {
  position: relative;
  display: grid;
  gap: var(--space-8);
  align-items: center;
}

.hero__copy {
  display: grid;
  gap: var(--space-4);
  justify-items: start;
}

.hero__sub {
  font-size: var(--text-lead);
  max-width: 34rem;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.hero__note {
  color: var(--title-blue);
  font-weight: 700;
  font-size: var(--text-small);
}

.hero__art {
  border-radius: var(--radius-m);
  overflow: hidden;
  box-shadow: var(--shadow-m);
  background: var(--white);
}

.hero__art img {
  width: 100%;
  height: auto;
}

@media (min-width: 60rem) {
  .hero {
    padding-block: var(--space-12) calc(var(--space-16) + var(--wave-h));
  }

  .hero__grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: var(--space-12);
  }
}

.cloud {
  position: absolute;
  color: var(--white);
  opacity: 0.85;
  pointer-events: none;
  animation: drift 40s ease-in-out infinite alternate;
}

.cloud--a { top: 8%; left: -3%; width: 9rem; }
.cloud--b { top: 4%; right: 6%; width: 7rem; animation-duration: 50s; }
.cloud--c { bottom: 10%; left: 38%; width: 6rem; animation-duration: 60s; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(24px); }
}

.daffodil {
  position: absolute;
  bottom: 0;
  width: 2.5rem;
  height: 2.5rem;
  color: var(--daffodil);
  pointer-events: none;
}

/* ---------- Friends ---------- */

.friend {
  --accent: var(--sky);
  --tint: var(--sky-soft);
}

.friend--tavi { --accent: var(--tavi); --tint: color-mix(in srgb, var(--tavi) 16%, white); }
.friend--melli { --accent: var(--melli); --tint: color-mix(in srgb, var(--melli) 28%, white); }
.friend--rolo { --accent: var(--rolo); --tint: color-mix(in srgb, var(--rolo) 12%, white); }
.friend--nori { --accent: var(--nori); --tint: color-mix(in srgb, var(--nori) 24%, white); }

.friends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.friend-card {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: var(--space-4) var(--space-4) var(--space-6);
  border: 0;
  border-bottom: 8px solid var(--accent);
  border-radius: var(--radius-m);
  background: var(--tint);
  color: var(--ink);
  font: inherit;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-s);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.friend-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-m);
}

.friend-card > span {
  display: block;
}

.friend-card__art {
  display: flex;
  align-items: flex-end; /* the four portraits differ slightly in ratio: keep names on one line, never crop */
  margin: var(--space-6) auto var(--space-3);
  width: min(100%, 13rem);
  aspect-ratio: 3 / 4;
}

.friend-card__art picture,
.friend-card__art img {
  width: 100%;
}

.friend-card__art img {
  border-radius: var(--radius-s);
}

.friend-card__name {
  color: var(--title-blue);
  font-family: var(--font-heading);
  font-size: var(--text-h3);
  font-weight: 800;
  line-height: 1.2;
}

.friend-card__animal {
  font-weight: 700;
}

.friend-card__tagline {
  margin-top: var(--space-2);
}

.friend-card__hint {
  margin-top: var(--space-3);
  color: var(--title-blue);
  font-size: var(--text-small);
  font-weight: 700;
}

/* The greeting is plain text without JS, and a speech bubble with JS. */
.friend-card__bubble {
  display: block;
  margin-top: var(--space-3);
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--title-blue);
}

.js .friend-card__bubble {
  position: absolute;
  top: var(--space-2);
  left: 50%;
  z-index: 2;
  min-width: 5rem;
  padding: var(--space-2) var(--space-4);
  border: 3px solid var(--accent);
  border-radius: var(--radius-m);
  background: var(--white);
  box-shadow: var(--shadow-s);
  transform: translateX(-50%) scale(0.8);
  transform-origin: 50% 100%;
  opacity: 0;
  pointer-events: none;
  margin: 0;
  transition: opacity 0.2s ease, transform 0.25s ease;
}

.js .friend-card__bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 16px;
  height: 16px;
  border-right: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  background: var(--white);
  transform: translateX(-50%) rotate(45deg);
}

.js .friend-card__bubble.is-visible {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.js .friend-card__bubble:empty {
  display: none;
}

.friend-card__bubble-text {
  position: relative;
  z-index: 1;
}

/* ---------- Episodes ---------- */

.episodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.episode {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: var(--radius-m);
  background: var(--white);
  box-shadow: var(--shadow-m);
  overflow: hidden;
}

.episode__media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--sky-soft);
}

.episode__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.episode__media--gradient {
  background: linear-gradient(135deg, var(--sky) 0%, var(--daffodil) 100%);
}

.ribbon {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--daffodil);
  color: var(--ink);
  font-size: var(--text-small);
  font-weight: 700;
  box-shadow: var(--shadow-s);
}

.episode__body {
  display: grid;
  gap: var(--space-2);
  align-content: start;
  padding: var(--space-4) var(--space-6) var(--space-6);
}

.episode__eyebrow {
  color: var(--roof-dark);
  font-size: var(--text-small);
  font-weight: 700;
}

.episode__theme {
  font-weight: 700;
}

.episode__note {
  color: var(--title-blue);
  font-size: var(--text-small);
}

.video-facade {
  position: absolute;
  inset: 0;
}

.video-facade__button {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.video-facade__button picture {
  position: absolute;
  inset: 0;
}

.video-facade__button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-facade__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: var(--roof-dark);
  color: var(--white);
  box-shadow: var(--shadow-warm);
  transition: transform 0.2s ease;
}

.video-facade__button:hover .video-facade__icon {
  transform: scale(1.06);
}

.video-facade iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- Village ---------- */

.village-grid {
  display: grid;
  align-items: start; /* the Sunny Tree art is taller than the others: let each tile keep its own height */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.village-tile {
  margin: 0;
  border-radius: var(--radius-m);
  background: var(--white);
  box-shadow: var(--shadow-warm);
  overflow: hidden;
}

.village-tile picture,
.village-tile img {
  width: 100%;
}

.village-tile figcaption {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-6) var(--space-6);
}

/* ---------- Grown-ups ---------- */

.points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.point {
  display: grid;
  gap: var(--space-3);
  align-content: start;
  padding: var(--space-6);
  border-radius: var(--radius-m);
  background: var(--white);
  box-shadow: var(--shadow-s);
}

.point__icon {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--sky-soft);
  color: var(--title-blue);
}

.contact-line {
  margin-top: var(--space-8);
  font-size: var(--text-lead);
  font-weight: 700;
}

.contact-line a {
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
}

/* ---------- Footer ---------- */

.site-footer {
  position: relative;
  background: var(--wall);
  padding-bottom: var(--space-12);
}

.footer-inner {
  display: grid;
  gap: var(--space-4);
  justify-items: start;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--title-blue);
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
}

.footer-brand img {
  width: auto;
  height: 3.5rem;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-s);
  background: var(--white); /* on the warm footer the white logo keeps its own white backing */
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
  color: var(--title-blue);
  font-weight: 700;
}

.footer-small {
  font-size: var(--text-small);
}

/* ---------- Legal and error pages ---------- */

.page {
  padding-block: var(--space-12) var(--space-16);
}

.prose {
  max-width: 46rem;
}

.prose > * + * {
  margin-top: var(--space-4);
}

.prose h2 {
  margin-top: var(--space-8);
  font-size: var(--text-h3);
}

.prose h3 {
  margin-top: var(--space-6);
  font-size: 1.25rem;
}

.prose ul {
  padding-left: var(--space-6);
}

.subtitle {
  color: var(--title-blue);
  font-weight: 700;
}

.template-notice {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--daffodil);
  color: var(--ink);
  font-weight: 700;
}

.not-found {
  display: grid;
  gap: var(--space-6);
  justify-items: center;
  text-align: center;
}

.not-found__art {
  width: min(100%, 28rem);
  border-radius: var(--radius-m);
  overflow: hidden;
  box-shadow: var(--shadow-m);
}

/* ---------- Preloader ---------- */

.preloader {
  display: none;
}

.is-loading .preloader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-6);
  background: var(--cream);
  opacity: 1;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  /* Safety net: the screen always leaves after 1.5 s, even if the script never runs. */
  animation: preloader-out 0.4s ease 1.5s forwards;
}

.is-loading.is-loaded .preloader {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader__logo {
  width: min(70vw, 16rem);
  height: auto;
}

.preloader__dots {
  display: flex;
  gap: var(--space-3);
}

.preloader__dots span {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  animation: bounce 1.2s ease-in-out infinite;
}

.preloader__dots span:nth-child(1) { background: var(--tavi); }
.preloader__dots span:nth-child(2) { background: var(--melli); animation-delay: 0.15s; }
.preloader__dots span:nth-child(3) { background: var(--rolo); animation-delay: 0.3s; }
.preloader__dots span:nth-child(4) { background: var(--nori); animation-delay: 0.45s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes preloader-out {
  to {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .is-loading .preloader {
    display: none;
  }
}
