/* ============================================================
   LegalDebug.com - Styles
   Where the courtroom meets the IDE
   ============================================================ */

/* --- Custom Properties --- */
:root {
    --bg-primary: #0F1114;
    --bg-secondary: #1A1D23;
    --surface-elevated: #252830;
    --text-primary: #D4D2CB;
    --text-secondary: #8A8878;
    --accent-green: #3D5A45;
    --accent-red: #8B3A3A;
    --accent-gold: #B8943E;
    --accent-teal: #4A7C7C;
    --bg-ruling: #161820;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
    --font-code: 'JetBrains Mono', 'Fira Code', monospace;
    --font-label: 'Space Grotesk', 'Inter', sans-serif;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.75;
    font-weight: 400;
    overflow-x: hidden;
    transition: background-color 1.2s ease;
}

/* --- Custom Gavel Cursor --- */
a, button, .interactive {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Crect x='2' y='1' width='10' height='4' rx='1' fill='%23B8943E' transform='rotate(-30 7 3)'/%3E%3Crect x='6' y='5' width='2.5' height='8' rx='0.5' fill='%23B8943E'/%3E%3Crect x='4' y='12' width='7' height='2' rx='0.5' fill='%23B8943E'/%3E%3C/svg%3E") 8 8, pointer;
}

/* --- Docket Bar --- */
#docket-bar {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    background-color: var(--surface-elevated);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#docket-progress-track {
    position: absolute;
    left: 4px;
    top: 0;
    width: 3px;
    height: 100%;
    background-color: rgba(61, 90, 69, 0.2);
}

#docket-progress-fill {
    width: 100%;
    height: 0%;
    background-color: var(--accent-green);
    transition: height 0.3s ease, background-color 0.5s ease;
}

#docket-number {
    font-family: var(--font-code);
    font-size: 11px;
    color: var(--text-secondary);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    letter-spacing: 0.1em;
}

/* --- Amendment Trail --- */
#amendment-trail {
    position: fixed;
    left: 48px;
    top: 0;
    width: 60px;
    height: 100vh;
    z-index: 50;
    pointer-events: none;
}

#trail-trunk,
.trail-branch {
    stroke-dasharray: 3000;
    stroke-dashoffset: 3000;
    transition: stroke-dashoffset 0.6s ease-in-out;
}

.trail-merge {
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* --- Sections --- */
.case-section {
    min-height: 100vh;
    padding-left: 108px;
    padding-right: 40px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* --- The Bench (Hero) --- */
#the-bench {
    align-items: center;
    background: radial-gradient(ellipse at center, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    overflow: hidden;
}

#seal-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
}

#seal-watermark svg {
    width: 100%;
    height: 100%;
}

.bench-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

/* Wordmark */
#wordmark {
    font-family: var(--font-display);
    font-size: 72px;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: -0.02em;
    margin-bottom: 32px;
}

#wordmark .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
}

#wordmark .letter.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Terminal tagline */
#terminal-line {
    font-family: var(--font-code);
    font-size: 18px;
    color: var(--accent-green);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 28px;
}

#tagline {
    color: var(--text-secondary);
}

.cursor-blink {
    animation: blink 1s infinite;
    color: var(--accent-green);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Ruling Lines --- */
.ruling-line {
    width: 100%;
    margin-bottom: 48px;
    overflow: hidden;
}

.ruling-svg {
    width: 100%;
    height: 20px;
}

.ruling-marker {
    font-family: var(--font-code);
    font-size: 14px;
    fill: var(--text-secondary);
}

.ruling-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
}

.ruling-path.animate {
    animation: drawLine 0.6s ease-in-out forwards;
}

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

/* --- Case File Grid (Bento Box) --- */
.case-file-grid {
    display: grid;
    grid-template-columns: 1fr 3fr 1fr;
    gap: 32px;
    max-width: 1200px;
    width: 100%;
}

.annotation-left,
.annotation-right {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-top: 60px;
}

.annotation-text {
    font-family: var(--font-code);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    display: block;
    transition: color 0.3s ease, border-color 0.3s ease;
    border-left: 1px solid transparent;
    padding-left: 8px;
}

.annotation-text:hover {
    color: var(--text-primary);
    border-left-color: var(--accent-green);
}

/* Progressive disclosure for annotations */
.fade-in-annotation {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    will-change: transform, opacity;
}

.annotation-left .fade-in-annotation {
    transform: translateX(-20px);
}

.fade-in-annotation.visible {
    opacity: 1;
    transform: translateX(0);
}

/* --- Primary Content --- */
.primary-content {
    max-width: 65ch;
}

.section-heading {
    font-family: var(--font-display);
    font-size: 40px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 32px;
}

.body-text {
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 24px;
    font-weight: 400;
}

.body-text em {
    font-weight: 600;
    font-style: italic;
    color: var(--accent-teal);
}

.body-text code {
    font-family: var(--font-code);
    font-size: 15px;
    background-color: var(--surface-elevated);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--accent-gold);
}

/* --- Redaction Bar Reveal --- */
.redact-reveal {
    position: relative;
    overflow: hidden;
}

.redact-reveal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    z-index: 1;
    transform-origin: left;
}

.redact-reveal.revealed::before {
    animation: declassify 0.8s ease-out forwards;
}

@keyframes declassify {
    from { width: 100%; }
    to { width: 0; }
}

