/* ============================================================
   KidyColor — Main Stylesheet
   ============================================================ */

/* --- Fonts --- */
@font-face {
  font-family: 'Comic Neue';
  src: url('/fonts/ComicNeue-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* --- Skip link --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: #e91e63;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 8px 8px;
  font-weight: bold;
  text-decoration: none;
  z-index: 9999;
}
.skip-link:focus { top: 0; }

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Comic Neue', 'Comic Sans MS', cursive, sans-serif;
  background: linear-gradient(to bottom right, #fff7e6, #ffe6f0);
  color: #333;
}

h1, h2, h3 { color: #444; }

a { color: inherit; }

/* --- Layout Shell --- */
.wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.layout {
  display: flex;
  flex: 1;
  flex-direction: row;
}

main {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
}

/* --- Header --- */
header {
  position: sticky;
  top: 0;
  z-index: 1001;
  background: #fff;
  padding: 0.75rem 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: #333;
}

.logo-container h1 {
  margin: 0;
  font-size: 2rem;
  color: #e91e63;
}

.logo-container p {
  margin: 0;
  font-size: 0.95rem;
  color: #888;
}

/* --- Hamburger toggle --- */
.nav-toggle {
  font-size: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  display: none;
  color: #444;
}

/* --- Overlay --- */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.4);
  z-index: 999;
}

.overlay.active { display: block; }

/* --- Sidebar --- */
aside {
  width: 240px;
  min-width: 240px;
  background: #fff8e1;
  border-right: 1px solid #f0e0b0;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  overflow-y: auto;
  z-index: 1000;
  transition: transform 0.3s ease;
}

aside h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #aaa;
  margin: 0 0 0.75rem;
  text-align: left;
}

.sidebar-summary {
  font-weight: bold;
  font-size: 0.95rem;
  cursor: pointer;
  color: #555;
  padding: 0.3rem 0;
  list-style: none;
  user-select: none;
}

.sidebar-summary:hover { color: #e91e63; }
.sidebar-summary.active { color: #e91e63; }

.sidebar-link {
  display: block;
  padding: 0.25rem 0 0.25rem 1rem;
  font-size: 0.9rem;
  color: #666;
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: #fff0f5;
  color: #e91e63;
}

.sidebar-link.active {
  font-weight: bold;
  color: #e91e63;
  background: #fff0f5;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 1.25rem;
}

.breadcrumbs a {
  color: #e91e63;
  text-decoration: none;
}

.breadcrumbs a:hover { text-decoration: underline; }

/* --- Footer --- */
footer {
  background: #f8f8f8;
  border-top: 1px solid #eee;
  text-align: center;
  padding: 1.25rem;
  font-size: 0.85rem;
  color: #888;
  line-height: 1.8;
}

/* ============================================================
   Homepage — Category Grid
   ============================================================ */

.page-intro {
  text-align: center;
  margin-bottom: 2rem;
}

.page-intro h1 {
  font-size: 2.2rem;
  color: #e91e63;
  margin-bottom: 0.4rem;
}

.page-intro p {
  font-size: 1.1rem;
  color: #666;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  background: #fff;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-align: center;
}

.category-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(233,30,99,0.15);
}

.category-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  transition: transform 0.2s ease;
}

.category-card:hover img {
  transform: scale(1.04) rotate(-1deg);
}

.category-title {
  margin-top: 0.6rem;
  font-size: 0.95rem;
  font-weight: bold;
  color: #444;
}

.category-count {
  font-size: 0.8rem;
  color: #aaa;
  margin-top: 0.2rem;
}

/* ============================================================
   Section / List pages
   ============================================================ */

.section-header {
  margin-bottom: 1.5rem;
}

.section-header h1 {
  font-size: 1.9rem;
  color: #e91e63;
  margin: 0 0 0.3rem;
}

.section-header p {
  color: #777;
  font-size: 1rem;
  margin: 0;
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.page-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-align: center;
}

