/*
 * TruPorch design tokens — v1.9.0
 * Copy into your app's global CSS (after @tailwind directives if you use Tailwind).
 * Spec: DESIGN.md §3 (tokens), §3.6 (materials), §6 (motion). Source of truth: Atlas src/app/globals.css.
 * Dark mode is class-based: put `class="dark"` on <html>.
 */

/* The perceptual palette as --tp-<hue>-<step> variables (DESIGN.md §4.0).
   Written by scripts/build-palette.mjs between these markers; don't edit by hand. */
/* palette:start */
:root {
  --tp-blue-50: #f3f8ff; --tp-blue-100: #e4efff; --tp-blue-200: #cadeff; --tp-blue-300: #a2c6ff; --tp-blue-400: #70a7ff; --tp-blue-500: #3281ff; --tp-blue-600: #1768e4; --tp-blue-700: #0855c4; --tp-blue-800: #0243a0; --tp-blue-900: #05367f; --tp-blue-950: #042459;
  --tp-sky-50: #eff9ff; --tp-sky-100: #dbf1ff; --tp-sky-200: #b7e3ff; --tp-sky-300: #7bcdff; --tp-sky-400: #2fb0f2; --tp-sky-500: #008eca; --tp-sky-600: #0075a7; --tp-sky-700: #00628d; --tp-sky-800: #004d71; --tp-sky-900: #003e5b; --tp-sky-950: #002a3f;
  --tp-cyan-50: #e9fbff; --tp-cyan-100: #d3f4fc; --tp-cyan-200: #ace7f5; --tp-cyan-300: #72d1e8; --tp-cyan-400: #1bb6d3; --tp-cyan-500: #0093ab; --tp-cyan-600: #00798d; --tp-cyan-700: #006576; --tp-cyan-800: #00505e; --tp-cyan-900: #00404d; --tp-cyan-950: #002c34;
  --tp-teal-50: #e9fbf7; --tp-teal-100: #d4f5ee; --tp-teal-200: #aee9de; --tp-teal-300: #76d4c6; --tp-teal-400: #26baa8; --tp-teal-500: #009686; --tp-teal-600: #007c6f; --tp-teal-700: #00685d; --tp-teal-800: #005249; --tp-teal-900: #00423a; --tp-teal-950: #002d27;
  --tp-emerald-50: #eafcf2; --tp-emerald-100: #d4f6e4; --tp-emerald-200: #adeacb; --tp-emerald-300: #76d7aa; --tp-emerald-400: #26bc85; --tp-emerald-500: #009969; --tp-emerald-600: #007e56; --tp-emerald-700: #006947; --tp-emerald-800: #005438; --tp-emerald-900: #00442c; --tp-emerald-950: #002e1d;
  --tp-green-50: #e9fcec; --tp-green-100: #d3f7d9; --tp-green-200: #acecb8; --tp-green-300: #74d98b; --tp-green-400: #22bf5b; --tp-green-500: #009a44; --tp-green-600: #008037; --tp-green-700: #006b2d; --tp-green-800: #005522; --tp-green-900: #00441a; --tp-green-950: #002f10;
  --tp-lime-50: #effbe5; --tp-lime-100: #dff5cd; --tp-lime-200: #c3e9a2; --tp-lime-300: #9cd463; --tp-lime-400: #75b800; --tp-lime-500: #5d9400; --tp-lime-600: #507a00; --tp-lime-700: #456500; --tp-lime-800: #395000; --tp-lime-900: #2f4000; --tp-lime-950: #202b00;
  --tp-yellow-50: #fbf8e5; --tp-yellow-100: #f6eecb; --tp-yellow-200: #efdca0; --tp-yellow-300: #e2c15f; --tp-yellow-400: #cda000; --tp-yellow-500: #a87f00; --tp-yellow-600: #8d6800; --tp-yellow-700: #795500; --tp-yellow-800: #634200; --tp-yellow-900: #513400; --tp-yellow-950: #392200;
  --tp-amber-50: #faf8e5; --tp-amber-100: #f4efcb; --tp-amber-200: #eade9f; --tp-amber-300: #d9c45e; --tp-amber-400: #c1a500; --tp-amber-500: #9c8400; --tp-amber-600: #816d00; --tp-amber-700: #6c5a00; --tp-amber-800: #564800; --tp-amber-900: #453a00; --tp-amber-950: #2f2700;
  --tp-orange-50: #fff6ec; --tp-orange-100: #ffead7; --tp-orange-200: #ffd5b4; --tp-orange-300: #ffb37e; --tp-orange-400: #ff8529; --tp-orange-500: #db6100; --tp-orange-600: #b74e00; --tp-orange-700: #9c3e00; --tp-orange-800: #7f2f00; --tp-orange-900: #682400; --tp-orange-950: #4a1600;
  --tp-red-50: #fff5f3; --tp-red-100: #ffe9e6; --tp-red-200: #ffd3ce; --tp-red-300: #ffb0a8; --tp-red-400: #ff8077; --tp-red-500: #f93b3f; --tp-red-600: #db0e25; --tp-red-700: #ba001b; --tp-red-800: #960014; --tp-red-900: #7b010e; --tp-red-950: #550308;
  --tp-rose-50: #fff5f5; --tp-rose-100: #ffe9e9; --tp-rose-200: #ffd2d3; --tp-rose-300: #ffafb2; --tp-rose-400: #ff7f89; --tp-rose-500: #fc315a; --tp-rose-600: #dc0045; --tp-rose-700: #b90038; --tp-rose-800: #95002c; --tp-rose-900: #7a0022; --tp-rose-950: #560015;
  --tp-pink-50: #fff5f8; --tp-pink-100: #ffe8f0; --tp-pink-200: #ffd1e2; --tp-pink-300: #ffaccc; --tp-pink-400: #ff79b4; --tp-pink-500: #ef3997; --tp-pink-600: #d20d7f; --tp-pink-700: #b2006a; --tp-pink-800: #900055; --tp-pink-900: #750144; --tp-pink-950: #51032e;
  --tp-purple-50: #f9f6ff; --tp-purple-100: #f3eaff; --tp-purple-200: #e7d6ff; --tp-purple-300: #d6b7ff; --tp-purple-400: #c28eff; --tp-purple-500: #ae5aff; --tp-purple-600: #9937eb; --tp-purple-700: #8227cb; --tp-purple-800: #691ba5; --tp-purple-900: #541884; --tp-purple-950: #39105c;
  --tp-violet-50: #f8f6ff; --tp-violet-100: #eeecff; --tp-violet-200: #dfd8ff; --tp-violet-300: #c8bbff; --tp-violet-400: #ae96ff; --tp-violet-500: #9469ff; --tp-violet-600: #8148f0; --tp-violet-700: #6d37d0; --tp-violet-800: #5729aa; --tp-violet-900: #452387; --tp-violet-950: #2e175e;
  --tp-indigo-50: #f5f7ff; --tp-indigo-100: #e9edff; --tp-indigo-200: #d5dbff; --tp-indigo-300: #b6c1ff; --tp-indigo-400: #939fff; --tp-indigo-500: #7076ff; --tp-indigo-600: #5b59f0; --tp-indigo-700: #4b47cf; --tp-indigo-800: #3b37a9; --tp-indigo-900: #2f2d86; --tp-indigo-950: #1f1e5d;
  --tp-gold-50: #faf8ed; --tp-gold-100: #f4eeda; --tp-gold-200: #e9dcbb; --tp-gold-300: #d7c290; --tp-gold-400: #bea361; --tp-gold-500: #a18136; --tp-gold-600: #8a691a; --tp-gold-700: #75570d; --tp-gold-800: #5e4405; --tp-gold-900: #4c3709; --tp-gold-950: #342405;
  --tp-gray-50: #f9fafb; --tp-gray-100: #f3f4f6; --tp-gray-200: #e5e7eb; --tp-gray-300: #d1d5db; --tp-gray-400: #9ca3af; --tp-gray-500: #6b7280; --tp-gray-600: #4b5563; --tp-gray-700: #374151; --tp-gray-800: #1f2937; --tp-gray-900: #111827; --tp-gray-950: #030712;
  --tp-zinc-50: #fafafa; --tp-zinc-100: #f4f4f5; --tp-zinc-200: #e4e4e7; --tp-zinc-300: #d4d4d8; --tp-zinc-400: #a1a1aa; --tp-zinc-500: #71717a; --tp-zinc-600: #52525b; --tp-zinc-700: #3f3f46; --tp-zinc-800: #27272a; --tp-zinc-900: #18181b; --tp-zinc-950: #09090b;
  --tp-slate-50: #f8fafc; --tp-slate-100: #f1f5f9; --tp-slate-200: #e2e8f0; --tp-slate-300: #cbd5e1; --tp-slate-400: #94a3b8; --tp-slate-500: #64748b; --tp-slate-600: #475569; --tp-slate-700: #334155; --tp-slate-800: #1e293b; --tp-slate-900: #0f172a; --tp-slate-950: #020617;
}
/* palette:end */

