/**
 * Maximus project styles – extends shadcn-design-system.css
 * Uses design tokens only; no duplicate color/spacing variables.
 * See docs/UI_STYLE_GUIDE.md.
 */

/* ---------------------------------------------------------------------------
   Global overflow and mobile fixes
   --------------------------------------------------------------------------- */
html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  position: relative;
}

/* Prevent horizontal overflow from any element */
*,
*::before,
*::after {
  max-width: 100%;
}

/* Exceptions for elements that need to overflow */
pre,
code,
.ui-table-wrapper {
  max-width: none;
}

/* Fix for iOS Safari 100vh issue */
@supports (-webkit-touch-callout: none) {
  body {
    min-height: -webkit-fill-available;
  }
}

/* Ensure images and media don't overflow */
img,
video,
iframe,
embed,
object {
  max-width: 100%;
  height: auto;
}

/* ---------------------------------------------------------------------------
   Skip link (a11y)
   --------------------------------------------------------------------------- */
.ui-skip-link {
  position: absolute;
  top: calc(-1 * (2.5rem + 4px));
  left: var(--space-4);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--primary-foreground);
  background-color: var(--primary);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: top 0.15s ease;
}

.ui-skip-link:focus {
  top: var(--space-4);
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   Mobile navigation
   --------------------------------------------------------------------------- */
.ui-header__menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
}

.ui-header__menu-btn:hover {
  background-color: var(--accent);
}

.ui-header__menu-btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Nav bar: button-style links and .ui-btn (e.g. Sign Up) align with same height */
.ui-nav .ui-nav__link,
.ui-nav .ui-btn {
  min-height: 2.25rem;
  box-sizing: border-box;
}

.ui-nav .ui-btn--sm {
  min-height: 2rem;
}

.ui-nav.is-open {
  display: flex;
}

.ui-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background-color: hsl(0 0% 0% / 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ui-nav-overlay.is-open {
  display: block;
  opacity: 1;
}

@media (max-width: 768px) {
  .ui-header__menu-btn {
    display: flex;
  }

  .ui-nav {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(20rem, 100vw);
    z-index: 50;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--space-8) var(--space-4);
    background-color: var(--card);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    overflow-y: auto;
  }

  .ui-nav .ui-nav__link {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
  }

  .ui-nav .ui-dropdown {
    position: static;
  }

  .ui-nav .ui-dropdown__menu {
    position: static;
    margin-top: 0;
    margin-left: var(--space-4);
    margin-bottom: var(--space-2);
    box-shadow: none;
    border: none;
    border-left: 2px solid var(--border);
    display: none;
    padding-left: var(--space-4);
  }

  .ui-nav .ui-dropdown.is-open .ui-dropdown__menu {
    display: block;
  }

  .ui-nav .ui-dropdown [data-dropdown-trigger] {
    width: 100%;
    justify-content: space-between;
  }

  .ui-nav .ui-dropdown [data-dropdown-trigger]::after {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.15s ease;
  }

  .ui-nav .ui-dropdown.is-open [data-dropdown-trigger]::after {
    transform: rotate(-135deg);
  }
}

/* ---------------------------------------------------------------------------
   Layout grids (replaces Bootstrap .row/.col-* where needed)
   --------------------------------------------------------------------------- */
.ui-grid {
  display: grid;
  gap: var(--space-6);
}
/* Tighter row gap where columns need more breathing room */
.ui-grid--form {
  column-gap: var(--space-8);
  row-gap: var(--space-6);
}

.ui-grid--2 { grid-template-columns: repeat(2, 1fr); }
.ui-grid--3 { grid-template-columns: repeat(3, 1fr); }
.ui-grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .ui-grid--3 { grid-template-columns: repeat(2, 1fr); }
  .ui-grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .ui-grid--2,
  .ui-grid--3,
  .ui-grid--4 { grid-template-columns: 1fr; }
}

.ui-grid--auto {
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
}

/* Main + sidebar layout (e.g. news + quick links) */
.ui-layout-main-sidebar {
  display: grid;
  gap: var(--space-12);
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .ui-layout-main-sidebar {
    grid-template-columns: 2fr 1fr;
  }
}

