/* ==========================================================================
   Kiddoo Play School - Reusable Components
   ========================================================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.75rem;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

/* In-flight / unavailable state. The :hover rules for the individual variants
   (.btn-primary:hover etc.) are declared further down, so the disabled state
   is written with the extra :hover specificity to beat them rather than
   relying on source order. */
.btn:disabled,
.btn[disabled],
.btn:disabled:hover,
.btn[disabled]:hover {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* The gradient runs through background-image rather than background-color so
   the flat-colour overrides further down (.cta-band .btn-primary) have to
   reset it explicitly - a silent half-override would leave a red gradient
   sitting on top of the yellow they intend. */
.btn-primary {
  background-image: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-image: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-dark) 100%);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--white);
  color: var(--secondary);
  border-color: var(--secondary);
}

.btn-secondary:hover {
  background-color: var(--secondary);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

/* Pressing should feel like pressing - the lift on :hover otherwise stays put
   through the whole click. */
.btn:active {
  transform: translateY(0);
}

.btn-block {
  width: 100%;
}

/* ---------------------------------------------------------------------- */
/* Site Header / Navigation                                               */
/* ---------------------------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
}

.site-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--text);
}

.brand img {
  height: 48px;
  width: auto;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.nav-links a {
  color: var(--text);
  font-weight: 600;
  padding: 0.5rem 0.25rem;
  position: relative;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  height: 3px;
  width: 0;
  background-color: var(--primary);
  border-radius: 2px;
  transition: width 0.2s ease;
}

.nav-links a:hover::after,
.nav-links a.is-active::after {
  width: 100%;
}

.nav-links a.is-active {
  color: var(--primary);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 3px;
  border-radius: 2px;
  background-color: var(--text);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* ---------------------------------------------------------------------- */
/* Hero                                                                    */
/* ---------------------------------------------------------------------- */
.hero {
  background: linear-gradient(180deg, var(--hero-tint) 0%, var(--background) 100%);
  padding: var(--space-xl) 0;
  position: relative;
  overflow: hidden;
}

/* Two soft out-of-frame colour blobs. Purely decorative depth behind the
   headline - the hero was otherwise a flat gradient with a yellow box on it.
   overflow:hidden on .hero is what crops them into arcs at the edges. */
.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.hero::before {
  width: 420px;
  height: 420px;
  top: -190px;
  right: -110px;
  background-color: var(--tint-primary);
  opacity: 0.55;
}

.hero::after {
  width: 300px;
  height: 300px;
  bottom: -170px;
  left: -90px;
  background-color: var(--tint-secondary);
  opacity: 0.6;
}

.hero .container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: var(--space-lg);
  /* Lifts the real content above the two decorative blobs. */
  position: relative;
  z-index: 1;
}

/* Compact centred hero used by About/Gallery/Contact. Replaces a
   `style="padding: 3rem 0"` + `style="grid-template-columns: 1fr; text-align:
   center"` pair that was duplicated verbatim across three pages. */
.hero--compact {
  padding: 3rem 0;
}

.hero--compact .container {
  grid-template-columns: 1fr;
  text-align: center;
}

/* Contact page's two-column layout. This previously existed ONLY as an inline
   style attribute, which is why the mobile override needed the codebase's
   single !important to beat it. */
.contact-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.hero-content .eyebrow {
  display: inline-block;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
  background-color: var(--white);
  padding: 0.35rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-sm);
}

.hero-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-md);
}

/* Illustration state: the placeholder graphic sits on a yellow panel, padded
   and centred. This is the fallback shown until real hero photos exist. */
.hero-visual {
  position: relative;
  background-color: var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.hero-visual img {
  margin: 0 auto;
  max-height: 320px;
}

/* Photo state: js/modules/index.js adds .is-photo as soon as at least one
   real hero photo loads. A photo should fill the frame edge-to-edge, not sit
   shrunk in the middle of a yellow box the way the illustration does - which
   is exactly what the padded/centred rules above would otherwise do to it. */
.hero-visual.is-photo {
  padding: 0;
  background-color: var(--surface);
  aspect-ratio: 4 / 3;
  box-shadow: var(--shadow-lg);
}

.hero-visual.is-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  border-radius: inherit;
}

/* Auto-rotating hero banner (2+ admin-uploaded hero images). Slides only ever
   exist in the .is-photo state, so they fill the frame too. */
.hero-carousel-slide {
  opacity: 0;
  transition: opacity 1s ease;
}

.hero-carousel-slide.is-active {
  opacity: 1;
}

/* ---------------------------------------------------------------------- */
/* Cards                                                                   */
/* ---------------------------------------------------------------------- */
/* .gallery-grid shares this definition - they were byte-identical. */
.card-grid,
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.card {
  background-color: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.card-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--tint-accent);
  color: var(--accent-dark);
  margin-bottom: var(--space-sm);
  transition: transform 0.2s ease;
}

