/* === Be on time — Amber LED Display === */

/* --- Self-hosted Departure Mono (SIL OFL 1.1, see fonts/LICENSE-DepartureMono.txt) --- */
@font-face {
    font-family: 'Departure Mono';
    font-style: normal;
    font-weight: 400;
    src: url('fonts/DepartureMono-Regular.woff2') format('woff2');
    font-display: swap;
}

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

:root {
    --amber: #ff9500;
    --amber-dim: #cc7700;
    --amber-glow: rgba(255, 149, 0, 0.5);
    --amber-delay: #ff6a3a;
    --bg: #0a0a0a;
    --bg-display: #111;
    --border: #333;
    --font-display: 'Departure Mono', 'Courier New', monospace;
}

html {
    font-size: 18px;
}

body {
    background: #000;
    color: var(--amber);
    font-family: var(--font-display);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 12px;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: auto;
}

/* --- Display Frame (simulates the physical LED housing) --- */
.display-frame {
    width: 100%;
    max-width: 900px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
}

/* Scanline overlay */
.display-frame::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
    pointer-events: none;
    z-index: 10;
}

/* --- Header --- */
.display-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6em 0.8em;
    border-bottom: 1px solid var(--border);
    min-height: 2.4em;
}

.stop-name {
    font-size: 1.1em;
    font-weight: normal;
    color: var(--amber);
    text-shadow: 0 0 8px var(--amber-glow);
    cursor: pointer;
    border: none;
    background: none;
    text-align: left;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 0.5em;
    letter-spacing: 0.05em;
}

.stop-name:hover,
.stop-name:focus-visible {
    color: #ffb040;
    outline: 1px dashed var(--amber-dim);
    outline-offset: 3px;
}

.clock {
    font-size: 1.1em;
    color: var(--amber);
    text-shadow: 0 0 8px var(--amber-glow);
    white-space: nowrap;
    letter-spacing: 0.1em;
}

/* --- Search --- */
.search-container {
    padding: 0.5em 0.8em;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.search-container[hidden] {
    display: none;
}

.search-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--amber-dim);
    color: var(--amber);
    font-family: var(--font-display);
    font-size: 1em;
    padding: 0.4em 0.6em;
    outline: none;
    letter-spacing: 0.05em;
}

.search-input::placeholder {
    color: var(--amber-dim);
    opacity: 0.6;
}

.search-input:focus {
    border-color: var(--amber);
    box-shadow: 0 0 6px var(--amber-glow);
}

.search-results {
    list-style: none;
    max-height: 12em;
    overflow-y: auto;
    margin-top: 0.3em;
}

.search-results:empty {
    display: none;
}

.search-results li {
    padding: 0.4em 0.6em;
    cursor: pointer;
    color: var(--amber-dim);
    border-bottom: 1px solid #222;
    letter-spacing: 0.03em;
}

.search-locality {
    display: block;
    font-size: 0.75em;
    color: #665500;
    letter-spacing: 0.02em;
}

.search-results li:hover,
.search-results li.active {
    background: #1a1200;
    color: var(--amber);
    text-shadow: 0 0 6px var(--amber-glow);
}

/* --- Departures Table --- */
.departures-wrapper {
    padding: 0.4em 0;
    min-height: 5em;
}

.departures-header {
    display: grid;
    grid-template-columns: 3.5rem 1fr 1.8rem 3.5rem;
    gap: 0.3rem;
    padding: 0.3em 0.8rem;
    color: var(--amber-dim);
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid #222;
}

.departure-row {
    display: grid;
    grid-template-columns: 3.5rem 1fr 1.8rem 3.5rem;
    gap: 0.3rem;
    padding: 0.35em 0.8rem;
    align-items: center;
    border-bottom: 1px solid #1a1a1a;
    text-shadow: 0 0 6px var(--amber-glow);
    animation: fadeIn 0.3s ease;
}

.departure-row:last-child {
    border-bottom: none;
}

.col-line {
    font-weight: bold;
    text-align: right;
    padding-right: 0.3rem;
    letter-spacing: 0.05em;
}

.col-destination {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.03em;
}

.col-access {
    text-align: center;
    font-size: 0.9em;
    opacity: 0.7;
}

.col-access:empty {
    opacity: 0;
}

.col-time {
    text-align: right;
    font-weight: bold;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* Time states */
.col-time.departing {
    animation: blink 1s step-end infinite;
}

.col-time.delayed {
    color: var(--amber-delay);
    text-shadow: 0 0 6px rgba(255, 106, 58, 0.5);
}

/* --- Status & Error --- */
.status-message {
    text-align: center;
    padding: 2em 1em;
    color: var(--amber-dim);
    font-size: 0.9em;
    letter-spacing: 0.05em;
}

.status-message[hidden] {
    display: none;
}

.error-bar {
    padding: 0.4em 0.8em;
    background: #1a0a00;
    color: var(--amber-delay);
    font-size: 0.75em;
    text-align: center;
    border-top: 1px solid #331a00;
}

.error-bar[hidden] {
    display: none;
}

/* --- Animations --- */
@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .col-time.departing {
        animation: none;
        opacity: 1;
    }

    .departure-row {
        animation: none;
    }
}

