/* ============================================================
   Nakuru East Senior School — Custom Styles
   Base: Tailwind CDN | Custom layer for school branding
   ============================================================ */

/* ── Google Fonts ────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Montserrat:wght@600;700;800;900&display=swap');

/* ── CSS Custom Properties ────────────────────────────────────── */
:root {
  --color-primary:        #1B3A6B;   /* Navy blue — authority, trust */
  --color-primary-dark:   #102447;
  --color-primary-light:  #2A5BA3;
  --color-secondary:      #D4A017;   /* Gold — excellence, achievement */
  --color-secondary-dark: #A87D10;
  --color-accent:         #006633;   /* Kenya green */
  --color-accent-light:   #008844;
  --color-surface:        #FFFFFF;
  --color-background:     #F4F6F8;
  --color-text-dark:      #1A1A2E;
  --color-text-medium:    #4A5568;
  --color-text-light:     #718096;
  --color-border:         #E2E8F0;
  --font-sans:            'Inter', system-ui, -apple-system, sans-serif;
  --font-heading:         'Montserrat', system-ui, -apple-system, sans-serif;
  --shadow-sm:            0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:            0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:            0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --shadow-xl:            0 20px 25px rgba(0,0,0,.1), 0 10px 10px rgba(0,0,0,.04);
  --radius-sm:            6px;
  --radius-md:            10px;
  --radius-lg:            16px;
  --transition:           0.25s cubic-bezier(0.4,0,0.2,1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  color: var(--color-text-dark);
  background-color: var(--color-background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.2;
  color: var(--color-text-dark);
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

/* ── Top Bar ──────────────────────────────────────────────────── */
.top-bar {
  background-color: var(--color-primary-dark);
  color: rgba(255,255,255,0.85);
  padding: 0.45rem 0;
  font-size: 0.8rem;
}

.top-bar a:hover { color: var(--color-secondary); }

.social-icon {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background-color var(--transition), color var(--transition);
  color: rgba(255,255,255,0.75);
}
.social-icon:hover { background-color: var(--color-secondary); color: #fff; }

/* ── Header / Navbar ──────────────────────────────────────────── */
.site-header {
  background-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo-text {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: -0.01em;
}
.nav-logo-sub {
  font-size: 0.7rem;
  color: var(--color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition), color var(--transition);
  position: relative;
}
.nav-link:hover,
.nav-link.active {
  color: #fff;
  background-color: rgba(255,255,255,0.12);
}
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 50%;
  transform: translateX(-50%);
  width: 60%; height: 3px;
  background-color: var(--color-secondary);
  border-radius: 2px;
}

.nav-cta {
  background-color: var(--color-secondary);
  color: var(--color-primary-dark) !important;
  font-weight: 700;
  padding: 0.5rem 1.1rem;
  border-radius: 20px;
  transition: background-color var(--transition), transform var(--transition);
}
.nav-cta:hover { background-color: var(--color-secondary-dark); transform: translateY(-1px); }

.hamburger { background: none; border: none; padding: 0.5rem; color: #fff; }
.hamburger svg { width: 24px; height: 24px; }

/* ── Hero ─────────────────────────────────────────────────────── */
.hero {
  background: #102447; /* fallback while slides load */
  position: relative;
  overflow: hidden;
}

/* Slideshow layers sit behind hero content */
.hero-slideshow {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.hero-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center center;
  opacity: 0;
  transition: opacity 2s ease-in-out;
  will-change: opacity;
}
.hero-slide.active { opacity: 1; }

/* Gradient overlay on top of slides.
   Two stacked layers: a flat scrim guarantees a minimum darkness on every
   slide (some Unsplash frames are very bright), the brand gradient sits on
   top for colour. This is what keeps the gold heading readable. */
.hero-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(16,36,71,0.88) 0%, rgba(27,58,107,0.80) 55%, rgba(0,102,51,0.70) 130%),
    rgba(0,0,0,0.45);
  z-index: 1;
}

/* Extra bottom-weighted scrim: text sits lower on mobile where the
   gradient is weakest. */
.hero-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.35) 100%);
}

