/* =====================================================
   SEO Opportunity Monitor — Wise-Inspired Design System
   No gradients. No shadows. Surface contrast only.
   ===================================================== */

/* ── Design Tokens ── */
:root {
  /* Primary — sage-leaning lime so it sits in the same hue
     family as --positive instead of reading as two clashing greens. */
  --primary: #9fe870;
  --on-primary: #0e0f0c;
  --primary-pale: #e2f6d5;

  /* Text */
  --ink: #0e0f0c;
  --body: #454745;
  --mute: #868685;
  --mute-soft: #b6b8b5;

  /* Surfaces */
  --canvas: #ffffff;
  --canvas-soft: #e8ebe6;
  --canvas-softer: #f5f5f4;

  /* Semantic — Positive (hue shifted toward primary lime so the
     two greens read as one palette rather than two systems). */
  --positive: #5cb045;
  --positive-deep: #1e5d28;

  /* Semantic — Warning */
  --warning: #ffd11a;
  --warning-deep: #b86700;
  --warning-pale: #fff8e0;

  /* Semantic — Negative */
  --negative: #d03238;
  --negative-deep: #a72027;
  --negative-pale: #fde8e8;

  /* Accent surfaces used in SERP intel cards */
  --info-pale: #e0edff;
  --info-deep: #1a4b8c;
  --plum-pale: #f3e8ff;
  --plum-deep: #6b21a8;

  /* Radii */
  --radius-card: 24px;
  --radius-btn: 24px;
  --radius-input: 12px;
  --radius-pill: 9999px;

  /* Spacing */
  --pad-card: 24px;
  --pad-section: 48px;

  /* Transitions */
  --ease: 0.15s ease;
}

/* ── Base ── */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--canvas-soft);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--canvas-soft);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--mute);
  background-clip: padding-box;
}

/* ── Header Accent Bar ── */
.header-accent-bar {
  height: 3px;
  background: var(--primary);
}

/* ── Cards ── */
.card {
  background: var(--canvas);
  border-radius: var(--radius-card);
  overflow: hidden;
  transition: background-color var(--ease);
}

/* ── Navigation ── */
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-input);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--ease), color var(--ease);
}
.nav-link:hover {
  background: var(--canvas-soft);
}
.nav-link.nav-active {
  background: var(--canvas-soft);
  color: var(--ink);
}
.nav-link svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}
.nav-link.nav-active svg {
  opacity: 1;
}
.nav-separator {
  color: var(--mute);
  font-size: 14px;
  user-select: none;
}
.sort-arrow {
  font-size: 10px;
  margin-left: 2px;
  color: var(--mute);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.02em;
  border: none;
  transition: background-color var(--ease), color var(--ease);
}

/* Impact levels */
.impact-high {
  background: var(--negative-pale);
  color: var(--negative-deep);
}
.impact-medium {
  background: var(--warning-pale);
  color: #7a6400;
}
.impact-low {
  background: var(--canvas-soft);
  color: var(--mute);
}

/* Recommendation lifecycle */
.status-new {
  background: var(--primary-pale);
  color: var(--positive-deep);
}
.status-seen {
  background: var(--canvas-soft);
  color: var(--ink);
}
.status-done {
  background: var(--primary-pale);
  color: var(--positive-deep);
}
.status-dismissed {
  background: var(--canvas-soft);
  color: var(--mute);
}

/* Job statuses */
.job-queued {
  background: var(--canvas-soft);
  color: var(--mute);
}
.job-running {
  background: var(--primary-pale);
  color: var(--ink);
}
.job-succeeded {
  background: var(--primary-pale);
  color: var(--positive-deep);
}
.job-failed {
  background: var(--negative-pale);
  color: var(--negative-deep);
}

/* ── Impact Dots ── */
.impact-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.impact-dot-high   { background: #d03238; }
.impact-dot-medium { background: #ffd11a; }
.impact-dot-low    { background: #868685; }

/* ── Tables ── */
.table-premium {
  width: 100%;
  font-size: 14px;
  border-collapse: collapse;
}
.table-premium thead {
  background: var(--canvas-soft);
}
.table-premium th {
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--canvas-soft);
}
.table-premium td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--canvas-soft);
  color: var(--body);
  font-size: 14px;
}
.table-premium tbody tr {
  transition: background-color var(--ease);
}
.table-premium tbody tr:hover {
  background: var(--primary-pale);
}
.table-premium tbody tr:last-child td {
  border-bottom: none;
}

/* ── Buttons ── */
.btn-primary {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity var(--ease);
}
.btn-primary:hover {
  opacity: 0.88;
}
.btn-primary:active {
  opacity: 0.8;
}
.btn-primary:focus-visible {
  outline: 2px solid #9fe870;
  outline-offset: 2px;
}