/* --- Responsive Breakpoints --- */

/* Mobile (<600px) */
@media (max-width: 599px) {
    html { font-size: 14px; }

    body { padding: 0; }

    .display-frame {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .departures-header {
        grid-template-columns: 2.8rem 1fr 1.5rem 3rem;
    }

    .departure-row {
        grid-template-columns: 2.8rem 1fr 1.5rem 3rem;
    }
}

/* Tablet (600-900px) */
@media (min-width: 600px) and (max-width: 899px) {
    html { font-size: 18px; }
}

/* Desktop (900-1200px) */
@media (min-width: 900px) and (max-width: 1199px) {
    html { font-size: 22px; }
}

/* Large screen / display mode (>1200px) */
@media (min-width: 1200px) {
    html { font-size: 28px; }

    body {
        justify-content: center;
        min-height: 100dvh;
    }

    .display-frame {
        max-width: 1100px;
    }
}

/* --- Scrollbar styling (for search results) --- */
.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: var(--bg);
}

.search-results::-webkit-scrollbar-thumb {
    background: var(--amber-dim);
    border-radius: 3px;
}

/* --- Demo Banner --- */
.demo-banner {
    padding: 0.3em 0.8em;
    background: #1a1200;
    color: var(--amber-dim);
    font-size: 0.7em;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    border-top: 1px solid #332a00;
}
.demo-banner[hidden] { display: none; }

/* --- Token Panel --- */
.token-panel {
    width: 100%;
    max-width: 900px;
    margin: 1em auto 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 13px;
    color: #999;
    line-height: 1.6;
}
.token-panel[hidden] { display: none; }

.token-toggle {
    background: none;
    border: 1px solid #444;
    color: #bb9944;
    font-size: 13px;
    padding: 0.4em 0.8em;
    cursor: pointer;
    width: 100%;
    text-align: left;
}
.token-toggle:hover { border-color: #bb9944; }

.token-content {
    padding: 1em;
    border: 1px solid #333;
    border-top: none;
    background: #0a0a0a;
}
.token-content[hidden] { display: none; }
.token-content h3 {
    color: #ccc;
    font-size: 13px;
    margin: 1em 0 0.5em;
}
.token-content ol {
    padding-left: 1.5em;
    margin-bottom: 1em;
}
.token-content li { margin-bottom: 0.4em; }
.token-content a { color: #bb9944; text-decoration: none; }
.token-content a:hover { text-decoration: underline; }

.token-input-row {
    display: flex;
    gap: 0.5em;
    margin: 0.8em 0;
}
.token-input {
    flex: 1;
    background: #111;
    border: 1px solid #444;
    color: #ddd;
    padding: 0.5em;
    font-family: monospace;
    font-size: 12px;
}
.token-input:focus { border-color: #bb9944; outline: none; }
.token-save {
    background: #332a00;
    border: 1px solid #bb9944;
    color: #bb9944;
    padding: 0.5em 1em;
    cursor: pointer;
    font-size: 12px;
}
.token-save:hover { background: #443600; }

.token-hint {
    font-size: 11px;
    color: #666;
    margin-top: 0.5em;
}

.token-logout a { color: #997a33; text-decoration: none; }
.token-logout a:hover { text-decoration: underline; color: #bb9944; }
.token-logout[hidden] { display: none; }

/* --- Legal Footer --- */
.legal-footer {
    width: 100%;
    max-width: 900px;
    margin: 1.5em auto 0;
    padding: 0 12px 12px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 11px;
    line-height: 1.5;
    color: #666;
}

.legal-footer p {
    margin-bottom: 0.5em;
}

.legal-footer a {
    color: #997a33;
    text-decoration: none;
}

.legal-footer a:hover {
    text-decoration: underline;
    color: #bb9944;
}

.legal-footer .disclaimer {
    color: #555;
}

.legal-footer .data-source {
    color: #666;
}

/* --- Impressum --- */
.impressum {
    margin: 1em 0 0.5em;
    padding-top: 0.8em;
    border-top: 1px solid #333;
}

.impressum-toggle {
    color: #997a33;
    text-decoration: none;
}
.impressum-toggle:hover {
    color: #bb9944;
    text-decoration: underline;
}

.impressum-content {
    margin-top: 0.4em;
}
.impressum-content[hidden] { display: none; }

.impressum-logo {
    display: block;
    width: 30vw;
    max-width: 200px;
    height: auto;
    margin: 0 auto 0.3em;
    opacity: 0.7;
}

.impressum-license {
    margin-top: 0.8em;
    font-style: italic;
    color: #555;
}