/* ─── Tokens ─── */

:root {
  --bg-page: #f8f9fc;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --border-primary: #e4e4e7;
  --border-secondary: #f4f4f5;
  --text-primary: #09090b;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;
  --shadow-card: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-card-hover: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --accent: #3b82f6;
  --radius-card: 16px;

  /* Brand (logo, print, email headers — not the in-app action color) */
  --brand-navy: #00255f;
  --brand-gray: #808080;

  /* Hospitality sub-brand (guest-facing pages only — DESIGN.md §10) */
  --hosp-gold: #d3b471;
  --hosp-gold-dark: #a9905a;
  --hosp-gold-tint: #ede1c6;
  --hosp-ink: #333333;
  --hosp-ink-muted: #666666;
  --hosp-brown: #594b36;
  --hosp-border: #dddddd;
}

.dark {
  --bg-page: #0f1117;
  --bg-card: #1a1c25;
  --bg-elevated: #22242e;
  --border-primary: rgba(255, 255, 255, 0.08);
  --border-secondary: rgba(255, 255, 255, 0.04);
  --text-primary: #e8eaed;
  --text-secondary: #9ca3b0;
  --text-tertiary: #5f6775;
  --shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.4);
  --shadow-card-hover: 0 4px 8px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.3);
}

/* ─── Base ─── */

