/* ============================================================
   UNDERSTAND — koncepcja B "Dziecięca kreska"
   Papier + kredka + animowana kreska SVG
   ============================================================ */

@font-face {
  font-family: "Caveat";
  src: url("../assets/fonts/caveat-v23-latin_latin-ext-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Caveat";
  src: url("../assets/fonts/caveat-v23-latin_latin-ext-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("../assets/fonts/nunito-v32-latin_latin-ext-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("../assets/fonts/nunito-v32-latin_latin-ext-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("../assets/fonts/nunito-v32-latin_latin-ext-800.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

:root {
  color-scheme: light only;
  --paper: #fbf6ec;
  --paper-deep: #f4ecdc;
  --graphite: #3f3a33;
  --red: #d95d44;
  --blue: #4f7fb8;
  --yellow: #e8a921;
  --green: #6f9e52;
  --purple: #8a6fb4;
  --pink: #d9799c;
  --ink-soft: #6b6358;
  --max: 680px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  background-color: #fbf6ec;
}

/* strona jest zawsze jasna — także przy systemowym dark mode (iPhone/Brave) */
@media (prefers-color-scheme: dark) {
  html, body { background-color: #fbf6ec; color: #3f3a33; }
}

body {
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  color: var(--graphite);
  background-color: var(--paper);
  /* delikatna faktura papieru */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.28 0 0 0 0 0.25 0 0 0 0 0.2 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23p)'/%3E%3C/svg%3E");
  overflow-x: hidden;
}

.hand { font-family: "Caveat", cursive; }

/* ---------- kreska: rysowanie ---------- */
svg path {
  fill: none;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#crayon);
}
.w-thick { stroke-width: 5; }
.c-graphite { stroke: var(--graphite); }
.c-red { stroke: var(--red); }
.c-blue { stroke: var(--blue); }
.c-yellow { stroke: var(--yellow); }
.c-green { stroke: var(--green); }
.c-purple { stroke: var(--purple); }
.c-pink { stroke: var(--pink); }

.draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.in-view .draw {
  animation: drawLine var(--t, 1.4s) ease forwards;
  animation-delay: var(--d, 0s);
}
@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

/* ---------- układ rozdziałów ---------- */
.chapter {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(70px, 12vh, 130px) 22px;
}

/* ---------- bazgrołki na marginesach (szerokie ekrany) ---------- */
.doodle {
  display: none;
  position: absolute;
  width: clamp(64px, 5.5vw, 110px);
  height: auto;
  /* bezpiecznik: nawet bez wyliczenia proporcji nie urośnie i nie wejdzie w treść */
  max-height: 120px;
  top: var(--dy, 30%);
  transform: rotate(var(--rot, 0deg));
  opacity: 0;
  transition: opacity 1.4s ease 1.8s;
  pointer-events: none;
}
.doodle path { stroke-width: 3; }
.doodle-left { left: -14vw; }
.doodle-right { right: -14vw; }
.in-view .doodle { opacity: .55; }
@media (min-width: 1200px) {
  .doodle { display: block; }
}

.chapter-no {
  font-size: 1.35rem;
  color: var(--ink-soft);
  opacity: 0;
  transform: rotate(-2deg);
  transition: opacity .8s ease .1s;
}
.chapter h2 {
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 6px 0 28px;
  opacity: 0;
  transform: translateY(14px) rotate(-0.5deg);
  transition: opacity .9s ease .2s, transform .9s ease .2s;
}
.in-view .chapter-no { opacity: 1; }
.in-view h2 { opacity: 1; transform: translateY(0) rotate(-0.5deg); }

.prose p {
  margin-bottom: 1.2em;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .9s ease, transform .9s ease;
}
.in-view .prose p { opacity: 1; transform: none; }
.in-view .prose p:nth-child(1) { transition-delay: .45s; }
.in-view .prose p:nth-child(2) { transition-delay: .75s; }
.in-view .prose p:nth-child(3) { transition-delay: 1.05s; }
.in-view .prose p:nth-child(4) { transition-delay: 1.3s; }

.prose em { color: var(--ink-soft); }
.prose strong { font-weight: 800; color: var(--red); }

/* ---------- hero ---------- */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  justify-content: safe center;
  text-align: center;
  padding-top: 48px;
  padding-bottom: 36px;
}
.hero-eyebrow {
  font-size: .82rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity 1.2s ease .3s;
}
.in-view .hero-eyebrow { opacity: .85; }
.hero-title {
  font-size: clamp(3.6rem, 13vw, 7.5rem);
  font-weight: 700;
  line-height: 1;
  margin-top: 10px;
  transform: rotate(-1.5deg);
  opacity: 0;
  transition: opacity 1s ease .15s;
}
.in-view .hero-title { opacity: 1; }
.hero-underline { width: min(420px, 70vw); height: 24px; margin-top: -6px; }
.hero-sub {
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
  margin-top: 22px;
  color: var(--ink-soft);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .9s ease 1.4s, transform .9s ease 1.4s;
}
.in-view .hero-sub { opacity: 1; transform: none; }

.scene { display: block; width: 100%; height: auto; }
.scene-hero { max-width: 520px; max-height: 44svh; margin: 8px auto 0; }

.in-view .rain path {
  animation: drawLine 1s ease forwards var(--d, 0s),
             rainFall 1.6s ease-in-out infinite calc(var(--d, 0s) + 1s);
}
@keyframes rainFall {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(7px); opacity: .55; }
}

/* strefy hover wewnątrz SVG */
.hover-zone {
  fill: transparent;
  stroke: none;
  filter: none;
  pointer-events: all;
}

/* ulewa po najechaniu na chmurę */
.in-view.raining .rain path {
  animation: rainPour .85s linear infinite;
}
.raining .rain path:nth-child(1) { animation-delay: 0s; }
.raining .rain path:nth-child(2) { animation-delay: .17s; }
.raining .rain path:nth-child(3) { animation-delay: .34s; }
.raining .rain path:nth-child(4) { animation-delay: .51s; }
.raining .rain path:nth-child(5) { animation-delay: .68s; }
@keyframes rainPour {
  0% { transform: translateY(-8px); opacity: 0; stroke-dashoffset: 0; }
  12% { opacity: 1; }
  78% { opacity: 1; }
  100% { transform: translateY(34px); opacity: 0; stroke-dashoffset: 0; }
}

.scroll-hint {
  background: none;
  border: none;
  cursor: pointer;
  margin-top: 18px;
  color: var(--ink-soft);
  font-size: 1.3rem;
  opacity: 0;
  transition: opacity 1s ease 2.8s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.in-view .scroll-hint { opacity: .9; }
.scroll-hint svg { width: 30px; height: 36px; animation: bob 2.2s ease-in-out infinite; }
.scroll-hint svg path { stroke-width: 2.6; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(7px); }
}

/* ---------- scena rodziny ---------- */
.scene-family { max-width: 640px; margin: 10px auto 0; }
.thread { stroke-width: 2.4; }
.figure { cursor: pointer; outline: none; }
.figure:focus-visible path { stroke-width: 4.2; }

.wobbling .figure { animation: wobble 1.6s ease-in-out; transform-origin: 50% 95%; transform-box: fill-box; }
.wobbling .figure:nth-of-type(odd) { animation-delay: .08s; }
.wobbling .thread { animation: threadSway 1.6s ease-in-out; transform-origin: 50% 50%; transform-box: fill-box; }
@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(3deg); }
  45% { transform: rotate(-2.4deg); }
  70% { transform: rotate(1.4deg); }
  88% { transform: rotate(-0.6deg); }
}
@keyframes threadSway {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(4px); }
  60% { transform: translateY(-3px); }
}

