/* ===== J1939-specific Styles ===== */

/* Hero SVG */
.circuit-node {
    fill: var(--accent);
    opacity: 0;
    animation: fadeIn 0.4s ease forwards;
    animation-delay: 0.5s;
}
.circuit-node:nth-child(9) { animation-delay: 0.4s; }
.circuit-node:nth-child(10) { animation-delay: 0.6s; }
.circuit-node:nth-child(11) { animation-delay: 0.8s; }
.circuit-node:nth-child(12) { animation-delay: 1.0s; }

.term-resistor { fill: var(--bg-card); stroke: var(--orange); stroke-width: 1.5; }
.term-label { fill: var(--orange); font-size: 8px; text-anchor: middle; dominant-baseline: middle; }
.bus-label { fill: var(--accent); font-size: 9px; font-weight: 600; }
.bus-label-l { fill: var(--accent-dim); font-size: 9px; font-weight: 600; }
.ecu-box { fill: var(--bg-card); stroke: var(--accent); stroke-width: 2; }
.ecu-label { fill: var(--accent); font-size: 12px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }

/* ===== Role Cards ===== */
.roles-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
.role-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.role-card:active { border-color: var(--accent-dim); }
.role-icon { font-size: 24px; margin-bottom: 8px; }
.role-name { font-size: 14px; color: var(--text-bright); margin-bottom: 4px; }
.role-desc { font-size: 12px; color: var(--text-dim); }

/* ===== Data Table ===== */
.data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 400px;
}
.data-table th {
    background: var(--bg-card);
    color: var(--text-dim);
    font-weight: 600;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.data-table tr:hover { background: rgba(0, 200, 255, 0.03); }
.row-label { font-weight: 600; color: var(--text-bright); white-space: nowrap; }
.row-active { background: rgba(0, 200, 255, 0.05); }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); font-weight: 600; }
.highlight-col { color: var(--accent); font-weight: 600; }

