/* Global variables & reset */
:root {
  --font-base:     'Open Sans', sans-serif;
  --clr-bg:        #FCF8F3;
  --clr-card:      #FFFFFF;
  --clr-text:      #333333;
  --clr-primary:   #0077CC;
  --clr-accent:    #F5A623;
  --header-height: 3.5rem;
}
* {
  margin:0; padding:0; box-sizing:border-box;
  touch-action: manipulation;
}
body {
  font-family: var(--font-base);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.5;
  overflow-x: hidden;
}
.container {
  width:100%; max-width:600px;
  margin:0 auto; padding:0 1rem;
}

/* Header */
.header {
  background: var(--clr-card);
  border-bottom:1px solid #e0e0e0;
  position:sticky; top:0; height:var(--header-height); z-index:100;
}
.header__inner {
  display:flex; align-items:center; justify-content:space-between;
  padding:.75rem 0;
}
.logo {
  display:flex; align-items:center; text-decoration:none;
  color:var(--clr-text); font-size:1.25rem; font-weight:600;
}
.logo img { height:45px; margin-right:.5rem; }
.nav-toggle {
  background:none; border:none; font-size:1.5rem; cursor:pointer;
}
.nav {
  display:none; flex-direction:column; gap:.75rem; margin-top:.5rem;
}
.nav.open { display:flex; }
.nav a {
  text-decoration:none; color:var(--clr-text); font-weight:500;
}

