
/* Base Variables */
:root {
  --font-sans: 'Quicksand', system-ui, sans-serif;
  --font-heading: 'Varela Round', system-ui, sans-serif;
  --font-story: 'Atkinson Hyperlegible', serif;

  --background: hsl(42, 30%, 97%);
  --foreground: hsl(240, 14%, 23%);

  --card: hsl(0, 0%, 100%);
  --card-foreground: hsl(240, 14%, 23%);

  --primary: hsl(173, 50%, 48%);
  --primary-foreground: hsl(0, 0%, 100%);

  --secondary: hsl(260, 70%, 80%);
  --secondary-foreground: hsl(240, 14%, 23%);

  --muted: hsl(210, 40%, 96.1%);
  --muted-foreground: hsl(215.4, 16.3%, 46.9%);

  --accent: hsl(39, 89%, 66%);
  --accent-foreground: hsl(240, 14%, 23%);

  --destructive: hsl(0, 84.2%, 60.2%);
  --destructive-foreground: hsl(0, 0%, 98%);

  --border: hsl(214.3, 31.8%, 91.4%);
  --input: hsl(214.3, 31.8%, 91.4%);
  --ring: hsl(173, 50%, 48%);

  --radius: 1rem;
  
  /* Custom magical theme colors */
  --magical-lavender: hsl(260, 70%, 80%);
  --magical-gold: hsl(39, 89%, 66%);
  --magical-white: hsl(42, 30%, 97%);
  
  /* Gradient colors */
  --magical-gradient: linear-gradient(45deg, var(--magical-teal), var(--magical-lavender));
}

/* Base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-color: var(--border);
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  position: relative;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.no-scroll {
  overflow: hidden;
}


h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
}

/* Utility classes */
.app-container {
  position: relative;
  width: 100%;
  min-height: 100vh;
}

.page-container {
  position: relative;
  max-width: 28rem;
  margin: 0 auto;
  min-height: calc(100vh - 70px);
  padding: 1.5rem 1rem;
  padding-bottom: 8rem; /* Add enough space for the nav bar */
}

.page-content {
  opacity: 0;
  filter: grayscale(20%);
  transition: none !important; /* Prevent transition flash */
}

