/* ==========================================================================
   GLOBAL TYPOGRAPHY & CONTRAST RULES
   Ensures readable text on all surfaces, especially over mural background
   ========================================================================== */

/* Base Typography */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.625;
  color: #1a1a1a;
}

/* Heading Scale */
h1, .h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  color: #111827;
}

h2, .h2 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 700;
  line-height: 1.2;
  color: #111827;
}

h3, .h3 {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  font-weight: 600;
  line-height: 1.3;
  color: #1f2937;
}

h4, .h4 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  color: #1f2937;
}

/* Paragraph defaults */
p {
  margin-bottom: 1rem;
  color: #374151;
}

p:last-child {
  margin-bottom: 0;
}

/* Link Colors - Standardized */
a {
  color: #166534;
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: #14532d;
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid #166534;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Links on dark backgrounds */
.text-white a,
.bg-green-800 a,
.bg-green-700 a,
.bg-green-600 a,
footer a {
  color: rgba(255, 255, 255, 0.9);
}

.text-white a:hover,
.bg-green-800 a:hover,
.bg-green-700 a:hover,
.bg-green-600 a:hover,
footer a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* Page Surface Typography - ensures contrast */
.page-surface {
  color: #1a1a1a;
}

.page-surface h1,
.page-surface h2,
.page-surface h3,
.page-surface h4 {
  color: #111827;
}

.page-surface p,
.page-surface li {
  color: #374151;
}

.page-surface a {
  color: #166534;
}

.page-surface a:hover {
  color: #14532d;
}

/* Prevent floating text on mural - safety net */
main > *:not(.page-surface-wrapper):not(.hero):not([class*="bg-"]) {
  /* Any direct child of main without a background gets one */
}

/* ==========================================================================
   CARD SYSTEM
   Consistent card patterns for lists and content blocks
   ========================================================================== */

/* Base Card - solid background, clear boundaries */
.card {
  background: #ffffff;
  border-radius: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  color: #1a1a1a;
  overflow: hidden;
}

.card-title {
  color: #111827;
  font-weight: 600;
}

.card-body {
  padding: 1.5rem;
}

.card-body p {
  color: #4b5563;
}

/* List Card - clickable card for lists */
.list-card {
  display: block;
  background: #ffffff;
  border-radius: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  color: #1a1a1a;
  overflow: hidden;
  transition: all 0.2s ease;
  text-decoration: none;
}

.list-card:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
  border-color: rgba(22, 101, 52, 0.2);
}

.list-card:focus-visible {
  outline: 2px solid #166534;
  outline-offset: 2px;
}

/* List Card Body */
.list-card-body {
  padding: 1.25rem;
}

/* List Card Image */
.list-card-image {
  width: 100%;
  height: 12rem;
  object-fit: cover;
}

.list-card-image-placeholder {
  width: 100%;
  height: 8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
}

/* List Card Title */
.list-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.5rem;
  transition: color 0.15s ease;
}

.list-card:hover .list-card-title {
  color: #166534;
}

/* List Card Meta */
.list-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

