/* ============================================
   LegalDebug.com - Styles
   Dashboard diagnostic legal interface
   Palette includes: #2A3544 (body text on light surfaces, reserved)
   ============================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 0.9375rem;
    line-height: 1.65;
    color: #C0CCD8;
    background-color: #0B1120;
    overflow: hidden;
    min-height: 100vh;
}

/* ---------- Typography ---------- */
h1, h2 {
    font-family: 'Space Grotesk', sans-serif;
    color: #E8ECF1;
    letter-spacing: -0.02em;
}

h1 {
    font-weight: 700;
    font-size: 2.5rem;
}

h2 {
    font-weight: 600;
    font-size: 1.75rem;
}

h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 1.25rem;
}

/* ---------- Boot Overlay ---------- */
#boot-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #0B1120;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease-out;
}

#boot-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#boot-overlay.hidden {
    display: none;
}

#boot-svg {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}

#boot-h-line,
#boot-v-line1,
#boot-v-line2,
#boot-v-line3,
#boot-v-line4,
#boot-h-line2,
#boot-h-line3 {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
}

#boot-h-line {
    animation: drawLine 800ms 300ms ease-out forwards;
}

#boot-v-line1 {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: drawLine 400ms 1100ms ease-out forwards;
}

#boot-v-line2 {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: drawLine 400ms 1100ms ease-out forwards;
}

#boot-v-line3 {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: drawLine 400ms 1200ms ease-out forwards;
}

#boot-v-line4 {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: drawLine 400ms 1200ms ease-out forwards;
}

#boot-h-line2 {
    stroke-dasharray: 1140;
    stroke-dashoffset: 1140;
    animation: drawLine 500ms 1400ms ease-out forwards;
}

#boot-h-line3 {
    stroke-dasharray: 1140;
    stroke-dashoffset: 1140;
    animation: drawLine 500ms 1400ms ease-out forwards;
}

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

/* ---------- Circuit Background ---------- */
#circuit-bg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}

