/* ===========================================
   מערכת המידע — המועצה לגיל הרך
   Government-compliant stylesheet (WCAG 2.1 AA)
   =========================================== */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --teal-dark: #0a4d50;
  --teal-mid: #0d7377;
  --teal-light: #11a3a8;
  --teal-bright: #17c5cb;
  --navy: #0c2d3f;
  --white: #ffffff;
  --gray-50: #f8fafa;
  --gray-100: #e8eded;
  --gray-200: #d0dada;
  --gray-600: #3d5b5e;
  --sidebar-width: 64px;
  --header-height: 56px;
  --subtabs-height: 52px;
}

/* --- Skip Navigation (Accessibility) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 0 0 8px 8px;
  font-size: 16px;
  font-weight: 600;
  z-index: 10000;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
  outline: 3px solid #f5a623;
  outline-offset: 2px;
}

/* --- Focus Indicators (WCAG) --- */
*:focus-visible {
  outline: 3px solid #f5a623;
  outline-offset: 2px;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #f5a623;
  outline-offset: 2px;
}

html, body {
  font-family: 'Heebo', Arial, sans-serif;
  background: var(--navy);
  color: var(--white);
  overflow: hidden;
  height: 100%;
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.screen.active { display: flex; }

.gradient-bg {
  background: var(--teal-dark);
  position: relative;
  overflow: hidden;
}
.gradient-bg::before {
  content: '';
  position: absolute;
  width: 110vmax; height: 110vmax;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.06);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.gradient-bg::after {
  content: '';
  position: absolute;
  width: 80vmax; height: 80vmax;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.04);
  top: 50%; left: 35%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.moetza-logo {
  z-index: 1;
  cursor: pointer;
  transition: transform 0.2s;
  background: none;
  border: none;
  padding: 0;
}
.moetza-logo:hover { transform: scale(1.03); }

/* ============================================
   SPLASH SCREEN — Orbital animation
   ============================================ */
#splash-screen {
  z-index: 100;
  background: radial-gradient(ellipse 130% 110% at 50% 45%, #0e6b6f 0%, #0a4d50 35%, #081e2e 100%);
}

.splash-orbit {
  position: absolute;
  width: 480px; height: 480px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  animation: orbitSpin 40s linear infinite;
}
@keyframes orbitSpin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.splash-orbit-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.07);
  animation: orbitRingIn 1.5s ease-out 0.3s both;
}
.splash-orbit-ring-2 {
  position: absolute;
  top: 50%; left: 50%;
  width: 620px; height: 620px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.04);
}
@keyframes orbitRingIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.splash-orbit-ring-2 {
  animation: orbitRing2In 2s ease-out 0.5s both;
}
@keyframes orbitRing2In {
  from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.orbit-icon {
  position: absolute;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  animation: orbitIconIn 0.6s ease-out forwards;
}
.orbit-icon svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: rgba(255,255,255,0.6);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: counterSpin 40s linear infinite;
}
@keyframes counterSpin { to { transform: rotate(-360deg); } }

.orbit-icon:nth-child(1) { top: -22px; left: 50%; transform: translateX(-50%); animation-delay: 0.6s; }
.orbit-icon:nth-child(2) { top: 12%; right: -2%; animation-delay: 0.75s; }
.orbit-icon:nth-child(3) { top: 55%; right: -6%; animation-delay: 0.9s; }
.orbit-icon:nth-child(4) { bottom: -8%; right: 20%; animation-delay: 1.05s; }
.orbit-icon:nth-child(5) { bottom: -8%; left: 20%; animation-delay: 1.2s; }
.orbit-icon:nth-child(6) { top: 55%; left: -6%; animation-delay: 1.35s; }
.orbit-icon:nth-child(7) { top: 12%; left: -2%; animation-delay: 1.5s; }

@keyframes orbitIconIn {
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: scale(1); }
}

