/* Cubs Dream Bedrooms - Storybook Fantasy Theme */

/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  /* Magical Colour Palette */
  --colour-primary: #7C3AED;
  --colour-secondary: #F59E0B;
  --colour-accent: #EC4899;

  /* Child-specific accent colours */
  --colour-fergus: #F97316;
  --colour-rosie: #3B82F6;
  --colour-emmy: #EAB308;
  --colour-ben: #DC2626;
  --colour-group: #8B5CF6;

  /* Backgrounds */
  --bg-page: linear-gradient(135deg, #FEF3C7 0%, #FECACA 50%, #E9D5FF 100%);
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 0.98);

  /* Text */
  --text-primary: #1F2937;
  --text-secondary: #4B5563;
  --text-light: #9CA3AF;

  /* Typography */
  --font-display: 'Fredoka One', cursive;
  --font-body: 'Nunito', sans-serif;
  --font-accent: 'Patrick Hand', cursive;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;

  /* Border Radius - rounded, friendly */
  --radius-sm: 0.75rem;
  --radius-md: 1.25rem;
  --radius-lg: 2rem;
  --radius-xl: 3rem;

  /* Shadows */
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 40px rgba(124, 58, 237, 0.25);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-medium: 300ms ease;
  --transition-slow: 500ms ease-out;

  /* Current accent (overridden per page) */
  --accent: var(--colour-primary);
}

/* Page-specific themes */
body.page-fergus {
  --accent: var(--colour-fergus);
  --bg-page: linear-gradient(135deg, #FEF3C7 0%, #FFEDD5 50%, #FED7AA 100%);
}
body.page-rosie {
  --accent: var(--colour-rosie);
  --bg-page: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 50%, #BFDBFE 100%);
}
body.page-emmy {
  --accent: var(--colour-emmy);
  --bg-page: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 50%, #FDE68A 100%);
}
body.page-ben {
  --accent: var(--colour-ben);
  --bg-page: linear-gradient(135deg, #FEF2F2 0%, #FECACA 50%, #FCA5A5 100%);
}
body.page-group {
  --accent: var(--colour-group);
  --bg-page: linear-gradient(135deg, #F5F3FF 0%, #EDE9FE 50%, #DDD6FE 100%);
}

/* ============================================
   BASE STYLES
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  background-attachment: fixed;
  min-height: 100vh;
  margin: 0;
  padding: var(--space-md);
  line-height: 1.6;
  color: var(--text-primary);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0 0 var(--space-sm);
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: var(--accent);
  text-shadow:
    2px 2px 0 rgba(255,255,255,0.9),
    -1px -1px 0 rgba(255,255,255,0.5);
  letter-spacing: 0.02em;
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  color: var(--text-primary);
}

h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  color: var(--accent);
}

p {
  margin: 0 0 var(--space-sm);
  font-size: 1.1rem;
}

.tagline {
  font-family: var(--font-accent);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  color: var(--text-secondary);
  font-style: italic;
  margin-top: var(--space-xs);
  position: relative;
  z-index: 2;
}

/* ============================================
   LAYOUT
   ============================================ */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-medium);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.page-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--colour-fergus), var(--colour-rosie), var(--colour-emmy), var(--colour-ben));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.header {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  position: relative;
  z-index: 1;
}

.header h1 {
  position: relative;
  z-index: 2;
}

.content {
  padding: var(--space-md) 0;
}

.footer {
  text-align: center;
  padding: var(--space-lg) 0 var(--space-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: var(--space-lg);
  border-top: 1px dashed var(--text-light);
  padding-top: var(--space-lg);
}

.footer p {
  margin: var(--space-xs) 0;
  font-size: 0.9rem;
}

.footer p:first-child {
  font-size: 1rem;
  font-weight: 600;
}

/* ============================================
   NAVIGATION
   ============================================ */
.nav {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  transition: all var(--transition-medium);
  box-shadow: var(--shadow-soft);
}

.nav-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
  border-color: var(--accent);
}

.nav-link.active {
  background: var(--accent);
  color: white;
}

.back-link {
  position: absolute;
  left: var(--space-md);
  top: var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  transition: all var(--transition-medium);
  box-shadow: var(--shadow-soft);
  border: 2px solid transparent;
  z-index: 10;
}

.back-link:hover {
  color: var(--accent);
  transform: translateX(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow-medium);
}

.back-link:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent);
}

/* ============================================
   ROOM CARDS (Landing Page)
   ============================================ */
