/* =========================================================================
   RelevancyLens shared design system
   Layered on top of Tailwind + daisyUI (loaded via CDN in each template).
   Defines brand tokens, the custom classes templates reference
   (gradient-text, hero-gradient, tier-badge, ...), and global polish.
   ========================================================================= */

/* Inter is loaded via <link> tags in each template head (preconnect +
   400/600/700 subset) instead of a render-blocking @import here. */

:root {
    /* Two colors only: one main (indigo) + one accent (cyan).
       The hero gradient is a single-hue indigo ramp. */
    --brand-1: #4f46e5;   /* indigo-600 (main) */
    --brand-2: #4338ca;   /* indigo-700 */
    --brand-3: #3730a3;   /* indigo-800 */
    --brand-gradient: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-3) 100%);
    --ring: rgba(79, 70, 229, 0.32);
    --shadow-soft: 0 10px 30px -12px rgba(17, 24, 39, 0.16);
    --shadow-lift: 0 18px 40px -16px rgba(79, 70, 229, 0.38);
}

/* ---------- Brand theme ----------
   Re-skin daisyUI's semantic tokens so the whole app inherits the brand.
   Color carries meaning: indigo/violet = brand & actions; green/amber/red are
   reserved for relevancy scores and system states only. Loaded after daisyUI
   (and unlayered), so these win. */
[data-theme="light"] {
    --color-primary: #4f46e5;
    --color-primary-content: #ffffff;
    /* Only one accent (cyan); secondary maps to it so there are just two hues. */
    --color-secondary: #0891b2;
    --color-secondary-content: #ffffff;
    --color-accent: #0891b2;          /* cyan — the single accent, used sparingly */
    --color-accent-content: #ffffff;
    --color-neutral: #1e293b;
    --color-neutral-content: #ffffff;
    --color-base-100: #ffffff;
    --color-base-200: #f5f6f9;
    --color-base-300: #e6e8ee;
    --color-base-content: #1e2433;
    --color-info: #4f46e5;
    --color-info-content: #ffffff;
    --color-success: #16a34a;
    --color-success-content: #ffffff;
    --color-warning: #d97706;
    --color-warning-content: #ffffff;
    --color-error: #dc2626;
    --color-error-content: #ffffff;
}

/* ---------- Base typography ---------- */
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.011em;
}

h1, h2, h3, .card-title { letter-spacing: -0.02em; }
h1 { line-height: 1.08; }

/* ---------- Brand gradients ---------- */
.hero-gradient,
.tier-gradient {
    background: var(--brand-gradient);
    background-size: 180% 180%;
    animation: gradientShift 16s ease infinite;
}

@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Subtle radial glow overlay for hero sections */
.hero-gradient::after,
.tier-gradient::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1100px 480px at 12% -10%, rgba(255, 255, 255, 0.22), transparent 60%),
        radial-gradient(800px 420px at 100% 0%, rgba(255, 255, 255, 0.12), transparent 55%);
    pointer-events: none;
}

/* ---------- Cards & hover lift ---------- */
.card { transition: transform 0.25s ease, box-shadow 0.25s ease; }
.card.shadow-xl, .card.shadow-lg { box-shadow: var(--shadow-soft); }

.card-hover:hover,
.tier-card:hover,
.feature-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lift);
}

/* ---------- Buttons ---------- */
.btn { transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease; }
/* Gradient fill is for solid primary buttons only — outline variants keep
   their transparent background so the label stays legible. */
.btn-primary:not(.btn-outline) {
    background-image: var(--brand-gradient);
    border: none;
    box-shadow: 0 8px 20px -10px var(--ring);
}
.btn-primary:not(.btn-outline):hover { filter: brightness(1.05); transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

/* ---------- Stats band ---------- */
.stat-number {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: #ffffff;
}

/* ---------- Inputs ---------- */
.api-key-input,
.input:focus,
.input:focus-within {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
    border-color: var(--brand-2);
}
.api-key-input { font-family: 'SF Mono', ui-monospace, 'Cascadia Code', monospace; letter-spacing: 0.02em; }

/* ---------- Tier / status badges (setup page) ---------- */
.tier-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--brand-gradient);
}
.tier-free { background: linear-gradient(135deg, #ef4444, #f97316); }
.tier-1    { background: linear-gradient(135deg, #f59e0b, #f97316); }
.tier-2    { background: linear-gradient(135deg, #10b981, #059669); }
.tier-4    { background: linear-gradient(135deg, #6366f1, #8b5cf6); }

.feature-impact { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.feature-impact:hover { transform: translateY(-3px); box-shadow: var(--shadow-soft); }

/* ---------- Homepage effects ---------- */
.ai-glow { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5); animation: aiGlow 2.6s ease-in-out infinite; }
@keyframes aiGlow {
    0%, 100% { box-shadow: 0 10px 30px -10px rgba(255, 255, 255, 0.35); }
    50%      { box-shadow: 0 16px 44px -8px rgba(255, 255, 255, 0.6); }
}

.ai-pulse { animation: aiPulse 2s ease-in-out infinite; }
@keyframes aiPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.12); opacity: 0.85; }
}

.floating { animation: floating 5s ease-in-out infinite; }
@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

.feature-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    border: 1px solid rgba(99, 102, 241, 0.08);
}

/* ---------- Analyzer tab cards ---------- */
.tab-card {
    transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}
.tab-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}
.tab-card.tab-active-card {
    border-color: var(--color-primary);
    background: color-mix(in oklch, var(--color-primary) 8%, var(--color-base-100));
}

/* ---------- Analyzer question ledger ↔ page sync ---------- */
/* A passage highlighted because its question is selected in the ledger. */
.qa-chunk.qa-focus {
    background: color-mix(in oklch, var(--color-primary) 7%, transparent);
    border-left-color: var(--color-primary) !important;
    border-radius: 0.375rem;
}
/* The selected ledger card. */
.ledger-card-active {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 1px var(--color-primary);
}

/* Rubric pips: grade encoded by shape, not color alone.
   solid = strong · ring = partial · dashed hollow = missing */
.qa-pip {
    width: 9px;
    height: 9px;
    border-radius: 9999px;
    display: inline-block;
    flex-shrink: 0;
}
.qa-pip-strong  { background: var(--color-success); }
.qa-pip-partial { background: transparent; border: 2px solid var(--color-warning); }
.qa-pip-missing { background: transparent; border: 1.5px dashed var(--color-error); }

/* Ledger/passage chips: keep the badge look but guarantee a 24px+ target. */
.qa-chip {
    min-height: 1.5rem;      /* 24px at 16px root, 21px at 14px root + padding below */
    padding-block: 0.25rem;
    padding-inline: 0.5rem;
    cursor: pointer;
}

/* Mobile pane switch: below lg the workspace shows one pane at a time.
   Sync actions (select question / view passage) flip panes in JS. */
@media (max-width: 1023.98px) {
    #resultsSection[data-mobile-pane="questions"] #content-tab { display: none; }
    #resultsSection[data-mobile-pane="page"] #ledgerPane { display: none; }
}

/* ---------- Scroll reveal ---------- */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Custom scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--brand-1), var(--brand-2));
    border-radius: 9999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Accessibility ---------- */
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .reveal { opacity: 1; transform: none; }
}
