@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;600;700&family=Roboto:wght@400;500;700&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* WCAG 2.4.7 — visible focus indicator for keyboard/switch users */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid #FFC107;
  outline-offset: 2px;
  border-radius: inherit;
}
.bus-search-input:focus-visible { outline-offset: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background: #EAEDF3;
  /* Stop rubber-band overscroll from revealing the hidden offline banner
     (which sits just above the viewport top) when the user pulls down. */
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font-tamil);
  background: #F2F3F7;
  color: var(--color-text);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  isolation: isolate;
}

/* ── Global toast (refresh feedback across all sections) ──── */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height, 64px) + 20px);
  transform: translateX(-50%) translateY(14px);
  background: #1B5E20;
  color: #fff;
  font-family: var(--font-tamil);
  font-size: 0.92rem;
  font-weight: 700;
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  max-width: 88vw;
  text-align: center;
  transition: opacity 200ms ease, transform 200ms ease;
}
.app-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Pannaipuram village watermark behind all content */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
  background: url('../icons/splash_bg.png') center top / cover no-repeat;
  opacity: 0.10;
  pointer-events: none;
  z-index: -1;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
a { text-decoration: none; color: inherit; }
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

/* Keyboard focus ring — visible only when using keyboard */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid #1A237E;
  outline-offset: 2px;
  border-radius: 6px;
}

/* Offline banner */
#offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: linear-gradient(135deg, #F57F17, #EF6C00);
  color: white;
  text-align: center;
  padding: 8px 16px calc(8px + env(safe-area-inset-top));
  font-size: 0.8rem;
  font-family: var(--font-tamil);
  font-weight: 600;
  z-index: 999;
  /* Hidden state stays AT top:0 (inside the viewport) but invisible — so the
     iOS rubber-band overscroll can't reveal it (translateY above the viewport
     was being exposed on pull-down; iOS ignores overscroll-behavior). */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms ease, visibility 200ms ease;
  box-shadow: 0 2px 8px rgba(245, 127, 23, 0.3);
}
#offline-banner.visible { opacity: 1; visibility: visible; pointer-events: auto; }

/* Retry button + error states (shared by bus + auto) */
.load-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  text-align: center;
}
.load-error-icon { font-size: 44px; margin-bottom: 6px; }
.load-error-ta {
  font-family: var(--font-tamil);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
}
.load-error-en {
  font-family: var(--font-latin);
  font-size: 0.8rem;
  color: var(--color-muted);
  max-width: 280px;
  line-height: 1.45;
}
.retry-btn {
  margin-top: 10px;
  padding: 11px 22px;
  background: #1A237E;
  color: #ffffff;
  border-radius: 24px;
  font-family: var(--font-tamil);
  font-size: 0.9rem;
  font-weight: 700;
  min-height: 44px;
  transition: transform var(--trans-fast), background var(--trans-fast);
}
.retry-btn:active { transform: scale(0.96); background: #283593; }

/* Safe area for iPhone notch / Dynamic Island */
main {
  padding-top: env(safe-area-inset-top);
}

/* ── Install-to-home-screen banner ─────────────────────────── */
#install-banner {
  position: relative;
  margin: calc(12px + env(safe-area-inset-top)) 12px 4px;
  padding: 14px 40px 14px 14px;
  background: linear-gradient(135deg, #1A237E 0%, #283593 100%);
  color: #ffffff;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(26, 35, 126, 0.25);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: slideInDown 320ms ease-out;
}
#install-banner[hidden] { display: none !important; }
@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.install-icon { font-size: 28px; line-height: 1; flex-shrink: 0; padding-top: 2px; }
.install-body { flex: 1; min-width: 0; }
.install-title-ta {
  font-family: var(--font-tamil);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 2px;
}
.install-title-en {
  font-family: var(--font-latin);
  font-size: 0.72rem;
  opacity: 0.82;
  margin-bottom: 10px;
}
.install-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  font-family: var(--font-tamil);
  font-size: 0.85rem;
  line-height: 1.55;
}
.install-steps li {
  display: flex;
  gap: 6px;
  align-items: baseline;
  padding: 2px 0;
}
.install-steps li::before {
  content: counter(step) ".";
  counter-increment: step;
  font-weight: 700;
  opacity: 0.9;
  min-width: 16px;
}
.install-steps { counter-reset: step; }
.install-why {
  font-family: var(--font-tamil);
  font-size: 0.72rem;
  opacity: 0.88;
  line-height: 1.5;
  margin-top: 4px;
}
.install-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 44px;
  height: 44px;
  font-size: 22px;
  color: #ffffff;
  opacity: 0.85;
  line-height: 44px;
  text-align: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
}
.install-close:active { opacity: 1; background: rgba(255,255,255,0.25); }