.room-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-md) 0;
}

.room-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-soft);
  transition: all var(--transition-medium);
  position: relative;
  border: 2px solid transparent;
}

.room-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: var(--card-colour, var(--accent));
  transition: height var(--transition-fast);
}

.room-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 0 0 3px var(--card-colour, var(--accent));
  border-color: var(--card-colour, var(--accent));
}

.room-card:hover::before {
  height: 6px;
}

.room-card:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--card-colour, var(--accent));
}

.room-card[data-child="fergus"] { --card-colour: var(--colour-fergus); }
.room-card[data-child="rosie"] { --card-colour: var(--colour-rosie); }
.room-card[data-child="emmy"] { --card-colour: var(--colour-emmy); }
.room-card[data-child="ben"] { --card-colour: var(--colour-ben); }
.room-card[data-child="group"] { --card-colour: var(--colour-group); }

.room-card-image {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  display: block;
}

.room-card-content {
  padding: var(--space-md);
}

.room-card-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--card-colour, var(--accent));
  margin: 0 0 var(--space-xs);
}

.room-card-tagline {
  font-family: var(--font-accent);
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin: 0;
}

/* ============================================
   HERO SECTION (Child Pages)
   ============================================ */
.hero {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.hero a {
  display: block;
  max-width: 800px;
  margin: var(--space-md) auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-medium);
  transition: all var(--transition-medium);
}

.hero a:hover {
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.2), 0 0 0 4px var(--accent);
  transform: scale(1.01);
}

.hero a:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--accent);
}

.hero-image {
  width: 100%;
  border-radius: var(--radius-lg);
  display: block;
  cursor: pointer;
  transition: transform var(--transition-medium), filter var(--transition-medium);
}

.hero a:hover .hero-image {
  transform: scale(1.02);
  filter: brightness(1.05) saturate(1.1);
}

/* ============================================
   STORY SECTION
   ============================================ */
.story {
  background: linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.7));
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
  border-left: 5px solid var(--accent);
  box-shadow: var(--shadow-soft);
  position: relative;
}

.story::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle at top right, rgba(var(--accent), 0.05) 0%, transparent 70%);
  pointer-events: none;
}

.story h2 {
  color: var(--accent);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.story p {
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.story p strong {
  color: var(--accent);
}

.features-list {
  list-style: none;
  padding: 0;
  margin: var(--space-md) 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-sm);
}

.features-list li {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255,255,255,0.85);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.features-list li:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.features-list li::before {
  content: '\2728';
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ============================================
   IMAGE GALLERY
   ============================================ */
.gallery-section {
  margin: var(--space-xl) 0;
}

.gallery-section h2 {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.gallery a {
  display: block;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: all var(--transition-medium);
  position: relative;
  border: 3px solid transparent;
}

.gallery a::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 60%,
    rgba(0, 0, 0, 0.15) 100%
  );
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.gallery a:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-medium), 0 0 0 3px var(--accent);
  border-color: var(--accent);
  z-index: 2;
}

.gallery a:hover::after {
  opacity: 1;
}

.gallery a:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--accent);
  border-color: var(--accent);
}

.gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  aspect-ratio: 16/10;
  transition: filter var(--transition-medium), transform var(--transition-medium);
}

.gallery a:hover img {
  filter: brightness(1.08) saturate(1.15);
  transform: scale(1.02);
}

/* Sub-gallery sections (Group page) */
.sub-gallery {
  margin-bottom: var(--space-xl);
}

.sub-gallery h3 {
  text-align: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 2px dashed var(--accent);
}

/* ============================================
   EXPLORE OTHER ROOMS
   ============================================ */
.explore-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 2px dashed var(--text-light);
}

.explore-section h2 {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.explore-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-md);
  max-width: 800px;
  margin: 0 auto;
}

.explore-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-sm);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-soft);
  transition: all var(--transition-medium);
  border: 2px solid transparent;
  min-height: 80px;
}

.explore-card:hover {
  transform: translateY(-6px) scale(1.03);
  border-color: var(--card-colour, var(--accent));
  box-shadow: var(--shadow-medium), 0 0 20px rgba(0, 0, 0, 0.08);
}

.explore-card:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--card-colour, var(--accent));
}

.explore-card-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--card-colour, var(--accent));
  transition: transform var(--transition-fast);
}

