/* ========================================
   Mind Fitness — Crumple Note (ขยำความคิด)
   Write, Crumple & Let Go
   ======================================== */

:root {
  --cn-pink: #f8b4c8;
  --cn-pink-light: #fde4ec;
  --cn-blue: #b8d8f8;
  --cn-blue-light: #e8f4fd;
  --cn-mint: #b8e8d0;
  --cn-mint-light: #e4f7ee;
  --cn-lavender: #d4b8f0;
  --cn-lavender-light: #f0e4fc;
  --cn-yellow: #fce4a8;
  --cn-yellow-light: #fef8e8;
  --cn-bg: #fef6fa;
  --cn-bg-note: #fffdf5;
  --cn-text: #4a3f50;
  --cn-text-secondary: #7d7088;
  --cn-text-light: #a899b4;
  --cn-accent: #e87da0;
  --cn-accent-hover: #d46a8c;
  --cn-border: #f0dce4;
  --cn-white: #ffffff;
  --cn-shadow-soft: 0 2px 16px rgba(74, 63, 80, 0.08);
  --cn-shadow-medium: 0 4px 24px rgba(74, 63, 80, 0.12);
  --cn-radius: 16px;
  --cn-transition: 0.3s ease;

  /* Map to shared --mf-* variables */
  --mf-text: var(--cn-text);
  --mf-text-secondary: var(--cn-text-secondary);
  --mf-text-dim: var(--cn-text-light);
  --mf-accent: var(--cn-accent);
  --mf-accent-glow: rgba(232, 125, 160, 0.3);
  --mf-border: var(--cn-border);
  --mf-btn-text: var(--cn-white);
}

body {
  background: var(--cn-bg);
  overflow: hidden;
}

/* ========================================
   Floating Decorations
   ======================================== */
.floating-deco {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.deco-shape {
  position: absolute;
  border-radius: 50%;
  opacity: 0.3;
  animation: decoFloat 8s ease-in-out infinite;
}

.deco-shape:nth-child(1) {
  width: 120px; height: 120px;
  background: var(--cn-pink-light);
  top: 10%; left: 5%;
  animation-delay: 0s;
}

.deco-shape:nth-child(2) {
  width: 80px; height: 80px;
  background: var(--cn-blue-light);
  top: 60%; right: 8%;
  animation-delay: -2s;
}

.deco-shape:nth-child(3) {
  width: 100px; height: 100px;
  background: var(--cn-mint-light);
  bottom: 15%; left: 15%;
  animation-delay: -4s;
}

.deco-shape:nth-child(4) {
  width: 60px; height: 60px;
  background: var(--cn-lavender-light);
  top: 25%; right: 20%;
  animation-delay: -6s;
}

@keyframes decoFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.05); }
}

/* ========================================
   Landing Screen
   ======================================== */