.page-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(233,30,99,0.13);
}

.page-card a {
  text-decoration: none;
  display: block;
}

.page-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #f5f5f5;
}

.page-card-title {
  font-size: 0.8rem;
  color: #555;
  padding: 0.5rem 0.4rem 0.6rem;
  line-height: 1.3;
}

.img-placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 0.8rem;
}

/* ============================================================
   Single coloring page
   ============================================================ */

.single-page { max-width: 900px; margin: 0 auto; }

.single-page h1 {
  font-size: 1.7rem;
  color: #333;
  margin-bottom: 0.5rem;
  text-align: left;
}

.single-description {
  color: #666;
  font-size: 1rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* Download + Print buttons */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.3rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-pdf {
  background: #e91e63;
  color: #fff;
}

.btn-png {
  background: #2196f3;
  color: #fff;
}

.btn-print {
  background: #fff;
  color: #555;
  border: 2px solid #ddd;
}

/* Image viewer */
.image-viewer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

.nav-arrow {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #eee;
  text-decoration: none;
  transition: background 0.2s, box-shadow 0.2s;
}

.nav-arrow:hover {
  background: #f5f5f5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.nav-arrow svg {
  width: 22px;
  height: 22px;
  fill: #555;
}

.nav-arrow.disabled {
  opacity: 0.25;
  pointer-events: none;
}

.coloring-image {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 2px solid #eee;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  cursor: pointer;
}

/* Tags */
.tags {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.tags-label {
  font-size: 0.85rem;
  color: #aaa;
  margin-right: 0.25rem;
}

.tag-link {
  display: inline-block;
  padding: 0.25em 0.65em;
  background: #f0f4ff;
  border-radius: 20px;
  text-decoration: none;
  color: #5c6bc0;
  font-size: 0.82rem;
  transition: background 0.15s;
}

.tag-link:hover { background: #dce3ff; }

/* Back nav */
.back-nav {
  margin-top: 1.5rem;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  background: #f0f4ff;
  border: 1px solid #c5d0f5;
  border-radius: 8px;
  color: #4a6fa5;
  font-size: 0.95rem;
  font-weight: bold;
  text-decoration: none;
}

.btn-back:hover { background: #dce3ff; }

/* More pages in category */
.more-pages {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid #eee;
}

.more-pages h3 {
  font-size: 1.1rem;
  color: #555;
  margin-bottom: 1rem;
}

/* Related pages */
.related-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #eee;
}

.related-section h2 {
  font-size: 1.1rem;
  color: #888;
  text-align: left;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

.related-card {
  text-decoration: none;
  text-align: center;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: transform 0.15s;
}

.related-card:hover { transform: translateY(-3px); }

.related-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #f5f5f5;
}

.related-card span {
  display: block;
  font-size: 0.72rem;
  color: #666;
  padding: 0.3rem 0.4rem 0.4rem;
  line-height: 1.3;
}

/* ============================================================
   Search
   ============================================================ */

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.search-bar input {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 2px solid #eee;
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus { border-color: #e91e63; }

#search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

/* ============================================================
   Print styles
   ============================================================ */

@media print {
  header, aside, footer, .action-buttons, .nav-arrow,
  .tags, .related-section, .breadcrumbs, .nav-toggle,
  .overlay, .single-description, .single-page h1,
  .back-nav, .more-pages { display: none !important; }

  body { background: #fff; }

  .coloring-image {
    max-width: 100%;
    max-height: none;
    width: 100%;
    border: none;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .image-viewer {
    display: block;
  }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .nav-toggle { display: block; }

  aside {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 1000;
  }

  aside.open { transform: translateX(0); }

  main { padding: 1rem; }

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

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

  .single-page h1 { font-size: 1.3rem; }

  .action-buttons { gap: 0.5rem; }

  .btn { padding: 0.55rem 1rem; font-size: 0.9rem; }
}

@media (max-width: 480px) {
  .related-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
