
@tailwind base;
@tailwind components;
@tailwind utilities;

/* Global input and textarea styling */
input, textarea {
  color: var(--gray-900) !important; /* Filled text color */
  background-color: var(--gray-50) !important; /* Fill color */
  border: 1px solid var(--gray-200) !important; /* Border color */
  border-radius: 2px !important; /* Border radius */
}

input::placeholder, textarea::placeholder {
  color: var(--gray-500) !important; /* Placeholder text color */
}

/* Active/focused input state */
input:focus, textarea:focus {
  border: 1px solid var(--gray-900) !important; /* Focus border */
  outline: none !important; /* Remove default outline */
}

/* Global select element styling - ensures caret padding matches text padding */
select {
  padding-right: 2.5rem !important; /* Extra space for the caret */
  background-color: var(--gray-50) !important; /* Fill color */
  background-image: url("data:image/svg+xml;charset=UTF-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'></polyline></svg>") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important; /* 12px from right edge, matching left padding */
  background-size: 1rem 1rem !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  color: var(--gray-900) !important; /* Filled text color for selects */
  border: 1px solid var(--gray-200) !important; /* Border color */
  border-radius: 2px !important; /* Border radius */
}

/* Active/focused select state */
select:focus {
  border: 1px solid var(--gray-900) !important; /* Focus border */
  outline: none !important; /* Remove default outline */
}

/* 1) Respect user settings */
html {
  font-size: 100%; /* 1rem = user's default (usually 16px) */
  scroll-behavior: smooth;
  /* Reserve scrollbar space permanently so mx-auto centering never shifts
     when a page gains or loses a scrollbar (scrollbar-induced layout shift fix) */
  scrollbar-gutter: stable;
}

/* 2) Set a sensible text baseline */
body {
  font-size: 1rem;          /* 16px base text */
  line-height: 1.5;         /* good readability */
  color: var(--gray-700);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
}

/* 3) Fluid, but anchored to your exact targets
   Targets at a typical laptop (~1024–1280px):
   H1: 28px(1.75rem) H2: 22px(1.375rem) H3: 18px(1.125rem)
   H4: 16px(1rem)    H5: 14px(0.875rem) H6: 12px(0.75rem)

   clamp(min, preferred, max)
   - min is ~90–95% of your target for small screens
   - max is ~110–120% of your target for large screens
   - the middle uses a small vw slope so sizes breathe naturally
*/

h1 { font-size: clamp(1.6rem, 1.2rem + 1.2vw, 1.9rem); /* ~25.6px → 30.4px, target ~28px */ }
h2 { font-size: clamp(1.25rem, 1.05rem + 0.7vw, 1.5rem); /* ~20px → 24px, target ~22px */ }
h3 { font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.2rem); /* ~16.8px → 19.2px, target ~18px */ }
h4 { font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.05rem); /* ~15.2px → 16.8px, target ~16px */ }
h5 { font-size: clamp(0.82rem, 0.8rem + 0.2vw, 0.9rem);  /* ~13.1px → 14.4px, target ~14px */ }
h6 { font-size: clamp(0.72rem, 0.7rem + 0.2vw, 0.8rem);  /* ~11.5px → 12.8px, target ~12px */ }

/* Optional: consistent heading rhythm */
h1,h2,h3,h4,h5,h6 {
  line-height: 1.2;
  margin: 0 0 0.5em;
  font-weight: 700;
}

/* Optional cap on ultra-wide displays */
@media (min-width: 1600px) {
  h1 { font-size: 1.9rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.2rem; }
  h4 { font-size: 1.05rem; }
  h5 { font-size: 0.9rem; }
  h6 { font-size: 0.8rem; }
}