.landing-container {
  text-align: center;
  padding: 40px 24px;
  position: relative;
  z-index: 1;
  max-width: 480px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 48px;
  color: var(--cn-text-secondary);
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.landing-mascot {
  margin-bottom: 24px;
  animation: mascotBounce 3s ease-in-out infinite;
  display: flex;
  justify-content: center;
}

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

/* Cloud Character Mascot */
.cloud-character {
  position: relative;
  width: 160px;
  height: 110px;
}

.cloud-body {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 60px;
  background: linear-gradient(180deg, #ffffff, #f0e8f8);
  border-radius: 60px;
  box-shadow: 0 6px 20px rgba(168, 130, 210, 0.18);
}

.cloud-bump {
  position: absolute;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #f4eefa);
}

.cloud-bump.cb-1 {
  width: 70px;
  height: 70px;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
}

.cloud-bump.cb-2 {
  width: 55px;
  height: 55px;
  bottom: 25px;
  left: 8px;
}

.cloud-bump.cb-3 {
  width: 50px;
  height: 50px;
  bottom: 22px;
  right: 10px;
}

.cloud-face {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 40px;
  z-index: 2;
}

.cloud-eye {
  position: absolute;
  width: 10px;
  height: 12px;
  background: #4a3f50;
  border-radius: 50%;
  top: 4px;
  animation: blink 4s ease-in-out infinite;
}

.cloud-eye.left {
  left: 16px;
}

.cloud-eye.right {
  right: 16px;
}

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

.cloud-mouth {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 8px;
  border-bottom: 3px solid #e87da0;
  border-radius: 0 0 50% 50%;
}

.cloud-blush {
  position: absolute;
  width: 16px;
  height: 10px;
  background: rgba(248, 180, 200, 0.5);
  border-radius: 50%;
  bottom: 8px;
}

.cloud-blush.left {
  left: 4px;
}

.cloud-blush.right {
  right: 4px;
}

.landing-title {
  font-size: 2.8rem;
  font-weight: 800;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--cn-accent), var(--cn-lavender), var(--cn-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-subtitle {
  font-size: 1.1rem;
  color: var(--cn-text-secondary);
  line-height: 1.8;
  margin-bottom: 40px;
}

.landing-note {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--cn-text-light);
}

.btn-primary:hover {
  background: var(--cn-accent-hover);
}

/* ========================================
   Writing Screen
   ======================================== */
.writing-container {
  width: 100%;
  max-width: 560px;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.writing-header {
  text-align: center;
  margin-bottom: 20px;
}

.writing-prompt {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--cn-text);
}

.note-paper {
  position: relative;
  background: var(--cn-bg-note);
  border-radius: var(--cn-radius);
  box-shadow: var(--cn-shadow-medium), inset 0 0 60px rgba(255, 253, 245, 0.5);
  padding: 32px 28px 28px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.note-paper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 40px;
  right: 40px;
  height: 4px;
  background: linear-gradient(90deg, var(--cn-pink), var(--cn-blue), var(--cn-mint));
  border-radius: 0 0 4px 4px;
}

.note-lines {
  position: absolute;
  inset: 40px 28px 28px;
  background-image: repeating-linear-gradient(
    transparent,
    transparent 31px,
    rgba(200, 180, 210, 0.15) 31px,
    rgba(200, 180, 210, 0.15) 32px
  );
  pointer-events: none;
}

.note-textarea {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Prompt', sans-serif;
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 32px;
  color: var(--cn-text);
  resize: none;
  position: relative;
  z-index: 1;
  min-height: 256px;
}

.note-textarea::placeholder {
  color: var(--cn-text-light);
  font-style: italic;
}

.note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
}

.privacy-note {
  font-size: 0.78rem;
  color: var(--cn-text-light);
  max-width: 240px;
  line-height: 1.5;
}

.btn-crumple {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--cn-accent), var(--cn-lavender));
  color: var(--cn-white);
  border: none;
  border-radius: 50px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--cn-transition), box-shadow var(--cn-transition);
}

.btn-crumple:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(232, 125, 160, 0.3);
}

.btn-crumple:active {
  transform: translateY(0) scale(0.97);
}

.btn-crumple:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ========================================
   Crumple Screen
   ======================================== */
.crumple-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  padding: 40px 24px;
  touch-action: none;
}

.crumple-instruction {
  font-size: 1rem;
  color: var(--cn-text-secondary);
  margin-bottom: 24px;
  text-align: center;
  transition: opacity 0.4s ease;
}

/* The paper ball */
.paper-ball-wrap {
  position: relative;
  cursor: grab;
  z-index: 10;
  transition: transform 0.1s ease;
}

.paper-ball-wrap:active {
  cursor: grabbing;
}

.paper-ball {
  width: 120px;
  height: 120px;
  position: relative;
}

.paper-ball-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

/* Crumple animation */
.paper-crumpling {
  animation: crumpleAnim 1.2s ease-in-out forwards;
}

@keyframes crumpleAnim {
  0% {
    transform: scale(1) rotate(0deg);
    border-radius: 12px;
  }
  30% {
    transform: scale(0.85) rotate(-5deg);
  }
  60% {
    transform: scale(0.7) rotate(8deg);
  }
  100% {
    transform: scale(0.6) rotate(0deg);
    border-radius: 50%;
  }
}

/* Trash bin */
.trash-zone {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.3s ease;
}

.trash-zone.active {
  transform: translateX(-50%) scale(1.15);
}

.trash-icon {
  font-size: 3.5rem;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.1));
  transition: transform 0.2s ease;
}

.trash-zone.active .trash-icon {
  animation: trashWiggle 0.5s ease-in-out;
}

@keyframes trashWiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

.trash-label {
  font-size: 0.85rem;
  color: var(--cn-text-light);
  margin-top: 4px;
}

/* Trash bin speech bubble */
.trash-speech {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--cn-white);
  border-radius: 16px;
  padding: 10px 18px;
  box-shadow: var(--cn-shadow-soft);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--cn-text);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.trash-speech.visible {
  opacity: 1;
}

.trash-speech::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: var(--cn-white);
}

/* Paper dissolve into trash */
.paper-dissolve {
  animation: dissolve 0.6s ease-in forwards;
}

@keyframes dissolve {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.2); }
}

/* ========================================
   Release Screen (After letting go)
   ======================================== */
.release-container {
  text-align: center;
  padding: 40px 24px;
  position: relative;
  z-index: 1;
  max-width: 500px;
}