/* Flex utilities */
.ui-flex { display: flex; }
.ui-flex-wrap { flex-wrap: wrap; }
.ui-items-center { align-items: center; }
.ui-justify-between { justify-content: space-between; }
.ui-justify-center { justify-content: center; }
.ui-gap-2 { gap: var(--space-2); }
.ui-gap-3 { gap: var(--space-3); }
.ui-gap-4 { gap: var(--space-4); }
.ui-gap-6 { gap: var(--space-6); }
.ui-items-end { align-items: flex-end; }
.ui-flex-1 { flex: 1; }
.ui-min-w-form { min-width: 200px; }
.ui-w-full { width: 100%; }
.ui-min-w-40 { min-width: 10rem; }
.ui-font-mono { font-family: ui-monospace, monospace; }
.ui-pl-6 { padding-left: var(--space-6); }

/* ---------------------------------------------------------------------------
   Page: home – hero, stats, CTA, news (uses design tokens)
   --------------------------------------------------------------------------- */
.home-page .ui-hero--home {
  min-height: 60vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* Police siren light effect (GTA V style) */
.ui-hero--siren {
  position: relative;
  overflow: hidden;
}

.siren-light {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  mix-blend-mode: screen;
}

/* Red lights - left side with multiple spots */
.siren-light--red {
  background:
    radial-gradient(ellipse 40% 80% at 5% 30%, hsl(0 90% 55% / 0.2) 0%, transparent 60%),
    radial-gradient(ellipse 35% 70% at 15% 60%, hsl(0 85% 50% / 0.15) 0%, transparent 55%),
    radial-gradient(ellipse 50% 90% at 10% 80%, hsl(0 90% 55% / 0.12) 0%, transparent 50%),
    radial-gradient(ellipse 60% 50% at 25% 40%, hsl(0 80% 50% / 0.08) 0%, transparent 60%);
  animation: sirenRed 2s ease-in-out infinite;
}

/* Blue lights - right side with multiple spots */
.siren-light--blue {
  background:
    radial-gradient(ellipse 40% 80% at 95% 30%, hsl(220 95% 60% / 0.2) 0%, transparent 60%),
    radial-gradient(ellipse 35% 70% at 85% 60%, hsl(220 90% 55% / 0.15) 0%, transparent 55%),
    radial-gradient(ellipse 50% 90% at 90% 80%, hsl(220 95% 60% / 0.12) 0%, transparent 50%),
    radial-gradient(ellipse 60% 50% at 75% 40%, hsl(210 85% 55% / 0.08) 0%, transparent 60%);
  animation: sirenBlue 2s ease-in-out infinite;
}

@keyframes sirenRed {
  0%, 100% {
    opacity: 0;
    transform: scale(1);
  }
  5% {
    opacity: 0.3;
  }
  12%, 18% {
    opacity: 1;
    transform: scale(1.02);
  }
  25% {
    opacity: 0.4;
  }
  30%, 50% {
    opacity: 0;
    transform: scale(1);
  }
}

@keyframes sirenBlue {
  0%, 30% {
    opacity: 0;
    transform: scale(1);
  }
  35% {
    opacity: 0.3;
  }
  42%, 48% {
    opacity: 1;
    transform: scale(1.02);
  }
  55% {
    opacity: 0.4;
  }
  60%, 100% {
    opacity: 0;
    transform: scale(1);
  }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .siren-light {
    animation: none;
    opacity: 0;
  }
}

.home-page .ui-hero--home::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><radialGradient id="a"><stop offset="0" stop-color="%23ffffff" stop-opacity=".1"/><stop offset="1" stop-color="%23ffffff" stop-opacity="0"/></radialGradient></defs><g opacity=".8"><circle cx="200" cy="200" r="200" fill="url(%23a)"/><circle cx="800" cy="800" r="300" fill="url(%23a)"/></g></svg>');
  opacity: 0.3;
  z-index: 1;
}

.home-page .ui-hero--home .ui-container {
  position: relative;
  z-index: 2;
}

.home-page .ui-hero__actions .ui-btn--primary {
  background-color: hsl(0 0% 100%);
  color: var(--primary);
}

.home-page .ui-hero__actions .ui-btn--primary:hover {
  opacity: 0.95;
  background-color: hsl(0 0% 98%);
}

.home-page .ui-hero__actions .ui-btn--outline {
  border-color: hsl(0 0% 100% / 0.4);
  color: hsl(0 0% 100%);
}

.home-page .ui-hero__actions .ui-btn--outline:hover {
  background-color: hsl(0 0% 100% / 0.15);
  color: hsl(0 0% 100%);
}

