/* ═══════════════════════════════════════════════════════════
   PUBLIC API PLAYGROUND — HAND-DRAWN SKETCHBOOK DESIGN
   Style: "The Notebook" — Paper, Pencil & Markers
   ═══════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ─────────────────────────────────────── */
:root {
  /* Base palette */
  --bg:          #fdfbf7;
  --bg-card:     #ffffff;
  --text:        #2d2d2d;
  --text-muted:  rgba(45, 45, 45, 0.5);

  /* Accent */
  --accent:      #ff4d4d;
  --accent-hover: #e03e3e;
  --secondary:   #2d5da1;
  --muted:       #e5e0d8;
  --postit:      #fff9c4;

  /* Typography */
  --font-display: 'Kalam', cursive;
  --font-body:    'Patrick Hand', cursive;

  /* Spacing */
  --s1: 0.5rem;
  --s2: 1rem;
  --s3: 1.5rem;
  --s4: 2rem;
  --s5: 3rem;
  --s6: 4rem;
  --s7: 6rem;
  --s8: 8rem;

  /* Wobbly borders */
  --wobbly: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wobbly-md: 30px 185px 25px 230px / 185px 25px 185px 25px;
  --wobbly-sm: 15px 85px 15px 110px / 85px 15px 90px 15px;

  /* Hard shadows */
  --shadow: 4px 4px 0px 0px #2d2d2d;
  --shadow-lg: 8px 8px 0px 0px #2d2d2d;
  --shadow-sm: 2px 2px 0px 0px #2d2d2d;

  /* Border */
  --border-w: 3px;
  --border-color: #2d2d2d;
}

/* ── RESET ─────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
  font-size: 18px;
}

/* Notebook dot-grid texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(var(--muted) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.7;
}

img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ── KEYFRAMES ─────────────────────────────────────────── */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(30px) rotate(-1deg); }
  to   { opacity: 1; transform: translateY(0) rotate(0deg); }
}

@keyframes bounce-gentle {
  0%, 100% { transform: translateY(0) rotate(2deg); }
  50%      { transform: translateY(-8px) rotate(-2deg); }
}

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

@keyframes spin-scribble {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-1deg); }
  50% { transform: rotate(1deg); }
}

@keyframes exclaim-rotate {
  0%, 100% { transform: rotate(-8deg) scale(1); }
  50% { transform: rotate(8deg) scale(1.1); }
}

/* ══════════════════════════════════════════════════════════
   D E C O R A T I V E   E L E M E N T S
   ══════════════════════════════════════════════════════════ */

/* --- Wavy underline decoration --- */
.wavy-underline {
  position: relative;
  display: inline-block;
}

.wavy-underline::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='6'%3E%3Cpath d='M0 3 Q 5 0, 10 3 Q 15 6, 20 3 Q 25 0, 30 3 Q 35 6, 40 3' fill='none' stroke='%23ff4d4d' stroke-width='2'/%3E%3C/svg%3E") repeat-x;
}

/* --- Tape decoration on cards --- */
.tape-deco {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 80px;
  height: 24px;
  background: rgba(45, 45, 45, 0.08);
  border: 1px solid rgba(45, 45, 45, 0.1);
  border-radius: 2px;
  z-index: 5;
  pointer-events: none;
}

/* --- Thumbtack decoration --- */
.tack-deco {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid #c0392b;
  box-shadow: 1px 1px 0px 0px rgba(0,0,0,0.2);
  z-index: 5;
  pointer-events: none;
}

/* --- Dashed circle around accent elements --- */
.dashed-circle {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px dashed var(--accent);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.4;
}

/* --- Post-it tag --- */
.postit-tag {
  display: inline-block;
  background: var(--postit);
  padding: 4px 14px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text);
  border: 2px solid var(--border-color);
  border-radius: var(--wobbly-sm);
  box-shadow: var(--shadow-sm);
  transform: rotate(-2deg);
}

/* --- Bouncing decorative circle (desktop only) --- */
.bounce-circle {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 3px dashed var(--secondary);
  border-radius: 40% 60% 55% 45% / 60% 40% 65% 35%;
  animation: bounce-gentle 3s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

/* ══════════════════════════════════════════════════════════
   H E R O
   ══════════════════════════════════════════════════════════ */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--s5);
  background: var(--bg);
  overflow: hidden;
  z-index: 1;
}

.hero__content {
  position: relative;
  z-index: 2;
  max-width: 800px;
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3rem, 9vw, 5.5rem);
  line-height: 1.15;
  color: var(--text);
  position: relative;
}

