@import "tailwindcss";

/* ============================================
   ADHD Focus PM - Design Token System
   8pt grid, mobile-first, ADHD-friendly
   ============================================ */

@theme {
  /* --- Colors (Dark - Default) --- */
  --color-surface: #0f0f13;
  --color-surface-raised: #1a1a23;
  --color-surface-overlay: #22222e;
  --color-surface-hover: #2a2a38;

  --color-text-primary: #f0f0f5;
  --color-text-secondary: #8888a0;
  --color-text-muted: #55556a;

  --color-accent: #6366f1;
  --color-accent-hover: #818cf8;
  --color-accent-glow: #6366f180;

  --color-energy-low: #22c55e;
  --color-energy-medium: #f59e0b;
  --color-energy-high: #ef4444;

  --color-horizon-now: #6366f1;
  --color-horizon-next: #8b5cf6;
  --color-horizon-later: #55556a;

  --color-status-active: #6366f1;
  --color-status-paused: #f59e0b;
  --color-status-completed: #22c55e;
  --color-status-pending: #55556a;

  --color-border: #2a2a38;
  --color-border-focus: #6366f1;

  /* --- Spacing (8pt grid) --- */
  --spacing-1: 4px;
  --spacing-2: 8px;
  --spacing-3: 12px;
  --spacing-4: 16px;
  --spacing-5: 24px;
  --spacing-6: 32px;
  --spacing-7: 48px;

  /* --- Sizes --- */
  --size-touch-min: 48px;
  --size-touch-primary: 56px;
  --size-touch-timer: 64px;
  --size-anchor-bar: 56px;
  --size-capture-bar: 64px;
  --size-card-padding: 16px;
  --size-card-gap: 10px;
  --size-max-width: 1920px;

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

  /* --- Shadows --- */
  --shadow-card: 0 1px 3px rgb(0 0 0 / 0.2), 0 1px 2px rgb(0 0 0 / 0.15);
  --shadow-card-hover: 0 8px 25px rgb(0 0 0 / 0.3), 0 3px 10px rgb(0 0 0 / 0.15);
  --shadow-overlay: 0 8px 32px rgb(0 0 0 / 0.5);

  /* --- Transitions --- */
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* --- Animations --- */
  --animate-pulse-complete: pulse-complete 0.6s ease-out;
  --animate-fade-in-up: fade-in-up 0.3s ease-out;
  --animate-collapse-card: collapse-card 0.4s ease-in-out forwards;
  --animate-glow: glow 2s ease-in-out infinite;
  --animate-slide-up: slide-up 0.3s ease-out;
  --animate-slide-down: slide-down 0.3s ease-out;
  --animate-stamp-pulse: stamp-pulse 2s ease-in-out infinite;

  /* --- Font --- */
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
}

/* ============================================
   Light Mode Overrides
   ============================================ */

html.light {
  --color-surface: #f5f5f7;
  --color-surface-raised: #ffffff;
  --color-surface-overlay: #f0f0f2;
  --color-surface-hover: #e8e8ec;

  --color-text-primary: #1a1a2e;
  --color-text-secondary: #6b6b80;
  --color-text-muted: #9898a8;

  --color-accent: #6366f1;
  --color-accent-hover: #4f46e5;
  --color-accent-glow: #6366f140;

  --color-border: #e0e0e6;
  --color-border-focus: #6366f1;

  --color-horizon-later: #9898a8;
  --color-status-pending: #9898a8;

  --shadow-card: 0 1px 3px rgb(0 0 0 / 0.06), 0 1px 2px rgb(0 0 0 / 0.04);
  --shadow-card-hover: 0 8px 25px rgb(0 0 0 / 0.1), 0 3px 10px rgb(0 0 0 / 0.06);
  --shadow-overlay: 0 8px 32px rgb(0 0 0 / 0.12);
}

/* ============================================
   Keyframes
   ============================================ */

@keyframes pulse-complete {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes collapse-card {
  from { max-height: 200px; opacity: 1; margin-bottom: 12px; }
  to { max-height: 0; opacity: 0; margin-bottom: 0; padding: 0; overflow: hidden; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 8px var(--color-accent-glow); }
  50% { box-shadow: 0 0 16px var(--color-accent-glow); }
}

@keyframes slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slide-down {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes stamp-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ============================================
   Reduced Motion
   ============================================ */

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

/* ============================================
   Base Styles
   ============================================ */

body {
  @apply bg-surface text-text-primary font-sans antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  transition: background-color var(--duration-normal), color var(--duration-normal);
}

/* ============================================
   Task Card
   ============================================ */

.task-card {
  transition: border-color var(--duration-fast), box-shadow var(--duration-normal);
}

.task-card:not(.task-card--completed):not(.sortable-drag):hover {
  border-color: var(--color-border);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
}

.task-card--completed {
  opacity: 0.55;
}

.task-card--paused {
  opacity: 0.6;
}

/* Drag handle hover tint */
.drag-handle:hover svg {
  color: var(--color-text-secondary);
}

.task-card--collapsing {
  animation: var(--animate-collapse-card);
}

.task-card--suggested {
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 1px var(--color-accent), 0 0 16px var(--color-accent-glow);
  animation: suggestion-pulse 1.4s ease-in-out 3;
}

@keyframes suggestion-pulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--color-accent), 0 0 12px var(--color-accent-glow); }
  50%       { box-shadow: 0 0 0 2px var(--color-accent), 0 0 28px var(--color-accent-glow); }
}