/* Emergency alert banner */
.ui-alert-banner {
  background: var(--destructive);
  color: var(--destructive-foreground);
  padding: var(--space-3) 0;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.ui-alert-banner a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.ui-alert-banner a:hover {
  text-decoration: none;
}

/* Stats section (muted background) */
.ui-stats-section {
  background-color: var(--muted);
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
}

/* CTA section (primary background) */
.ui-cta-section {
  background-color: var(--primary);
  color: var(--primary-foreground);
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
  text-align: center;
}

.ui-cta-section .ui-btn--primary {
  background-color: hsl(0 0% 100%);
  color: var(--primary);
}

.ui-cta-section .ui-btn--primary:hover {
  opacity: 0.95;
  background-color: hsl(0 0% 98%);
}

.ui-cta-section .ui-btn--outline {
  border-color: hsl(0 0% 100% / 0.4);
  color: hsl(0 0% 100%);
}

.ui-cta-section .ui-btn--outline:hover {
  background-color: hsl(0 0% 100% / 0.15);
  color: hsl(0 0% 100%);
}

/* News card */
.ui-news-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.ui-news-card:hover {
  box-shadow: var(--shadow-md);
}

.ui-news-card__image {
  width: 100%;
  height: 12rem;
  object-fit: cover;
}

.ui-news-card__image-placeholder {
  width: 100%;
  height: 12rem;
  background-color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  font-size: var(--text-3xl);
}

.ui-news-card__body {
  padding: var(--space-6);
}

.ui-news-card__title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--foreground);
}

.ui-news-card__excerpt {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-4);
}

.ui-news-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

/* Sidebar card (e.g. quick links, emergency contacts) */
.ui-sidebar-card.ui-card__header {
  background-color: var(--muted);
}

.ui-sidebar-card.ui-card--destructive .ui-card__header {
  background-color: var(--destructive);
  color: var(--destructive-foreground);
}

.ui-sidebar-card.ui-card--destructive .ui-card__header h6 {
  color: inherit;
}

.ui-list--links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ui-list--links li {
  margin-bottom: var(--space-2);
}

.ui-list--links a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--foreground);
  text-decoration: none;
  font-size: var(--text-sm);
  padding: var(--space-2) 0;
}

.ui-list--links a:hover {
  color: var(--primary);
}

/* Emergency CTA button (red outline on hero) */
.ui-btn--emergency {
  border-color: var(--destructive);
  color: var(--destructive);
  background-color: hsl(0 84% 60% / 0.1);
}

.ui-btn--emergency:hover {
  background-color: var(--destructive);
  color: var(--destructive-foreground);
}

/* Outline destructive (e.g. alert "View Details") */
.ui-btn--outline.ui-btn--destructive {
  border-color: var(--destructive);
  color: var(--destructive);
}

.ui-btn--outline.ui-btn--destructive:hover {
  background-color: var(--destructive);
  color: var(--destructive-foreground);
}

/* ---------------------------------------------------------------------------
   Spacing utilities (shadcn-aligned; use --space-* tokens only)
   --------------------------------------------------------------------------- */
.ui-m-0 { margin: 0; }
.ui-mt-1 { margin-top: var(--space-1); }
.ui-mt-2 { margin-top: var(--space-2); }
.ui-mt-3 { margin-top: var(--space-3); }
.ui-mt-4 { margin-top: var(--space-4); }
.ui-mt-6 { margin-top: var(--space-6); }
.ui-mt-8 { margin-top: var(--space-8); }
.ui-mb-0 { margin-bottom: 0; }
.ui-mb-1 { margin-bottom: var(--space-1); }
.ui-mb-2 { margin-bottom: var(--space-2); }
.ui-mb-3 { margin-bottom: var(--space-3); }
.ui-mb-4 { margin-bottom: var(--space-4); }
.ui-mb-6 { margin-bottom: var(--space-6); }
.ui-mb-8 { margin-bottom: var(--space-8); }
.ui-mb-12 { margin-bottom: var(--space-12); }
.ui-ml-2 { margin-left: var(--space-2); }
.ui-ml-auto { margin-left: auto; }
.ui-mr-auto { margin-right: auto; }
.ui-mx-auto { margin-left: auto; margin-right: auto; }

.ui-p-4 { padding: var(--space-4); }
.ui-p-6 { padding: var(--space-6); }
.ui-p-8 { padding: var(--space-8); }
.ui-p-16 { padding: var(--space-16); }
.ui-pt-4 { padding-top: var(--space-4); }
.ui-pt-6 { padding-top: var(--space-6); }
.ui-pb-4 { padding-bottom: var(--space-4); }
.ui-pb-6 { padding-bottom: var(--space-6); }
.ui-px-0 { padding-left: 0; padding-right: 0; }
.ui-py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.ui-py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.ui-py-8 { padding-top: var(--space-8); padding-bottom: var(--space-8); }