/* Readability: shadow on hero type so it survives any slide behind it. */
.hero-content h1 {
  text-shadow: 0 2px 4px rgba(0,0,0,0.55), 0 6px 24px rgba(0,0,0,0.45);
}
.hero-content p,
.hero-content .hero-badge {
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* Hero content above both slides and overlay */
.hero-content {
  position: relative;
  z-index: 2;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.hero-badge {
  background-color: rgba(212,160,23,0.2);
  border: 1px solid var(--color-secondary);
  color: var(--color-secondary);
  font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0.35rem 1rem; border-radius: 20px;
  display: inline-block; margin-bottom: 1.25rem;
}

.btn-primary {
  background-color: var(--color-secondary);
  color: var(--color-primary-dark);
  font-weight: 700; font-size: 0.9rem;
  padding: 0.75rem 2rem; border-radius: 25px;
  display: inline-flex; align-items: center; gap: 0.5rem;
  transition: background-color var(--transition), transform var(--transition), box-shadow var(--transition);
  border: none;
}
.btn-primary:hover {
  background-color: var(--color-secondary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(212,160,23,0.4);
}

.btn-outline {
  border: 2px solid rgba(255,255,255,0.7);
  color: #fff; font-weight: 600; font-size: 0.9rem;
  padding: 0.7rem 1.8rem; border-radius: 25px;
  display: inline-flex; align-items: center; gap: 0.5rem;
  transition: border-color var(--transition), background-color var(--transition);
  background: transparent;
}
.btn-outline:hover { border-color: #fff; background-color: rgba(255,255,255,0.1); }

/* ── Section Headings ─────────────────────────────────────────── */
.section-label {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--color-secondary);
  margin-bottom: 0.5rem;
}
.section-title {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 800; color: var(--color-text-dark);
  margin-bottom: 1rem;
}
.section-subtitle {
  font-size: 1rem; color: var(--color-text-medium);
  max-width: 600px; line-height: 1.7;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s ease;
}
.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.13);
}

.card-category {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--color-secondary);
}

/* ── Stat Blocks ──────────────────────────────────────────────── */
.stat-block {
  text-align: center; padding: 1.5rem;
}
.stat-number {
  font-family: var(--font-heading);
  font-size: 2.5rem; font-weight: 900;
  color: var(--color-secondary); line-height: 1;
}
.stat-label {
  font-size: 0.8rem; font-weight: 600; color: rgba(255,255,255,0.7);
  text-transform: uppercase; letter-spacing: 0.06em; margin-top: 0.25rem;
}

/* ── Footer ───────────────────────────────────────────────────── */
.site-footer { background-color: var(--color-primary-dark); color: rgba(255,255,255,0.8); }
.footer-heading { font-family: var(--font-heading); font-size: 0.9rem; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 1rem; }
.footer-link { font-size: 0.875rem; color: rgba(255,255,255,0.65); display: block; margin-bottom: 0.4rem; transition: color var(--transition); }
.footer-link:hover { color: var(--color-secondary); }

/* ── Forms ────────────────────────────────────────────────────── */
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--color-text-dark); margin-bottom: 0.35rem; }
.form-input {
  width: 100%; padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem; color: var(--color-text-dark);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--color-primary-light); box-shadow: 0 0 0 3px rgba(42,91,163,0.15); }
.form-input::placeholder { color: var(--color-text-light); }

