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

/* Premium UI fonts — Elvaro Grotesque (primary) */
@font-face {
  font-family: 'Elvaro Grotesque';
  src: url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-Light.woff2') format('woff2'),
       url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-Light.woff') format('woff');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Elvaro Grotesque';
  src: url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-Regular.woff2') format('woff2'),
       url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Elvaro Grotesque';
  src: url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-Medium.woff2') format('woff2'),
       url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-Medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Elvaro Grotesque';
  src: url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-SemiBold.woff2') format('woff2'),
       url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-SemiBold.woff') format('woff');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Elvaro Grotesque';
  src: url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-Bold.woff2') format('woff2'),
       url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Elvaro Grotesque';
  src: url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-ExtraBold.woff2') format('woff2'),
       url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-ExtraBold.woff') format('woff');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Elvaro Grotesque';
  src: url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-Black.woff2') format('woff2'),
       url('/Fonts/Elvaro Grotesque Sans Family/WOFF/TBJElvaro-Black.woff') format('woff');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* Monospace — Interval Mono */
@font-face {
  font-family: 'Interval Mono';
  src: url('/Fonts/IntervalMono/WOFF/TBJInterval-Light.woff2') format('woff2'),
       url('/Fonts/IntervalMono/WOFF/TBJInterval-Light.woff') format('woff');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Interval Mono';
  src: url('/Fonts/IntervalMono/WOFF/TBJInterval-Regular.woff2') format('woff2'),
       url('/Fonts/IntervalMono/WOFF/TBJInterval-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Interval Mono';
  src: url('/Fonts/IntervalMono/WOFF/TBJInterval-Bold.woff2') format('woff2'),
       url('/Fonts/IntervalMono/WOFF/TBJInterval-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Premium UI fonts — Blumir (alternative) */
@font-face {
  font-family: 'Blumir';
  src: url('/Fonts/blumir-font-family/WOFF/Blumir-VF.woff2') format('woff2-variations'),
       url('/Fonts/blumir-font-family/WOFF/Blumir-VF.woff') format('woff-variations');
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Original design system tokens (for boot phase) */
  --bg: #FFFFFF;
  --text: #334155;
  --heading: #0F172A;
  --teal: #00897B;
  --teal-light: rgba(0, 137, 123, 0.08);
  --teal-medium: rgba(0, 137, 123, 0.15);
  --coral: #FF6B6B;
  --coral-light: rgba(255, 107, 107, 0.08);
  --muted: #94A3B8;
  --card-bg: #FFFFFF;
  --radius: 16px;
  --font-primary: 'Elvaro Grotesque', system-ui, sans-serif;
  --font-secondary: 'Blumir', system-ui, sans-serif;

  /* Typography — Elvaro Grotesque primary, Blumir alternative */
  --font-ui: 'Elvaro Grotesque', system-ui, sans-serif;
  --font-ui-alt: 'Blumir', system-ui, sans-serif;
  --font-geist-mono: 'Geist Mono', 'Fira Code', monospace;

  /* GP System Dashboard tokens */
  --bg-dashboard: #F0F5F4;
  --surface: #FFFFFF;
  --sidebar-bg: #F7FAFA;
  --text-primary: #1A2B2A;
  --text-secondary: #5B7A78;
  --text-tertiary: #6B8886;
  --accent: #0D6E6E;
  --accent-hover: #0A8080;
  --accent-pressed: #085858;
  --accent-light: rgba(10,128,128,0.08);
  --accent-border: rgba(10,128,128,0.18);
  --amber: #D97706;
  --amber-light: rgba(217,119,6,0.08);
  --amber-border: rgba(217,119,6,0.18);
  --success: #059669;
  --success-light: rgba(5,150,105,0.08);
  --success-border: rgba(5,150,105,0.18);
  --alert: #DC2626;
  --alert-light: rgba(220,38,38,0.08);
  --alert-border: rgba(220,38,38,0.18);
  --purple: #7C3AED;
  --purple-light: rgba(124,58,237,0.08);
  --purple-border: rgba(124,58,237,0.18);
  --border: #D4E0DE;
  --border-light: #E4EDEB;
  --sidebar-width: 304px;
  --sidebar-rail-width: 64px;
  --radius-card: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(26,43,42,0.05);
  --shadow-md: 0 2px 8px rgba(26,43,42,0.08);
  --shadow-lg: 0 8px 32px rgba(26,43,42,0.12);
  --font-body: var(--font-ui);
  --font-mono-dashboard: 'Interval Mono', 'Fira Code', monospace;

  /* Detail panel */
  --panel-narrow: 400px;
  --panel-wide: 60vw;
  --backdrop-blur: 4px;
  --backdrop-bg: rgba(26,43,42,0.15);

}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@layer utilities {
  .font-primary {
    font-family: var(--font-primary);
  }
  .font-secondary {
    font-family: var(--font-secondary);
  }
  .font-mono {
    font-family: 'Fira Code', monospace;
  }
  .font-ui {
    font-family: var(--font-ui);
  }
  .font-ui-alt {
    font-family: var(--font-ui-alt);
  }
  .font-geist-mono {
    font-family: var(--font-geist-mono);
  }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes seedPulse {
  0%, 100% { text-shadow: 0 0 8px #00ff41, 0 0 16px #00ff41; }
  50% { text-shadow: 0 0 14px #00ff41, 0 0 28px #00ff41, 0 0 40px rgba(0,255,65,0.3); }
}

.animate-blink {
  animation: blink 1s step-end infinite;
}

.animate-seed-pulse {
  animation: seedPulse 0.6s ease-in-out infinite;
}

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

.animate-fadeIn {
  animation: fadeIn 200ms ease-out forwards;
}

.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

html {
  scroll-behavior: smooth;
}

/* Pulse animation for status badge dot */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Live pill pulse — gentle glow throb */
@keyframes live-pill-pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.2);
  }
  50% {
    opacity: 0.8;
    box-shadow: 0 0 6px 2px rgba(34, 197, 94, 0.15);
  }
}

/* Login button pulse — draws attention when button becomes clickable */
@keyframes login-pulse {
  0%, 60%, 100% { transform: scale(1); }
  30% { transform: scale(1.03); }
}

.login-pulse-active {
  animation: login-pulse 3s ease-in-out infinite;
}

.login-pulse-active:hover {
  animation: none;
}

/* Custom scrollbar for sidebar */
.pmr-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.pmr-scrollbar::-webkit-scrollbar {
  width: 4px;
}

.pmr-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.pmr-scrollbar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.pmr-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Dashboard main content offset for mobile sidebar rail */
.dashboard-main {
  margin-left: var(--sidebar-rail-width);
}

@media (min-width: 1024px) {
  .dashboard-main {
    margin-left: 0;
  }
}

/* Sidebar control styles */
.sidebar-control:hover {
  background: rgba(10, 128, 128, 0.05) !important;
  color: var(--accent) !important;
}

.sidebar-control:focus-visible {
  outline: 2px solid rgba(13, 110, 110, 0.45);
  outline-offset: 2px;
}

.metric-card:hover {
  border-color: var(--accent-border) !important;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.metric-card:focus-visible {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(10, 128, 128, 0.22);
  outline: none;
}

.metric-card:active {
  transform: translateY(0) scale(0.992);
}

.latest-results-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.latest-results-header > div {
  margin-bottom: 0 !important;
}

.latest-results-grid {
  margin-top: 12px;
}

@media (min-width: 768px) {
  .latest-results-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
}

@media (min-width: 1024px) {
  .latest-results-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

/* Dashboard card grid responsive — mobile-first */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

/* Tablet: 2 columns on wider screens */
@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .dashboard-grid > :first-child {
    grid-column: 1 / -1;
  }
}

/* Desktop: maintain 2 columns with generous gap */
@media (min-width: 1024px) {
  .dashboard-grid {
    gap: 20px;
  }
}


/* Pathway two-column layout — mobile-first (used in Patient Pathway) */
.pathway-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  min-width: 0;
}

.pathway-graph-sticky {
  min-width: 0;
  overflow: hidden;
}

.chronology-stream {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chronology-item {
  padding: 10px 12px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--surface);
}

.chronology-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-family: var(--font-geist-mono);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
}

.timeline-intervention-item {
  width: 100%;
  gap: 8px;
  
}


.timeline-intervention-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-family: var(--font-geist-mono);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
}

.timeline-intervention-pill--education {
  color: #6B21A8;
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.28);
}

/* Tablet+: 2 columns */
@media (min-width: 768px) {
  .pathway-columns {
    grid-template-columns: minmax(0, 3fr) minmax(0, 3.5fr);
    align-items: start;
    gap: 22px;
  }

  .pathway-graph-sticky {
    position: sticky;
    top: 12px;
    min-height: 100%;
  }
}

/* Repeat medications 3-column grid */
.medications-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

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

/* ===== COMMAND PALETTE ANIMATIONS ===== */
@keyframes palette-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@media (prefers-reduced-motion: reduce) {
  @keyframes palette-overlay-in {
    from { opacity: 1; }
    to { opacity: 1; }
  }
  @keyframes palette-modal-in {
    from { transform: none; opacity: 1; }
    to { transform: none; opacity: 1; }
  }
}

/* ===== CONSTELLATION FULLSCREEN ANIMATION ===== */
@keyframes constellation-fullscreen-in {
  from { transform: scale(0.95); opacity: 0.8; }
  to { transform: scale(1); opacity: 1; }
}

/* ===== CONSTELLATION FOCUS MODE — axis/background dimming ===== */
svg.constellation-focus-active .axis-line,
svg.constellation-focus-active .year-tick {
  stroke-opacity: 0.25;
  transition: stroke-opacity 150ms ease-out;
}

svg.constellation-focus-active .year-label {
  opacity: 0.25;
  transition: opacity 150ms ease-out;
}

svg:not(.constellation-focus-active) .axis-line,
svg:not(.constellation-focus-active) .year-tick {
  transition: stroke-opacity 150ms ease-out;
}

svg:not(.constellation-focus-active) .year-label {
  transition: opacity 150ms ease-out;
}

/* ===== FOCUS VISIBLE STYLES (WCAG Compliance) ===== */
/* Default focus ring for all focusable elements */
*:focus-visible {
  outline: 2px solid rgba(13, 110, 110, 0.4);
  outline-offset: 2px;
}

/* Button-like interactive elements */
button:focus-visible,
[role="button"]:focus-visible,
[role="option"]:focus-visible {
  outline: 2px solid rgba(13, 110, 110, 0.4);
  outline-offset: 2px;
}

/* Links */
a:focus-visible {
  outline: 2px solid rgba(13, 110, 110, 0.4);
  outline-offset: 2px;
}

/* Inputs and textareas */
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(13, 110, 110, 0.6);
  outline-offset: 0px;
}