* { border-color: var(--border-primary); }

::selection { background-color: rgba(59, 130, 246, 0.15); color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

html { transition: background-color 0.2s ease, color 0.2s ease; }

/* Follow the phone's Text Size setting on iPhone and iPad (Dynamic Type).
   Opt in with <html class="tp-system-text"> (Field Ops should). Every kit size is
   in rem, so the whole app scales with it. (DESIGN.md §12) */
@supports (font: -apple-system-body) {
  html.tp-system-text { font: -apple-system-body; }
}

body {
  /* --font-inter is set by next/font; otherwise load Inter from Google Fonts */
  font-family: var(--font-inter, 'Inter'), system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  text-rendering: optimizeLegibility;
}

/* Slim scrollbars */
* { scrollbar-width: thin; scrollbar-color: #d1d5db transparent; }
.dark * { scrollbar-color: #374151 transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 9999px; }
.dark ::-webkit-scrollbar-thumb { background: #374151; }

/* ─── Surfaces ─── */

.card-base,
.card-premium {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.card-base:hover { box-shadow: var(--shadow-card-hover); }
.card-premium:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(99, 102, 241, 0.2);
}

/* ─── Materials (DESIGN.md §3.6) ───
 * Glass is for the CONTROL layer only: top bar, sidebar over content,
 * bulk-action bar, ⌘K palette, toasts, floating map controls, phone tab bar.
 * Content (cards, tables, charts, forms) stays solid. Never glass on glass:
 * a menu opened from a glass bar uses .material-raised.
 * Text on glass: --text-primary / --text-secondary only, weight ≥ 500 under 14px.
 */
:root {
  --material-regular-bg: rgba(255, 255, 255, 0.78);
  --material-thick-bg: rgba(255, 255, 255, 0.9);
  --material-clear-bg: rgba(255, 255, 255, 0.18);
  --material-blur-regular: blur(16px) saturate(180%);
  --material-blur-thick: blur(24px) saturate(180%);
  --material-blur-clear: blur(6px) saturate(150%);
  --material-edge: rgba(0, 0, 0, 0.06);
  --material-highlight: inset 0 1px 0 0 rgba(255, 255, 255, 0.7);
  --material-shadow: 0 8px 24px -6px rgb(0 0 0 / 0.12), 0 2px 6px -2px rgb(0 0 0 / 0.06);
  --material-dim: rgba(0, 0, 0, 0.35);
}
.dark {
  --material-regular-bg: rgba(26, 28, 37, 0.72);
  --material-thick-bg: rgba(26, 28, 37, 0.88);
  --material-clear-bg: rgba(15, 17, 23, 0.2);
  --material-edge: rgba(255, 255, 255, 0.08);
  --material-highlight: inset 0 1px 0 0 rgba(255, 255, 255, 0.06);
  --material-shadow: 0 8px 24px -6px rgb(0 0 0 / 0.5), 0 2px 6px -2px rgb(0 0 0 / 0.3);
}

/* Regular: the default glass. Bars, palette, toasts, bulk-action bar. */
.material-regular,
.glass {
  background: var(--material-regular-bg);
  -webkit-backdrop-filter: var(--material-blur-regular);
  backdrop-filter: var(--material-blur-regular);
  border: 1px solid var(--material-edge);
  box-shadow: var(--material-highlight), var(--material-shadow);
}
/* Thick: glass that carries more text (sidebar over content, side sheets). */
.material-thick {
  background: var(--material-thick-bg);
  -webkit-backdrop-filter: var(--material-blur-thick);
  backdrop-filter: var(--material-blur-thick);
  border: 1px solid var(--material-edge);
  box-shadow: var(--material-highlight), var(--material-shadow);
}
/* Clear: ONLY over maps and photos, for icon buttons and one-line labels.
   Any text sits on .material-dim (35% black) and is white. */
.material-clear {
  background: var(--material-clear-bg);
  -webkit-backdrop-filter: var(--material-blur-clear);
  backdrop-filter: var(--material-blur-clear);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: var(--material-shadow);
}
.material-dim { background: var(--material-dim); color: #ffffff; }
/* Raised: the solid surface for anything that sits on glass (menus, popovers). */
.material-raised {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  box-shadow: var(--material-shadow);
}

/* Fallbacks — part of the material, not an afterthought. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .material-regular, .glass, .material-thick { background: var(--bg-elevated); }
  .material-clear { background: rgba(15, 17, 23, 0.7); }
}
@media (prefers-reduced-transparency: reduce) {
  .material-regular, .glass, .material-thick {
    background: var(--bg-elevated);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .material-clear { background: rgba(15, 17, 23, 0.85); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
/* Same as above, for an in-app "Reduce transparency" switch on <html>. */
.reduce-transparency .material-regular,
.reduce-transparency .glass,
.reduce-transparency .material-thick {
  background: var(--bg-elevated);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.reduce-transparency .material-clear { background: rgba(15, 17, 23, 0.85); -webkit-backdrop-filter: none; backdrop-filter: none; }
@media (prefers-contrast: more) {
  .material-regular, .glass, .material-thick, .material-clear, .material-raised {
    border-color: var(--text-secondary);
    box-shadow: none;
  }
}

/* ─── Increase contrast (DESIGN.md §12, §18) ───
   The OS setting (Increase Contrast on Apple, high contrast elsewhere) or a
   .increase-contrast class on <html>: muted text gets darker, hairlines
   become real borders. Only the chrome's quiet grays change; meaning colors
   already pass AA. */
@media (prefers-contrast: more) {
  :root { --text-secondary: #374151; --text-tertiary: #4b5563; --border-primary: #9ca3af; }
  .dark { --text-secondary: #d1d5db; --text-tertiary: #9ca3af; --border-primary: rgba(255, 255, 255, 0.35); }
  .text-gray-400, .text-gray-500 { color: #374151; }
  .dark .text-gray-400, .dark .text-gray-500, .dark .dark\:text-gray-400, .dark .dark\:text-gray-500 { color: #d1d5db; }
  .border-gray-100, .border-gray-200 { border-color: #9ca3af; }
  .dark .border-white\/5, .dark .border-white\/10, .dark .dark\:border-white\/5, .dark .dark\:border-white\/10 { border-color: rgba(255, 255, 255, 0.35); }
  ::placeholder { color: #4b5563; }
}
.increase-contrast { --text-secondary: #374151; --text-tertiary: #4b5563; --border-primary: #9ca3af; }
.increase-contrast .text-gray-400, .increase-contrast .text-gray-500 { color: #374151; }
.increase-contrast .border-gray-100, .increase-contrast .border-gray-200 { border-color: #9ca3af; }
.dark.increase-contrast { --text-secondary: #d1d5db; --text-tertiary: #9ca3af; --border-primary: rgba(255, 255, 255, 0.35); }
.dark.increase-contrast .text-gray-400, .dark.increase-contrast .text-gray-500 { color: #d1d5db; }

/* ─── Continuous corners (DESIGN.md §18) ───
   Apple's squircle: the curve starts earlier and eases into the straight edge,
   so a rounded card looks soft rather than "cut". Progressive: browsers that
   support corner-shape get it on every rounded kit surface; others keep
   ordinary rounded corners. */
@supports (corner-shape: squircle) {
  .card-premium, .rounded-xl, .rounded-2xl, .rounded-3xl, .material-regular, .material-thick { corner-shape: squircle; }
}

/* ─── Motion (DESIGN.md §6) ─── */

:root {
  /* The house curve, for fades and small moves. */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  /* An Apple-style spring (SwiftUI response 0.4, damping 0.82): settles in
     about half a second with a 1% overshoot, so a sheet arrives and settles
     instead of stopping dead. Falls back to the house curve. */
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-spring: 460ms;
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --ease-spring: linear(0, 0.0528, 0.1733, 0.3197, 0.4665, 0.5993, 0.7117, 0.8018, 0.8709, 0.9217, 0.9574, 0.9814, 0.9965, 1.0052, 1.0095, 1.011, 1.0108, 1.0096, 1.0081, 1.0064, 1.0049, 1.0036, 1.0025, 1.0016, 1.001);
  }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slide-in-right { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes highlight-flash { 0% { background-color: rgb(254 243 199); } 100% { background-color: transparent; } }
@keyframes status-pulse {
  0% { box-shadow: 0 0 0 0 var(--pulse-color, rgba(59, 130, 246, 0.5)); transform: scale(1); }
  50% { box-shadow: 0 0 12px 4px var(--pulse-color, rgba(59, 130, 246, 0.3)); transform: scale(1.05); }
  100% { box-shadow: 0 0 0 0 var(--pulse-color, rgba(59, 130, 246, 0)); transform: scale(1); }
}
@keyframes status-glow {
  0%, 100% { box-shadow: 0 0 4px 1px var(--glow-color, rgba(59, 130, 246, 0.2)); }
  50% { box-shadow: 0 0 8px 3px var(--glow-color, rgba(59, 130, 246, 0.4)); }
}
@keyframes bounce-in {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes check-draw { 0% { stroke-dashoffset: 20; } 100% { stroke-dashoffset: 0; } }

.animate-page-in { animation: fade-in 0.2s cubic-bezier(0.22, 1, 0.36, 1); }
.animate-fade-in { animation: fade-in 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.animate-scale-in { animation: scale-in 0.2s cubic-bezier(0.22, 1, 0.36, 1); }
.animate-slide-in-panel { animation: slide-in-right 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
.animate-slide-up { animation: slide-up 0.25s ease-out; }
/* Spring entrances: sheets rise from where they live, panels slide from their edge, the palette pops in place. */
.animate-sheet-in { animation: slide-up var(--duration-spring) var(--ease-spring); }
.animate-panel-in { animation: slide-in-right var(--duration-spring) var(--ease-spring); }
.animate-pop-in { animation: scale-in 320ms var(--ease-spring); }
.animate-highlight { animation: highlight-flash 2s ease-out; }
.animate-status-pulse { animation: status-pulse 0.6s ease-out; }
.animate-status-glow { animation: status-glow 2s ease-in-out infinite; }
.animate-bounce-in { animation: bounce-in 0.4s ease-out; }
.animate-check-draw { stroke-dasharray: 20; animation: check-draw 0.3s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.animate-shimmer {
  background-image: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.4) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
.dark .animate-shimmer {
  background-image: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.06) 50%, transparent 100%);
}

.stagger-children > * { opacity: 0; animation: fade-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 75ms; }
.stagger-children > *:nth-child(4) { animation-delay: 100ms; }
.stagger-children > *:nth-child(5) { animation-delay: 125ms; }
.stagger-children > *:nth-child(6) { animation-delay: 150ms; }
.stagger-children > *:nth-child(7) { animation-delay: 175ms; }
.stagger-children > *:nth-child(8) { animation-delay: 200ms; }
.stagger-children > *:nth-child(n+9) { animation-delay: 225ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .stagger-children > * { opacity: 1; }
}