.splash-center {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 750px;
}
.splash-logo-anim {
  opacity: 0;
  transform: scale(0.5);
  animation: splashLogoIn 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
}
.splash-logo-anim img {
  height: 110px;
  width: auto;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.3));
}
@keyframes splashLogoIn {
  to { opacity: 1; transform: scale(1); }
}
.splash-title {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.25;
  opacity: 0;
  margin-top: 24px;
  text-shadow: 0 2px 24px rgba(0,0,0,0.2);
  animation: splashTextIn 0.7s ease-out 0.9s forwards;
}
.splash-subtitle {
  font-size: 20px;
  font-weight: 400;
  opacity: 0;
  margin-top: 10px;
  animation: splashTextIn 0.6s ease-out 1.3s forwards;
}
.splash-divider {
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  margin: 18px 0;
  opacity: 0;
  animation: splashLineIn 0.8s ease-out 1.6s forwards;
}
@keyframes splashLineIn {
  from { opacity: 0; width: 0; }
  to { opacity: 1; width: 60px; }
}
.splash-desc {
  font-size: 14px;
  font-weight: 300;
  line-height: 1.9;
  color: rgba(255,255,255,0.9);
  opacity: 0;
  animation: splashTextIn 0.6s ease-out 1.8s forwards;
}
.enter-btn {
  margin-top: 24px;
  padding: 14px 52px;
  font-size: 18px;
  font-weight: 600;
  font-family: 'Heebo', Arial, sans-serif;
  color: var(--white);
  background: linear-gradient(135deg, #3a1854 0%, #2a1040 100%);
  border: none;
  border-radius: 40px;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 24px rgba(42, 16, 64, 0.4);
  opacity: 0;
  animation: splashTextIn 0.6s ease-out 2.2s forwards;
}
.enter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(42, 16, 64, 0.5);
}
@keyframes splashTextIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 0.9; transform: translateY(0); }
}

.splash-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.particle {
  position: absolute;
  width: 2px; height: 2px;
  background: rgba(255,255,255,0.12);
  border-radius: 50%;
  animation: particleFloat 6s ease-in-out infinite;
}
@keyframes particleFloat {
  0%, 100% { transform: translateY(0); opacity: 0.12; }
  50% { transform: translateY(-25px); opacity: 0.25; }
}

#splash-screen.exit {
  animation: splashExit 0.8s ease-in-out forwards;
}
@keyframes splashExit {
  to { opacity: 0; transform: scale(1.02); }
}

/* ============================================
   CATEGORIES SCREEN — Full page with icons
   ============================================ */
#categories-screen {
  background: #0a4d50;
  gap: 40px;
}
.cat-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 1;
}
.cat-header img {
  height: 90px;
  width: auto;
  filter: drop-shadow(0 3px 10px rgba(0,0,0,0.2));
}
.cat-header h1 {
  font-size: 46px;
  font-weight: 800;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 220px);
  gap: 28px;
  justify-content: center;
  z-index: 1;
}
.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 36px 20px;
  border-radius: 18px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: background 0.3s, transform 0.2s, box-shadow 0.3s;
  font-family: 'Heebo', Arial, sans-serif;
  color: var(--white);
  font-size: inherit;
}
.cat-card:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}
.cat-card-icon {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}
.cat-card:hover .cat-card-icon {
  background: rgba(255,255,255,0.18);
}
.cat-card-icon svg {
  width: 28px; height: 28px;
  fill: none;
  stroke: rgba(255,255,255,0.85);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cat-card-name {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}
.cat-grid-bottom {
  display: grid;
  grid-template-columns: repeat(3, 220px);
  gap: 28px;
  justify-content: center;
  z-index: 1;
}

.cat-note {
  font-size: 14px;
  font-weight: 300;
  opacity: 0.8;
  text-align: center;
  line-height: 1.8;
  z-index: 1;
}

/* ============================================
   CATEGORY VIEW
   ============================================ */
#category-screen {
  flex-direction: row;
  align-items: stretch;
  justify-content: stretch;
  background: var(--gray-50);
  color: var(--navy);
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--teal-mid) 0%, var(--teal-dark) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  flex-shrink: 0;
  z-index: 10;
}
.sidebar-logo-wrap {
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 0.2s;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
}
.sidebar-logo-wrap:hover { transform: scale(1.08); }
.sidebar-logo-wrap img {
  height: 40px;
  width: auto;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}