/* --- Terminal Exhibit --- */
.terminal-exhibit {
    width: 100%;
    margin: 32px 0;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-secondary);
    border: 1px solid var(--surface-elevated);
}

.terminal-titlebar {
    background-color: var(--surface-elevated);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.terminal-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.terminal-dot.red { background-color: var(--accent-red); }
.terminal-dot.gold { background-color: var(--accent-gold); }
.terminal-dot.green { background-color: var(--accent-green); }

.terminal-title {
    font-family: var(--font-code);
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: 12px;
}

.terminal-body {
    padding: 24px;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 23px,
        var(--surface-elevated) 23px,
        var(--surface-elevated) 24px
    );
}

/* --- Diff View --- */
.diff-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.diff-old .diff-line {
    background-color: rgba(139, 58, 58, 0.15);
}

.diff-new .diff-line {
    background-color: rgba(61, 90, 69, 0.15);
}

.diff-line {
    font-family: var(--font-code);
    font-size: 14px;
    line-height: 24px;
    padding: 2px 8px;
    display: flex;
    gap: 12px;
    border-radius: 2px;
}

.line-num {
    color: var(--text-secondary);
    user-select: none;
    min-width: 20px;
    text-align: right;
}

.diff-marker {
    font-weight: 700;
    user-select: none;
}

.diff-old .diff-marker {
    color: var(--accent-red);
}

.diff-new .diff-marker {
    color: var(--accent-green);
}

.diff-old .diff-line {
    color: var(--text-primary);
    text-decoration: line-through;
    text-decoration-color: var(--accent-red);
}

.diff-new .diff-line {
    color: var(--text-primary);
}

/* --- Log View --- */
.log-view {
    font-family: var(--font-code);
    font-size: 14px;
}

.log-line {
    display: flex;
    gap: 12px;
    padding: 2px 8px;
    line-height: 24px;
}

.log-warn {
    color: var(--accent-gold);
    font-weight: 700;
}

.log-info {
    color: var(--accent-teal);
    font-weight: 700;
}

.log-success {
    color: var(--accent-green);
    font-weight: 700;
}

/* --- The Ruling --- */
#the-ruling {
    background-color: var(--bg-ruling);
    align-items: center;
    padding-top: 80px;
    padding-bottom: 80px;
    transition: background-color 1.2s ease;
}

#the-ruling .seal-pulse {
    animation: sealPulse 3s ease-in-out;
}

@keyframes sealPulse {
    0% { opacity: 0.04; }
    50% { opacity: 0.08; }
    100% { opacity: 0.04; }
}

.ruling-content {
    max-width: 680px;
    margin: 0 auto;
}

.ruling-heading {
    font-family: var(--font-display);
    font-size: 44px;
    font-weight: 600;
    color: var(--accent-gold);
    letter-spacing: -0.02em;
    margin-bottom: 48px;
    text-align: center;
}

.ruling-text {
    font-family: var(--font-body);
    font-size: 22px;
    line-height: 1.8;
    color: var(--text-primary);
    font-weight: 400;
    margin-bottom: 32px;
}

.ruling-closing {
    font-weight: 600;
    color: var(--accent-gold);
    text-align: center;
    margin-top: 48px;
    font-style: italic;
}

/* --- Docket Closes --- */
#docket-closes {
    min-height: 50vh;
    align-items: center;
}

.closing-content {
    text-align: center;
}

#closing-terminal {
    font-family: var(--font-code);
    font-size: 20px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.terminal-prompt {
    color: var(--accent-green);
}

/* --- Progress bar flash --- */
#docket-progress-fill.complete {
    background-color: var(--accent-gold);
    transition: background-color 0.3s ease;
}

#docket-progress-fill.complete-return {
    background-color: var(--accent-green);
    transition: background-color 0.5s ease 0.5s;
}

/* --- Responsive (below 768px) --- */
@media (max-width: 768px) {
    .case-section {
        padding-left: 56px;
        padding-right: 16px;
    }

    #docket-bar {
        width: 40px;
    }

    #amendment-trail {
        left: 40px;
        width: 40px;
    }

    .case-file-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .annotation-left,
    .annotation-right {
        padding-top: 0;
        padding-bottom: 16px;
        border-left: 2px solid var(--surface-elevated);
        padding-left: 12px;
    }

    .fade-in-annotation {
        transform: translateX(0) !important;
    }

    #wordmark {
        font-size: 48px;
    }

    .section-heading {
        font-size: 28px;
    }

    .ruling-heading {
        font-size: 32px;
    }

    .ruling-text {
        font-size: 18px;
    }

    .diff-view {
        grid-template-columns: 1fr;
    }

    #terminal-line {
        font-size: 14px;
    }

    #seal-watermark {
        width: 280px;
        height: 280px;
    }
}

/* --- Gavel strike animation --- */
@keyframes gavelStrike {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(-15deg); }
    100% { transform: rotate(0deg); }
}

.gavel-strike {
    animation: gavelStrike 0.15s ease-out;
}

/* --- Section labels --- */
.section-label {
    font-family: var(--font-label);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* --- Scrollbar styling --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-elevated);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-green);
}

/* --- Selection --- */
::selection {
    background-color: rgba(184, 148, 62, 0.3);
    color: var(--text-primary);
}

/* --- Links --- */
a {
    color: var(--accent-teal);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-gold);
}