/* ── Alerts / Notices ─────────────────────────────────────────── */
.notice-info { background-color: #EBF5FB; border-left: 4px solid #3498DB; padding: 1rem 1.25rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.notice-warning { background-color: #FEF9E7; border-left: 4px solid var(--color-secondary); padding: 1rem 1.25rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.notice-success { background-color: #E9F7EF; border-left: 4px solid #27AE60; padding: 1rem 1.25rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.notice-error { background-color: #FDEDEC; border-left: 4px solid #E74C3C; padding: 1rem 1.25rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Pathway Cards ────────────────────────────────────────────── */
.pathway-card {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  border-radius: var(--radius-lg); padding: 2rem;
  color: #fff; position: relative; overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s ease;
  cursor: default;
}
.pathway-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 28px 56px rgba(0,0,0,0.22);
}
.pathway-card::before {
  content: '';
  position: absolute; top: -30px; right: -30px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
.pathway-icon {
  width: 56px; height: 56px;
  background: rgba(212,160,23,0.2);
  border: 2px solid var(--color-secondary);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1.25rem; font-size: 1.5rem;
}

/* ── Gallery Grid ─────────────────────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.gallery-item {
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, var(--color-border), #d1d5db);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--color-text-light); font-size: 0.8rem; text-align: center; padding: 1rem;
}

/* ── Breadcrumbs ──────────────────────────────────────────────── */
.breadcrumb { font-size: 0.8rem; color: var(--color-text-light); display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.breadcrumb a { color: var(--color-primary-light); }
.breadcrumb a:hover { color: var(--color-primary); }

/* ── Table ────────────────────────────────────────────────────── */
.table-clean { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table-clean th { background-color: var(--color-primary); color: #fff; padding: 0.75rem 1rem; text-align: left; font-weight: 600; }
.table-clean td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--color-border); }
.table-clean tr:nth-child(even) td { background-color: #F8FAFC; }
.table-clean tr:hover td { background-color: #EBF4FF; }

/* ── Admin Dashboard ──────────────────────────────────────────── */
.admin-sidebar {
  background-color: var(--color-primary-dark);
  width: 240px; min-height: 100vh;
  padding: 1.5rem 0;
  flex-shrink: 0;
}
.admin-nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  color: rgba(255,255,255,0.7); font-size: 0.875rem; font-weight: 500;
  transition: background-color var(--transition), color var(--transition);
}
.admin-nav-link:hover,
.admin-nav-link.active { background-color: rgba(255,255,255,0.1); color: #fff; }
.admin-nav-link.active { border-left: 3px solid var(--color-secondary); }

.admin-stat-card {
  background: var(--color-surface); border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 1rem;
}
.admin-stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; flex-shrink: 0;
}

/* ── Quill Editor Override ─────────────────────────────────────── */
.ql-toolbar { border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important; border-color: var(--color-border) !important; }
.ql-container { border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important; border-color: var(--color-border) !important; font-family: var(--font-sans) !important; font-size: 0.9rem !important; min-height: 280px; }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in-up { animation: fadeInUp 0.6s ease-out forwards; }
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }

/* ── Mobile Menu (animated, not display:none) ─────────────────── */
/* max-height + opacity transition instead of display toggling, so the
   panel slides open smoothly. visibility keeps it out of the tab order
   while closed. */
.mobile-menu {
  background-color: var(--color-primary-dark);
  border-top: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  padding: 0 1.25rem;
  transition:
    max-height 0.32s cubic-bezier(0.4,0,0.2,1),
    opacity 0.22s ease,
    padding 0.32s cubic-bezier(0.4,0,0.2,1),
    visibility 0.32s;
}
.mobile-menu.open {
  max-height: 85vh;
  overflow-y: auto;
  opacity: 1;
  visibility: visible;
  padding: 0.75rem 1.25rem 1.25rem;
  -webkit-overflow-scrolling: touch;
}
.mobile-menu .nav-link {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0.75rem 0.5rem;
  font-size: 1rem;
  border-radius: var(--radius-sm);
}

/* ── Responsive Helpers ───────────────────────────────────────── */
@media (max-width: 768px) {
  .hero { padding: 4rem 0; }
  .section-title { font-size: 1.6rem; }
  .stat-number { font-size: 2rem; }
  .admin-sidebar { width: 100%; min-height: auto; }
}

/* ── Nav Dropdowns ─────────────────────────────────────────────── */
.nav-dropdown { position: relative; }

.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.nav-dropdown-trigger .dropdown-chevron {
  transition: transform 0.22s ease;
  font-size: 0.6rem;
  opacity: 0.75;
}
.nav-dropdown:hover .dropdown-chevron,
.nav-dropdown:focus-within .dropdown-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

.nav-dropdown-menu {
  position: absolute;
  /* Sit flush against trigger — padding-top creates visual gap without breaking hover */
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  min-width: 230px;
  background: #fff;
  border-radius: 0 0 14px 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
  /* padding-top creates space visually, no physical gap for mouse to cross */
  padding: 10px 0 0.5rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  z-index: 200;
}
/* Invisible hover bridge — covers the space between trigger bottom and menu */
.nav-dropdown::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  height: 12px;
  background: transparent;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.845rem;
  font-weight: 500;
  color: var(--color-text-dark);
  transition: background-color 0.15s, color 0.15s, padding-left 0.15s;
  white-space: nowrap;
}
.nav-dropdown-item i {
  width: 15px;
  color: var(--color-secondary);
  font-size: 0.8rem;
  text-align: center;
  flex-shrink: 0;
}
.nav-dropdown-item:hover {
  background-color: #EBF4FF;
  color: var(--color-primary);
  padding-left: 1.5rem;
}
.nav-dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: 0.35rem 1.25rem;
}

