/* =============================================================
   ABC PLAYGROUND — Master Stylesheet
   Mobile-first. Breakpoints: 480px | 768px | 1024px | 1200px
   ============================================================= */

/* ── RESET & BASE ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Subject colors */
  --math-color:       #2196c4;
  --math-light:       #e8f4fb;
  --ela-color:        #5cb85c;
  --ela-light:        #eaf6ea;
  --science-color:    #c8b800;
  --science-light:    #faf8e0;
  --social-color:     #e6a800;
  --social-light:     #fdf5d9;
  --arts-color:       #e07090;
  --arts-light:       #fdeef3;
  --grades-color:     #9b6bbf;
  --grades-light:     #f3eefb;

  /* UI */
  --white:            #ffffff;
  --bg:               #f4f5f7;
  --border:           #d0d0d0;
  --text:             #222222;
  --text-muted:       #666666;
  --link:             #2196c4;
  --free-yellow:      #f0b800;

  /* Ad slot colors */
  --ad-yellow-bg:     #f9c840;
  --ad-yellow-border: #d4a800;
  --ad-yellow-text:   #7a5f00;
  --ad-green-bg:      #b5d96a;
  --ad-green-border:  #8aaf30;
  --ad-green-text:    #3a5a00;

  /* Layout */
  --max-width:        1200px;
  --header-h:         60px;
  --nav-h:            42px;
  --sidebar-w:        215px;
  --ad-col-w:         160px;
  --radius:           6px;
  --shadow:           0 2px 8px rgba(0,0,0,.10);
  --shadow-hover:     0 6px 20px rgba(0,0,0,.18);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
ul { list-style: none; }


/* ── UTILITY ────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}
.free-label { color: var(--free-yellow); font-family: 'Fredoka One', cursive; }


/* =============================================================
   HEADER
   ============================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  height: var(--header-h);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
  height: 100%;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  font-family: 'Fredoka One', cursive;
  font-size: 1.9rem;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.logo .l-a { color: #e53935; }
.logo .l-b { color: #43a047; }
.logo .l-c { color: #1e88e5; }
.logo .l-text {
  color: #555;
  font-size: 1.4rem;
  margin-left: 5px;
  /* hide on very small screens */
}

