@import "tailwindcss" source(none);

@source "../../views";
@source "../../components";
@source "../../helpers";
@source "../../../app/javascript";

/* Sidebar nav link utilities are applied conditionally from the portal layout, so
   guarantee they're always emitted regardless of content-scanning quirks (helper
   files not scanned; classes hidden inside ERB `<% %>` blocks). This safelist is
   why the nav links can never silently fall back to black again. */
@source inline("text-white/85 hover:bg-white/10 hover:text-white bg-teal/15 text-white shadow-[inset_3px_0_0_#04C2CF] ml-auto tabular-nums text-xs text-white/55");

@theme {
  /* ─── Typography ───
     DS canonical families: DM Serif Display (headlines) + Jost (body/UI).
     --font-serif kept as alias; --font-nav and --font-mono are portal extras. */
  --font-display: "DM Serif Display", "Playfair Display", Georgia, "Times New Roman", serif;
  --font-sans: "Jost", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "DM Serif Display", "Playfair Display", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-nav: "Open Sans", sans-serif;

  /* Dashboard type scale — compound definitions */
  --text-display: 2.25rem;
  --text-display--line-height: 1.15;
  --text-display--letter-spacing: -0.025em;
  --text-display--font-weight: 600;

  --text-heading: 1.25rem;
  --text-heading--line-height: 1.3;
  --text-heading--letter-spacing: -0.01em;
  --text-heading--font-weight: 600;

  --text-subheading: 1rem;
  --text-subheading--line-height: 1.4;
  --text-subheading--font-weight: 600;

  --text-body: 0.9375rem;
  --text-body--line-height: 1.6;

  --text-label: 0.8125rem;
  --text-label--line-height: 1.5;
  --text-label--font-weight: 500;

  --text-caption: 0.75rem;
  --text-caption--line-height: 1.5;
  --text-caption--letter-spacing: 0.01em;

  --text-overline: 0.6875rem;
  --text-overline--line-height: 1.45;
  --text-overline--letter-spacing: 0.08em;
  --text-overline--font-weight: 600;

  --text-metric: 2rem;
  --text-metric--line-height: 1;
  --text-metric--letter-spacing: -0.02em;
  --text-metric--font-weight: 700;

  /* ─── Brand ─── */
  --color-brand: #002B56;
  --color-brand-hover: #04C2CF;
  --color-brand-pressed: #002040;
  --color-brand-subtle: #E6F9FA;
  --color-brand-wash: #F0FBFC;

  /* ─── Accent ─── */
  --color-teal: #04C2CF;
  --color-teal-hover: #03A8B4;
  --color-yellow: #FFD577;
  --color-yellow-hover: #FFC94D;

  /* ─── Tint/shade variants (DS hover, press, focus states) ─── */
  --color-navy-90: #1A3F66;
  --color-navy-80: #335476;
  --color-navy-10: #E6EAEF;
  --color-teal-90: #18C8D4;
  --color-teal-80: #3CCED9;
  --color-teal-10: #E0F8FA;
  --color-gold-90: #FFCC60;
  --color-gold-10: #FFF7E4;

  /* ─── Surfaces ─── */
  --color-page: #FFFFFF;
  --color-surface: #F8F9FB;
  --color-surface-sunken: #F1F3F6;
  --color-surface-hover: #ECEFF3;
  --color-paper: #FFFFFF;
  --color-paper-2: #F7F8FA;
  --color-paper-3: #ECECEC;

  /* ─── Text ───
     Existing generic grays kept for backward compat; navy-tinted ink
     tokens from the DS added alongside for new work. */
  --color-ink: #111827;
  --color-ink-secondary: #374151;
  --color-ink-tertiary: #6B7280;
  --color-ink-900: #002B56;
  --color-ink-700: #1F4571;
  --color-ink-500: #5A7290;
  --color-ink-300: #A8B6C7;
  --color-ink-200: #CED7E2;

  /* ─── Borders ─── */
  --color-border: #E5E7EB;
  --color-border-strong: #D1D5DB;
  --color-line: #E2E6EC;
  --color-line-strong: #C9D0DA;

  /* ─── Status — generic semantic (existing, kept) ─── */
  --color-success: #16A34A;
  --color-success-bg: #F0FDF4;
  --color-warning: #CA8A04;
  --color-warning-bg: #FFFBEB;
  --color-danger: #DC2626;
  --color-danger-bg: #FEF2F2;

  /* ─── Condition status — DS-specific (inspections/reports) ─── */
  --color-c-good: #1F8A5B;
  --color-c-good-bg: #E6F4ED;
  --color-c-fair: #C98A0C;
  --color-c-fair-bg: #FFF3D6;
  --color-c-poor: #B23A2A;
  --color-c-poor-bg: #FBE6E2;
  --color-c-info: #04C2CF;
  --color-c-info-bg: #E0F8FA;

  /* ─── Focus — DS mandates teal ring ─── */
  --color-focus: #04C2CF;

  /* ─── Radii — DS: flat/geometric, not rounded-2xl ─── */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* ─── Shadows — navy-tinted, low-elevation ─── */
  --shadow-sm: 0 1px 2px rgba(0, 43, 86, 0.06);
  --shadow-md: 0 2px 8px rgba(0, 43, 86, 0.08), 0 1px 2px rgba(0, 43, 86, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 43, 86, 0.10), 0 2px 6px rgba(0, 43, 86, 0.06);
  --shadow-focus: 0 0 0 3px rgba(4, 194, 207, 0.35);
  --shadow-inset-line: inset 0 -1px 0 var(--color-line);

  /* ─── Layout ─── */
  --sidebar-w: 248px;
  --topbar-h: 64px;

  /* ─── Animations ─── */
  --animate-fade-in: fade-in 200ms ease-out both;
  --animate-slide-up: slide-up 200ms ease-out both;
  --animate-scale-in: scale-in 200ms ease-out both;

  /* ─── Easing ─── */
  --ease-standard: cubic-bezier(0.2, 0.6, 0.2, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  /* ─── Durations ─── */
  --duration-fast: 120ms;
  --duration-med: 200ms;
  --duration-slow: 320ms;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide-up {
  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); }
}

/* Animation delay utility for staggered reveals */
@utility animation-delay-* {
  animation-delay: --value([time]);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Lightbox dialog ─── */
dialog.lightbox {
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  padding: 0;
  border: none;
  background: transparent;
  overflow: visible;
}

dialog.lightbox::backdrop {
  background: rgba(0, 11, 27, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

dialog.lightbox[open] .lightbox-card {
  animation: lightbox-in 280ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

dialog.lightbox[open]::backdrop {
  animation: lightbox-backdrop-in 280ms ease-out both;
}

@keyframes lightbox-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes lightbox-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Scroll-target flash - briefly rings the section a deep-link/anchor jumps to.
   Default is a static ring (reduced-motion + fallback); the JS flash-target
   controller removes it after ~2s so it can replay. With motion allowed it fades. */
.flash-target {
  border-radius: 0.5rem; /* match the rounded-lg section cards so the ring is rounded */
  box-shadow: 0 0 0 3px var(--color-brand-hover);
}

@media (prefers-reduced-motion: no-preference) {
  .flash-target {
    box-shadow: none;
    animation: flash-target 2s ease-out;
  }
}

@keyframes flash-target {
  from { box-shadow: 0 0 0 3px var(--color-brand-hover); }
  to   { box-shadow: 0 0 0 3px transparent; }
}