/* Mobile accordion sub-menu */
.mobile-sub-menu {
  display: none;
  padding-left: 1rem;
  border-left: 2px solid rgba(212,160,23,0.4);
  margin-left: 0.5rem;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}
.mobile-sub-menu.open { display: block; }
.mobile-sub-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.mobile-sub-trigger .sub-chevron {
  transition: transform 0.2s ease;
  font-size: 0.65rem;
  opacity: 0.6;
}
.mobile-sub-trigger.open .sub-chevron { transform: rotate(180deg); }
.mobile-sub-item {
  display: block;
  padding: 0.45rem 0;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.65);
  transition: color 0.15s;
}
.mobile-sub-item:hover { color: var(--color-secondary); }

/* ── Gallery Scroll Carousel ───────────────────────────────────── */
@keyframes gallery-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.gallery-scroll-wrapper {
  overflow: hidden;
  position: relative;
  /* fade edges */
  mask-image: linear-gradient(to right, transparent 0%, black 6%, black 94%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 6%, black 94%, transparent 100%);
}
.gallery-scroll-track {
  display: flex;
  gap: 1rem;
  animation: gallery-scroll 32s linear infinite;
  width: max-content;
  will-change: transform;
}
.gallery-scroll-wrapper:hover .gallery-scroll-track {
  animation-play-state: paused;
}
.gallery-scroll-item {
  flex-shrink: 0;
  width: 280px;
  height: 200px;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: box-shadow 0.3s ease, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.gallery-scroll-item:hover {
  transform: scale(1.04);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
.gallery-scroll-item img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform 0.4s ease;
}
.gallery-scroll-item:hover img {
  transform: scale(1.06);
}

/* ============================================================
   MOBILE OPTIMISATION & ACCESSIBILITY LAYER
   Appended last so it wins on cascade order.
   ============================================================ */

/* ── 1. Base font size ─────────────────────────────────────────
   iOS Safari auto-zooms any input whose computed font-size is
   under 16px. Setting the root to 16px and forcing all form
   controls to >=16px prevents that zoom-jump on focus. */
html { font-size: 100%; }               /* = 16px unless the user overrode it */
body { font-size: 1rem; }               /* 16px */

input, select, textarea, button {
  font-family: inherit;
  font-size: 1rem;                      /* 16px — stops iOS zoom */
}
.form-input,
input[type="text"], input[type="tel"], input[type="email"],
input[type="password"], input[type="number"], input[type="search"],
input[type="date"], select, textarea {
  font-size: 1rem;
  min-height: 44px;                     /* comfortable tap + type target */
}
textarea { min-height: 120px; }

/* Kill the iOS "tap flash" but keep our own focus styles */
a, button, input, select, textarea, [role="button"] {
  -webkit-tap-highlight-color: rgba(212,160,23,0.25);
}

/* ── 2. Touch targets — the 44x44 rule ─────────────────────────
   Every interactive element gets at least a 44x44 CSS-pixel hit
   area. Small icons keep their visual size and gain invisible
   padding instead of growing. */
.social-icon {
  width: 44px;
  height: 44px;
  font-size: 0.9rem;
}
/* Icons in the dense top bar / footer rows stay visually small but
   still present a full 44px target via padding. */
.top-bar .social-icon,
.site-footer .social-icon {
  width: 44px;
  height: 44px;
}

.nav-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.btn-primary,
.btn-outline,
.nav-cta {
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
}

.hamburger {
  min-width: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition);
}
.hamburger:hover,
.hamburger:focus-visible { background-color: rgba(255,255,255,0.14); }
.hamburger svg { width: 28px; height: 28px; }