/* Search */
.search-form {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--white);
  flex-shrink: 0;
}
.search-form input {
  border: none;
  outline: none;
  padding: 7px 12px;
  font-size: 0.88rem;
  font-family: 'Nunito', sans-serif;
  width: 180px;
}
.search-form button {
  border: none;
  border-left: 1px solid var(--border);
  background: var(--white);
  padding: 7px 11px;
  cursor: pointer;
  color: #555;
  font-size: 1rem;
  transition: background .15s;
}
.search-form button:hover { background: #f0f0f0; }

/* Mobile: hide logo text, shrink search */
@media (max-width: 479px) {
  .logo .l-text { display: none; }
  .logo { font-size: 1.6rem; }
  .search-form input { width: 120px; }
}


/* =============================================================
   NAVIGATION (subject tabs)
   ============================================================= */
.site-nav {
  position: sticky;
  top: var(--header-h);
  z-index: 199;
  background: var(--white);
  border-bottom: 2px solid var(--border);
  overflow-x: auto;          /* scrollable on mobile */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;     /* hide scrollbar Firefox */
  
  display: flex;
  justify-content: center;
}
.site-nav::-webkit-scrollbar { display: none; }

.nav-list {
  display: flex;
  min-width: max-content;    /* don't wrap; let it scroll */
  
  max-width: 1200px;
  width: 100%;
}

.nav-list li a {
  display: block;
  padding: 10px 20px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  transition: background .15s;
  text-decoration: none;
}
.nav-list li:first-child a { border-left: 1px solid var(--border); }
.nav-list li a:hover { background: #f0f0f0; text-decoration: none; }

/* Active states per subject */
.nav-list li.nav-math.active    a { background: var(--math-color);    color: #fff; }
.nav-list li.nav-ela.active     a { background: var(--ela-color);     color: #fff; }
.nav-list li.nav-science.active a { background: var(--science-color); color: #fff; }
.nav-list li.nav-social.active  a { background: var(--social-color);  color: #fff; }
.nav-list li.nav-arts.active    a { background: var(--arts-color);    color: #fff; }
.nav-list li.nav-grades.active  a { background: var(--grades-color);  color: #fff; }

@media (min-width: 768px) {
  .nav-list li a { padding: 10px 26px; font-size: 0.92rem; }
}


/* =============================================================
   PAGE WRAPPER — 3-column layout
   ============================================================= */
.page-wrap {
  display: flex;
  justify-content: center;
  max-width: var(--max-width);
  margin: 20px auto;
  padding: 0;
  gap: 0;
  align-items: flex-start;
}

/* Ad columns — hidden by default, shown on desktop */
.ad-col {
  width: var(--ad-col-w);
  flex-shrink: 0;
  display: none;          /* mobile: hidden */
  flex-direction: column;
  gap: 20px;
  padding-top: 4px;
}

@media (min-width: 1060px) {
  .ad-col--right { display: flex; }   /* only show right ad column */
}

/* Center area */
.center-col {
  flex: 1;
  min-width: 0;           /* CRITICAL: prevents flex overflow */
  padding: 0;
}

/* On mobile, remove padding when no ad cols */
/*
@media (max-width: 1059px) {
  .center-col { padding: 0 6px; }
}
*/


/* =============================================================
   AD SLOTS
   ============================================================= */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-weight: 800;
  font-size: 0.75rem;
  text-align: center;
  line-height: 1.5;
  flex-shrink: 0;
}

/* Yellow (right column) */
.ad-slot--yellow {
  background: var(--ad-yellow-bg);
  border: 2px dashed var(--ad-yellow-border);
  color: var(--ad-yellow-text);
}

/* Green (left sidebar below nav) */
.ad-slot--green {
  background: var(--ad-green-bg);
  border: 2px dashed var(--ad-green-border);
  color: var(--ad-green-text);
}

.ad-160x600 { width: 160px; height: 600px; }
.ad-300x600 { width: 300px; height: 600px; }
.ad-300x250 { width: 300px; height: 250px; }


/* =============================================================
   INNER LAYOUT — sidebar + content
   ============================================================= */
.inner-wrap {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  width: 100%;
}

/* Sidebar — hidden on mobile, shown tablet+ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: none;
}

@media (min-width: 768px) {
  .sidebar { display: block; }
}

/* Sidebar box */
.sidebar-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.sidebar-title {
  padding: 9px 14px;
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--white);
}

/* Subject-specific sidebar headers */
.sidebar-title--math    { background: var(--math-color); }
.sidebar-title--ela     { background: var(--ela-color); }
.sidebar-title--science { background: var(--science-color); }
.sidebar-title--social  { background: var(--social-color); }
.sidebar-title--arts    { background: var(--arts-color); }
.sidebar-title--grades  { background: var(--grades-color); }

.sidebar-list li a {
  display: block;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text);
  border-bottom: 1px solid #ebebeb;
  transition: background .12s;
  text-decoration: none;
}
.sidebar-list li a:hover { background: var(--math-light); color: var(--math-color); text-decoration: none; }
.sidebar-list li.active > a { background: var(--math-light); color: var(--math-color); }
.sidebar-list li:last-child a { border-bottom: none; }

/* Subject-tinted hover/active */
.sidebar--ela     .sidebar-list li a:hover,
.sidebar--ela     .sidebar-list li.active > a { background: var(--ela-light); color: var(--ela-color); }
.sidebar--science .sidebar-list li a:hover,
.sidebar--science .sidebar-list li.active > a { background: var(--science-light); color: var(--science-color); }
.sidebar--social  .sidebar-list li a:hover,
.sidebar--social  .sidebar-list li.active > a { background: var(--social-light); color: var(--social-color); }
.sidebar--arts    .sidebar-list li a:hover,
.sidebar--arts    .sidebar-list li.active > a { background: var(--arts-light); color: var(--arts-color); }
.sidebar--grades  .sidebar-list li a:hover,
.sidebar--grades  .sidebar-list li.active > a { background: var(--grades-light); color: var(--grades-color); }

/* Subtopics (indented under expanded grade) */
.subtopic-list li a {
  padding: 5px 14px 5px 26px;
  font-weight: 400;
  font-size: 0.81rem;
  color: var(--text-muted);
  border-bottom: 1px solid #f2f2f2;
  display: block;
  transition: background .12s;
  text-decoration: none;
}
.subtopic-list li a:hover { color: var(--math-color); background: var(--math-light); text-decoration: none; }
.subtopic-list li.active a { color: var(--math-color); font-weight: 700; }


/* =============================================================
   CONTENT AREA
   ============================================================= */
.content-area { flex: 1; min-width: 0; }

/* Breadcrumb */
.breadcrumb {
  font-size: 0.80rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
}
.breadcrumb a { color: var(--link); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 3px; color: #aaa; }

/* Content panel (the white bordered box) */
.content-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
  margin-bottom: 20px;
}

.content-panel__header {
  padding: 12px 18px;
}
.content-panel__header h1 {
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  color: var(--white);
  line-height: 1.2;
}

/* Subject-colored headers */
.content-panel__header--math    { background: var(--math-color); }
.content-panel__header--ela     { background: var(--ela-color); }
.content-panel__header--science { background: var(--science-color); }
.content-panel__header--social  { background: var(--social-color); }
.content-panel__header--arts    { background: var(--arts-color); }
.content-panel__header--grades  { background: var(--grades-color); }

.content-panel__desc {
  padding: 12px 18px;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.6;
  border-bottom: 1px solid #ebebeb;
}

/* Section dividers inside content box */
.section-divider {
  background: #eef5f9;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 18px;
  font-weight: 800;
  font-size: 0.90rem;
  color: var(--text);
}

/* Grade / topic link grids */
.link-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 14px 18px;
  gap: 5px 24px;
}
.link-grid a {
  font-size: 0.86rem;
  color: var(--text);
  padding: 3px 0;
  text-decoration: none;
  transition: color .12s;
}
.link-grid a:hover { color: var(--link); text-decoration: underline; }

/* Mobile: single column link grid */
@media (max-width: 479px) {
  .link-grid { grid-template-columns: 1fr; }
}


/* =============================================================
   WORKSHEET THUMBNAIL CARDS
   ============================================================= */
.ws-grid {
  display: grid;
  grid-template-columns: 1fr;   /* mobile: 1 col */
  gap: 18px;
  padding: 18px;
}

@media (min-width: 480px) {
  .ws-grid { grid-template-columns: 1fr 1fr; }
}

.ws-card {
  display: block;
  text-decoration: none;
  transition: transform .2s;
}
.ws-card:hover { transform: translateY(-3px); }

.ws-thumb {
  width: 100%;
  aspect-ratio: 8.5 / 11;      /* Letter-size proportion */
  background: #fdf5e4;
  border: 1px solid #e0c898;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  color: #c9a500;
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s;
}
.ws-card:hover .ws-thumb {
  box-shadow: var(--shadow-hover);
}

/* Hover overlay */
.ws-thumb__overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(33, 150, 196, 0.88);
  color: var(--white);
  font-family: 'Nunito', sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
  padding: 8px;
  transform: translateY(100%);
  transition: transform .2s ease;
}
.ws-card:hover .ws-thumb__overlay { transform: translateY(0); }

.ws-title {
  margin-top: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--link);
  text-align: center;
  text-decoration: none;
}


/* =============================================================
   HOMEPAGE HERO BANNER
   ============================================================= */
.hero {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, #a8e6cf 0%, #7ec8e3 40%, #ffe082 75%, #ffccbc 100%);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 20px;
  box-shadow: var(--shadow);

  /* Mobile: shorter */
  min-height: 160px;
  padding: 24px 16px;
}

@media (min-width: 480px)  { .hero { min-height: 200px; } }
@media (min-width: 768px)  { .hero { min-height: 240px; } }

.hero::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 80px;
  background: rgba(255,255,255,.12);
  clip-path: ellipse(55% 100% at 50% 100%);
}

.hero-content { position: relative; z-index: 2; }

.hero-icon {
  font-size: 2.8rem;
  display: block;
  margin-bottom: 8px;
  animation: bob 2.8s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

@media (min-width: 480px) { .hero-icon { font-size: 3.5rem; } }

.hero h1 {
  font-family: 'Fredoka One', cursive;
  color: var(--white);
  text-shadow: 2px 3px 0 rgba(0,0,0,.15);
  line-height: 1.15;
  font-size: 1.6rem;
}
@media (min-width: 480px) { .hero h1 { font-size: 2rem; } }
@media (min-width: 768px) { .hero h1 { font-size: 2.6rem; } }

.hero p {
  color: rgba(255,255,255,.92);
  font-weight: 700;
  font-size: 0.88rem;
  margin-top: 6px;
  text-shadow: 1px 1px 3px rgba(0,0,0,.2);
}
@media (min-width: 480px) { .hero p { font-size: 1rem; } }


/* =============================================================
   SUBJECT CARDS GRID (homepage)
   ============================================================= */
.subject-grid {
  display: grid;
  gap: 14px;

  /* Mobile: 1 column */
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .subject-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 768px) {
  .subject-grid { grid-template-columns: repeat(3, 1fr); }
}

.subject-card {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  height: 160px;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}

@media (min-width: 768px) { .subject-card { height: 185px; } }

.subject-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  text-decoration: none;
}

.subject-card__bg {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 5rem;
  opacity: .20;
}

.subject-card--math    { background: var(--math-color); }
.subject-card--ela     { background: var(--ela-color); }
.subject-card--science { background: var(--science-color); }
.subject-card--social  { background: var(--social-color); }
.subject-card--arts    { background: var(--arts-color); }
.subject-card--grades  { background: var(--grades-color); }

.subject-card__label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 14px 16px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.32));
}
.subject-card__label h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  color: var(--white);
  text-shadow: 1px 2px 4px rgba(0,0,0,.28);
  line-height: 1;
}
@media (min-width: 768px) {
  .subject-card__label h2 { font-size: 1.55rem; }
}
.subject-card__label p {
  font-size: 0.78rem;
  color: rgba(255,255,255,.82);
  margin-top: 2px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}


/* =============================================================
   MOBILE SUBJECT ACCORDION (replaces sidebar on mobile)
   ============================================================= */
.mobile-subject-nav {
  display: block;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .mobile-subject-nav { display: none; }  /* hidden when sidebar shows */
}

.mobile-subject-nav select {
  width: 100%;
  padding: 10px 14px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  border: 2px solid var(--math-color);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%232196c4' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}


/* =============================================================
   FOOTER
   ============================================================= */
.site-footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 28px 16px;
  text-align: center;
  font-size: 0.80rem;
  color: var(--text-muted);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  margin-bottom: 10px;
  /* override sticky positioning from site-nav */
  position: static;
  border: none;
  background: none;
  overflow: visible;
}

.site-footer nav a {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
}
.site-footer nav a:hover { text-decoration: underline; }
.site-footer p { margin-top: 6px; }


/* =============================================================
   PRINT STYLES
   ============================================================= */
@media print {
  .site-header, .site-nav, .sidebar, .ad-col, .site-footer,
  .breadcrumb, .mobile-subject-nav { display: none !important; }
  .page-wrap { margin: 0; padding: 0; }
  .center-col { padding: 0; }
  .content-panel { border: none; }
}