.explore-card:hover .explore-card-name {
  transform: scale(1.05);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes sparkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.2) rotate(180deg); }
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-15px) rotate(3deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.sparkle {
  animation: sparkle 3s ease-in-out infinite;
}

.floating {
  animation: float 6s ease-in-out infinite;
}

.fade-in {
  animation: fadeIn 0.6s ease-out forwards;
}

/* Staggered fade-in for gallery items */
.gallery a {
  opacity: 0;
  animation: fadeIn 0.4s ease-out forwards;
}

.gallery a:nth-child(1) { animation-delay: 0.05s; }
.gallery a:nth-child(2) { animation-delay: 0.1s; }
.gallery a:nth-child(3) { animation-delay: 0.15s; }
.gallery a:nth-child(4) { animation-delay: 0.2s; }
.gallery a:nth-child(5) { animation-delay: 0.25s; }
.gallery a:nth-child(6) { animation-delay: 0.3s; }
.gallery a:nth-child(7) { animation-delay: 0.35s; }
.gallery a:nth-child(8) { animation-delay: 0.4s; }
.gallery a:nth-child(9) { animation-delay: 0.45s; }
.gallery a:nth-child(10) { animation-delay: 0.5s; }
.gallery a:nth-child(n+11) { animation-delay: 0.55s; }

/* Decorative sparkles - positioned to frame content, not overlap it */
.sparkles {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 200px;
  pointer-events: none;
  font-size: 1.25rem;
  overflow: visible;
  z-index: 0;
}

.sparkles span {
  position: absolute;
  animation: sparkle 3s ease-in-out infinite;
  opacity: 0.7;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8));
}

/* Position sparkles in corners and edges, away from central content */
.sparkles span:nth-child(1) { top: 20px; left: 3%; animation-delay: 0s; font-size: 1rem; }
.sparkles span:nth-child(2) { top: 45px; left: 8%; animation-delay: 0.7s; font-size: 0.9rem; }
.sparkles span:nth-child(3) { top: 25px; right: 3%; left: auto; animation-delay: 1.2s; font-size: 1rem; }
.sparkles span:nth-child(4) { top: 50px; right: 7%; left: auto; animation-delay: 0.3s; font-size: 0.85rem; }
.sparkles span:nth-child(5) { top: 70px; left: 2%; animation-delay: 1.8s; font-size: 0.75rem; }

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Mobile: Hide some sparkles to reduce clutter */
@media (max-width: 639px) {
  .sparkles span:nth-child(2),
  .sparkles span:nth-child(4) {
    display: none;
  }

  .sparkles span:nth-child(1) { left: 2%; font-size: 0.9rem; }
  .sparkles span:nth-child(3) { right: 2%; font-size: 0.9rem; }
  .sparkles span:nth-child(5) { display: none; }

  .back-link {
    position: relative;
    left: auto;
    top: auto;
    display: inline-block;
    margin-bottom: var(--space-sm);
  }

  .header {
    padding-top: var(--space-sm);
  }

  .features-list {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 640px) {
  body {
    padding: var(--space-lg);
  }

  .gallery {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
  }

  .page-container {
    padding: var(--space-xl);
  }

  .sparkles span:nth-child(1) { left: 4%; }
  .sparkles span:nth-child(2) { left: 12%; }
  .sparkles span:nth-child(3) { right: 4%; }
  .sparkles span:nth-child(4) { right: 10%; }
}

@media (min-width: 1024px) {
  .gallery {
    grid-template-columns: repeat(4, 1fr);
  }

  .room-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .hero-image {
    max-width: 70%;
  }

  /* More room for sparkles on larger screens */
  .sparkles span:nth-child(1) { left: 5%; font-size: 1.1rem; }
  .sparkles span:nth-child(2) { left: 15%; font-size: 1rem; }
  .sparkles span:nth-child(3) { right: 5%; font-size: 1.1rem; }
  .sparkles span:nth-child(4) { right: 12%; font-size: 0.95rem; }
  .sparkles span:nth-child(5) { left: 3%; top: 90px; font-size: 0.85rem; }
}

@media (min-width: 1280px) {
  .gallery {
    grid-template-columns: repeat(5, 1fr);
  }

  html {
    font-size: 18px;
  }
}

/* Touch devices - larger targets */
@media (pointer: coarse) {
  .gallery a {
    min-height: 100px;
  }

  .nav-link, .back-link {
    padding: var(--space-sm) var(--space-md);
    min-height: 48px;
  }

  .explore-card {
    min-height: 70px;
    padding: var(--space-md);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .sparkles {
    display: none;
  }
}