/* List Card Description */
.list-card-desc {
  font-size: 0.875rem;
  color: #4b5563;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* List Card Arrow - visual affordance */
.list-card-arrow {
  color: #9ca3af;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.list-card:hover .list-card-arrow {
  color: #166534;
  transform: translateX(4px);
}

/* List Card Footer */
.list-card-footer {
  padding: 0.75rem 1.25rem;
  background: #f9fafb;
  border-top: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Info Card - for detail page sections */
.info-card {
  background: #ffffff;
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.info-card-header {
  padding: 1rem 1.25rem;
  background: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card-body {
  padding: 1.25rem;
}

/* Card Grid */
.card-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Compact Card - for smaller lists */
.compact-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #ffffff;
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  transition: all 0.15s ease;
}

.compact-card:hover {
  border-color: #166534;
  box-shadow: 0 2px 8px rgba(22, 101, 52, 0.1);
}

/* Badge on cards */
.card-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  background: #f3f4f6;
  color: #4b5563;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

/* Full-bleed: break out of surface for edge-to-edge content */
/* Note: Uses calc to account for scrollbar width, preventing horizontal overflow */
.full-bleed {
  width: 100%;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50%;
  margin-right: -50%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Text on mural - for rare cases where text must be on background */
.text-on-mural {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Ensure readable text in any context */
.readable-text {
  color: #1a1a1a;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
}

/* ==========================================================================
   DROPDOWN MENUS
   Ensure readable dropdowns on all backgrounds
   ========================================================================== */

/* Dropdown menu surface */
.dropdown-content {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 0.75rem !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1) !important;
  color: #111827 !important;
}

/* Menu items */
.dropdown-content li > a,
.dropdown-content li > button {
  color: #374151;
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  transition: background-color 0.15s ease;
}

.dropdown-content li > a:hover,
.dropdown-content li > button:hover {
  background-color: #f3f4f6;
  color: #111827;
}

/* Menu title/header */
.dropdown-content .menu-title span {
  color: #6b7280;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* Dividers */
.dropdown-content li.border-t {
  border-color: #e5e7eb;
}

/* Logout button special styling */
.dropdown-content button.text-red-600:hover {
  background-color: #fef2f2;
  color: #dc2626;
}

/* Select inside dropdown */
.dropdown-content select {
  background: transparent;
  color: #374151;
}

/* ==========================================================================
   BUTTON SYSTEM
   Consistent button styles across the platform
   ========================================================================== */

/* Base Button Reset */
.mv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.mv-btn:focus-visible {
  outline: 2px solid #166534;
  outline-offset: 2px;
}

/* Primary Button - Green filled */
.mv-btn-primary {
  background: #166534;
  color: #ffffff;
  border-color: #166534;
}

.mv-btn-primary:hover {
  background: #14532d;
  border-color: #14532d;
  color: #ffffff;
  text-decoration: none;
}

.mv-btn-primary:active {
  background: #0f3d22;
}

/* Secondary Button - Gray filled */
.mv-btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border-color: #e5e7eb;
}

.mv-btn-secondary:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
  color: #1f2937;
  text-decoration: none;
}

.mv-btn-secondary:active {
  background: #d1d5db;
}

/* Outline Button - Transparent with border */
.mv-btn-outline {
  background: transparent;
  color: #166534;
  border-color: #166534;
}

.mv-btn-outline:hover {
  background: #166534;
  color: #ffffff;
  text-decoration: none;
}

.mv-btn-outline:active {
  background: #14532d;
}

/* Ghost Button - No border, subtle hover */
.mv-btn-ghost {
  background: transparent;
  color: #374151;
  border-color: transparent;
}

.mv-btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #111827;
  text-decoration: none;
}

/* White Button - For dark backgrounds */
.mv-btn-white {
  background: #ffffff;
  color: #166534;
  border-color: #ffffff;
}

.mv-btn-white:hover {
  background: #f0fdf4;
  border-color: #f0fdf4;
  color: #14532d;
  text-decoration: none;
}

/* White Outline - For dark backgrounds */
.mv-btn-white-outline {
  background: transparent;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.mv-btn-white-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: #ffffff;
  text-decoration: none;
}

/* Button Sizes */
.mv-btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
}

.mv-btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
}

.mv-btn-xl {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* Disabled State */
.mv-btn:disabled,
.mv-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading State */
.mv-btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.mv-btn.loading::after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: mv-btn-spin 0.6s linear infinite;
}

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

/* Full Width */
.mv-btn-block {
  width: 100%;
}

/* Icon Only */
.mv-btn-icon {
  padding: 0.5rem;
  aspect-ratio: 1;
}

/* ==========================================================================
   FILTER/SEARCH CONTROLS
   Consistent styling for filter and search UI
   ========================================================================== */

/* Filter Bar - sits on same surface as results */
.filter-bar {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.filter-bar-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

/* Filter Input */
.filter-input {
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background: #ffffff;
  color: #1f2937;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-input:focus {
  outline: none;
  border-color: #166534;
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.1);
}

.filter-input::placeholder {
  color: #9ca3af;
}

/* Filter Select */
.filter-select {
  padding: 0.5rem 2rem 0.5rem 0.875rem;
  font-size: 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background: #ffffff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") right 0.5rem center/1.25rem no-repeat;
  color: #1f2937;
  cursor: pointer;
  appearance: none;
  transition: border-color 0.15s ease;
}

.filter-select:focus {
  outline: none;
  border-color: #166534;
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.1);
}

/* Search Input with Icon */
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 0.75rem;
  color: #9ca3af;
  pointer-events: none;
}

.search-input-wrapper input {
  padding-left: 2.5rem;
}

/* Filter Group */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* Filter Actions */
.filter-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

/* Active Filter Badge */
.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: #dcfce7;
  color: #166534;
  border-radius: 9999px;
}

.filter-badge-remove {
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.filter-badge-remove:hover {
  opacity: 1;
}

/* ==========================================================================
   HERO STYLES
   ========================================================================== */

/* HERO */
.hero-wrap { height: clamp(520px, 68vh, 800px); border-bottom-left-radius: 1.25rem; border-bottom-right-radius: 1.25rem; overflow: hidden; position: relative; }
.hero-video, .hero-fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.45), rgba(0,0,0,.35) 35%, rgba(0,0,0,.5)); }
.hero-content { position: relative; z-index: 1; }

/* VALUE CARDS */
.card-raise { transition: transform .25s ease, box-shadow .25s ease; }
.card-raise:hover { transform: translateY(-4px); box-shadow: 0 8px 28px rgba(16, 185, 129, .15); }