.btn-secondary {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  background: var(--canvas-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background-color var(--ease);
}
.btn-secondary:hover {
  background: var(--primary-pale);
}
.btn-secondary:focus-visible {
  outline: 2px solid #9fe870;
  outline-offset: 2px;
}

.btn-tertiary {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  background: var(--canvas);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: background-color var(--ease);
}
.btn-tertiary:hover {
  background: var(--canvas-soft);
}
.btn-tertiary:focus-visible {
  outline: 2px solid #9fe870;
  outline-offset: 2px;
}

/* ── Stat Cards ── */
.stat-card {
  background: var(--canvas);
  border-radius: var(--radius-card);
  padding: var(--pad-card);
}
.stat-value {
  font-size: 32px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.stat-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* ── Code blocks ── */
code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.85em;
  background: var(--canvas-soft);
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--ink);
}

/* ── Copy button ── */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--canvas-soft);
  color: var(--ink);
  border-radius: var(--radius-input);
  border: none;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--ease);
}
.copy-btn:hover {
  background: var(--primary-pale);
}
.copy-btn:focus-visible {
  outline: 2px solid #9fe870;
  outline-offset: 2px;
}
.copy-btn.copied {
  background: var(--primary);
  color: var(--on-primary);
}

/* ── HTMX swap animations ── */
.htmx-swapping {
  opacity: 0;
  transition: opacity var(--ease);
}
.htmx-settling {
  opacity: 1;
  transition: opacity 0.25s ease;
}

/* ── Overlay ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  animation: overlayIn 0.2s forwards;
  z-index: 50;
}
@keyframes overlayIn {
  to { opacity: 1; }
}

/* ── Modal ── */
.modal-panel {
  background: var(--canvas);
  border-radius: var(--radius-card);
  padding: var(--pad-card);
  opacity: 0;
  transform: translateY(12px);
  animation: modalIn 0.2s ease forwards;
  animation-delay: 60ms;
}
@keyframes modalIn {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Page Transition ── */
@keyframes pageIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.page-enter {
  animation: pageIn 0.2s ease-out;
}

/* ── Login ── */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas-soft);
}
.login-card {
  width: 100%;
  max-width: 24rem;
  background: var(--canvas);
  border-radius: var(--radius-card);
  padding: 32px;
}
.login-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-input);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  background: var(--canvas);
  transition: border-color var(--ease);
}
.login-input:focus {
  outline: none;
  border-color: var(--primary);
}
.input-icon-wrap {
  position: relative;
}
.input-icon-wrap svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--mute);
  pointer-events: none;
}

/* ── Footer ── */
.site-footer {
  background: var(--ink);
  color: var(--canvas-soft);
  padding: 48px 24px;
  text-align: center;
  font-size: 12px;
  margin-top: auto;
}

/* ── Recommendation list items ── */
.rec-item {
  padding: 16px 20px;
  transition: background-color var(--ease);
}
.rec-item:hover {
  background: var(--primary-pale);
}

/* ── Smooth transitions on interactive elements ── */
a, button, input, select, textarea {
  transition: background-color var(--ease),
              border-color var(--ease),
              color var(--ease),
              opacity var(--ease);
}

/* ── Toast notification ── */
#status-toast {
  animation: toast-in 0.3s ease-out;
}
@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* =====================================================
   Token-backed utility classes
   These let templates stop hardcoding hex values inline.
   ===================================================== */

/* Backgrounds */
.bg-ink         { background-color: var(--ink) !important; }
.bg-canvas      { background-color: var(--canvas) !important; }
.bg-canvas-soft { background-color: var(--canvas-soft) !important; }
.bg-canvas-softer { background-color: var(--canvas-softer) !important; }
.bg-primary     { background-color: var(--primary) !important; }
.bg-primary-pale { background-color: var(--primary-pale) !important; }
.bg-positive-pale { background-color: var(--primary-pale) !important; }
.bg-warning-pale { background-color: var(--warning-pale) !important; }
.bg-negative-pale { background-color: var(--negative-pale) !important; }
.bg-info-pale   { background-color: var(--info-pale) !important; }
.bg-plum-pale   { background-color: var(--plum-pale) !important; }

/* Text colors */
.text-ink       { color: var(--ink) !important; }
.text-body      { color: var(--body) !important; }
.text-mute      { color: var(--mute) !important; }
.text-mute-soft { color: var(--mute-soft) !important; }
.text-primary   { color: var(--primary) !important; }
.text-positive  { color: var(--positive) !important; }
.text-positive-deep { color: var(--positive-deep) !important; }
.text-warning-deep { color: var(--warning-deep) !important; }
.text-negative  { color: var(--negative) !important; }
.text-negative-deep { color: var(--negative-deep) !important; }
.text-info-deep { color: var(--info-deep) !important; }
.text-plum-deep { color: var(--plum-deep) !important; }

/* Borders */
.border-canvas-soft { border-color: var(--canvas-soft) !important; }
.border-ink     { border-color: var(--ink) !important; }
.border-primary { border-color: var(--primary) !important; }