/* ===== DETAIL PANEL ANIMATIONS ===== */
@keyframes panel-slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes panel-slide-out {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

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

/* Detail panel responsive widths */
.detail-panel[data-width="narrow"] {
  width: var(--panel-narrow);
}

.detail-panel[data-width="wide"] {
  width: var(--panel-wide);
}

/* Desktop: cap panel width at 33% */
@media (min-width: 1025px) {
  .detail-panel[data-width="narrow"],
  .detail-panel[data-width="wide"] {
    max-width: 33vw;
  }
}

/* Mobile: both narrow and wide become full-width */
@media (max-width: 767px) {
  .detail-panel[data-width="narrow"],
  .detail-panel[data-width="wide"] {
    width: 100vw;
  }
}

/* Hide skill tags on project cards at mobile */
@media (max-width: 639px) {
  .skills-tags {
    display: none !important;
  }
}

/* ===== MOBILE RESPONSIVE FIXES (<600px) ===== */
@media (max-width: 599px) {
  .dashboard-main {
    margin-left: 0;
  }
}

/* ===== SMALL VIEWPORT FIXES (<480px) ===== */
@media (max-width: 479px) {
  .card-base {
    padding: 16px !important;
  }

  .chronology-item {
    padding: 8px 8px 10px;
  }
}

/* KPI grid — responsive columns */
.kpi-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 359px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* Detail panel responsive padding */
@media (max-width: 479px) {
  .detail-panel [data-panel-body] {
    padding: 16px !important;
  }

  .detail-panel [data-panel-header] {
    padding: 16px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Disable pulse animation on status badge dot */
  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 1; }
  }

  /* Instant panel animations */
  @keyframes panel-slide-in {
    from { transform: none; }
    to { transform: none; }
  }

  @keyframes panel-slide-out {
    from { transform: none; }
    to { transform: none; }
  }

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

  /* No transition for constellation focus mode axis dimming */
  svg.constellation-focus-active .axis-line,
  svg.constellation-focus-active .year-tick,
  svg.constellation-focus-active .year-label,
  svg:not(.constellation-focus-active) .axis-line,
  svg:not(.constellation-focus-active) .year-tick,
  svg:not(.constellation-focus-active) .year-label {
    transition: none;
  }

  /* Instant constellation fullscreen */
  @keyframes constellation-fullscreen-in {
    from { transform: none; opacity: 1; }
    to { transform: none; opacity: 1; }
  }

  /* No pulse animation */
  .login-pulse-active {
    animation: none;
  }

  /* Static live pill */
  .live-pill {
    animation: none !important;
    box-shadow: none !important;
  }

  /* Instant smooth scroll override */
  html {
    scroll-behavior: auto;
  }

}