/* ===== Variant Cards ===== */
.variant-cards {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.variant-card {
    flex: 1;
    min-width: 140px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.variant-voltage {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}
.variant-name { font-size: 13px; color: var(--text-bright); margin-bottom: 4px; }
.variant-target { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.pdu-detail {
    font-size: 11px;
    color: var(--text-dim);
    text-align: left;
    padding: 4px 0;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}
.detail-label {
    font-weight: 600;
    color: var(--text);
    font-size: 12px;
}

/* ===== Standard Cards ===== */
.standard-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
.standard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.standard-card h3 { font-size: 16px; color: var(--accent); margin-bottom: 4px; }
.std-fullname { font-size: 11px; color: var(--text-dim); margin-bottom: 10px; }
.standard-card p { font-size: 12px; line-height: 1.7; }

/* ===== Competitor Grid (PGN cards) ===== */
.competitor-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
.competitor-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.competitor-card h3 { font-size: 16px; color: var(--text-bright); margin-bottom: 4px; }
.comp-product { font-size: 12px; color: var(--accent); margin-bottom: 2px; }
.comp-target { font-size: 11px; color: var(--text-dim); margin-bottom: 10px; }
.comp-features { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.comp-tag {
    font-size: 10px;
    padding: 2px 7px;
    background: var(--accent-glow);
    border: 1px solid var(--accent-dim);
    border-radius: 12px;
    color: var(--accent);
}
.comp-highlight { font-size: 12px; color: var(--text-dim); font-style: italic; }

/* ===== Timeline ===== */
.timeline { }
.timeline-item {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-left: 2px solid var(--accent-dim);
    padding-left: 16px;
    margin-left: 8px;
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 12px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}
.timeline-year {
    font-weight: 700;
    color: var(--accent);
    font-size: 13px;
    min-width: 44px;
}
.timeline-event { font-size: 12px; color: var(--text); }

/* ===== Dev Flow ===== */
.dev-flow { }
.flow-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.flow-num {
    width: 26px; height: 26px;
    background: var(--accent);
    color: var(--bg-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.flow-text { font-size: 12px; }
.flow-step-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.flow-step-body small { font-size: 10px; color: var(--text-dim); }

/* ===== Feature List ===== */
.feature-list { list-style: none; }
.feature-list li {
    padding: 6px 0 6px 18px;
    position: relative;
    font-size: 13px;
}
.feature-list li::before {
    content: '\25b8';
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* ===== Code Block ===== */
.code-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    overflow-x: auto;
}
.code-block code {
    font-size: 12px;
    color: var(--green);
    word-break: break-all;
}
.hex-value {
    font-family: 'Consolas', 'Courier New', monospace;
    color: var(--green);
    background: rgba(0, 230, 118, 0.08);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 12px;
}

/* ===== Info Card ===== */
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 12px;
}

/* ===== SVG Diagrams ===== */
.svg-diagram {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.bitfield-svg { width: 100%; min-width: 500px; display: block; margin: 0 auto; }
.bf-label {
    font-size: 11px;
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: middle;
}
.bf-bits {
    font-size: 10px;
    text-anchor: middle;
    fill: var(--text-dim);
    font-family: 'Consolas', monospace;
}
.bf-anim { opacity: 0; animation: fadeIn 0.4s ease forwards; }
.pgn-bracket-label {
    fill: var(--accent);
    font-size: 11px;
    text-anchor: middle;
    font-weight: 600;
}

/* Sequence SVG */
.sequence-svg { width: 100%; min-width: 400px; display: block; margin: 0 auto; }
.seq-actor { fill: var(--text-bright); font-size: 13px; font-weight: 700; text-anchor: middle; }
.seq-msg { fill: var(--accent); font-size: 11px; font-weight: 600; text-anchor: middle; }
.seq-data { fill: var(--green); }
.seq-detail { fill: var(--text-dim); font-size: 9px; text-anchor: middle; }
.seq-timing { fill: var(--orange); font-size: 9px; }
.seq-dots { fill: var(--text-dim); font-size: 16px; text-anchor: middle; }
.seq-complete { fill: var(--text-dim); font-size: 11px; text-anchor: middle; font-style: italic; }
.seq-line { stroke-dasharray: 400; stroke-dashoffset: 400; }
.seq-anim { opacity: 0; animation: seqDraw 0.5s ease forwards; }
@keyframes seqDraw { to { opacity: 1; stroke-dashoffset: 0; } }

/* Priority bar chart */
.priority-svg { width: 100%; min-width: 400px; display: block; margin: 0 auto; }
.pri-label { fill: var(--text-bright); font-size: 14px; font-weight: 700; dominant-baseline: middle; }
.pri-bar { opacity: 0; }
.pri-bar-anim { animation: barGrow 0.6s ease forwards; }
@keyframes barGrow { from { opacity: 0; width: 0; } to { opacity: 0.35; } }
.pri-usage { fill: var(--text-dim); font-size: 11px; dominant-baseline: middle; }

/* ===== Decode Example ===== */
.decode-example {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.decode-example h3 {
    font-size: 15px;
    color: var(--text-bright);
    margin-bottom: 10px;
    border-left: none;
    padding-left: 0;
}
.decode-id { margin-bottom: 12px; font-size: 13px; }
.decode-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.decode-field {
    background: var(--bg-dark);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 6px 10px;
    min-width: 100px;
    flex: 1;
}
.decode-fname {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.decode-fval {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-bright);
    font-family: 'Consolas', monospace;
}
.decode-fmean { font-size: 10px; color: var(--text-dim); }

/* ===== Calc Example ===== */
.calc-example {
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--bg-dark);
    border-radius: var(--radius);
    font-size: 12px;
}

/* ===== CAN Comparison Table ===== */
.can-compare-table { min-width: 500px; }

/* ===== Desktop ===== */
@media (min-width: 768px) {
    .roles-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
    .standard-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
    .competitor-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

    .data-table { font-size: 13px; }
    .data-table th { padding: 10px 12px; }
    .data-table td { padding: 10px 12px; }
    .data-table-wrap { margin: 0; padding: 0; }

    .variant-card { padding: 24px; min-width: 180px; }
    .variant-voltage { font-size: 28px; }

    .decode-field { min-width: 120px; padding: 8px 14px; }
    .decode-fval { font-size: 14px; }

    .detail-label { font-size: 13px; }
    .hex-value { font-size: 13px; }

    .bitfield-svg { min-width: 0; max-width: 740px; }
    .sequence-svg { min-width: 0; max-width: 520px; }
    .priority-svg { min-width: 0; max-width: 600px; }
    .svg-diagram { padding: 20px; }
}