/* Hero – desktop background */
.hero {
  background:
    linear-gradient(rgba(0,0,0,0.3),rgba(0,0,0,0.3)),
    url("../assets/images/hero-desktop.png") center/cover no-repeat;
  height: calc(100vh - var(--header-height));
  display:flex; align-items:center; justify-content:center;
  padding:0 1rem;
}
.hero-picture    { display:none; }
.hero__inner     { text-align:center; }
.hero__title     { color:#fff; font-size:clamp(1.75rem,6vw,2.5rem); margin-bottom:.5rem; }
.hero__subtitle  { color:#f0f0f0; margin-bottom:1.25rem; }
.btn--primary    {
  background:var(--clr-card); color:var(--clr-primary);
  border:none; padding:.75rem 1.5rem; border-radius:999px;
  font-weight:600; cursor:pointer; transition:transform .2s;
}
.btn--primary:hover { transform:translateY(-3px); }

/* Sections */
.section         { padding:2rem 0; }
.section__title  { text-align:center; font-size:1.5rem; margin-bottom:1rem; }

/* Featured Book */
.book-card {
  width:120px; margin:0 auto;
  cursor:pointer; border-radius:8px; overflow:hidden;
  box-shadow:0 4px 12px rgba(0,0,0,0.1); transition:transform .2s;
}
.book-card img{width:100%;display:block;}
.book-card:hover { transform:translateY(-4px); }

/* Stories Grid */
.stories-grid {
  display:grid; gap:0.75rem;
  grid-template-columns:repeat(auto-fill,minmax(120px,1fr));
}
.stories-grid.collapsed .story-card:nth-child(n+5) {
  display: none;
}
.story-card {
  background:var(--clr-card); padding:0.75rem; border-radius:8px;
  box-shadow:0 2px 6px rgba(0,0,0,0.1); text-align:center;
  cursor:pointer; transition:transform .2s; font-size:0.875rem;
}
.story-card:hover { transform:translateY(-3px); }
.story-card img {
  width:100%; height:auto; border-radius:6px;
}
.story-card h3 {
  font-size:1rem; margin-top:0.5rem;
}
/* Quick Stories toggle */
.stories__toggle {
  display:block; margin:1rem auto 0; padding:0.5rem 1rem;
  font-size:1rem; cursor:pointer;
  background:#fff; border:1px solid #ccc; border-radius:4px;
}

/* Lullabies List */
.lullabies-list {
  list-style:none; display:grid; gap:1rem;
}
.lullabies-list li {
  background:var(--clr-card); padding:1rem; border-radius:8px;
  box-shadow:0 2px 6px rgba(0,0,0,0.1);
  display:flex; flex-direction:column; gap:.5rem;
}
.lullabies-list audio { width:100%; }
.lullabies-list.collapsed li:nth-child(n+4) {
  display: none;
}
.lullabies__toggle {
  display:block; margin:1rem auto 0; padding:0.5rem 1rem;
  font-size:1rem; cursor:pointer;
  background:#fff; border:1px solid #ccc; border-radius:4px;
}

/* Modals */
.modal {
  position:fixed; top:0; left:0; width:100%; height:100%;
  background:rgba(0,0,0,0.6); display:none;
  align-items:center; justify-content:center; padding:1rem;
  z-index:200;
}
.modal__content {
  background:var(--clr-card); padding:1.5rem; border-radius:8px;
  max-width:300px; width:90%; max-height:90vh; overflow-y:auto;
  position:relative; box-shadow:0 4px 12px rgba(0,0,0,0.1);
}
.modal__content img {
  width:100%; height:auto; object-fit:contain; margin-bottom:1rem;
}
.modal__content h3,
.modal__content p {
  margin-bottom:1rem; word-wrap:break-word;
}
.modal__close {
  position:absolute; top:.5rem; right:.5rem;
  background:none; border:none; font-size:1.25rem; cursor:pointer;
}

/* Pagination (shared by story & book modals) */
.pagination {
  display:flex; justify-content:space-between; margin-top:1rem;
  position:sticky; bottom:0; background:var(--clr-card); padding-top:.5rem;
}
.pagination button {
  background:var(--clr-primary); color:var(--clr-card);
  border:none; padding:.5rem 1rem; border-radius:6px; cursor:pointer;
}
#story-prev[disabled],
#story-next[disabled] {
  opacity:0.5; cursor:default;
}

/* Story modal cover */
.story-modal__img {
  width:100%; max-height:200px; object-fit:cover;
  border-radius:6px; margin-bottom:1rem;
}

/* Footer */
.footer {
  text-align:center; padding:1rem 0; border-top:1px solid #e0e0e0;
}

/* Mobile (≤600px) */
@media(max-width:600px){
  .hero { background:none!important; height:auto!important; padding:0!important; display:block!important; }
  .hero-picture { display:block; width:100%; }
  .hero-picture img.hero-image { width:100%; height:auto; display:block; }
  .nav { width:100%; }
}
@media(min-width:600px){
  .nav { display:flex!important; flex-direction:row; margin-top:0; }
  .nav-toggle { display:none; }
}

/* Landscape tweak */
@media(orientation:landscape) and (max-height:400px){
  .section { padding:1.5rem 0; }
}
/* === Dark-Mode theme variables === */
body.dark-mode {  
  --clr-bg:      #1a1a1a;
  --clr-card:    #2a2a2a;
  --clr-text:    #e0e0e0;
  --clr-primary: #4faafc;
  --clr-accent:  #f39c12;
}

/* Theme-toggle button styling */
.theme-toggle {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  margin-left: 0.5rem;
  color: var(--clr-text);
}
/* Mobile (≤600px) */
@media (max-width: 600px) {
  .header {
    position: relative; /* ensure nav absolute positions off this */
  }

  .nav {
    position: absolute;
    top: var(--header-height);
    left: 0;
    width: 100%;
    background-color: var(--clr-card);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    flex-direction: column;
    gap: .75rem;
    padding: 1rem;
    z-index: 101;
  }
  .nav.open {
    display: flex;
  }
}
/* Desktop (≥600px) */
@media (min-width: 600px) {
  .nav {
    position: static;        /* no longer absolute */
    display: flex !important;/* always visible */
    width: auto;             /* let it size to its contents */
    background: none;        /* transparent so hero can show through */
    box-shadow: none;        /* remove the mobile “panel” look */
    padding: 0;              /* no extra padding */
    flex-direction: row;     /* horizontal links */
    gap: 1rem;               /* space between links */
  }
  .nav-toggle { display: none; }
}