.task-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}

/* Inline title edit hint */
.task-card-title {
  transition: color var(--duration-fast);
}

.task-card:not(.task-card--completed) .task-card-title:hover {
  color: var(--color-accent);
}

/* ============================================
   Expand Panel (animated)
   ============================================ */

.expand-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows var(--duration-normal) ease-out,
              opacity var(--duration-normal) ease-out;
}

.expand-panel > * {
  overflow: hidden;
}

.expand-panel--open {
  grid-template-rows: 1fr;
  opacity: 1;
}

/* ============================================
   Save Indicator
   ============================================ */

.save-indicator {
  position: absolute;
  top: -2px;
  right: 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-status-completed);
  opacity: 0;
  transition: opacity var(--duration-fast), transform var(--duration-fast);
  pointer-events: none;
  z-index: 10;
}

.save-indicator--visible {
  opacity: 1;
}

/* ============================================
   Focus Mode
   ============================================ */

.focus-mode .task-card:not(.task-card--focused) {
  opacity: 0.12;
  filter: blur(2px);
  pointer-events: none;
  transition: opacity var(--duration-normal), filter var(--duration-normal);
}

.focus-mode .task-card--focused {
  opacity: 1;
  filter: none;
  transform: scale(1.02);
  transition: transform var(--duration-normal);
}

/* ============================================
   Drag States
   ============================================ */

.sortable-ghost {
  opacity: 0.4;
}

.sortable-drag {
  transform: rotate(2deg);
  box-shadow: var(--shadow-overlay);
}

/* ============================================
   Horizon Zone
   ============================================ */

/* In board mode (grid), give each column a subtle distinct feel */
.grid > [data-horizon="now"] .horizon-zone {
  padding: 8px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-horizon-now) 3%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-horizon-now) 8%, transparent);
}

.grid > [data-horizon="next"] .horizon-zone {
  padding: 8px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-horizon-next) 3%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-horizon-next) 8%, transparent);
}

.grid > [data-horizon="later"] .horizon-zone {
  padding: 8px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-horizon-later) 3%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-horizon-later) 8%, transparent);
}

/* ============================================
   Scrollbar
   ============================================ */

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

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

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast-enter {
  animation: var(--animate-slide-up);
}

.toast-exit {
  animation: slide-down 0.3s ease-in forwards;
  animation-direction: reverse;
}

/* ============================================
   Lexical Editor
   ============================================ */

.lexical-editable {
  white-space: pre-wrap;
  word-break: break-word;
}

.lexical-editable:empty::before {
  content: "Add notes...";
  color: var(--color-text-muted);
  pointer-events: none;
}

.lexical-paragraph {
  margin: 0 0 0.25em;
}

.lexical-paragraph:last-child {
  margin-bottom: 0;
}

.lexical-bold { font-weight: 700; }
.lexical-italic { font-style: italic; }
.lexical-underline { text-decoration: underline; }
.lexical-strikethrough { text-decoration: line-through; }
.lexical-code {
  font-family: ui-monospace, monospace;
  font-size: 0.875em;
  background: var(--color-surface-hover);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

.lexical-ul { list-style: disc; padding-left: 1.5em; margin: 0.25em 0; }
.lexical-ol { list-style: decimal; padding-left: 1.5em; margin: 0.25em 0; }
.lexical-li { margin: 0.1em 0; }

.lexical-link {
  color: var(--color-accent);
  text-decoration: underline;
}

/* ============================================
   Due Date Badges
   ============================================ */

.due-badge--expired {
  color: var(--color-energy-high);
  animation: var(--animate-stamp-pulse);
}

.due-badge--approaching {
  color: var(--color-energy-medium);
}

/* ============================================
   Date Input Theming
   ============================================ */

.date-input {
  color-scheme: dark;
}

html.light .date-input {
  color-scheme: light;
}

/* ============================================
   Logo Theme Swap
   ============================================ */

.logo-light { display: none; }
.logo-dark  { display: block; }

html.light .logo-light { display: block; }
html.light .logo-dark  { display: none; }

/* ============================================
   Hotkey Hints & Kbd Badges
   ============================================ */

.hotkey-hint {
  position: absolute;
  bottom: -2px;
  right: -2px;
  height: 16px;
  min-width: 16px;
  padding: 0 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, monospace;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  color: var(--color-text-secondary);
  background: var(--color-surface-overlay);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--color-border);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast);
  white-space: nowrap;
}

.group:hover .hotkey-hint {
  opacity: 1;
}

.hotkey-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  min-width: 24px;
  padding: 0 6px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: var(--color-text-primary);
  background: var(--color-surface-overlay);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 2px 0 var(--color-border);
}

/* ============================================
   Action Text Content (rendered comment body)
   ============================================ */

.trix-content {
  color: var(--color-text-primary);
  line-height: 1.625;
}

.trix-content a {
  color: var(--color-accent);
  text-decoration: underline;
}

.trix-content a:hover {
  color: var(--color-accent-hover);
}

/* ============================================
   Safe Area Padding (notched phones)
   ============================================ */

@supports (padding: env(safe-area-inset-top)) {
  header.sticky { padding-top: env(safe-area-inset-top); }
}

@supports (padding: env(safe-area-inset-bottom)) {
  .fixed.bottom-0 { padding-bottom: env(safe-area-inset-bottom); }
}