.scene-hint {
  text-align: center;
  color: var(--ink-soft);
  font-size: 1.25rem;
  margin: 4px 0 30px;
  opacity: 0;
  transition: opacity 1s ease 2.2s;
  transform: rotate(-1.5deg);
}
.in-view .scene-hint { opacity: .8; }

/* ---------- scena listu: wiadomość do przeczytania ---------- */
.scene-letter { max-width: 560px; margin: 8px auto 0; }
.scene-letter text {
  font-family: "Caveat", cursive;
  font-size: 22px;
  fill: var(--ink-soft);
  stroke: none;
  filter: none;
  opacity: 0;
  transition: opacity 1s ease 1.9s;
}
.in-view .scene-letter text { opacity: .85; }
.fill-card { fill: #fffdf6; }
.fill-env { fill: #f6efdf; }
.fill-flap { fill: #efe6d2; }
.scene-letter .fill-card,
.scene-letter .fill-env,
.scene-letter .fill-flap { fill-opacity: 0; transition: fill-opacity .9s ease .85s; }
.in-view .scene-letter .fill-card,
.in-view .scene-letter .fill-env,
.in-view .scene-letter .fill-flap { fill-opacity: 1; }
.letter-group { cursor: pointer; }
.letter-card {
  transform: translateY(90px);
  transition: transform 1.1s cubic-bezier(.3, 1.25, .45, 1);
}
.letter-open .letter-card { transform: translateY(-30px); }

/* ---------- scena węzła: rozplątywanie pod kursorem ---------- */
.scene-knot { max-width: 640px; margin: 0 auto 6px; touch-action: pan-y; }
.scene-knot path { stroke-width: 3.6; }
/* knot-smooth = tylko geometria docelowa dla JS, nigdy nie widać */
.knot-smooth { visibility: hidden; }
.knot-live { display: none; }
.scene-knot.live .knot-tangled { visibility: hidden; }
.scene-knot.live .knot-live { display: inline; }

/* ---------- karty "jak to wygląda" ---------- */
.cards-how {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 26px;
  margin-top: 12px;
}
.card {
  background: rgba(255, 252, 244, .65);
  border: 2.5px solid var(--paper-deep);
  border-radius: 18px 22px 16px 24px;
  padding: 26px 20px;
  text-align: center;
  opacity: 0;
  transform: translateY(16px) rotate(0.4deg);
  transition: opacity .8s ease, transform .8s ease;
}
.card:nth-child(2) { transform: translateY(16px) rotate(-0.6deg); }
.in-view .card { opacity: 1; transform: translateY(0) rotate(0.4deg); }
.in-view .card:nth-child(1) { transition-delay: .3s; }
.in-view .card:nth-child(2) { transition-delay: .55s; transform: translateY(0) rotate(-0.6deg); }
.in-view .card:nth-child(3) { transition-delay: .8s; }
.card svg { width: 92px; height: 84px; margin-bottom: 8px; }
.card h3 { font-size: 1.7rem; font-weight: 700; margin-bottom: 8px; }
.card p { font-size: .95rem; color: var(--ink-soft); }

/* ---------- dla kogo ---------- */
.who-list { list-style: none; display: grid; gap: 18px; margin-top: 8px; }
.who {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  opacity: 0;
  transform: translateX(-14px);
  transition: opacity .7s ease, transform .7s ease;
}
.in-view .who { opacity: 1; transform: none; }
.in-view .who:nth-child(1) { transition-delay: .25s; }
.in-view .who:nth-child(2) { transition-delay: .4s; }
.in-view .who:nth-child(3) { transition-delay: .55s; }
.in-view .who:nth-child(4) { transition-delay: .7s; }
.in-view .who:nth-child(5) { transition-delay: .85s; }
.in-view .who:nth-child(6) { transition-delay: 1s; }
.who-dot {
  flex: 0 0 18px;
  height: 18px;
  margin-top: 9px;
  border-radius: 46% 54% 52% 48%;
  transform: rotate(8deg);
}
.c-bg-red { background: var(--red); }
.c-bg-blue { background: var(--blue); }
.c-bg-yellow { background: var(--yellow); }
.c-bg-green { background: var(--green); }
.c-bg-purple { background: var(--purple); }
.c-bg-pink { background: var(--pink); }
.who h3 { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.who p { color: var(--ink-soft); font-size: .97rem; }

/* ---------- bio ---------- */
/* zdjęcie Ewy — jak odbitka przyklejona do kartki */
.bio-photo {
  width: min(250px, 64%);
  margin: 6px auto 28px;
  padding: 10px 10px 16px;
  background: #fff;
  border: 1px solid rgba(63, 58, 51, .1);
  box-shadow: 0 12px 26px rgba(63, 58, 51, .16);
  transform: rotate(-2deg) translateY(12px);
  opacity: 0;
  transition: opacity .9s ease .3s, transform .9s ease .3s;
}
.in-view .bio-photo { opacity: 1; transform: rotate(-2deg); }
.bio-photo img { display: block; width: 100%; height: auto; }

.bio-name { font-size: 2.4rem; font-weight: 700; transform: rotate(-1deg); }
.bio-role { color: var(--ink-soft); font-weight: 600; margin-bottom: 18px !important; }
.bio > p:nth-of-type(3) {
  font-style: italic;
  color: var(--ink-soft);
  border-left: 3px solid var(--yellow);
  padding-left: 16px;
}
.bio-facts {
  list-style: none;
  margin-top: 10px;
  display: grid;
  gap: 9px;
}
.bio-facts li {
  padding-left: 26px;
  position: relative;
  font-size: .95rem;
  color: var(--ink-soft);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .6s ease, transform .6s ease;
}
.bio-facts li::before {
  content: "✎";
  position: absolute;
  left: 0;
  color: var(--red);
}
.in-view .bio-facts li { opacity: 1; transform: none; }
.in-view .bio-facts li:nth-child(1) { transition-delay: .5s; }
.in-view .bio-facts li:nth-child(2) { transition-delay: .62s; }
.in-view .bio-facts li:nth-child(3) { transition-delay: .74s; }
.in-view .bio-facts li:nth-child(4) { transition-delay: .86s; }
.in-view .bio-facts li:nth-child(5) { transition-delay: .98s; }
.in-view .bio-facts li:nth-child(6) { transition-delay: 1.1s; }
.in-view .bio-facts li:nth-child(7) { transition-delay: 1.22s; }
.in-view .bio-facts li:nth-child(8) { transition-delay: 1.34s; }
.in-view .bio-facts li:nth-child(9) { transition-delay: 1.46s; }
.in-view .bio-facts li:nth-child(10) { transition-delay: 1.58s; }

/* ---------- kontakt ---------- */
.chapter-contact { text-align: center; }
.scene-sun { max-width: 480px; margin: 0 auto 10px; }
.in-view .sun-rays path { animation: drawLine 1s ease forwards var(--d, 0s); }

/* słońce ożywa po najechaniu */
.sun-group { cursor: pointer; }
.sun-active .sun-group {
  animation: sunWobble 3.2s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 0 16px rgba(232, 169, 33, .55));
}
.in-view.sun-active .sun-rays path {
  animation: rayDance 1.3s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: 50% 50%;
}
.in-view.sun-active .sun-rays path:nth-child(odd) { animation-delay: .2s; }
.in-view.sun-active .sun-rays path:nth-child(3n) { animation-delay: .45s; }
@keyframes sunWobble {
  0%, 100% { transform: rotate(0deg) scale(1); }
  30% { transform: rotate(4deg) scale(1.03); }
  70% { transform: rotate(-3deg) scale(1.02); }
}
@keyframes rayDance {
  0%, 100% { transform: scale(1); stroke-dashoffset: 0; opacity: 1; }
  50% { transform: scale(1.55); stroke-dashoffset: 0; opacity: .8; }
}
.in-view .cloud-away { animation: drawLine 1.4s ease forwards var(--d, 0s), drift 14s linear infinite 3s; }
@keyframes drift {
  0% { transform: translateX(0); opacity: 1; }
  85% { transform: translateX(90px); opacity: .25; }
  100% { transform: translateX(120px); opacity: 0; }
}
.contact-lead {
  color: var(--ink-soft);
  margin: 14px 0 34px;
  opacity: 0;
  transition: opacity .9s ease .8s;
}
.in-view .contact-lead { opacity: 1; }
.contact-actions {
  display: flex;
  gap: 22px;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
}
.contact-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--graphite);
  background: rgba(255, 252, 244, .8);
  border: 2.8px solid var(--graphite);
  border-radius: 22px 18px 24px 16px;
  padding: 16px 34px;
  transform: rotate(-1deg);
  transition: transform .25s ease, box-shadow .25s ease;
  opacity: 0;
}
.contact-btn:nth-child(2) { transform: rotate(1.2deg); }
.in-view .contact-btn { animation: popIn .6s ease forwards 1.1s; }
.in-view .contact-btn:nth-child(2) { animation-delay: 1.3s; }
@keyframes popIn {
  from { opacity: 0; transform: translateY(14px) rotate(-1deg) scale(.96); }
  to { opacity: 1; transform: translateY(0) rotate(-1deg) scale(1); }
}
.contact-btn:hover { transform: rotate(0deg) scale(1.04) !important; box-shadow: 4px 5px 0 var(--paper-deep); }
.contact-label { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.contact-value { font-family: "Nunito", sans-serif; font-size: .85rem; color: var(--ink-soft); }

/* ---------- footer ---------- */
.footer {
  text-align: center;
  padding: 50px 20px 60px;
  color: var(--ink-soft);
  font-size: .9rem;
}
.footer .hand { font-size: 2rem; color: var(--graphite); transform: rotate(-1.5deg); }
.footer-small { opacity: .6; font-size: .78rem; margin-top: 6px; }

/* ---------- dostępność: reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .draw, .in-view .draw { animation: none !important; stroke-dashoffset: 0 !important; }
  .chapter-no, .chapter h2, .prose p, .card, .who, .bio-facts li,
  .hero-eyebrow, .hero-title, .hero-sub, .scroll-hint, .scene-hint,
  .contact-lead, .contact-btn {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
  }
  .rain path, .cloud-away, .scroll-hint svg,
  .raining .rain path, .sun-active .sun-group,
  .in-view.sun-active .sun-rays path { animation: none !important; }
  .scene-letter text,
  .scene-letter .fill-card, .scene-letter .fill-env, .scene-letter .fill-flap {
    opacity: 1 !important; fill-opacity: 1 !important; transition: none !important;
  }
  .letter-card { transition: none !important; }
  .doodle { opacity: .55 !important; transition: none !important; }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .contact-actions { flex-direction: column; align-items: center; }
  .contact-btn { width: min(300px, 86vw); }
}

/* ---------- duże ekrany: strona wypełnia przestrzeń ----------
   (blok musi być na końcu pliku, żeby wygrać z regułami bazowymi) */
@media (min-width: 1500px) {
  body { font-size: 19px; }
  .chapter { max-width: 840px; }
  .prose, .who-list, .bio-facts { max-width: 700px; margin-left: auto; margin-right: auto; }
  .hero-title { font-size: clamp(5rem, 8vw, 9.5rem); }
  .hero-underline { width: min(540px, 56vw); }
  .hero-sub { font-size: 1.45rem; }
  .chapter h2 { font-size: clamp(2.8rem, 3.6vw, 4.2rem); }
  .scene-hero { max-width: 660px; }
  .scene-letter { max-width: 680px; }
  .scene-family { max-width: 800px; }
  .scene-knot { max-width: 800px; }
  .scene-sun { max-width: 600px; }
  .card h3 { font-size: 1.95rem; }
  .who h3 { font-size: 1.85rem; }
  .bio-name { font-size: 2.8rem; }
}