/* Sky background */
.sky-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #e8f4fd 0%, #fef6fa 40%, #fef8e8 100%);
  transition: opacity 1s ease;
}

.sky-bg .cloud {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
}

.sky-bg .cloud:nth-child(1) {
  width: 200px; height: 60px; top: 8%; left: 5%;
  animation: cloudDrift 20s linear infinite;
}

.sky-bg .cloud:nth-child(2) {
  width: 150px; height: 45px; top: 15%; right: 10%;
  animation: cloudDrift 25s linear infinite reverse;
}

.sky-bg .cloud:nth-child(3) {
  width: 180px; height: 50px; top: 5%; left: 40%;
  animation: cloudDrift 30s linear infinite;
  animation-delay: -5s;
}

@keyframes cloudDrift {
  0% { transform: translateX(0); }
  100% { transform: translateX(60px); }
}

/* Flowers */
.flowers {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
  font-size: 2rem;
}

.flowers span {
  animation: flowerPop 0.6s ease backwards;
}

.flowers span:nth-child(1) { animation-delay: 0.2s; }
.flowers span:nth-child(2) { animation-delay: 0.4s; }
.flowers span:nth-child(3) { animation-delay: 0.6s; }
.flowers span:nth-child(4) { animation-delay: 0.8s; }
.flowers span:nth-child(5) { animation-delay: 1.0s; }

@keyframes flowerPop {
  0% { opacity: 0; transform: scale(0) rotate(-20deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

.release-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--cn-text);
  margin-bottom: 12px;
  animation: fadeInUp 0.8s ease 0.5s backwards;
}

.release-message {
  font-size: 1.05rem;
  color: var(--cn-text-secondary);
  line-height: 1.8;
  margin-bottom: 40px;
  animation: fadeInUp 0.8s ease 0.7s backwards;
}

/* Breathing Exercise */
.breathing-box {
  background: var(--cn-white);
  border-radius: var(--cn-radius);
  box-shadow: var(--cn-shadow-soft);
  padding: 28px;
  margin-bottom: 32px;
  animation: fadeInUp 0.8s ease 1s backwards;
}

.breathing-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--cn-text-secondary);
  margin-bottom: 20px;
}

.breathing-circle-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.breathing-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cn-pink-light), var(--cn-blue-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--cn-text-secondary);
  transition: transform 4s ease-in-out, background 4s ease-in-out;
}

.breathing-circle.inhale {
  transform: scale(1.4);
  background: linear-gradient(135deg, var(--cn-blue-light), var(--cn-mint-light));
}

.breathing-circle.exhale {
  transform: scale(1);
  background: linear-gradient(135deg, var(--cn-pink-light), var(--cn-lavender-light));
}

.breathing-status {
  font-size: 0.85rem;
  color: var(--cn-text-light);
}

/* Action buttons */
.release-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeInUp 0.8s ease 1.2s backwards;
}

.btn-write-again {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 36px;
  background: var(--cn-accent);
  color: var(--cn-white);
  border: none;
  border-radius: 50px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--cn-transition), box-shadow var(--cn-transition);
}

.btn-write-again:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(232, 125, 160, 0.3);
}

/* CTA section */
.release-cta {
  margin-top: 32px;
  padding: 20px;
  background: linear-gradient(135deg, var(--cn-pink-light), var(--cn-blue-light));
  border-radius: var(--cn-radius);
  animation: fadeInUp 0.8s ease 1.4s backwards;
}

.release-cta p {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.cta-link {
  color: var(--cn-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.cta-link:hover {
  text-decoration: underline;
}

.cta-link-hub {
  display: block;
  margin-top: 8px;
  font-size: 0.82rem;
  opacity: 0.7;
}

.cta-link-hub:hover {
  opacity: 1;
}

/* ========================================
   Shared Animations
   ======================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen.active .landing-container,
.screen.active .writing-container,
.screen.active .release-container {
  animation: fadeInUp 0.6s ease forwards;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 480px) {
  .landing-title {
    font-size: 2.2rem;
  }

  .landing-subtitle {
    font-size: 1rem;
  }

  .note-paper {
    padding: 24px 20px 20px;
    min-height: 260px;
  }

  .note-textarea {
    font-size: 0.95rem;
    min-height: 200px;
  }

  .note-footer {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .privacy-note {
    max-width: 100%;
    text-align: center;
  }

  .btn-crumple {
    justify-content: center;
  }

  .paper-ball {
    width: 100px;
    height: 100px;
  }

  .release-title {
    font-size: 1.5rem;
  }

  .release-actions {
    align-items: stretch;
  }

  .btn-write-again {
    justify-content: center;
  }
}