@font-face {
  font-family: 'skribbled';
  src: url('/static/fonts/skribbled.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

.heading-text {
  font-family: 'skribbled'; /* or your preferred font */
  font-weight: 200;
  font-size: 3.5rem;
  margin-bottom: 1.5rem;
}

.red-text {
  background-image: 
    linear-gradient(#eb5e5d, #eb5e5d), 
    url('/static/images/texture.png');
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}


.teal-text {
  background: linear-gradient(#33b8a1,#33b8a1), url('/static/images/texture.png');;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

.gradient-text {
  background: linear-gradient(to right, #f6c75c, #33b8a1), url('/static/images/texture.png');;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

.greenish-text {
  background: linear-gradient(#2da18f,#2da18f), url('/static/images/texture.png');
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

/* Buttons */
:root {
  --magical-teal: #33b8a1;
  --magical-teal-hover: #2da18f;
}

.btn-primary {
  position: relative;
  overflow: hidden;
  background-color: var(--magical-teal);
  color: white;
  border-radius: 9999px;
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.3s, background-color 0.3s;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-sans, 'Helvetica Neue', sans-serif);
  text-decoration: none;
  font-size: 1rem;
}

.btn-primary:hover {
  background-color: var(--magical-teal-hover);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--magical-gold);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-primary:hover::before {
  opacity: 0.1;
}

:root {
  --magical-navy: #2B2E4A;
  --border: #d1d5db;
  --background-hover: #f3f4f6;
}

.btn-outline {
  background-color: transparent;
  color: var(--magical-navy);
  border: 2px solid var(--border);
  border-radius: 9999px;
  padding: 0.65rem 1.5rem;
  font-weight: 500;
  font-size: 1rem;
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-sans, 'Helvetica Neue', sans-serif);
  text-decoration: none;
}

.btn-outline:hover {
  background-color: var(--background-hover);
  border-color: var(--magical-navy);
  color: var(--magical-navy);
}


.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.btn-icon-ghost {
  background-color: transparent;
  color: var(--foreground);
  border: none;
  border-radius: 0.375rem;
  padding: 0.5rem;
  transition: background-color 0.3s;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-ghost:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Card styles */
.glass-card {
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.4);
  overflow: hidden;
  /* height:85px; */
}

.story-page {
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.4);
  overflow: hidden;
  padding: 1.5rem;
  width: 100%;
  height: 100%;
  max-width: 28rem;
  margin: 0 auto;
  perspective: 1000px;
  transform: translateZ(0);
}

/* Navigation bar */
.navigation-bar {
  position: sticky;
  bottom: 1rem;
  left: 0;
  right: 0;
  z-index: 50;
  max-width: 28rem;
  margin: 0 auto;
  transition: transform 0.3s;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: color 0.3s;
  color: var(--muted-foreground);
  text-decoration: none;
  cursor: pointer;
  background-color: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: inherit;
}

.nav-item:hover {
  color: var(--foreground);
}

.nav-item.active {
  color: var(--primary);
}

.more-menu-dropdown {
  position: absolute;
  bottom: 4rem;     /* Appears above the More button; adjust as needed */
  left: 0%;        /* Center horizontally on the More button */
  transform: translateX(-50%);
  min-width: 170px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(16px);
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(44,62,80,0.14);
  padding: 0.5rem 0;
  z-index: 1000;
  border: 1px solid rgba(200,200,200,0.14);
  display: none;
}
.more-menu-dropdown.open { display: block; }

.more-menu-dropdown .nav-item {
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 0.7em;
  padding: 0.5rem 1.2rem;
  font-size: 1rem;
  border-radius: 0.6rem;
  background: transparent;
  color: #656b8a;
  min-width: 0;
}
.more-menu-dropdown .nav-item:hover {
  background: rgba(230,236,255,0.30);
  /* color: #425cf5; */
}

.dropdown-divider {
  height: 1px;
  margin: 0.2rem 0 0.2rem 1rem;
  background: rgba(0,0,0,0.06);
  border: none;
  width: 70%;
}



/* Animations */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(0.95);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

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

.logo-container {
  display: inline-block;
  animation: float 4s infinite ease-in-out;
}

.logo-container .absolute {
  animation: pulse 3s infinite;
}

/* Narration highlight */
.narration-highlight {
  background-color: rgba(var(--magical-teal), 0.2);
  border-radius: 0.125rem;
  padding: 0 0.125rem;
}

/* Form elements */
input, select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--background);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  transition: border-color 0.3s, box-shadow 0.3s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary), 0.2);
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
  height: 1rem;
  background-color: var(--secondary);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--primary);
  transition: width 0.3s ease-out;
}

/* Toast messages */
.toast {
  position: relative;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: 0.375rem;
  font-weight: 500;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  min-width: 16rem;
  max-width: 24rem;
  animation: toast-slide-in 0.3s ease-out;
}

.toast-success {
  background-color: #10B981;
  color: white;
}

.toast-error {
  background-color: #EF4444;
  color: white;
}

.toast-info {
  background-color: #3B82F6;
  color: white;
}

.toast-warning {
  background: #fbbf24; /* amber-400, adjust as needed */
  color: #222;
}

.toast-default {
  background: #e5e7eb; /* gray-200, adjust as needed */
  color: #111;
}

@keyframes toast-slide-in {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-container {
  position: relative;
  background-color: white;
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 24rem;
  z-index: 101;
}

.modal-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.hidden {
  display: none;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Utility classes for flexbox */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

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

.justify-between {
  justify-between: space-between;
}

.justify-around {
  justify-content: space-around;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-4 {
  gap: 1rem;
}

/* Width/height utilities */
.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.flex-1 {
  flex: 0.9;
}

/* Text utilities */
.text-center {
  text-align: center;
}

.text-sm {
  font-size: 0.875rem;
}

.text-lg {
  font-size: 1.125rem;
}

.text-xl {
  font-size: 1.25rem;
}

.text-2xl {
  font-size: 1.5rem;
}

.text-3xl {
  font-size: 1.875rem;
}

.font-medium {
  font-weight: 500;
}

.font-bold {
  font-weight: 700;
}

.text-muted-foreground {
  color: var(--muted-foreground);
}

/* Margin/padding utilities */
.p-2 {
  padding: 0.5rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.py-7 {
  padding-top: 1.75rem;
  padding-bottom: 1.75rem;
}

.m-4 {
  margin: 1rem;
}

.mx-4 {
  margin-left: 1rem;
  margin-right: 1rem;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-3 {
  margin-bottom: 0.65rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-6 {
  margin-bottom: 1.5rem;
}

.mb-8 {
  margin-bottom: 2rem;
}

.mt-1 {
  margin-top: 0.25rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-4 {
  margin-top: 1rem;
}

.mt-8 {
  margin-top: 2rem;
}

.ml-2 {
  margin-left: 0.5rem;
}

.mr-1 {
  margin-right: 0.25rem;
}

.mr-2 {
  margin-right: 0.5rem;
}

/* Images */
.object-cover {
  object-fit: cover;
}

.object-contain {
  object-fit: contain;
}

/* Positions */
.relative {
  position: relative;
}

.absolute {
  position: absolute;
}

.fixed {
  position: fixed;
}

.inset-0 {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.z-10 {
  z-index: 10;
}

.z-50 {
  z-index: 50;
}

.top-4 {
  top: 1rem;
}

.right-4 {
  right: 1rem;
}

.self-end {
  align-self: flex-end;
}

/* Misc */
.rounded-lg {
  border-radius: 0.5rem;
}

.rounded-full {
  border-radius: 9999px;
}

.blur-xl {
  filter: blur(1.5rem);
}

.opacity-0 {
  opacity: 0;
}

.transition-opacity {
  transition-property: opacity;
}

.duration-300 {
  transition-duration: 300ms;
}

.animate-pulse {
  animation: pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Responsive utilities */
@media (min-width: 640px) {
  .sm\:flex-row {
    flex-direction: row;
  }
}

/* Grid utilities */
.grid {
  display: grid;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.gap-3 {
  gap: 0.75rem;
}


#story-loading-overlay {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#story-loading-overlay.show {
    opacity: 1;
    pointer-events: all;
    transition: opacity 0.3s;
}

/* Book animation */
#loading-book #book-page {
    /* Center left of the animated page (x+width/2, y+height/2) */
    transform-origin: 40px 60px; /* x=30+10, y=32+28. Adjust for perfect left-center */
    animation: svg-page-flip 1.25s infinite cubic-bezier(0.5,0.2,0.2,1.2);
}
/* ————————————————————————————————————————  
   Page-Flip Animation  
   ———————————————————————————————————————— */

/* --- MODIFIED CODE --- */

.page-flip {
  /* make sure transforms work on an inline element */
  display: inline-block;

  /* pivot around the left-center of the image */
  -webkit-transform-origin: left center;
          transform-origin: left center;

  /* 
    ADD THESE LINES: Force element onto its own layer for hardware acceleration.
    This is the most common fix for transform/animation bugs on iOS WebKit.
  */
  -webkit-transform: translateZ(0);
          transform: translateZ(0);
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;


  /* both prefixed & unprefixed animations */
  -webkit-animation: svg-page-flip 1.25s infinite cubic-bezier(0.5,0.2,0.2,1.2);
          animation: svg-page-flip 1.25s infinite cubic-bezier(0.5,0.2,0.2,1.2);
}

/* ————————————————————————————————————————  
   Prefixed keyframes for older iOS WebViews (CLEANED UP)
   ———————————————————————————————————————— */
@-webkit-keyframes svg-page-flip {
  0%, 100% {
    -webkit-transform: scaleX(1) skewY(0deg);
    opacity: 0.85;
  }
  35% {
    -webkit-transform: scaleX(1.13) skewY(10deg) translateX(6px);
    opacity: 1;
  }
  65% {
    -webkit-transform: scaleX(0.93) skewY(-12deg) translateX(-4px);
    opacity: 0.6;
  }
}

/* ————————————————————————————————————————  
   Standard keyframes for modern browsers (No change needed)
   ———————————————————————————————————————— */
@keyframes svg-page-flip {
  0%, 100% {
    transform: scaleX(1) skewY(0deg);
    opacity: 0.85;
  }
  35% {
    transform: scaleX(1.13) skewY(10deg) translateX(6px);
    opacity: 1;
  }
  65% {
    transform: scaleX(0.93) skewY(-12deg) translateX(-4px);
    opacity: 0.6;
  }
}

/* Gold circle spinner animation */
@keyframes spin-slow {
  0% { transform: rotate(0deg);}
  100% { transform: rotate(360deg);}
}
.animate-spin-slow {
  animation: spin-slow 1.5s linear infinite;
}

/* Responsive book size (optional) */
@media (max-width: 700px) {
    #loading-book { width: 120px; height: 80px;}
}

.overlay-text.show {
  opacity: 1;
}
.overlay-text.hide {
  opacity: 0;
}

#story-loading-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 9999;
}

hr {
  height: 1px;
  border:0.02px;
  background-color: lightgray
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.heart-pop {
  animation: pop 200ms ease-in-out;
}