/* ---------- Dashboard Layout ---------- */
.dashboard {
    display: grid;
    grid-template-columns: 56px 1fr;
    grid-template-rows: 64px 1fr 32px;
    grid-template-areas:
        "nav header"
        "nav main"
        "nav footer";
    height: 100vh;
    width: 100vw;
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.dashboard.visible {
    opacity: 1;
}

/* ---------- Navigation Rail ---------- */
.nav-rail {
    grid-area: nav;
    background: linear-gradient(180deg, #111D2E 0%, #0E1928 100%);
    border-right: 1px solid #7B8794;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 12px;
    gap: 4px;
    position: relative;
    z-index: 100;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.nav-rail.visible {
    opacity: 1;
    transform: translateX(0);
}

.nav-logo {
    padding: 8px 0 12px;
}

.nav-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    background: none;
    border: none;
    color: #7B8794;
    cursor: pointer;
    transition: color 0.15s ease-out, transform 0.15s ease-out;
    position: relative;
}

.nav-item:hover {
    color: #4ECDC4;
    transform: scale(1.2);
}

.nav-item.active {
    color: #4ECDC4;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: #4ECDC4;
    border-radius: 0 2px 2px 0;
}

.nav-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.5625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.nav-pulse-line {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    pointer-events: none;
}

.nav-pulse-dot {
    animation: navPulse 8s linear infinite;
}

@keyframes navPulse {
    0% { cy: 0; opacity: 1; }
    100% { cy: 600; opacity: 0.3; }
}

/* ---------- Header Bar ---------- */
.header-bar {
    grid-area: header;
    background: linear-gradient(135deg, #111D2E 0%, #152238 50%, #111D2E 100%);
    border-bottom: 1px solid #7B8794;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 90;
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

.header-bar.visible {
    opacity: 1;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.wordmark {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.375rem;
    color: #E8ECF1;
    letter-spacing: -0.02em;
}

.wordmark-accent {
    color: #4ECDC4;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-green {
    background: #2ECC71;
    box-shadow: 0 0 4px 2px rgba(46, 204, 113, 0.4);
    animation: statusPulse 2s ease-in-out infinite;
}

.status-teal {
    background: #4ECDC4;
    box-shadow: 0 0 4px 2px rgba(78, 205, 196, 0.4);
}

.status-amber {
    background: #E8A317;
    box-shadow: 0 0 4px 2px rgba(232, 163, 23, 0.4);
}

@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 2px 2px rgba(46, 204, 113, 0.3); }
    50% { box-shadow: 0 0 4px 6px rgba(46, 204, 113, 0.15); }
}

.status-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6875rem;
    color: #2ECC71;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #7B8794;
    cursor: pointer;
    transition: color 0.15s ease-out, transform 0.15s ease-out, border-color 0.15s ease-out;
}

.header-icon-btn:hover {
    color: #4ECDC4;
    transform: scale(1.1);
    border-color: rgba(78, 205, 196, 0.2);
}

/* ---------- Main Content ---------- */
.main-content {
    grid-area: main;
    display: grid;
    grid-template-columns: 7fr 5fr;
    gap: 1px;
    background: #7B8794;
    overflow: hidden;
}

/* ---------- Primary Panel ---------- */
.primary-panel {
    background: #0B1120;
    overflow-y: auto;
    padding: 24px 28px;
    scrollbar-width: thin;
    scrollbar-color: #1A2A3E #0B1120;
}

.primary-panel::-webkit-scrollbar {
    width: 6px;
}

.primary-panel::-webkit-scrollbar-track {
    background: #0B1120;
}

.primary-panel::-webkit-scrollbar-thumb {
    background: #1A2A3E;
    border-radius: 3px;
}

/* ---------- Section Label ---------- */
.section-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8899AA;
    margin-bottom: 12px;
}

/* ---------- Content Section ---------- */
.content-section {
    margin-bottom: 36px;
}

/* ---------- Circuit Divider ---------- */
.circuit-divider {
    margin-bottom: 20px;
    opacity: 0.7;
}

/* ---------- Case Cards ---------- */
.case-card {
    background: linear-gradient(135deg, #111D2E 0%, #152238 50%, #111D2E 100%);
    border-radius: 4px;
    margin-bottom: 16px;
    border-left: 2px solid #7B8794;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out, box-shadow 0.2s ease-out, border-left-color 0.2s ease-out;
}

.case-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.case-card:hover {
    transform: scale(1.015);
    box-shadow: 0 0 12px 4px rgba(78, 205, 196, 0.15);
}

/* Category border colors */
.case-card[data-category="gold"] {
    border-left-color: #C9A84C;
}

.case-card[data-category="copper"] {
    border-left-color: #B87333;
}

.case-card[data-category="silver"] {
    border-left-color: #7B8794;
}

.case-card[data-category="platinum"] {
    border-left-color: #E8ECF1;
}

.case-card:hover[data-category="gold"] {
    border-left-color: #d4b85c;
}

.case-card:hover[data-category="copper"] {
    border-left-color: #c98343;
}

.case-card:hover[data-category="silver"] {
    border-left-color: #8b97a4;
}

.case-card:hover[data-category="platinum"] {
    border-left-color: #ffffff;
}

/* Card scan line effect */
.card-scan-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: #4ECDC4;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease-out;
}

.case-card.visible .card-scan-line {
    animation: scanDraw 0.2s ease-out forwards;
}

@keyframes scanDraw {
    0% { transform: scaleX(0); }
    100% { transform: scaleX(1); }
}

/* Card border fill animation */
.case-card.visible::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 0;
    animation: borderFill 0.2s 0.5s ease-out forwards;
}

.case-card[data-category="gold"].visible::after {
    background: #C9A84C;
}

.case-card[data-category="copper"].visible::after {
    background: #B87333;
}

.case-card[data-category="silver"].visible::after {
    background: #7B8794;
}

.case-card[data-category="platinum"].visible::after {
    background: #E8ECF1;
}

@keyframes borderFill {
    0% { height: 0; }
    100% { height: 100%; }
}

.card-content {
    padding: 20px 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    flex: 1;
}

.card-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6875rem;
    color: #8899AA;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(26, 42, 62, 0.8);
}

.meta-code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8125rem;
    color: #4ECDC4;
}

.meta-date {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: #7B8794;
}

/* ---------- Secondary Column ---------- */
.secondary-column {
    background: #0B1120;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #1A2A3E #0B1120;
}

.secondary-column::-webkit-scrollbar {
    width: 6px;
}

.secondary-column::-webkit-scrollbar-track {
    background: #0B1120;
}

.secondary-column::-webkit-scrollbar-thumb {
    background: #1A2A3E;
    border-radius: 3px;
}