/* Accordion trigger + sub-items: full-width, generous rows */
.mobile-sub-trigger {
  min-height: 48px;
  padding: 0.75rem 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  /* touch-action stops the double-tap-to-zoom delay that made
     accordion taps feel like they "did nothing" the first time */
  touch-action: manipulation;
}
.mobile-sub-trigger:hover,
.mobile-sub-trigger:focus-visible { background-color: rgba(255,255,255,0.1); }

.mobile-sub-item {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0.6rem 0.5rem;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  touch-action: manipulation;
}
.mobile-sub-item:hover,
.mobile-sub-item:focus-visible {
  color: var(--color-secondary);
  background-color: rgba(255,255,255,0.06);
}

.nav-dropdown-item { min-height: 44px; }
.footer-link { min-height: 40px; display: flex; align-items: center; }

#back-to-top { width: 48px; height: 48px; }

/* ── 3. Interactive states — hover AND keyboard focus ──────────
   :focus-visible only fires for keyboard/AT users, so mouse
   clicks don't leave a lingering ring. */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--color-secondary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
/* On dark surfaces the gold ring can blend — add a light halo */
.site-header a:focus-visible,
.site-header button:focus-visible,
.top-bar a:focus-visible,
.site-footer a:focus-visible,
.hero a:focus-visible {
  outline-color: #FFD75E;
  box-shadow: 0 0 0 5px rgba(0,0,0,0.35);
}
.form-input:focus-visible {
  outline: 3px solid var(--color-primary-light);
  outline-offset: 1px;
}

/* Text links inside body copy get an underline on hover/focus so the
   state is not colour-only (WCAG 1.4.1) */