.hero__title .exclaim {
  display: inline-block;
  color: var(--accent);
  animation: exclaim-rotate 2s ease-in-out infinite;
  font-size: 1.1em;
}

.hero__subtitle {
  font-family: var(--font-body);
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  color: var(--text-muted);
  margin-top: var(--s3);
  font-weight: 400;
}

.hero__deco-line {
  width: 200px;
  height: 3px;
  margin: var(--s3) auto;
  border: none;
  border-top: 3px dashed var(--muted);
}

.hero__scroll-hint {
  margin-top: var(--s6);
}

.scroll-chevron {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 1.6rem;
  color: var(--text-muted);
  animation: chevron-bounce 2s ease-in-out infinite;
}

/* Hand-drawn SVG arrow near hero */
.hero__arrow {
  position: absolute;
  bottom: 18%;
  right: 8%;
  width: 100px;
  height: 60px;
  z-index: 2;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════
   A P I   S E C T I O N S
   ══════════════════════════════════════════════════════════ */
.api-section {
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s8) var(--s4);
  overflow: hidden;
  z-index: 1;
}

.api-section:nth-child(even) {
  background: rgba(229, 224, 216, 0.15);
}

.section__inner {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s4);
  position: relative;
  z-index: 2;
}

/* ── Section Header ────────────────────────────────────── */
.section__numeral {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
}

.section__icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  background: var(--bg-card);
  border: 3px solid var(--border-color);
  border-radius: 40% 60% 55% 45% / 60% 40% 65% 35%;
  box-shadow: var(--shadow);
  position: relative;
  margin: 0 auto;
  transition: transform 0.1s ease;
}

.section__icon:hover {
  transform: rotate(3deg);
}

.section__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3rem);
  text-align: center;
  color: var(--text);
  position: relative;
}

.section__title .wavy-underline::after {
  bottom: -6px;
}

.section__desc {
  color: var(--text-muted);
  font-size: 1.1rem;
  text-align: center;
  max-width: 420px;
}

.section__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s1);
}

.section__deco-line {
  width: 120px;
  height: 2px;
  border: none;
  border-top: 2px dashed var(--muted);
  margin: var(--s1) auto;
}

/* ── Scroll Reveal ─────────────────────────────────────── */
.reveal-section {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.reveal-section.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ══════════════════════════════════════════════════════════
   B U T T O N S — Hand-Drawn Wobbly Style
   ══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  min-height: 48px;
  padding: 0.8rem 2.2rem;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.15rem;
  border: 3px solid var(--border-color);
  border-radius: var(--wobbly);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: all 0.1s ease;
  position: relative;
  z-index: 2;
}

.btn:hover {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-sm);
  transform: translate(2px, 2px);
}

.btn:active {
  box-shadow: none;
  transform: translate(4px, 4px);
}

.btn:focus-visible {
  outline: 3px solid var(--secondary);
  outline-offset: 3px;
}

/* Small variant */
.btn--sm {
  padding: 0.45rem 1.4rem;
  font-size: 0.95rem;
  min-height: 36px;
}

/* Secondary variant */
.btn--secondary {
  background: var(--muted);
}

.btn--secondary:hover {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

/* ══════════════════════════════════════════════════════════
   R E S U L T   C A R D S — Notebook Pages
   ══════════════════════════════════════════════════════════ */
.section__result {
  width: 100%;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 3px solid var(--border-color);
  border-radius: var(--wobbly-md);
  padding: var(--s5);
  position: relative;
  box-shadow: 3px 3px 0px 0px rgba(45, 45, 45, 0.1);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.section__result:hover {
  transform: rotate(-0.5deg);
  box-shadow: 5px 5px 0px 0px rgba(45, 45, 45, 0.15);
}

.result__placeholder {
  color: var(--text-muted);
  font-size: 1.1rem;
  text-align: center;
  font-family: var(--font-body);
}

/* ── Loading Spinner ───────────────────────────────────── */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  color: var(--text-muted);
  font-size: 1rem;
}

.loader__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin-scribble 0.8s linear infinite;
}

/* ── Error State ───────────────────────────────────────── */
.result__error {
  color: var(--accent);
  text-align: center;
  font-weight: 400;
  padding: var(--s3);
  border: 2px dashed var(--accent);
  background: rgba(255, 77, 77, 0.06);
  font-size: 1rem;
  border-radius: var(--wobbly-sm);
  font-family: var(--font-body);
}

/* ══════════════════════════════════════════════════════════
   R E S U L T   S T Y L E S
   ══════════════════════════════════════════════════════════ */

/* --- DOG RESULT --- */
.dog-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s4);
  animation: fade-in-up 0.5s ease;
  width: 100%;
}