/* ---------------------------------------------------------------------------
   Page layout (consistent vertical rhythm and content padding)
   --------------------------------------------------------------------------- */
.ui-page {
  padding-top: var(--space-8);
  padding-bottom: var(--space-12);
}

.ui-page-header {
  margin-bottom: var(--space-2);
}

.ui-page-header + .ui-page-intro,
.ui-page-intro {
  margin-top: var(--space-1);
  margin-bottom: var(--space-6);
}

.ui-page-intro.ui-mb-0 {
  margin-bottom: 0;
}

/* Stack: vertical flex with consistent gap (use with ui-stack--2, --4, --6, --8) */
.ui-stack {
  display: flex;
  flex-direction: column;
}

.ui-stack--2 { gap: var(--space-2); }
.ui-stack--4 { gap: var(--space-4); }
.ui-stack--6 { gap: var(--space-6); }
.ui-stack--8 { gap: var(--space-8); }

/* Inner-page hero title (smaller than home hero, consistent margin) */
.ui-hero__title--page {
  font-size: var(--text-2xl);
  color: var(--foreground);
  margin-bottom: var(--space-2);
}

/* Section spacing: consistent margin below content blocks */
.ui-section-bottom {
  margin-bottom: var(--space-12);
}

.ui-section-bottom--sm {
  margin-bottom: var(--space-8);
}

/* Empty state card (e.g. no news, no notices) */
.ui-empty-state {
  padding: var(--space-16);
  text-align: center;
}

.ui-empty-state__icon {
  display: block;
  font-size: var(--text-4xl);
  color: var(--muted-foreground);
  margin-bottom: var(--space-4);
}

/* Icon block (icon above label, e.g. contact cards) */
.ui-icon-block {
  display: block;
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
}

/* Feature card icon centered in grid (replaces margin: 0 auto var(--space-4)) */
.ui-feature-card__icon--center {
  margin: 0 auto var(--space-4);
}

/* Card content with consistent padding (for success/empty panels) */
.ui-card__content--center {
  padding: var(--space-8);
  text-align: center;
}

/* Subheading with top margin (e.g. second/third h4 in a card) */
.ui-heading-with-margin {
  margin: var(--space-4) 0 var(--space-2);
}