.sidebar-item {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  position: relative;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}
.sidebar-item:hover { background: rgba(255,255,255,0.15); }
.sidebar-item.active { background: rgba(255,255,255,0.22); }
.sidebar-item svg { width: 22px; height: 22px; fill: none; stroke: white; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-item .tooltip {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--navy);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.sidebar-item:hover .tooltip,
.sidebar-item:focus-visible .tooltip { opacity: 1; }

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.top-header {
  height: var(--header-height);
  background: linear-gradient(90deg, var(--teal-bright) 0%, var(--teal-mid) 50%, var(--teal-dark) 100%);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
.header-title { font-size: 20px; font-weight: 700; color: white; }
.header-back {
  background: none; border: none;
  color: white; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  font-family: 'Heebo', Arial, sans-serif;
  font-size: 13px; font-weight: 400;
  opacity: 0.9; transition: opacity 0.2s;
  margin-right: auto;
}
.export-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  padding: 6px 16px;
  border-radius: 6px;
  font-family: 'Heebo', Arial, sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: background 0.2s;
}
.export-btn[hidden] { display: none; }
.export-btn:hover { background: rgba(255,255,255,0.25); }
.export-btn:disabled { opacity: 0.5; cursor: wait; }
.export-btn svg { width: 16px; height: 16px; }
.header-back:hover { opacity: 1; }
.header-back svg { width: 18px; height: 18px; }

.sub-tabs {
  height: var(--subtabs-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 16px; gap: 4px;
  overflow-x: auto; flex-shrink: 0;
}
.sub-tabs::-webkit-scrollbar { height: 3px; }
.sub-tabs::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }
.sub-tab {
  padding: 8px 18px;
  font-size: 13.5px; font-weight: 500;
  font-family: 'Heebo', Arial, sans-serif;
  border: none; border-radius: 8px;
  cursor: pointer; white-space: nowrap;
  transition: background 0.2s, color 0.2s;
  background: transparent; color: var(--gray-600);
}
.sub-tab:hover { background: var(--gray-100); color: var(--navy); }
.sub-tab.active { background: var(--teal-mid); color: var(--white); }

.iframe-container { flex: 1; position: relative; background: var(--white); }
.iframe-container iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.iframe-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--white); z-index: 2; transition: opacity 0.3s;
}
.iframe-loading.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--teal-mid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   FOOTER (Accessibility statement link)
   ============================================ */
.site-footer {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  text-align: center;
}
.site-footer a {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  text-decoration: underline;
  transition: color 0.2s;
}
.site-footer a:hover,
.site-footer a:focus-visible {
  color: rgba(255,255,255,1);
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  /* Splash */
  .splash-orbit { width: 320px; height: 320px; }
  .orbit-icon { width: 34px; height: 34px; }
  .orbit-icon svg { width: 16px; height: 16px; }
  .splash-center { max-width: 90vw; padding: 0 16px; }
  .splash-logo-anim img { height: 80px; }
  .splash-title { font-size: 26px; }
  .splash-subtitle { font-size: 16px; }
  .splash-desc { font-size: 13px; line-height: 1.7; }
  .enter-btn { padding: 12px 36px; font-size: 16px; }

  /* Categories */
  #categories-screen { gap: 24px; padding: 20px; overflow-y: auto; }
  .cat-header img { height: 60px; }
  .cat-header h1 { font-size: 28px; }
  .cat-header { gap: 12px; margin-bottom: 0; }
  .cat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 100%;
  }
  .cat-grid-bottom {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 100%;
  }
  .cat-card {
    padding: 20px 12px;
    gap: 10px;
  }
  .cat-card-icon { width: 44px; height: 44px; }
  .cat-card-icon svg { width: 22px; height: 22px; }
  .cat-card-name { font-size: 14px; }
  .cat-note { font-size: 11px; margin-top: 0; }

  /* Category view — sidebar becomes top bar */
  #category-screen {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: 52px;
    flex-direction: row;
    padding: 0 8px;
    gap: 2px;
    overflow-x: auto;
  }
  .sidebar-logo-wrap {
    margin-bottom: 0;
    margin-left: 8px;
    flex-shrink: 0;
  }
  .sidebar-logo-wrap img { height: 30px; }
  .sidebar-item {
    width: 38px; height: 38px;
    flex-shrink: 0;
  }
  .sidebar-item svg { width: 18px; height: 18px; }
  .sidebar-item .tooltip { display: none; }

  .top-header { height: 44px; padding: 0 12px; }
  .header-title { font-size: 16px; }
  .header-back { font-size: 12px; }
  .header-back svg { width: 14px; height: 14px; }

  .sub-tabs { height: 44px; padding: 0 8px; gap: 2px; }
  .sub-tab { padding: 6px 12px; font-size: 12px; }
}

@media (max-width: 480px) {
  .splash-orbit { width: 260px; height: 260px; }
  .splash-title { font-size: 22px; }
  .splash-subtitle { font-size: 14px; }
  .splash-desc { font-size: 12px; }

  .cat-header h1 { font-size: 24px; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-grid-bottom { grid-template-columns: repeat(1, 1fr); gap: 10px; }
}

/* ============================================
   REDUCED MOTION (Accessibility)
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .splash-orbit { animation: none; }
  .orbit-icon svg { animation: none; }
  .particle { animation: none; }
}

/* ============================================
   HIGH CONTRAST (Accessibility)
   ============================================ */
@media (forced-colors: active) {
  .cat-card {
    border: 2px solid ButtonText;
  }
  .sidebar-item.active {
    border: 2px solid Highlight;
  }
  .sub-tab.active {
    border: 2px solid Highlight;
  }
}