/* Icons are inline <svg> drawn with stroke="currentColor", so each badge's
   `color` above is what tints the glyph. They replaced emoji, which rendered
   as a different picture on every OS and at a different weight from the
   headings beside them. */
.card-icon svg {
  width: 30px;
  height: 30px;
  display: block;
  /* fill/stroke/stroke-width are inherited SVG properties, so setting them on
     the <svg> reaches the shadow content <use> clones out of the sprite. That
     keeps the sprite itself free of presentation attributes. */
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The sprite is markup, not a picture - it defines the symbols the <use>
   elements clone and must never take up layout space itself. */
.icon-sprite {
  display: none;
}

.card:hover .card-icon {
  transform: scale(1.08) rotate(-4deg);
}

/* Badge colourways. Cycling these across a grid is what stops six identical
   yellow circles reading as one undifferentiated block. */
.card-icon--primary   { background-color: var(--tint-primary);   color: var(--primary); }
.card-icon--secondary { background-color: var(--tint-secondary); color: var(--secondary); }
.card-icon--accent    { background-color: var(--tint-accent);    color: var(--accent-dark); }
.card-icon--blue      { background-color: var(--tint-blue);      color: var(--info-blue); }
.card-icon--green     { background-color: var(--tint-green);     color: var(--success-green); }

.card h3 {
  margin-bottom: 0.4rem;
}

.card p {
  margin-bottom: 0;
}

/* Programs */
.program-card {
  text-align: center;
  border-top: 6px solid var(--primary);
}

/* Cycles every 4 rather than colouring only the first four. Programs are
   admin-managed rows now, so a 5th one previously fell off the end of the
   rotation and rendered with no accent colour at all. */
.program-card:nth-child(4n + 1) { border-top-color: var(--primary); }
.program-card:nth-child(4n + 2) { border-top-color: var(--secondary); }
.program-card:nth-child(4n + 3) { border-top-color: var(--info-blue); }
.program-card:nth-child(4n)     { border-top-color: var(--success-green); }

/* Activities */
.activity-card {
  text-align: center;
}

.activity-card .card-icon {
  margin: 0 auto var(--space-sm);
}

/* ---------------------------------------------------------------------- */
/* Gallery preview / grid                                                 */
/* ---------------------------------------------------------------------- */
.gallery-filters {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
}

.filter-btn {
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background-color: var(--white);
  font-family: var(--font-heading);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  border-color: var(--primary);
}

.filter-btn.is-active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.gallery-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  background-color: var(--white);
  border: 1px solid var(--border);
  position: relative;
}

.gallery-card img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.gallery-card:hover img {
  transform: scale(1.07);
}

.gallery-card:hover {
  box-shadow: var(--shadow-lg);
}

/* The caption sits over the bottom of the photo instead of in a strip beneath
   it, so the image is the whole card. It needs the scrim because the text
   colour is fixed white while the pixels underneath are an arbitrary
   admin-uploaded photo. */
.gallery-card-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--space-lg) var(--space-sm) 0.8rem;
  background-image: var(--photo-scrim);
}

.gallery-card-caption span {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--white);
}

.gallery-card.is-hidden {
  display: none;
}

/* Lightbox modal */
.lightbox {
  position: fixed;
  inset: 0;
  background-color: var(--overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: var(--space-md);
}

.lightbox.is-open {
  display: flex;
}

.lightbox-content {
  max-width: 900px;
  width: 100%;
  background-color: var(--white);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.lightbox-content img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background-color: #000;
}

.lightbox-caption {
  padding: var(--space-sm) var(--space-md);
}

.lightbox-close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background-color: var(--white);
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------------- */
/* Programs / Events / Testimonials                                        */
/* ---------------------------------------------------------------------- */
/* The Programs page uses .program-card too, but left-aligned for long copy
   (the Home summary cards stay centred). */
#programs-list .program-card {
  text-align: left;
}

