/* Prioritize — Complete Stylesheet */
/* Includes Tailwind utility equivalents + custom component styles */

/* ─── CSS Reset (Tailwind Preflight) ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: #E5E7EB;
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  margin: 0;
  line-height: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
}

p {
  margin: 0;
}

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

button, input {
  font-family: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
}

button {
  cursor: pointer;
  background-color: transparent;
  background-image: none;
}

img, svg {
  display: inline-block;
  vertical-align: middle;
}

/* ─── Font Faces ─────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Inter Regular'), local('Inter-Regular'), local('Inter');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: local('Inter Medium'), local('Inter-Medium'), local('Inter');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: local('Inter SemiBold'), local('Inter-SemiBold'), local('Inter');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('Inter Bold'), local('Inter-Bold'), local('Inter');
}
@font-face {
  font-family: 'Lora';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: local('Lora SemiBold'), local('Lora-SemiBold'), local('Lora');
}
@font-face {
  font-family: 'Lora';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('Lora Bold'), local('Lora-Bold'), local('Lora');
}

/* ─── Custom Properties ──────────────────────────────────────────────────── */
:root {
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Lora', Georgia, serif;
  --color-bg: #FAF8F5;
  --color-surface: #FFFFFF;
  --color-primary: #6B7C47;
  --color-primary-hover: #5A6A3C;
  --color-accent: #059669;
  --color-warning: #D97706;
  --color-danger: #DC2626;
  --color-text-primary: #111827;
  --color-text-secondary: #4B5563;
  --color-text-muted: #9CA3AF;
  --color-border: #E5E7EB;
  --color-divider: #F3F4F6;
  --color-winner-highlight: #FEF3C7;
}

/* ─── Base Styles ────────────────────────────────────────────────────────── */
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-size: 16px;
  line-height: 1.6;
}

.font-display,
h1, h2, h3 {
  font-family: var(--font-display);
}

h1 {
  font-size: 36px;
  letter-spacing: -0.02em;
  font-weight: 700;
}

h2 {
  font-size: 24px;
  font-weight: 700;
}

h3 {
  font-size: 18px;
  font-weight: 600;
}

/* ─── Tailwind Utility Classes ───────────────────────────────────────────── */

/* Display & Visibility */
.hidden { display: none; }
.flex { display: flex; }
.grid { display: grid; }
.inline-flex { display: inline-flex; }
.block { display: block; }

/* Position */
.fixed { position: fixed; }
.relative { position: relative; }
.absolute { position: absolute; }
.top-0 { top: 0; }
.right-0 { right: 0; }
.left-0 { left: 0; }
.bottom-6 { bottom: 1.5rem; }
.left-1\/2 { left: 50%; }
.-translate-x-1\/2 { transform: translateX(-50%); }

/* Z-index */
.z-50 { z-index: 50; }

/* Sizing */
.w-full { width: 100%; }
.w-4 { width: 1rem; }
.w-5 { width: 1.25rem; }
.w-10 { width: 2.5rem; }
.h-1 { height: 0.25rem; }
.h-4 { height: 1rem; }
.h-5 { height: 1.25rem; }
.h-10 { height: 2.5rem; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }
.min-w-0 { min-width: 0; }

/* Max width */
.max-w-2xl { max-width: 672px; }

/* Margin */
.mx-auto { margin-left: auto; margin-right: auto; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-10 { margin-bottom: 2.5rem; }
.ml-4 { margin-left: 1rem; }
.mt-4 { margin-top: 1rem; }

/* Padding */
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }

/* Flexbox */
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-1 { flex: 1 1 0%; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* Gap */
.gap-1 { gap: 0.25rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* Grid */
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }

/* Space between children */
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }

/* Typography */
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-5xl { font-size: 3rem; line-height: 1; }
.text-6xl { font-size: 3.75rem; line-height: 1; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.underline { text-decoration: underline; }

/* Colors */
.text-white { color: #FFFFFF; }
.text-gray-400 { color: #9CA3AF; }
.text-gray-500 { color: #6B7280; }
.text-gray-600 { color: #4B5563; }
.text-gray-900 { color: #111827; }
.text-indigo-600 { color: #6B7C47; }
.text-amber-600 { color: #D97706; }

.bg-white { background-color: #FFFFFF; }
.bg-gray-100 { background-color: #F3F4F6; }
.bg-indigo-100 { background-color: #E8ECD8; }
.bg-indigo-600 { background-color: #6B7C47; }
.bg-amber-600 { background-color: #D97706; }

/* Border */
.rounded-full { border-radius: 9999px; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }

/* Pointer events */
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* Transitions */
.transition-colors { transition-property: color, background-color, border-color; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-transform { transition-property: transform; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-all { transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.duration-200 { transition-duration: 200ms; }
.ease-out { transition-timing-function: cubic-bezier(0, 0, 0.2, 1); }

/* Hover states */
.hover\:text-indigo-600:hover { color: #6B7C47; }

/* Disabled states */
.disabled\:opacity-40:disabled { opacity: 0.4; }
.disabled\:cursor-not-allowed:disabled { cursor: not-allowed; }

/* Responsive: sm (640px+) */
@media (min-width: 640px) {
  .sm\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
  .sm\:py-12 { padding-top: 3rem; padding-bottom: 3rem; }
  .sm\:w-auto { width: auto; }
  .sm\:flex-row { flex-direction: row; }
  .sm\:gap-4 { gap: 1rem; }
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sm\:text-2xl { font-size: 1.5rem; line-height: 2rem; }
  .sm\:text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
  .sm\:text-6xl { font-size: 3.75rem; line-height: 1; }
}

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

/* ─── Letter Chips ───────────────────────────────────────────────────────── */
.letter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-feature-settings: 'tnum';
  font-weight: 700;
  font-family: var(--font-body);
  border-radius: 6px;
  flex-shrink: 0;
}

.letter-chip-sm {
  width: 32px;
  height: 32px;
  font-size: 14px;
  background: #EDF1E0;
  color: #5A6A3C;
}

.letter-chip-lg {
  width: 40px;
  height: 40px;
  font-size: 16px;
  background: #EDF1E0;
  color: #5A6A3C;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 24px;
  background: var(--color-primary);
  color: white;
  font-weight: 600;
  font-size: 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background-color 150ms ease, transform 100ms ease;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary:disabled:hover {
  background: var(--color-primary);
  transform: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}

.btn-secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-secondary:active {
  transform: scale(0.98);
}

/* Focus states */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ─── Task Input Rows ────────────────────────────────────────────────────── */
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.task-row.faded {
  opacity: 0.4;
}

.task-row.faded:focus-within {
  opacity: 1;
}

.task-input {
  flex: 1;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 16px;
  font-family: var(--font-body);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  transition: border-color 150ms ease;
}

.task-input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(107, 124, 71, 0.1);
}

.task-input::placeholder {
  color: var(--color-text-muted);
}

/* ─── Comparison Cards ───────────────────────────────────────────────────── */
.comparison-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 120px;
  padding: 24px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
  text-align: left;
  font-family: var(--font-body);
}

.comparison-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  transform: scale(1.02);
}

.comparison-card:active {
  transform: scale(0.99);
}

.comparison-card.flash {
  background: var(--color-winner-highlight);
}

.comparison-card .card-letter {
  margin-bottom: 12px;
}

.comparison-card .card-text {
  font-size: 18px;
  font-weight: 500;
  color: var(--color-text-primary);
  word-break: break-word;
}

/* ─── Results Ranked List ────────────────────────────────────────────────── */
.ranked-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.ranked-item.top-priority {
  background: var(--color-winner-highlight);
}

.ranked-item .rank-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  color: var(--color-primary);
  min-width: 36px;
  text-align: center;
}

.ranked-item .rank-text {
  flex: 1;
  font-size: 18px;
  font-weight: 500;
  color: var(--color-text-primary);
  word-break: break-word;
}

.ranked-item .rank-score {
  font-size: 14px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ─── Matrix Grid ────────────────────────────────────────────────────────── */
.matrix-table {
  border-collapse: collapse;
  font-size: 14px;
  font-weight: 600;
}

.matrix-table th,
.matrix-table td {
  width: 40px;
  height: 40px;
  text-align: center;
  vertical-align: middle;
  border: 1px solid var(--color-border);
}

.matrix-table th {
  background: var(--color-divider);
  font-weight: 700;
  color: var(--color-text-secondary);
}

.matrix-table td.cell-row-wins {
  color: #5A6A3C;
}

.matrix-table td.cell-col-wins {
  color: #059669;
}

.matrix-table td.cell-tie {
  color: var(--color-warning);
}

.matrix-table td.cell-empty {
  background: var(--color-divider);
  color: var(--color-text-muted);
}

/* ─── History Cards ──────────────────────────────────────────────────────── */
.history-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--color-surface);
  border-radius: 12px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.history-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.history-card-content {
  flex: 1;
  min-width: 0;
}

.history-card-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--color-text-primary);
}

.history-card-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card-footer {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.history-delete-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.history-delete-btn:hover {
  color: var(--color-danger);
  background: #FEF2F2;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  background: var(--color-text-primary);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  animation: toast-in 200ms ease-out;
  pointer-events: auto;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 639px) {
  h1 {
    font-size: 28px;
  }
  h2 {
    font-size: 20px;
  }
  .comparison-card {
    padding: 16px;
    min-height: 100px;
  }
  .ranked-item {
    padding: 12px;
  }
  .ranked-item .rank-number {
    font-size: 24px;
    min-width: 30px;
  }
}

@media (max-width: 320px) {
  h1 {
    font-size: 24px;
  }
  .comparison-card {
    padding: 12px;
    min-height: 80px;
  }
}

/* ─── Reduced Motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ─── Print Styles ───────────────────────────────────────────────────────── */
@media print {
  .no-print {
    display: none !important;
  }
  body {
    background: white;
  }
  .ranked-item {
    box-shadow: none;
    border: 1px solid #E5E7EB;
  }
  #toast-container,
  #storage-banner {
    display: none !important;
  }
}