/* SCROLL-SNAP RAIL */
.snap-rail { scroll-snap-type: x mandatory; overflow-x: auto; gap: 1rem; padding-bottom: .75rem; }
.snap-item { scroll-snap-align: start; flex: 0 0 16rem; }
.cover-img { width: 100%; height: 9rem; object-fit: cover; border-top-left-radius: .75rem; border-top-right-radius: .75rem; }

/* QUOTES */
.quote { display: none; }
.quote.active { display: block; animation: fadeIn .5s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

/* TICKER BANNER */
.mv-ticker-track {
  overflow: hidden;
}

.mv-ticker {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  width: max-content;
  animation: mv-ticker-scroll 200s linear infinite;
}

.mv-ticker-item {
  display: inline-block;
  padding-right: 2.5rem;
  white-space: nowrap;
}

.mv-ticker:hover {
  animation-play-state: paused;
}

@keyframes mv-ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* PREFERS REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  .pulse-btn, .doodle-float, [data-reveal] { animation: none !important; transition: none !important; }
  .mv-ticker { animation: none; }
}

/* ==========================================================================
   MOBILE OPTIMIZATIONS
   iPhone Safari priority - fixes for spacing, overflow, and touch
   ========================================================================== */

/* Global overflow guard - seatbelt after fixing root causes */
/* Prefer clip over hidden: less "masky", doesn't create new stacking context */
body {
  overflow-x: clip;
  -webkit-overflow-scrolling: touch;
}

@supports not (overflow-x: clip) {
  body {
    overflow-x: hidden;
  }
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
  .safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .safe-area-top {
    padding-top: env(safe-area-inset-top);
  }
}

/* Mobile header spacing */
@media (max-width: 639px) {
  /* Navbar adjustments */
  .navbar {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    min-height: 3.5rem;
  }
  
  /* Page surface mobile padding */
  .page-surface-wrapper {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  
  .page-surface {
    padding: 1rem;
    border-radius: 1rem;
  }
  
  /* Card grid single column on small screens */
  .card-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* List card mobile adjustments */
  .list-card-body {
    padding: 1rem;
  }
  
  .list-card-footer {
    padding: 0.625rem 1rem;
  }
  
  .list-card-image {
    height: 10rem;
  }
  
  /* Filter bar mobile */
  .filter-bar {
    padding: 0.875rem;
  }
  
  .filter-actions {
    width: 100%;
    margin-top: 0.75rem;
    margin-left: 0;
  }
  
  .filter-actions .mv-btn {
    flex: 1;
  }
  
  /* Button touch targets - minimum 44px */
  .mv-btn {
    min-height: 2.75rem;
  }
  
  .mv-btn-sm {
    min-height: 2.5rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* Typography mobile scale */
  h1, .h1 {
    font-size: 1.75rem;
  }
  
  h2, .h2 {
    font-size: 1.375rem;
  }
  
  h3, .h3 {
    font-size: 1.125rem;
  }
  
  /* Hero mobile height */
  .hero-wrap {
    height: clamp(400px, 60vh, 600px);
  }
}

/* Prevent text size adjustment on orientation change (iOS) */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Smooth scrolling with momentum on iOS */
.scroll-container {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

/* Fix for iOS input zoom - ensure inputs are 16px+ */
@media (max-width: 639px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Tap highlight removal for cleaner touch */
a, button, input, select, textarea {
  -webkit-tap-highlight-color: transparent;
}

/* Fix sticky positioning on iOS Safari */
.sticky {
  position: -webkit-sticky;
  position: sticky;
}

/* Prevent pull-to-refresh on overscroll */
body {
  overscroll-behavior-y: none;
}

/* Mobile-specific utility classes */
.mobile-full-width {
  width: 100%;
}

@media (max-width: 639px) {
  .mobile-hidden {
    display: none !important;
  }
  
  .mobile-stack {
    flex-direction: column !important;
  }
  
  .mobile-gap-sm {
    gap: 0.5rem !important;
  }
  
  .mobile-text-sm {
    font-size: 0.875rem !important;
  }
  
  .mobile-p-0 {
    padding: 0 !important;
  }
  
  .mobile-px-3 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}

/* Ensure media elements don't overflow */
img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

/* Flex overflow prevention - apply to containers with long text content */
/* Use .flex-truncate on flex containers where children may have long text */
.flex-truncate > * {
  min-width: 0;
}

/* Ensure long text wraps properly */
.break-words {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Fix for 100vh on mobile (accounts for browser chrome) */
.min-h-screen-mobile {
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

/* Card overflow prevention */
.list-card,
.card,
.info-card {
  max-width: 100%;
  overflow: hidden;
}

/* Text truncation utilities */
.truncate-mobile {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Fix horizontal scroll on tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Bottom navigation safe area (if used) */
.bottom-nav {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Modal/drawer fixes for iOS */
.modal-open,
.drawer-open {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
