/* ESE Custom Styles */
body {
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

.material-symbols-outlined {
    font-size: 24px;
    vertical-align: middle;
}

/* Page motion */
@keyframes page-enter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes surface-enter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.995);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.page-transition {
    animation: page-enter 220ms ease-out both;
    will-change: opacity, transform;
}

.page-transition > * {
    animation: surface-enter 260ms ease-out both;
}

.page-transition > *:nth-child(2) { animation-delay: 35ms; }
.page-transition > *:nth-child(3) { animation-delay: 70ms; }
.page-transition > *:nth-child(4) { animation-delay: 105ms; }

body.is-leaving .page-transition {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 140ms ease-in, transform 140ms ease-in;
}

/* HTMX loading indicator */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.animate-spin {
    animation: spin 1s linear infinite;
}

/* Landing hero justice scale */
.justice-scale-banner {
    overflow: visible;
    background: transparent;
}

.dark .justice-scale-banner {
    background: transparent;
}

.justice-scale-svg {
    display: block;
    width: 100%;
    min-height: 420px;
    overflow: visible;
}

.justice-scale-beam {
    transform-origin: 240px 148px;
    animation: justice-beam-tilt 4.6s ease-in-out infinite;
}

.justice-scale-pan-left {
    animation: justice-pan-left 4.6s ease-in-out infinite;
}

.justice-scale-pan-right {
    animation: justice-pan-right 4.6s ease-in-out infinite;
}

.justice-scale-shine {
    animation: justice-column-shine 3.4s ease-in-out infinite;
}

.justice-scale-floor-shadow {
    transform-origin: 240px 494px;
    animation: justice-shadow-breathe 4.6s ease-in-out infinite;
}

@keyframes justice-beam-tilt {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

@keyframes justice-pan-left {
    0%, 100% { transform: translateY(14px); }
    50% { transform: translateY(-14px); }
}

@keyframes justice-pan-right {
    0%, 100% { transform: translateY(-14px); }
    50% { transform: translateY(14px); }
}

@keyframes justice-column-shine {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.75; }
}

@keyframes justice-shadow-breathe {
    0%, 100% { transform: scaleX(1); opacity: 0.42; }
    50% { transform: scaleX(1.06); opacity: 0.32; }
}

/* Smooth page transitions */
.htmx-swapping {
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}

.htmx-settling {
    animation: surface-enter 220ms ease-out both;
}

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

    .page-transition,
    .page-transition > *,
    .htmx-settling {
        animation: none !important;
    }

    .justice-scale-beam,
    .justice-scale-pan-left,
    .justice-scale-pan-right,
    .justice-scale-shine,
    .justice-scale-floor-shadow {
        animation: none !important;
    }

    body.is-leaving .page-transition {
        opacity: 1;
        transform: none;
    }
}

/* Chat scroll */
.chat-messages {
    scroll-behavior: smooth;
}

/* File upload drop zone */
.drop-zone {
    transition: all 0.2s ease;
}
.drop-zone.drag-over {
    border-color: #e06315;
    background-color: rgba(224, 99, 21, 0.05);
}

/* Triage textarea — primary-orange border, explicit focus ring */
.triage-textarea {
    border-color: rgba(224, 99, 21, 0.45);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.triage-textarea:hover {
    border-color: rgba(224, 99, 21, 0.7);
}
.triage-textarea:focus, #triage-input:focus {
    outline: none !important;
    box-shadow: none !important;
    background-color: #ffffff;
}
.dark .triage-textarea {
    border-color: rgba(224, 99, 21, 0.55);
}
.dark .triage-textarea:hover {
    border-color: rgba(224, 99, 21, 0.8);
}
.dark .triage-textarea:focus, .dark #triage-input:focus {
    background-color: #0f172a;
    outline: none !important;
    box-shadow: none !important;
}

/* Markdown body — used for streamed LLM answers and rendered chat responses */
.md-body {
    font-family: 'Newsreader', 'Source Serif 4', Georgia, ui-serif, serif;
    line-height: 1.78;
    font-size: 1.0625rem; /* 17px — easier long-form reading */
    color: rgb(51 65 85);
    text-wrap: pretty;
    font-feature-settings: "kern", "liga", "onum";
}
.dark .md-body { color: rgb(203 213 225); }
.md-body > *:first-child { margin-top: 0; }
.md-body > *:last-child { margin-bottom: 0; }
.md-body p { margin: 1.25rem 0; }
.md-body strong { font-weight: 700; color: rgb(15 23 42); }
.dark .md-body strong { color: rgb(248 250 252); }
.md-body p:has(> strong:first-child) {
    margin: 2rem 0 0.85rem;
}
.md-body p:has(> strong:first-child) + p {
    margin-top: 0.5rem;
}
.md-body p:has(> strong:only-child) {
    margin: 2rem 0 0.7rem;
}
.md-body p:has(> strong:only-child):first-child {
    margin-top: 0;
}
.md-body p > strong:only-child {
    display: block;
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.35;
    font-weight: 700;
    color: rgb(100 116 139);
    margin-bottom: 0.55rem;
}
.dark .md-body p > strong:only-child {
    color: rgb(148 163 184);
}
/* The LLM frequently opens with the entire first paragraph wrapped in **...**
   (and law-name highlights add more bold). Render the first paragraph as plain
   prose so the answer doesn't read as one giant heading. */