/* One-click native install button (Android only) */
.install-native-btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  margin: 10px 0 6px;
  background: #ffffff;
  color: #0D47A1;
  font-family: var(--font-tamil);
  font-size: 1.05rem;
  font-weight: 800;
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  cursor: pointer;
  min-height: 52px;
  letter-spacing: 0.01em;
}
.install-native-btn:active { transform: scale(0.97); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.install-native-hint {
  display: block;
  font-family: var(--font-tamil);
  font-size: 0.72rem;
  opacity: 0.9;
  margin-top: 2px;
  line-height: 1.4;
}
/* Remove list bullet when we render the button as a single item */
#install-steps:has(.install-native-btn) { list-style: none; padding-left: 0; }
#install-steps:has(.install-native-btn) li { list-style: none; }

/* ── Install wall overlay ─────────────────────────────────── */
#install-wall {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(160deg, #1A237E 0%, #283593 40%, #0D47A1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#install-wall[hidden] { display: none !important; }

.iw-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  color: #fff;
}
.iw-icon {
  font-size: 64px;
  margin-bottom: 12px;
  line-height: 1;
}
.iw-title-ta {
  font-family: var(--font-tamil);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.iw-title-en {
  font-family: var(--font-tamil);
  font-size: 0.95rem;
  opacity: 0.85;
  margin-bottom: 28px;
}
.iw-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 36px;
}
.iw-features span {
  font-family: var(--font-tamil);
  font-size: 1rem;
  opacity: 0.9;
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 16px;
}
/* Pulsing arrow to draw eye to the button */
@keyframes iw-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
@keyframes iw-pulse-ring {
  0%   { transform: scale(1);    opacity: 0.6; }
  100% { transform: scale(1.18); opacity: 0; }
}
@keyframes iw-glow {
  0%, 100% { box-shadow: 0 8px 24px rgba(0,0,0,0.25), 0 0 0 0 rgba(255,255,255,0.5); }
  50%       { box-shadow: 0 8px 32px rgba(0,0,0,0.3),  0 0 0 14px rgba(255,255,255,0); }
}

.iw-tap-arrow {
  font-size: 2rem;
  animation: iw-bounce 0.9s ease-in-out infinite;
  margin-bottom: 6px;
  display: block;
}
.iw-tap-label {
  font-family: var(--font-tamil);
  font-size: 0.95rem;
  font-weight: 700;
  opacity: 0.95;
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

/* Pulsing ring behind button */
.iw-btn-wrap {
  position: relative;
  margin-bottom: 16px;
}
.iw-btn-wrap::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 24px;
  background: rgba(255,255,255,0.25);
  animation: iw-pulse-ring 1.4s ease-out infinite;
  pointer-events: none;
}

.iw-install-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 76px;
  padding: 18px 24px;
  background: #FFD600;
  color: #1A237E;
  font-family: var(--font-tamil);
  font-size: 1.25rem;
  font-weight: 900;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  gap: 4px;
  animation: iw-glow 1.6s ease-in-out infinite;
  transition: transform 0.1s;
}
.iw-install-btn:active {
  transform: scale(0.96);
  animation: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.iw-install-sub {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.7;
  font-family: var(--font-latin);
}
/* iOS variant of the install wall — numbered Safari steps */
.iw-ios-steps {
  text-align: left;
  margin: 14px auto 4px;
  padding: 14px 16px 14px 34px;
  max-width: 300px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  color: #fff;
  font-family: var(--font-tamil);
  font-size: 0.95rem;
  line-height: 1.55;
}
.iw-ios-steps li { margin-bottom: 9px; }
.iw-ios-steps li:last-child { margin-bottom: 0; }
.iw-ios-steps b { color: #FFD600; }

.iw-skip-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-family: var(--font-tamil);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 12px 24px;
  min-height: 48px;
}
.iw-skip-btn:active { opacity: 0.8; }

/* Section base */
.section { display: block; }
.section[hidden] { display: none; }

/* ── Village announcements (📢) ─────────────────────────── */
#announce-host:not(:empty) { padding: 10px 12px 0; display: flex; flex-direction: column; gap: 8px; }
/* First card sits beside the floating ☰ button — indent its text clear of it */
#announce-host .ann-card:first-child { padding-left: 56px; }
@media (min-width: 700px) {
  #announce-host .ann-card:first-child { padding-left: 84px; }
}
.ann-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  border-left: 4px solid #1565C0;
}
.ann-info    { border-left-color: #1565C0; }
.ann-warning { border-left-color: #E65100; }
.ann-urgent  { border-left-color: #C62828; }
.ann-event   { border-left-color: #6A1B9A; }
.ann-ic { font-size: 18px; line-height: 1.3; }
.ann-txt { flex: 1; min-width: 0; }
.ann-ta {
  font-family: var(--font-tamil);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
  line-height: 1.45;
  overflow-wrap: break-word;
}
.ann-en {
  font-family: var(--font-latin);
  font-size: 0.72rem;
  color: var(--color-muted);
  margin: 2px 0 0;
  line-height: 1.4;
  overflow-wrap: break-word;
}
.ann-close {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 14px;
  line-height: 1;
  padding: 8px;
  margin: -4px -4px 0 0;
  min-width: 32px;
  min-height: 32px;
  cursor: pointer;
  border-radius: 50%;
}
.ann-close:active { background: rgba(0,0,0,0.06); }