/* Composite badge utilities — common combos */
.badge-soon {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--primary-pale);
  color: var(--positive-deep);
}
.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-pale);
  color: var(--positive-deep);
}
.badge-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* =====================================================
   Sticky table headers + responsive table behavior
   ===================================================== */

.table-premium {
  position: relative;
}
.table-premium thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
.table-premium thead th {
  background: var(--canvas-soft);
}

/* Generic sticky thead for ad-hoc tables that opt in. */
table.sticky-head thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
table.sticky-head thead th {
  background: var(--canvas-soft);
}

/* Compact table behavior below 720px: hide opt-out columns
   (any cell tagged .col-secondary) so the table doesn't squeeze. */
@media (max-width: 720px) {
  .col-secondary { display: none; }
}

/* =====================================================
   Skeleton loader
   ===================================================== */

.skeleton {
  display: inline-block;
  background: linear-gradient(90deg,
    var(--canvas-soft) 0%,
    var(--canvas-softer) 50%,
    var(--canvas-soft) 100%);
  background-size: 200% 100%;
  border-radius: 8px;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
}
.skeleton-line {
  height: 12px;
  width: 100%;
  border-radius: 6px;
}
.skeleton-line.short { width: 40%; }
.skeleton-line.mid   { width: 65%; }
.skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--canvas-soft);
}
.skeleton-row .skeleton:first-child {
  flex: 0 0 32px;
  height: 12px;
}
.skeleton-row .skeleton:nth-child(2) {
  flex: 1 1 auto;
  height: 14px;
}
.skeleton-row .skeleton:nth-child(3) {
  flex: 0 0 70px;
  height: 12px;
}
@keyframes skeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .badge-live::before { animation: none; }
}

/* =====================================================
   Spinner (used inside the Run Analysis button)
   ===================================================== */

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spinnerRotate 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spinnerRotate {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
}

button.is-loading {
  opacity: 0.8;
  pointer-events: none;
}

/* =====================================================
   Breadcrumbs
   ===================================================== */

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--body);
}
.breadcrumb a {
  color: var(--body);
  text-decoration: none;
  transition: color var(--ease);
}
.breadcrumb a:hover {
  color: var(--ink);
  text-decoration: underline;
}
.breadcrumb .crumb-sep {
  color: var(--mute-soft);
  font-size: 12px;
  user-select: none;
}
.breadcrumb [aria-current="page"] {
  color: var(--mute);
}

/* =====================================================
   Recommendation TOC (right rail on the detail page)
   ===================================================== */

.rec-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}
@media (min-width: 1100px) {
  .rec-layout { grid-template-columns: minmax(0, 1fr) 220px; }
}
.rec-toc {
  display: none;
  font-size: 12px;
}
@media (min-width: 1100px) {
  .rec-toc {
    display: block;
    position: sticky;
    top: 24px;
    align-self: start;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 4px 0;
  }
}
.rec-toc-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 12px 8px;
}
.rec-toc a {
  display: block;
  padding: 7px 12px;
  border-left: 2px solid transparent;
  color: var(--body);
  text-decoration: none;
  border-radius: 0 8px 8px 0;
  transition: background-color var(--ease), color var(--ease), border-color var(--ease);
}
.rec-toc a:hover {
  background: var(--canvas-soft);
  color: var(--ink);
}
.rec-toc a.is-active {
  background: var(--primary-pale);
  color: var(--positive-deep);
  border-left-color: var(--primary);
  font-weight: 600;
}

/* =====================================================
   Empty state
   ===================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 32px;
  background: var(--canvas);
  border-radius: var(--radius-card);
  gap: 14px;
}
.empty-state-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary-pale);
  color: var(--positive-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.empty-state-icon svg {
  width: 32px;
  height: 32px;
  opacity: 0.85;
}
.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.empty-state-body {
  font-size: 13px;
  color: var(--mute);
  max-width: 320px;
}

/* =====================================================
   Coming Soon (sidebar) — full opacity, soft branded badge.
   Item stays prominent but clearly non-interactive.
   ===================================================== */

.soon-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--body);
  pointer-events: none;
  user-select: none;
}
.soon-item .soon-icon,
svg.soon-icon {
  /* Explicit so the SVG can't stretch to its flex parent when the
     sidebar expands to full width on mobile. */
  width: 16px !important;
  height: 16px !important;
  min-width: 16px;
  min-height: 16px;
  flex-shrink: 0;
  opacity: 0.75;
  display: inline-block;
}
.soon-item .soon-label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

/* =====================================================
   Mobile sidebar (site detail)
   At narrow widths the sidebar's sticky position would
   overflow, so let it scroll inline and shrink padding.
   ===================================================== */

@media (max-width: 900px) {
  .site-shell { flex-direction: column; }
  .site-shell aside { width: 100%; }
  .site-shell aside > div { position: static !important; }
}