.section-subtitle a,
p a:not(.btn-primary):not(.btn-outline):not(.nav-cta):not(.footer-link) {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-link:hover,
.footer-link:focus-visible { text-decoration: underline; text-underline-offset: 3px; }

.btn-primary:focus-visible,
.nav-cta:focus-visible { transform: translateY(-2px); }
.btn-outline:hover,
.btn-outline:focus-visible {
  border-color: #fff;
  background-color: rgba(255,255,255,0.18);
}
.nav-link:focus-visible { background-color: rgba(255,255,255,0.16); color: #fff; }

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 999;
  background: var(--color-secondary);
  color: var(--color-primary-dark);
  font-weight: 700;
  padding: 0.85rem 1.5rem;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
  outline: 3px solid var(--color-primary-dark);
}

/* ── 4. Responsive images ──────────────────────────────────────
   Belt-and-braces: the base reset already sets max-width, this
   also covers height so aspect ratio is never distorted, plus
   embedded media. */
img, svg, video, canvas, iframe {
  max-width: 100%;
}
img, video {
  height: auto;
}
/* object-fit images inside fixed-ratio boxes must keep height:100% */
.gallery-item img,
.gallery-scroll-item img,
.teacher-avatar,
img[style*="height:100%"] {
  height: 100%;
}
iframe { border: 0; }

/* ── 5. Tables — always horizontally scrollable ────────────────
   Wrap any table in .table-scroll (or let the JS helper do it).
   The tabindex on the wrapper lets keyboard users scroll it. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  /* subtle right-edge shadow hints there is more to scroll */
  background:
    linear-gradient(to right, #fff 30%, rgba(255,255,255,0)) left center / 24px 100% no-repeat,
    linear-gradient(to left,  #fff 30%, rgba(255,255,255,0)) right center / 24px 100% no-repeat;
}
.table-scroll:focus-visible { outline: 3px solid var(--color-primary-light); }
.table-scroll table { min-width: 480px; }

/* ── 6. Section spacing / breathing room on mobile ─────────────
   Desktop uses 5rem section padding, which crowds badly once the
   grid collapses to one column. Scale it down but add gap between
   stacked children. */
@media (max-width: 768px) {
  section { padding-top: 3rem !important; padding-bottom: 3rem !important; }
  .hero { padding: 3.5rem 0 !important; }

  /* Any Tailwind grid collapses to a single column here anyway;
     this guarantees the vertical gap is generous enough. */
  .grid { gap: 2rem !important; }

  .section-title { font-size: 1.5rem; line-height: 1.25; }
  .section-subtitle { font-size: 0.975rem; }

  .card, .pathway-card, .info-card { margin-bottom: 0.25rem; }
  .pathway-card { padding: 1.5rem; }

  /* Stacked cards need room to breathe from the heading above */
  .section-label { margin-bottom: 0.65rem; }
}

/* ── 7. Layout breakpoints — force single column on small screens */
@media (max-width: 640px) {
  /* Gallery auto-fill can still squeeze two cramped columns on a
     360px phone — pin it to one. */
  .gallery-grid { grid-template-columns: 1fr; gap: 0.85rem; }

  /* Hero stat panel: 2 cols is fine, but tighten the padding */
  .stat-block { padding: 1rem 0.5rem; }
  .stat-number { font-size: 1.9rem; }
  .stat-label { font-size: 0.7rem; letter-spacing: 0.04em; }

  /* Carousel cards sized for a phone viewport */
  .gallery-scroll-item { width: 220px; height: 158px; }

  /* Buttons go full-width so they're easy to hit and don't wrap oddly */
  .hero-content .btn-primary,
  .hero-content .btn-outline { width: 100%; }

  /* Long words / KNEC codes shouldn't force horizontal page scroll */
  h1, h2, h3, p { overflow-wrap: break-word; }
}

/* Nothing should ever cause sideways page scroll on a phone */
@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
}

/* ── 8. Reduced motion ─────────────────────────────────────────
   Respect the OS setting: stop the carousel and slideshow
   cross-fades, drop transform-based hover lifts. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .gallery-scroll-track { animation: none !important; }
  .hero-slide { transition: none !important; }
  .card:hover, .pathway-card:hover, .gallery-scroll-item:hover {
    transform: none;
  }
}

/* ── 9. Hover-capable devices only ─────────────────────────────
   Touch screens fire :hover on tap and it sticks until the next
   tap, which makes cards look stuck mid-lift. Gate the lift
   effects behind a real pointer. */
@media (hover: none) {
  .card:hover,
  .pathway-card:hover,
  .gallery-scroll-item:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }
  .gallery-scroll-item:hover img { transform: none; }
  /* Desktop dropdowns are hover-driven; on touch the mobile
     accordion handles it, so make sure hover can't half-open them. */
  .nav-dropdown:hover .nav-dropdown-menu {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .nav-dropdown:focus-within .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
  }
}

/* ── 10. Hero slider touch behaviour ──────────────────────────── */
.hero-slideshow { touch-action: pan-y; }

.hero-slider-dots {
  display: flex;
  gap: 0.5rem;
  margin-top: 2rem;
  position: relative;
  z-index: 3;
}
.hero-slider-dot {
  width: 44px;                 /* 44px touch target… */
  height: 44px;
  padding: 0;
  border: none;
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}
.hero-slider-dot::before {     /* …with a small visible dot inside */
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  transition: background-color var(--transition), transform var(--transition);
}
.hero-slider-dot[aria-current="true"]::before {
  background: var(--color-secondary);
  transform: scale(1.45);
}
.hero-slider-dot:hover::before { background: rgba(255,255,255,0.85); }

/* Carousel: pause on focus too, not just hover (keyboard users) */
.gallery-scroll-wrapper:focus-within .gallery-scroll-track,
.gallery-scroll-track.is-paused {
  animation-play-state: paused;
}

/* Visually-hidden but available to screen readers */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── 11. Static news fallback card ────────────────────────────── */
.news-fallback-note {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: var(--color-text-light);
}

/* ── Print ────────────────────────────────────────────────────── */
@media print {
  .site-header, .site-footer, .hamburger, .nav-cta { display: none; }
  body { background: #fff; }
}
