/* ============================================
   courthouse.stream — Procedural Minimalism
   Single typeface: IBM Plex Mono
   Palette: #FFFFFF, #0D0D0D, #888888, #8B0000, #333333, #FFFDE7
   ============================================ */

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

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

body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    color: #0D0D0D;
    background-color: #FFFFFF;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background-color: #FFFDE7;
    color: #0D0D0D;
}

/* --- Entry Screen --- */
#entry-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #FFFFFF;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    padding-top: 20vh;
    transition: opacity 600ms ease;
}

#entry-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

#entry-screen.removed {
    display: none;
}

#entry-column {
    width: 60ch;
    max-width: 90vw;
}

#typing-line-entry {
    width: 100%;
    height: 1px;
    background: #333333;
    transform: scaleX(0);
    transform-origin: left;
    margin-bottom: 1.5rem;
}

#typing-line-entry.animate {
    animation: drawLine 600ms ease forwards;
}

@keyframes drawLine {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

#entry-title {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #0D0D0D;
    line-height: 1.75;
    min-height: 1.75em;
    position: relative;
    white-space: nowrap;
}

#entry-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #888888;
    line-height: 1.75;
    min-height: 1.75em;
    margin-top: 0.5rem;
    position: relative;
    white-space: nowrap;
}

/* Inline cursor for entry typing */
.entry-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: #8B0000;
    vertical-align: text-bottom;
    animation: cursorBlink 530ms step-end infinite;
    margin-left: 1px;
}

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

/* --- Main Transcript --- */
#transcript {
    position: relative;
    padding-bottom: 6rem;
}

#transcript.hidden {
    opacity: 0;
    visibility: hidden;
}

#transcript.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 400ms ease;
}

/* --- Transcript Column --- */
.transcript-column {
    max-width: 60ch;
    margin: 0 auto;
    padding: 0 1.5rem;
    position: relative;
}

/* --- Header --- */
#transcript-header {
    padding-top: 4.5rem;
    padding-bottom: 1.5rem;
}

.header-title {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #0D0D0D;
    line-height: 1.75;
}

.header-rule {
    width: 100%;
    height: 1px;
    background: #333333;
    margin: 1rem 0;
}

.header-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filed-date,
.docket-number {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    letter-spacing: 0.04em;
    color: #888888;
    text-transform: uppercase;
}

/* --- Section Dividers --- */
.section-divider {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: #333333;
}

.divider-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #333333;
    white-space: nowrap;
}

/* --- Section Markers --- */
.section-marker-area {
    position: absolute;
    left: -2rem;
    margin-top: -0.2rem;
}

.section-marker.square {
    display: block;
    width: 6px;
    height: 6px;
    background: #0D0D0D;
}

.section-marker.circle {
    display: block;
    width: 4px;
    height: 4px;
    border: 1px solid #333333;
    border-radius: 50%;
}

.section-marker.triangle {
    display: block;
    width: 0;
    height: 0;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    border-left: 5px solid #8B0000;
}

/* Active section triangle */
.transcript-section.active .section-marker-area .section-marker.square {
    display: none;
}

.transcript-section.active .section-marker-area::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    border-left: 5px solid #8B0000;
}

/* --- Transcript Sections --- */
.transcript-section {
    padding: 4.5rem 0 0 0;
    position: relative;
    counter-reset: line-counter;
}

/* --- Content --- */
.section-content p {
    margin-bottom: 1.5rem;
    position: relative;
    counter-increment: line-counter;
}

/* Line numbers via counter at every 5th paragraph */
.section-content p:nth-child(5n)::before {
    content: counter(line-counter);
    position: absolute;
    left: -4ch;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    letter-spacing: 0.04em;
    color: #888888;
    text-align: right;
    width: 3ch;
}

/* Line numbers visible on all sections using a global counter approach */
.transcript-section {
    counter-increment: section-line-counter;
}

/* --- Bracket References (Links) --- */
.bracket-ref {
    color: #0D0D0D;
    cursor: pointer;
    text-decoration: none;
    transition: color 150ms ease;
    position: relative;
}

.bracket-ref:hover {
    color: #8B0000;
}

.bracket-ref:hover::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 1px;
    background: #8B0000;
}

/* --- Typing Cursor --- */
#typing-cursor {
    position: absolute;
    width: 2px;
    height: 1.2em;
    background: #8B0000;
    animation: cursorBlink 530ms step-end infinite;
    z-index: 100;
    pointer-events: none;
    display: none;
}

#typing-cursor.visible {
    display: block;
}

/* --- Typing line (horizontal tracker) --- */
.typing-line-tracker {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: #333333;
    z-index: 50;
    pointer-events: none;
    transition: top 400ms ease;
}

/* --- Typed content visibility --- */
.section-content[data-typeable] {
    visibility: hidden;
}

.section-content[data-typeable].typing-active,
.section-content[data-typeable].typing-complete {
    visibility: visible;
}

.section-content[data-typeable] .char-hidden {
    visibility: hidden;
}

.section-content[data-typeable] .char-visible {
    visibility: visible;
}

/* Upcoming content faint preview */
.section-content[data-typeable].preview {
    visibility: visible;
    opacity: 0.08;
}

/* --- Margin Annotations --- */
.margin-annotations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.margin-dot-cluster {
    position: absolute;
    display: flex;
    gap: 4px;
}

.margin-dot {
    display: block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #888888;
}

.margin-line-mark {
    position: absolute;
    width: 8px;
    height: 1px;
    background: #888888;
}

/* --- Recording Indicator --- */
#recording-indicator {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 2000;
}

#recording-dot {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8B0000;
    animation: cursorBlink 530ms step-end infinite;
}

#recording-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    color: #888888;
    text-transform: uppercase;
}

/* --- Line Numbers (global approach) --- */
#transcript {
    counter-reset: global-line;
}

.section-content p {
    counter-increment: global-line;
}

.transcript-section:first-of-type .section-content p:first-child::before,
.section-content p:nth-child(5n)::before {
    content: counter(global-line);
    position: absolute;
    left: -4ch;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    letter-spacing: 0.04em;
    color: #888888;
    text-align: right;
    width: 3ch;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .transcript-column {
        max-width: 90vw;
        padding: 0 1rem;
    }

    #entry-column {
        width: 90vw;
    }

    .section-marker-area {
        left: -1.2rem;
    }

    .section-content p::before {
        display: none !important;
    }

    .margin-annotations {
        display: none;
    }

    #entry-screen {
        padding-top: 12vh;
    }
}

/* --- Print Stylesheet --- */
@media print {
    #entry-screen,
    #recording-indicator,
    #typing-cursor,
    .typing-line-tracker,
    .margin-annotations {
        display: none !important;
    }

    #transcript {
        opacity: 1 !important;
        visibility: visible !important;
    }

    .section-content[data-typeable] {
        visibility: visible !important;
        opacity: 1 !important;
    }

    .section-content[data-typeable] .char-hidden {
        visibility: visible !important;
    }

    body {
        color: #000000;
        background: #FFFFFF;
        font-size: 11pt;
    }

    .transcript-column {
        max-width: 100%;
    }

    .section-content p::before {
        color: #000000 !important;
    }

    @page {
        margin: 2.5cm;
        @bottom-center {
            content: "Page " counter(page) " of " counter(pages);
            font-family: 'IBM Plex Mono', monospace;
            font-size: 9pt;
        }
    }
}