.dog-result__frame {
  position: relative;
  border: 3px solid var(--border-color);
  border-radius: var(--wobbly-md);
  overflow: hidden;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow);
  transform: rotate(-1deg);
  transition: transform 0.1s ease;
}

.dog-result__frame:hover {
  transform: rotate(1deg);
}

.dog-result__img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.dog-result__breed {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  text-transform: capitalize;
  color: var(--text);
}

.dog-result__actions {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
  justify-content: center;
}

/* --- Toast Notification --- */
.copy-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--postit);
  color: var(--text);
  border: 3px solid var(--border-color);
  border-radius: var(--wobbly-sm);
  padding: 0.7rem 1.8rem;
  font-family: var(--font-body);
  font-size: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 100;
  box-shadow: var(--shadow);
}

.copy-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- JOKE RESULT --- */
.joke-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s4);
  animation: fade-in-up 0.5s ease;
  text-align: center;
  width: 100%;
}

.joke-result__text {
  font-family: var(--font-body);
  font-size: 1.3rem;
  max-width: 550px;
  line-height: 1.7;
  color: var(--text);
}

.joke-result__punchline {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  max-width: 550px;
  line-height: 1.5;
}

.joke-result__actions {
  margin-top: var(--s2);
}

/* --- USER RESULT --- */
.user-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s4);
  animation: fade-in-up 0.5s ease;
  width: 100%;
}

.user-result__avatar-frame {
  width: 130px;
  height: 130px;
  border: 3px solid var(--border-color);
  border-radius: 40% 60% 55% 45% / 60% 40% 65% 35%;
  overflow: hidden;
  box-shadow: var(--shadow);
  transform: rotate(2deg);
  transition: transform 0.1s ease;
}

.user-result__avatar-frame:hover {
  transform: rotate(-2deg);
}

.user-result__avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-result__info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.user-result__name {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
}

.user-result__detail {
  color: var(--text-muted);
  font-size: 1rem;
}

.user-result__detail span {
  color: var(--text);
  font-weight: 400;
}

/* --- POST RESULT --- */
.post-result {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  animation: fade-in-up 0.5s ease;
  width: 100%;
}

.post-result__id {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--postit);
  padding: 3px 12px;
  border: 2px solid var(--border-color);
  border-radius: var(--wobbly-sm);
  box-shadow: var(--shadow-sm);
  transform: rotate(-1deg);
  width: fit-content;
}

.post-result__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.4;
  text-transform: capitalize;
  color: var(--text);
}

.post-result__body {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.8;
  max-width: 600px;
}

.post-result__body::first-letter {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  float: left;
  margin-right: 6px;
  line-height: 1;
}

/* ══════════════════════════════════════════════════════════
   F O O T E R
   ══════════════════════════════════════════════════════════ */
.footer {
  text-align: center;
  padding: var(--s6) var(--s4) var(--s5);
  color: var(--text-muted);
  font-size: 1rem;
  position: relative;
  z-index: 1;
  border-top: 3px dashed var(--muted);
}

.footer__deco-line {
  width: 160px;
  height: 2px;
  border: none;
  border-top: 2px dashed var(--muted);
  margin: 0 auto var(--s3);
}

/* ══════════════════════════════════════════════════════════
   S V G   D E C O R A T I O N S   (between sections)
   ══════════════════════════════════════════════════════════ */
.squiggly-connector {
  display: block;
  margin: -20px auto;
  position: relative;
  z-index: 3;
  height: 60px;
  width: 100%;
  max-width: 200px;
}

/* ══════════════════════════════════════════════════════════
   R E S P O N S I V E
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .api-section {
    padding: var(--s6) var(--s3);
    min-height: auto;
  }

  .section__inner { gap: var(--s3); }

  .section__title {
    font-size: clamp(1.6rem, 7vw, 2.4rem);
  }

  .btn {
    padding: 0.65rem 1.4rem;
    font-size: 1rem;
  }

  .section__result {
    padding: var(--s4);
  }

  .hero__arrow,
  .bounce-circle,
  .squiggly-connector {
    display: none;
  }

  .dog-result__frame { max-width: 100%; }

  .user-result__avatar-frame {
    width: 100px;
    height: 100px;
  }

  .user-result__name { font-size: 1.4rem; }

  .section__icon {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: var(--s4) var(--s2);
    min-height: 85vh;
  }

  .hero__title {
    font-size: clamp(2.2rem, 11vw, 3rem);
  }

  .api-section {
    padding: var(--s5) var(--s2);
  }

  .section__icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
}