.program-meta {
  color: var(--secondary);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.event-card {
  text-align: left;
}

.event-photo {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
}

.event-date {
  color: var(--secondary);
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.testimonial-card {
  text-align: center;
}

.testimonial-quote {
  font-style: italic;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.testimonial-quote::before {
  content: "\201C";
}

.testimonial-quote::after {
  content: "\201D";
}

.testimonial-author {
  font-family: var(--font-heading);
  font-weight: 600;
  margin-bottom: 0;
}

.testimonial-relationship {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* Admissions page: long-form prose under generated headings. */
#admissions-content h2 {
  margin-top: var(--space-lg);
}

#admissions-content h2:first-child {
  margin-top: 0;
}

/* ---------------------------------------------------------------------- */
/* Team member cards ("Our People")                                        */
/* ---------------------------------------------------------------------- */
/* These previously existed ONLY as inline element.style assignments in
   about.js - there was no CSS for them at all. */
.team-card {
  text-align: center;
}

.team-avatar {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 50%;
  margin: 0 auto var(--space-sm);
}

.team-role {
  color: var(--secondary);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

/* ---------------------------------------------------------------------- */
/* Small utilities (replacing repeated inline styles)                       */
/* ---------------------------------------------------------------------- */
.stack-top-sm {
  margin-top: var(--space-sm);
}

.stack-top-md {
  margin-top: var(--space-md);
}

.stack-top-lg {
  margin-top: var(--space-lg);
}

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

.footer-tagline {
  color: var(--dark-text-muted);
}

.narrow-column {
  max-width: 420px;
}

/* ---------------------------------------------------------------------- */
/* Loading / empty / error states                                          */
/* ---------------------------------------------------------------------- */
/* Injected into grid containers, so span every column rather than sitting
   in the first cell. */
.state-block {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-lg);
  color: var(--text-muted);
}

/* An empty gallery and a failed fetch are different things and previously
   looked identical ("Photos coming soon!" for both). */
.state-block.is-error {
  color: var(--primary);
  font-weight: 600;
}

.state-block p {
  margin: 0;
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  margin-bottom: var(--space-xs);
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: kiddoo-spin 0.8s linear infinite;
}

@keyframes kiddoo-spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------------- */
/* CTA band                                                                */
/* ---------------------------------------------------------------------- */
.cta-band {
  background-color: var(--secondary);
  background-image: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  color: var(--white);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  text-align: center;
  margin: 0 auto;
  max-width: var(--max-width);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

/* Decorative rings, cropped by the band's own overflow. */
.cta-band::before,
.cta-band::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--white);
  opacity: 0.16;
  pointer-events: none;
}

.cta-band::before {
  width: 260px;
  height: 260px;
  top: -130px;
  left: -70px;
}

.cta-band::after {
  width: 200px;
  height: 200px;
  bottom: -120px;
  right: -50px;
}

.cta-band > * {
  position: relative;
  z-index: 1;
}

.cta-band h2,
.cta-band p {
  color: var(--white);
}

/* .btn-primary now carries a red gradient via background-image, so a
   background-COLOUR override alone would leave that gradient painted on top
   of the yellow. The image has to be reset explicitly. */
.cta-band .btn-primary {
  background-image: none;
  background-color: var(--accent);
  color: var(--text);
}

.cta-band .btn-primary:hover {
  background-image: none;
  background-color: var(--accent-dark);
}

/* ---------------------------------------------------------------------- */
/* Footer                                                                  */
/* ---------------------------------------------------------------------- */
.site-footer {
  background-color: var(--dark-surface);
  color: var(--dark-text);
  padding: var(--space-xl) 0 var(--space-md);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--white);
  margin-bottom: var(--space-sm);
}

.footer-brand img {
  height: 40px;
}

.site-footer h4 {
  color: var(--white);
  margin-bottom: var(--space-sm);
}

.site-footer a {
  color: var(--dark-text-muted);
}

.site-footer a:hover {
  color: var(--accent);
}

.footer-list li {
  margin-bottom: 0.5rem;
}

.footer-bottom {
  border-top: 1px solid var(--dark-border);
  padding-top: var(--space-sm);
  text-align: center;
  font-size: 0.85rem;
  color: var(--dark-text-subtle);
}

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  font-family: var(--font-body);
  font-size: 1rem;
  background-color: var(--white);
}

/* Keep a real focus ring. This previously set `outline: none`, and because a
   bare :focus rule is more specific for inputs than the global
   :focus-visible, a 2px border-colour shift was the ONLY focus signal on
   every form field. */
.form-group input:focus-visible,
.form-group textarea:focus-visible,
.form-group select:focus-visible {
  border-color: var(--info-blue);
  outline: 3px solid var(--info-blue);
  outline-offset: 2px;
}

/* Mouse users still get the softer border-only treatment. */
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--info-blue);
}

.form-group.has-error input,
.form-group.has-error textarea {
  border-color: var(--primary);
}

.form-error {
  display: none;
  color: var(--primary);
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.form-group.has-error .form-error {
  display: block;
}

.form-success {
  display: none;
  background-color: var(--success-bg);
  border: 2px solid var(--success-green);
  color: var(--success-text);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
}

.form-success.is-visible {
  display: block;
}

.form-success.is-error {
  background-color: var(--error-bg);
  border-color: var(--primary);
  color: var(--error-text);
}

/* Contact info list */
.contact-info-list li {
  display: flex;
  gap: 0.75rem;
  margin-bottom: var(--space-sm);
}

.contact-info-list strong {
  color: var(--text);
}

/* Google Maps embed. The stock Google snippet ships width="600" height="450"
   + style="border:0", which overflows the column on mobile - this makes it
   fluid and moves the border reset out of an inline style. */
.map-embed {
  display: block;
  width: 100%;
  height: 300px;
  border: 0;
  border-radius: var(--radius-md);
  margin-top: var(--space-md);
}

.map-placeholder {
  background-color: var(--border);
  border-radius: var(--radius-md);
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: var(--space-md);
}