/* Ensure containers don't cause horizontal overflow */
.container {
  max-width: 100vw;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

/* Improve touch targets on mobile */
@media (max-width: 768px) {
  button:not([role="checkbox"]):not([role="switch"]), a[href] {
    min-width: 44px;
  }
  
  /* Better mobile scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Prevent text zoom on orientation change */
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  
  /* Prevent layout shifts */
  img, video {
    max-width: 100%;
    height: auto;
  }
  
  /* Better tap highlighting */
  * {
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Ensure proper viewport behavior */
  body {
    position: relative;
    width: 100%;
    min-height: 100vh;
  }
  
  /* Fix potential width overflow issues */
  * {
    max-width: 100%;
    box-sizing: border-box;
  }
  
  html, body {
    max-width: 100vw;
  }
  
  /* Grid and flexbox mobile fixes - only target containers, not flex items */
  /* Removed [class*="flex-"] which was matching flex-shrink-0, flex-1, flex-col etc.
     and incorrectly giving them width: 100% which broke horizontal flex layouts */
  .grid {
    width: 100%;
    overflow-x: hidden;
  }
  
  /* Text and content overflow prevention */
  p, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none; /* FIXED: Changed from 'auto' to 'none' to prevent mid-word breaks */
  }

  /* Headings should never auto-hyphenate */
  h1, h2, h3, h4, h5, h6 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none;
  }
}

:root {
  /* ── Neutral scale (theme.txt — identical to Tailwind's default gray) ── */
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* ── Brand action button (gradient) — promoted from button-styles.json ── */
  --brand-gradient: linear-gradient(135deg, #0d1117 0%, #1a1f35 60%, #0f1829 100%);
  --brand-gradient-hover: linear-gradient(135deg, #11161f 0%, #222842 60%, #14203a 100%);
  --brand-gradient-light: linear-gradient(135deg, #fbcfe8 0%, #e9d5ff 35%, #c7d2fe 65%, #bae6fd 100%);
  --brand-text-gradient: linear-gradient(90deg, #F9A8D4 0%, #A78BFA 35%, #818CF8 60%, #93C5FD 85%, #C4B5FD 100%);
  --brand-border: rgba(255, 255, 255, 0.12);
  --brand-glow: 0 0 0 1px rgba(139, 92, 246, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.06);

  /* ── Semantic tokens (mapped onto the neutral scale) ── */
  --background: #FFFFFF;
  --foreground: var(--gray-900);
  --card: #FFFFFF;
  --card-foreground: var(--gray-900);
  --popover: #FFFFFF;
  --popover-foreground: var(--gray-900);
  --primary: var(--gray-900);
  --primary-foreground: #FFFFFF;          /* FIX: was dark-on-dark */
  --secondary: var(--gray-100);
  --secondary-foreground: var(--gray-900);
  --muted: var(--gray-100);
  --muted-foreground: var(--gray-500);
  --accent: var(--gray-100);
  --accent-foreground: var(--gray-900);
  --destructive: #EF4444;
  --destructive-foreground: #FFFFFF;
  --border: var(--gray-200);
  --input: var(--gray-300);
  --ring: #8B5CF6;                          /* visible focus (brand purple) */
  --action-blue: #0C56CC;                   /* links / secondary actions */
  --accent-purple: #6C63FF;                 /* secondary accent (illustrations, highlights) */
  --chart-1: var(--gray-900);
  --chart-2: var(--gray-600);
  --chart-3: var(--gray-400);
  --chart-4: #8B5CF6;
  --chart-5: #6366F1;
  --sidebar: #FFFFFF;
  --sidebar-foreground: var(--gray-900);
  --sidebar-primary: var(--gray-900);
  --sidebar-primary-foreground: #FFFFFF;
  --sidebar-accent: var(--gray-100);
  --sidebar-accent-foreground: var(--gray-900);
  --sidebar-border: var(--gray-200);
  --sidebar-ring: #8B5CF6;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: Georgia, serif;
  --font-mono: "Inter", ui-monospace, monospace;
  --radius: 0.5rem;                         /* FIX: was 0rem (rounded-lg rendered square) */

  /* ── Real shadow scale (FIX: every stop was 0-alpha / invisible) ── */
  --shadow-2xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.10), 0 1px 2px -1px rgba(0, 0, 0, 0.10);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.10), 0 1px 2px -1px rgba(0, 0, 0, 0.10);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.10), 0 2px 4px -2px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.10), 0 4px 6px -4px rgba(0, 0, 0, 0.10);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.10), 0 8px 10px -6px rgba(0, 0, 0, 0.10);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --tracking-normal: 0em;
  --spacing: 0.25rem;

  /* ── Legacy tb-* aliases → neutral scale (kept so existing usages don't break) ── */
  --tb-cream: var(--gray-50);
  --tb-dark: var(--gray-900);
  --tb-gray-text: var(--gray-700);
  --tb-warm-beige: var(--gray-400);
  --tb-sage: var(--gray-900);
  --tb-charcoal: var(--gray-600);
}