.md-body > p:first-child strong {
    font-weight: 400;
    color: inherit;
}
.md-body > p.answer-opening,
.md-body > p.answer-opening * {
    font-weight: 400 !important;
}
.md-body > p.answer-opening .legal-ref,
.md-body > p.answer-opening .legal-citation {
    font-weight: 700 !important;
}
.md-body > p:first-child > strong:only-child {
    display: inline;
    font-size: inherit;
    margin-bottom: 0;
}
.md-body > p:first-child:has(> strong:only-child) {
    margin: 0 0 0.95rem;
}
.md-body .legal-ref {
    font-weight: 700;
    color: rgb(15 23 42);
}
.dark .md-body .legal-ref {
    color: rgb(248 250 252);
}
.md-body .legal-citation {
    display: inline;
    font-size: 0.82em;
    font-weight: 700;
    color: #e06315;
    font-variant-numeric: tabular-nums;
    white-space: normal;
    cursor: pointer;
    border-bottom: 1px dotted rgba(224, 99, 21, 0.45);
    transition: color 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}
.md-body .legal-citation:hover,
.md-body .legal-citation:focus {
    background-color: rgba(224, 99, 21, 0.08);
    border-bottom-color: #e06315;
    outline: none;
}
.md-body .legal-citation:focus-visible {
    box-shadow: 0 0 0 2px rgba(224, 99, 21, 0.35);
    border-radius: 0.125rem;
}
.dark .md-body .legal-citation {
    color: #fb923c;
}
.md-body em { font-style: italic; }
.md-body code { background: rgba(15, 23, 42, 0.06); padding: 0.1rem 0.35rem; border-radius: 0.25rem; font-size: 0.8125rem; white-space: normal; }
.dark .md-body code { background: rgba(255, 255, 255, 0.08); color: rgb(226 232 240); }
.md-body pre { background: rgb(15 23 42); color: rgb(241 245 249); padding: 0.75rem 1rem; border-radius: 0.5rem; overflow-x: auto; margin: 1rem 0; font-size: 0.8125rem; white-space: pre-wrap; }
.md-body pre code { background: transparent; padding: 0; color: inherit; }
.md-body h1, .md-body h2, .md-body h3 {
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    color: rgb(15 23 42);
    letter-spacing: -0.01em;
}
.md-body h1 { font-size: 1.375rem; font-weight: 700; margin: 2.25rem 0 0.85rem; line-height: 1.3; }
.md-body h2 { font-size: 1.1875rem; font-weight: 500; font-style: italic; margin: 2rem 0 0.75rem; line-height: 1.35; }
.md-body h3 { font-size: 1.0625rem; font-weight: 700; margin: 1.75rem 0 0.6rem; line-height: 1.4; }
.md-body > h1:first-child, .md-body > h2:first-child, .md-body > h3:first-child { margin-top: 0; }
.dark .md-body h1, .dark .md-body h2, .dark .md-body h3 { color: rgb(248 250 252); }
.md-body ul, .md-body ol { margin: 1rem 0 1.25rem 1.5rem; padding-left: 0.25rem; }
.md-body ul { list-style: disc; }
.md-body ol { list-style: decimal; }
.md-body li { margin: 0.45rem 0; padding-left: 0.25rem; }
.md-body li > p { margin: 0.25rem 0; }
.md-body blockquote { border-left: 3px solid #e06315; padding: 0.25rem 0.75rem; margin: 0.5rem 0; color: rgb(71 85 105); background: rgba(224, 99, 21, 0.05); border-radius: 0 0.25rem 0.25rem 0; }
.dark .md-body blockquote { color: rgb(203 213 225); }
.md-body a { color: #e06315; text-decoration: underline; }
.md-body table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; font-size: 0.8125rem; }
.md-body th, .md-body td { border: 1px solid rgb(226 232 240); padding: 0.4rem 0.6rem; text-align: left; }
.dark .md-body th, .dark .md-body td { border-color: rgb(51 65 85); }
.md-body th { background: rgb(248 250 252); font-weight: 700; }
.dark .md-body th { background: rgb(30 41 59); }
.md-body hr { border: 0; border-top: 1px solid rgb(226 232 240); margin: 1rem 0; }
.dark .md-body hr { border-color: rgb(51 65 85); }