/* List reset (for ul/ol that are already .ui-list--links) */
.ui-list-reset {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Block with top border (e.g. resolution section) */
.ui-divider-top {
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
}

/* Map container (e.g. report crime location picker) */
.ui-map-placeholder {
  height: 18.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* Divider in nav (replaces inline separator; add role="separator" in HTML) */
.ui-nav-divider {
  display: block;
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}

/* ---------------------------------------------------------------------------
   Typography utilities
   --------------------------------------------------------------------------- */
.ui-text-muted { color: var(--muted-foreground); }
.ui-text-sm { font-size: var(--text-sm); }
.ui-text-xl { font-size: var(--text-xl); }
.ui-text-2xl { font-size: var(--text-2xl); }
.ui-text-4xl { font-size: var(--text-4xl); }
.ui-text-base { font-size: var(--text-base); }
.ui-text-lg { font-size: var(--text-lg); }
.ui-px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.ui-py-1 { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.ui-text-center { text-align: center; }
.ui-max-w-sm { max-width: 20rem; }
.ui-max-w-md { max-width: 36rem; }
.ui-max-w-lg { max-width: 48rem; }
.ui-max-w-xl { max-width: 56rem; }
.ui-h-full { height: 100%; }

/* Avatar badge (user initial in header) */
.ui-avatar-badge {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

/* Table (data tables) */
.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.ui-table th,
.ui-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.ui-table th {
  font-weight: 600;
  color: var(--foreground);
  background-color: var(--muted);
}

.ui-table tbody tr:hover {
  background-color: var(--muted);
}

/* ---------------------------------------------------------------------------
   Multi-step form (Report Crime)
   --------------------------------------------------------------------------- */
.ui-form-step {
  display: none;
}

.ui-form-step.is-active {
  display: block;
}

.ui-step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.ui-step {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  background-color: var(--muted);
  color: var(--muted-foreground);
  border: 2px solid var(--border);
}

.ui-step.is-active {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.ui-step.is-completed {
  background-color: hsl(142 72% 45%);
  color: white;
  border-color: hsl(142 72% 45%);
}

.ui-step-connector {
  width: 2rem;
  height: 2px;
  background-color: var(--border);
}

.ui-step-connector.is-completed {
  background-color: hsl(142 72% 45%);
}

.ui-progress-bar {
  height: 0.5rem;
  border-radius: var(--radius-full);
  background-color: var(--muted);
  margin-bottom: var(--space-6);
  overflow: hidden;
}

.ui-progress-bar__fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.2s ease;
}

.ui-form-navigation {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}

.ui-form-section {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  margin-bottom: var(--space-6);
}

/* Form grids: generous gap so side-by-side fields never touch */
.ui-form-section .ui-grid,
.ui-card__content .ui-grid:has(.ui-label) {
  gap: var(--space-8);
  align-items: start;
}
.ui-form-section .ui-grid > *,
.ui-card__content .ui-grid:has(.ui-label) > * {
  min-width: 0;
}

/* Hint text below inputs: clear spacing so it doesn’t touch or overlap */
.ui-input + .ui-text-muted,
.ui-textarea + .ui-text-muted {
  margin-top: var(--space-2);
  display: block;
}
.ui-textarea + .ui-text-muted {
  margin-top: var(--space-3);
}

.ui-form-section__title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--primary);
}

.ui-input.is-invalid {
  border-color: var(--destructive);
}

/* Radio/checkbox in forms (align with first line of label) */
.ui-input[type="radio"],
.ui-input[type="checkbox"] {
  width: auto;
  margin-top: 0.2rem;
}

.ui-success-panel {
  display: none;
  margin-top: var(--space-8);
}

.ui-success-panel.is-visible {
  display: block;
}

/* ---------------------------------------------------------------------------
   Animations (respects reduced motion in design system)
   --------------------------------------------------------------------------- */
.ui-fade-in {
  animation: ui-fadeIn 0.5s ease-out;
}

@keyframes ui-fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ui-slide-up {
  animation: ui-slideUp 0.6s ease-out;
}

@keyframes ui-slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .ui-fade-in,
  .ui-slide-up {
    animation: none;
  }
}

/* ---------------------------------------------------------------------------
   Responsive: home
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .home-page .ui-hero--home {
    min-height: 50vh;
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
  }

  .home-page .ui-hero__title {
    font-size: var(--text-2xl);
  }

  .home-page .ui-hero__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .home-page .ui-hero__actions .ui-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ---------------------------------------------------------------------------
   PWA Standalone Mode Styles
   --------------------------------------------------------------------------- */
@media all and (display-mode: standalone) {
  /* Adjust for notch/safe areas on modern phones */
  html, body {
    overflow-x: hidden;
    width: 100%;
  }
  
  .ui-header {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  .ui-footer {
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  main {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  /* Hide browser-specific elements */
  .pwa-hide-standalone {
    display: none !important;
  }
}

body.pwa-standalone {
  /* Safe areas handled by header/footer, not body padding */
}

body.pwa-standalone .ui-header {
  position: sticky;
  top: 0;
  z-index: 100;
}

/* PWA Install Banner (optional) */
.pwa-install-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-4);
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.pwa-install-banner__content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: 600px;
  margin: 0 auto;
}

.pwa-install-banner__text {
  flex: 1;
}

.pwa-install-banner__title {
  font-weight: 600;
  margin: 0 0 var(--space-1);
}

.pwa-install-banner__desc {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  margin: 0;
}

.pwa-install-banner__actions {
  display: flex;
  gap: var(--space-2);
}

/* Touch-friendly improvements for mobile */
@media (max-width: 768px) {
  /* Prevent horizontal overflow */
  html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
  }
  
  /* Ensure containers don't overflow */
  .ui-container {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
    overflow-x: hidden;
  }
  
  /* Prevent long words from causing overflow */
  h1, h2, h3, h4, h5, h6, p, span, a, li {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }
  
  /* Larger touch targets */
  .ui-btn,
  .ui-nav__link,
  .ui-dropdown__item {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Better spacing for touch */
  .ui-card {
    padding: var(--space-4);
    overflow: hidden;
  }
  
  /* Prevent text selection on interactive elements */
  .ui-btn,
  .ui-nav__link {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  
  /* Smooth scrolling on iOS */
  .ui-page,
  main {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Fix hero section on mobile */
  .ui-hero {
    overflow: hidden;
  }
  
  /* Ensure footer doesn't overflow */
  .ui-footer {
    overflow: hidden;
  }
  
  .ui-footer__grid {
    overflow: hidden;
  }
}

/* Offline indicator */
.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--space-2);
  background: var(--destructive);
  color: var(--destructive-foreground);
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 500;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.offline-indicator.is-visible {
  transform: translateY(0);
}

body.pwa-standalone .offline-indicator.is-visible ~ .ui-header {
  margin-top: 2.5rem;
}