/* Custom input styling with 4px border-radius and solid border */
input, textarea {
  border-radius: 4px !important;
  border: 1px solid var(--gray-200) !important;
  background-color: var(--gray-50) !important;
}

/* Input active/focus state styling */
input:focus, input:active, textarea:focus, textarea:active {
  border: 1px solid var(--gray-900) !important;
  outline: none !important;
}

/* Dropdown/select styling to match inputs */
select {
  border-radius: 4px !important;
  border: 1px solid var(--gray-200) !important;
  background-color: var(--gray-50) !important;
}

select:focus, select:active {
  border: 1px solid var(--gray-900) !important;
  outline: none !important;
}

/* Filter pill select — overrides global select !important rules for pill-shaped selects */
select.filter-pill {
  border-radius: 9999px !important;
  background-color: white !important;
  background-image: none !important;
  padding-left: 0.75rem !important;
  padding-right: 1.75rem !important;
  padding-top: 0.375rem !important;
  padding-bottom: 0.375rem !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  border: none !important;
  color: var(--gray-700) !important;
  cursor: pointer !important;
}

select.filter-pill:focus {
  border: none !important;
  outline: none !important;
}

select.filter-pill.active {
  border: none !important;
  color: var(--gray-900) !important;
  font-weight: 600 !important;
}

/* Override for instant search bar inputs - borderless inside unified container */
input.search-bar-input {
  border: none !important;
  background-color: transparent !important;
  border-radius: 0 !important;
  font-size: 16px !important;
  font-weight: 600 !important;
}

input.search-bar-input::placeholder {
  font-size: 16px !important;
  font-weight: 600 !important;
  color: var(--gray-600);
}

input.search-bar-input:focus,
input.search-bar-input:active {
  border: none !important;
  outline: none !important;
}

/* Override for main search input to be fully rounded and borderless */
input.main-search-input {
  border-radius: 9999px !important;
  border: none !important;
  caret-color: var(--gray-900) !important;
  -webkit-text-fill-color: var(--gray-900) !important;
}

