/* app/assets/stylesheets/portal/base.css */

:root {
  /* Surface — warm neutrals */
  --portal-bg:            #f5f3f0;
  --portal-sidebar-bg:    #18181b;
  --portal-sidebar-text:  #a1a1aa;
  --portal-sidebar-active: #fafafa;
  --portal-sidebar-hover: rgba(255, 255, 255, 0.06);
  --portal-topbar-bg:     #ffffff;
  --portal-card-bg:       #ffffff;
  --portal-border:        #e4e2de;
  --portal-text:          #18181b;
  --portal-text-muted:    #71717a;
  --portal-text-secondary: #a1a1aa;

  /* Primary — deep teal */
  --portal-primary:        #0d9488;
  --portal-primary-hover:  #0f766e;
  --portal-primary-light:  #f0fdfa;
  --portal-primary-dark:   #115e59;

  /* Accent — amber for CTAs */
  --portal-accent:         #f59e0b;
  --portal-accent-hover:   #d97706;

  /* Status */
  --status-scheduled:   #3b82f6;
  --status-on-my-way:   #f59e0b;
  --status-in-progress: #8b5cf6;
  --status-completed:   #10b981;
  --status-canceled:    #ef4444;

  /* Calendar */
  --calendar-slot-height: 60px;
  --calendar-hour-line:   #e5e7eb;
  --calendar-weekend-bg:  #faf9f7;
  --calendar-now-line:    #ef4444;

  /* Typography */
  --font-display: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", monospace;

  /* Spacing */
  --sidebar-width: 240px;
  --topbar-height: 56px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.08);
  --shadow-lift: 0 8px 24px rgba(13, 148, 136, 0.10), 0 2px 8px rgba(0, 0, 0, 0.06);

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Interactive */
  --portal-hover-bg: rgba(13, 148, 136, 0.06);

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 350ms ease;

  /* Focus */
  --focus-ring: 0 0 0 2px var(--portal-primary-light), 0 0 0 4px var(--portal-primary);

  /* Gradient shortcuts */
  --gradient-primary: linear-gradient(135deg, #0d9488, #0f766e);
  --gradient-sidebar: linear-gradient(180deg, #1e1e23, #18181b 40%);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-body);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--portal-text);
  line-height: 1.55;
}

/* 1. Background texture — subtle noise grain */
.portal-body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

/* 5. Typography — push harder */
.portal-content h1 {
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.625rem;
}

.portal-content h2 {
  position: relative;
  padding-bottom: 0.5rem;
}

.portal-content h2::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--portal-primary);
  border-radius: 1px;
}

code, .font-mono, [class*="mono"] {
  background: rgba(13, 148, 136, 0.06);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
}

a {
  color: inherit;
  text-decoration: none;
}

/* Table scroll wrapper for mobile */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Touch targets */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  .btn,
  button,
  a.btn,
  select,
  input[type="submit"] {
    min-height: 44px;
  }

  .card-body {
    padding: 1rem;
  }
}

/* === Animations === */

/* Card fade-in-up on page load */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card,
.portal-card,
.job-section,
.invoice-card,
.job-card {
  animation: fade-in-up var(--transition-slow) ease both;
}

/* Stagger cards */
.job-card:nth-child(1),
.card:nth-child(1) { animation-delay: 0ms; }
.job-card:nth-child(2),
.card:nth-child(2) { animation-delay: 50ms; }
.job-card:nth-child(3),
.card:nth-child(3) { animation-delay: 100ms; }
.job-card:nth-child(4),
.card:nth-child(4) { animation-delay: 150ms; }
.job-card:nth-child(5),
.card:nth-child(5) { animation-delay: 200ms; }

/* Turbo progress bar */
.turbo-progress-bar {
  height: 3px;
  background: var(--portal-primary);
}

/* 8. Page transitions — staggered reveals */
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slide-in-left {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes focus-ring-pulse {
  0%   { box-shadow: 0 0 0 2px var(--portal-primary-light), 0 0 0 4px var(--portal-primary); }
  50%  { box-shadow: 0 0 0 3px var(--portal-primary-light), 0 0 0 6px rgba(13, 148, 136, 0.3); }
  100% { box-shadow: 0 0 0 2px var(--portal-primary-light), 0 0 0 4px var(--portal-primary); }
}

.portal-content > *:not(.card):not(.portal-card):not(.job-card) {
  animation: fade-in-up var(--transition-slow) ease both;
}

.portal-topbar-user,
.portal-topbar .btn {
  animation: slide-in-right 0.3s ease both;
}

/* Status transition flash */
@keyframes status-flash {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

.status-badge[data-updated] {
  animation: status-flash 0.4s ease;
}

/* 9. Scrollbar styling */
.portal-main {
  scrollbar-width: thin;
  scrollbar-color: var(--portal-primary) transparent;
}

.portal-main::-webkit-scrollbar {
  width: 6px;
}

.portal-main::-webkit-scrollbar-track {
  background: transparent;
}

.portal-main::-webkit-scrollbar-thumb {
  background: rgba(13, 148, 136, 0.3);
  border-radius: 3px;
  transition: background 0.2s;
}

.portal-main::-webkit-scrollbar-thumb:hover {
  background: rgba(13, 148, 136, 0.5);
  width: 8px;
}

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

/* Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