/* ---------- Side Tiles ---------- */
.side-tile {
    background: linear-gradient(135deg, #111D2E 0%, #152238 50%, #111D2E 100%);
    padding: 20px;
    flex: 1;
    min-height: 0;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.side-tile.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Recent Traces Ticker ---------- */
.traces-ticker {
    overflow: hidden;
    height: calc(100% - 30px);
    position: relative;
}

.ticker-content {
    animation: tickerScroll 20s linear infinite;
}

@keyframes tickerScroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

.trace-entry {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(26, 42, 62, 0.5);
    font-size: 0.8125rem;
}

.trace-time {
    font-family: 'IBM Plex Mono', monospace;
    color: #7B8794;
    font-size: 0.75rem;
    white-space: nowrap;
}

.trace-msg {
    color: #C0CCD8;
    font-size: 0.8125rem;
}

.teal {
    color: #4ECDC4;
}

/* ---------- Precedent Radar ---------- */
.radar-container {
    position: relative;
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

#radar-svg {
    max-height: 220px;
}

.radar-ring {
    stroke-dasharray: 630;
    stroke-dashoffset: 630;
}

.radar-ring.drawn {
    animation: drawRing 0.4s ease-out forwards;
}

@keyframes drawRing {
    to { stroke-dashoffset: 0; }
}

.radar-node {
    transform-origin: center;
    transform: scale(0);
    transition: transform 0.15s ease-out, stroke 0.15s ease-out;
    cursor: pointer;
}

.radar-node.visible {
    transform: scale(1);
}

.radar-node:hover {
    stroke: #4ECDC4;
    transform: scale(1.5);
}

.radar-connection {
    transition: opacity 0.3s ease-out;
}

.radar-connection.visible {
    opacity: 0.5;
}

.radar-connection.highlight {
    opacity: 1;
    stroke-width: 1.5;
    filter: drop-shadow(0 0 3px rgba(78, 205, 196, 0.5));
}

.radar-tooltip {
    position: absolute;
    background: #152238;
    border: 1px solid #4ECDC4;
    color: #E8ECF1;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6875rem;
    padding: 6px 10px;
    border-radius: 3px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease-out;
    white-space: nowrap;
    z-index: 10;
}

.radar-tooltip.active {
    opacity: 1;
}

/* ---------- Resolution Status Ring ---------- */
.ring-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}

.progress-ring {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: conic-gradient(
        #4ECDC4 0%,
        #2ECC71 0%,
        #1A2A3E 0%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.progress-ring::before {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: #111D2E;
}

.ring-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 2.25rem;
    color: #E8ECF1;
    position: relative;
    z-index: 1;
}

.ring-percent {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: #8899AA;
    position: relative;
    z-index: 1;
}

.ring-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6875rem;
    color: #8899AA;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ---------- Footer Ticker ---------- */
.footer-ticker {
    grid-area: footer;
    background: #111D2E;
    border-top: 1px solid #7B8794;
    overflow: hidden;
    display: flex;
    align-items: center;
    height: 32px;
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

.footer-ticker.visible {
    opacity: 1;
}

.ticker-track {
    display: flex;
    width: max-content;
    animation: tickerSlide 40s linear infinite;
}

@keyframes tickerSlide {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.ticker-strip {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    white-space: nowrap;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6875rem;
    color: #7B8794;
}

.ticker-sep {
    color: #1A2A3E;
}

.ticker-teal {
    color: #4ECDC4;
}

/* ---------- Mobile Bottom Tabs ---------- */
.mobile-tabs {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #111D2E;
    border-top: 1px solid #7B8794;
    justify-content: space-around;
    align-items: center;
    z-index: 200;
}

.mobile-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: #7B8794;
    cursor: pointer;
    transition: color 0.15s ease-out;
}

.mobile-tab.active {
    color: #4ECDC4;
}

/* ---------- Circuit Pulse Animation (Panel Top) ---------- */
.primary-panel {
    position: relative;
}

.primary-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #4ECDC4 50%, transparent 100%);
    background-size: 200% 100%;
    animation: circuitPulse 8s linear infinite;
    z-index: 10;
}

@keyframes circuitPulse {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ---------- Responsive: Tablet ---------- */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .secondary-column {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 1px;
        max-height: 260px;
    }

    .side-tile {
        min-width: 280px;
        flex: 0 0 280px;
    }
}

/* ---------- Responsive: Mobile ---------- */
@media (max-width: 640px) {
    .dashboard {
        grid-template-columns: 1fr;
        grid-template-rows: 56px 1fr 32px;
        grid-template-areas:
            "header"
            "main"
            "footer";
        padding-bottom: 56px;
    }

    .nav-rail {
        display: none;
    }

    .mobile-tabs {
        display: flex;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .secondary-column {
        flex-direction: column;
    }

    .side-tile {
        min-width: auto;
        flex: none;
    }

    .header-bar {
        padding: 0 16px;
    }

    .wordmark {
        font-size: 1.125rem;
    }

    .status-text {
        display: none;
    }

    .primary-panel {
        padding: 16px;
    }

    .card-content {
        padding: 16px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-header h2 {
        font-size: 1rem;
    }

    .footer-ticker {
        height: 28px;
    }

    #circuit-bg {
        opacity: 0.3;
    }
}

/* ---------- Scrollbar for secondary column (mobile) ---------- */
@media (max-width: 640px) {
    .secondary-column::-webkit-scrollbar {
        height: 4px;
    }
}
