/* ============================================================
   PrairieOps — base.css
   CSS variables, dark mode palette, typography, reset
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  /* Background layers */
  --bg-app:        #0d1117;
  --bg-surface:    #161b22;
  --bg-elevated:   #21262d;
  --bg-hover:      #2a3038;
  --bg-input:      #0d1117;

  /* Borders */
  --border:        #2d3540;
  --border-subtle: #1e242c;
  --border-focus:  #c49060;

  /* Text */
  --text-primary:   #e8edf3;
  --text-secondary: #cdd5de;
  --text-muted:     #8b949e;
  --text-inverse:   #0d1117;

  /* Brand bronze/copper — from logo */
  --bronze-300: #d4a878;   /* highlight */
  --bronze-400: #c49060;   /* primary accent */
  --bronze-500: #a07040;   /* mid-depth */
  --bronze-600: #8a5c30;   /* shadow */
  --bronze-100: #1e140a;   /* tinted surface */
  --charcoal:   #141414;   /* login/splash background */

  /* Brand green — upgraded to deep premium */
  --green-500: #1a5c2e;
  --green-400: #226b36;
  --green-300: #2d8a47;
  --green-100: #0e2118;

  /* Priority: Urgent */
  --urgent:        #ff4444;
  --urgent-bg:     #2d0f0f;
  --urgent-border: #7a1a1a;
  --urgent-glow:   rgba(255, 68, 68, 0.25);

  /* iOS system red — used for destructive UI affordances (notification badge,
     Clear all button, swipe-to-delete background). Distinct from --urgent
     (priority alarm red) on purpose; iOS red has a colder cast. */
  --ios-red:       #FF3B30;

  /* Priority: Deadline */
  --deadline:        #ff8c00;
  --deadline-bg:     #2b1a00;
  --deadline-border: #6b4400;
  --deadline-glow:   rgba(255, 140, 0, 0.25);

  /* Priority: End of Day */
  --eod:        #f0c040;
  --eod-bg:     #2b2000;
  --eod-border: #6b5000;

  /* Priority: End of Week */
  --eow:        #4a9eff;
  --eow-bg:     #0d1f3c;
  --eow-border: #1a3a6e;

  /* Priority: Backlog */
  --backlog:        #6e7681;
  --backlog-bg:     #1c2128;
  --backlog-border: #30363d;

  /* Board tab accents */
  --board-field:  #1a4d22;
  --board-grain:  #7a5a10;
  --board-shop:   #1a3358;

  /* Status colours */
  --status-pending:    #6e7681;
  --status-live:       #226b36;
  --status-claimed:    #4a9eff;
  --status-progress:   #ff8c00;
  --status-signoff:    #f0c040;
  --status-complete:   #226b36;
  --status-rejected:   #ff4444;

  /* Role badge colours */
  --role-manager:  #a371f7;
  --role-foreman:  #4a9eff;
  --role-crew:     #2d8a47;
  --role-owner:    #c49060;  /* bronze — matches brand; Phase 2 / Owner-auth */

  /* Feedback */
  --success: #226b36;
  --warning: #f0c040;
  --danger:  #ff4444;
  --info:    #4a9eff;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;

  /* Phase 4 (2026-05-24): xs + sm bumped +1px for outdoor readability.   */
  /* Affects body / meta / label tokens across the app. Buttons + badges  */
  /* hardcode their own px sizes so they're insulated.                    */
  --text-xs:   13px;
  --text-sm:   15px;
  --text-base: 16px;
  --text-md:   18px;
  --text-lg:   21px;
  --text-xl:   25px;
  --text-2xl:  32px;

  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --line-tight:  1.2;
  --line-normal: 1.5;
  --line-loose:  1.75;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.45);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.55);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.65);
  --shadow-glow-urgent:   0 0 12px var(--urgent-glow);
  --shadow-glow-deadline: 0 0 12px var(--deadline-glow);
  --shadow-glow-bronze:   0 0 16px rgba(196, 144, 96, 0.18);

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

  /* Z-index scale */
  --z-base:    1;
  --z-dropdown: 100;
  --z-sticky:  200;
  --z-overlay: 300;
  --z-modal:   400;
  --z-toast:   500;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--line-normal);
  color: var(--text-primary);
  background-color: var(--bg-app);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--line-tight);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

p {
  color: var(--text-secondary);
  line-height: var(--line-normal);
}

a {
  color: var(--eow);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

strong { font-weight: var(--weight-semibold); color: var(--text-primary); }
small  { font-size: var(--text-xs); color: var(--text-secondary); }

code, pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
code { padding: 2px 6px; }

/* ── Utility: visibility ────────────────────────────────────── */
.hidden  { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* ── Utility: text helpers ──────────────────────────────────── */
.text-xs      { font-size: var(--text-xs); }
.text-sm      { font-size: var(--text-sm); }
.text-base    { font-size: var(--text-base); }
.text-lg      { font-size: var(--text-lg); }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-info    { color: var(--info); }
.text-center  { text-align: center; }
.font-bold    { font-weight: var(--weight-bold); }
.font-semibold{ font-weight: var(--weight-semibold); }
.font-medium  { font-weight: var(--weight-medium); }

/* ── Utility: spacing ───────────────────────────────────────── */
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }

/* ── Utility: flex helpers ──────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.flex-1       { flex: 1; }

/* ── Scrollbar styling ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-app); }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ── Focus ring ─────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ── Selection ──────────────────────────────────────────────── */
::selection {
  background: rgba(196, 144, 96, 0.25);
  color: var(--text-primary);
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

@keyframes flash {
  0%, 100% { opacity: 1; }
  25%, 75% { opacity: 0.3; }
}

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

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes urgentPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--urgent-glow); }
  50%       { box-shadow: 0 0 0 6px transparent; }
}

@keyframes deadlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--deadline-glow); }
  50%       { box-shadow: 0 0 0 6px transparent; }
}

.anim-pulse          { animation: pulse 1.5s ease-in-out infinite; }
.anim-flash          { animation: flash 1s ease-in-out infinite; }
.anim-slide-in-down  { animation: slideInDown 0.2s ease forwards; }
.anim-slide-in-up    { animation: slideInUp 0.2s ease forwards; }
.anim-fade-in        { animation: fadeIn 0.2s ease forwards; }
.anim-urgent-pulse   { animation: urgentPulse 2s ease-in-out infinite; }
.anim-deadline-pulse { animation: deadlinePulse 1s ease-in-out infinite; }

/* ── Responsive breakpoint helpers ─────────────────────────── */
/* Mobile first — these helpers show/hide at sm (640px) and md (1024px) */
@media (max-width: 639px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 640px) {
  .hide-tablet-up { display: none !important; }
}
@media (min-width: 1024px) {
  .hide-desktop { display: none !important; }
}