/* Override for location filter input - no border, fills container */
input.location-filter-input {
  border: none !important;
  background-color: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

input.location-filter-input:focus,
input.location-filter-input:active {
  border: none !important;
  background-color: transparent !important;
  outline: none !important;
  box-shadow: none !important;
}

/* Google Maps PlaceAutocompleteElement — host element and wrapper styling
   Shadow DOM is closed so we style the host + wrapper from outside */
.places-input-wrapper {
  border: 1px solid var(--gray-200) !important;
  border-radius: 4px !important;
  background-color: var(--gray-50) !important;
  transition: border-color 0.15s ease;
  /* overflow must stay visible so the suggestions dropdown can extend below */
  overflow: visible;
}

/* Focus border via :focus-within (fires when internal shadow DOM input is focused) */
.places-input-wrapper:focus-within,
.places-input-focused {
  border-color: var(--gray-900) !important;
  outline: none !important;
}

/* Neutralise the host element's own border/background so the wrapper controls it.
   CSS custom properties (--gmpx-*) DO pass through closed shadow DOM — use them
   to force the internal input text and placeholder to be dark/readable. */
gmp-place-autocomplete {
  display: block !important;
  width: 100% !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;

  /* Force light color scheme so the shadow DOM renders with light backgrounds and dark text */
  color-scheme: light;
  color: var(--gray-900) !important;

  /* GMPX theme tokens — inherited by shadow DOM internals */
  --gmpx-color-surface: white;
  --gmpx-color-on-surface: var(--gray-900);
  --gmpx-color-on-surface-variant: #6b7280;
  --gmpx-color-primary: var(--gray-900);
  --gmpx-color-outline: #e5e7eb;
  --gmpx-font-family-base: inherit;
  --gmpx-font-size-base: 0.875rem;
}

/* Override react-day-picker selected date styling */
.rdp-day_selected,
.rdp-day_selected:focus,
.rdp-day_selected:hover,
.rdp-day_selected:active {
  background-color: var(--gray-900) !important;
  color: white !important;
}

/* Active tab: transparent bg, black text, 2px bottom border indicator */
[role="tablist"] button[aria-selected="true"] {
  background-color: transparent !important;
  color: var(--gray-900) !important;
  box-shadow: none !important;
  border-bottom: 2px solid var(--gray-900) !important;
  border-radius: 0 !important;
}

/* Dark mode dropped (May 2026): the .dark token block was broken (sage-green
   primary, mismatched radius) and had no working toggle. Any leftover `dark:`
   utility classes are inert without a `.dark` ancestor. Re-introduce a single
   coherent dark token set here if/when dark mode is actually built. */

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply font-sans antialiased bg-tb-cream text-tb-gray-text;
  }

  h1, h2, h3, h4, h5 {
    /* Default heading color. Honors an ancestor's --heading-override-color (e.g. dark
       sections set it to white), and is overridable by text-* utilities / inline color
       because this lives in @layer base. */
    color: var(--heading-override-color, var(--gray-900));
  }

  label {
    color: var(--gray-600);
  }
}

@layer utilities {
  .text-tb-dark {
    color: var(--tb-dark);
  }
  
  .text-tb-gray-text {
    color: var(--tb-gray-text);
  }
  
  .bg-tb-cream {
    background-color: var(--tb-cream);
  }
  
  .bg-tb-sage {
    background-color: var(--tb-sage);
  }
  
  .bg-tb-warm-beige {
    background-color: var(--tb-warm-beige);
  }
  
  .bg-tb-charcoal {
    background-color: var(--tb-charcoal);
  }
  
  .border-tb-warm-beige {
    border-color: var(--tb-warm-beige);
  }
  
  .hover\:bg-tb-sage\/90:hover {
    background-color: hsl(87, 21%, 35%, 0.9);
  }
  
  .animate-scroll-smooth {
    animation: scroll-smooth 60s linear infinite;
  }
}

@keyframes scroll-smooth {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(-100% / 3));
  }
}

/* Hide profession list scrollbar specifically */
.max-h-64.overflow-y-auto::-webkit-scrollbar {
  display: none;  /* Safari and Chrome */
}

/* Override mobile image rules for instructor headshot container */
@media (max-width: 768px) {
  .instructor-headshot-container {
    width: 2rem !important;
    height: 2rem !important;
    max-width: 2rem !important;
    max-height: 2rem !important;
    min-width: 2rem !important;
    min-height: 2rem !important;
    flex-shrink: 0 !important;
  }
}

.prism-btn:hover {
  filter: brightness(1.15);
}

.map-popup-rounded .mapboxgl-popup-content {
  border-radius: 12px !important;
  overflow: hidden;
  padding: 0 !important;
}

.listing-page-title {
  font-size: 30px !important;
}

.instructor-card-name {
  font-size: 16px !important;
}

.city-suggestion-name {
  font-size: 16px !important;
}

/* Remove uppercase and letter-spacing from all heading levels except h5 */
/* Font sizes add 10px to the base while preserving the h1 > h2 > h3 > h4 hierarchy */
h1 {
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: clamp(1.5rem, 2.5vw + 1rem, 40px) !important;}
h2 {
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: 30px !important;}
.listing-editor-content h2 {
  font-size: 18px !important;
  font-weight: 700 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  color: var(--gray-900) !important;
}
h3 {
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: 20px !important;}
h4 {
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: 18px !important;}
h5 {}

/* Hide scrollbar for horizontal tabs */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Global scrollbar-hide utility */
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Portal profile tab content transition */
@keyframes page-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes heroImageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes page-fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.page-enter {
  animation: page-fade-in 0.22s ease-out forwards;
}

.page-exit {
  animation: page-fade-out 0.2s ease-in forwards;
  pointer-events: none;
}

@keyframes tab-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

[role="tabpanel"][data-state="active"] {
  animation: tab-fade-in 0.22s ease-out forwards;
}

/* Google Places Autocomplete dropdown — must sit above modal overlays */
.pac-container {
  z-index: 9999 !important;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  font-family: inherit;
  margin-top: 2px;
}
.pac-item {
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
.pac-item:hover {
  background-color: #f9fafb;
}

@keyframes orbit-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes counter-orbit-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

/* Brand rainbow text fill (used by the brand gradient button's label) */
.prism-text-gradient {
  background: var(--brand-text-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ─────────────────────────────────────────────────────────────────────────
   Typography scale (theme.txt, applied to Inter)
   Mobile-first: base = Mobile values, ≥768px = Desktop values.
   Use these utilities instead of ad-hoc text-size/weight/leading combos.
   ───────────────────────────────────────────────────────────────────────── */
@layer components {
  .text-display-xl { font-family: var(--font-sans); font-weight: 600; font-size: 32px; line-height: 35px; }
  .text-display-lg { font-family: var(--font-sans); font-weight: 600; font-size: 24px; line-height: 29px; }
  .text-display-md { font-family: var(--font-sans); font-weight: 600; font-size: 20px; line-height: 24px; }
  .text-display-sm { font-family: var(--font-sans); font-weight: 600; font-size: 16px; line-height: 20px; }
  .text-display-xs { font-family: var(--font-sans); font-weight: 600; font-size: 15px; line-height: 18px; }
  .text-heading    { font-family: var(--font-sans); font-weight: 600; font-size: 17px; line-height: 24px; }
  .text-subheading { font-family: var(--font-sans); font-weight: 600; font-size: 13px; line-height: 17px; letter-spacing: 0.5px; text-transform: uppercase; }
  .text-body       { font-family: var(--font-sans); font-weight: 400; font-size: 15px; line-height: 20px; }
  .text-body-strong { font-family: var(--font-sans); font-weight: 600; font-size: 15px; line-height: 20px; }
  .text-number      { font-family: var(--font-sans); font-weight: 400; font-size: 15px; line-height: 20px; font-variant-numeric: lining-nums tabular-nums; }
  .text-number-strong { font-family: var(--font-sans); font-weight: 600; font-size: 15px; line-height: 20px; font-variant-numeric: lining-nums tabular-nums; }
  .text-small       { font-family: var(--font-sans); font-weight: 400; font-size: 13px; line-height: 17px; }
  .text-small-strong { font-family: var(--font-sans); font-weight: 600; font-size: 13px; line-height: 17px; }

  @media (min-width: 768px) {
    .text-display-xl { font-size: 48px; line-height: 52px; }
    .text-display-lg { font-size: 36px; line-height: 44px; }
    .text-display-md { font-size: 30px; line-height: 36px; }
    .text-display-sm { font-size: 24px; line-height: 30px; }
    .text-display-xs { font-size: 20px; line-height: 26px; }
    .text-heading    { font-size: 16px; line-height: 22px; }
    .text-subheading { font-size: 12px; line-height: 16px; letter-spacing: 0.48px; }
    .text-body       { font-size: 14px; line-height: 20px; }
    .text-body-strong { font-size: 14px; line-height: 20px; }
    .text-number      { font-size: 14px; line-height: 20px; }
    .text-number-strong { font-size: 14px; line-height: 20px; }
    .text-small       { font-size: 12px; line-height: 16px; }
    .text-small-strong { font-size: 12px; line-height: 16px; }
  }
}
