/* ==========================================================================
   Dictionary page — Tire diagram + reference tables
   ========================================================================== */

/* --- Full dictionary wrapper --- */
.tp-dict {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 var(--tp-space-md, 16px);
}

/* --- Table of contents (sticky horizontal nav) --- */
.tp-dict-toc {
    display: flex;
    gap: var(--tp-space-xs, 4px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--tp-space-sm, 8px) 0;
    margin-bottom: var(--tp-space-xl, 32px);
    position: sticky;
    top: 70px; /* header height */
    z-index: 10;
    background: var(--tp-gray-50, #f9fafb);
    border-bottom: 1px solid var(--tp-gray-200, #e5e7eb);
    scrollbar-width: none;
}
.tp-dict-toc::-webkit-scrollbar { display: none; }

.tp-dict-toc-item {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: var(--tp-radius-md, 6px);
    font-size: var(--tp-text-sm, 14px);
    color: var(--tp-gray-600, #4b5563);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}
.tp-dict-toc-item:hover,
.tp-dict-toc-item.active {
    background: white;
    border-color: var(--tp-gray-300, #d1d5db);
    color: var(--tp-gray-900, #111827);
}

/* --- Section shared styles --- */
.tp-dict-section {
    margin-bottom: var(--tp-space-2xl, 48px);
    scroll-margin-top: 120px; /* header + TOC */
}

.tp-dict-section-title {
    font-size: var(--tp-text-xl, 20px);
    font-weight: 700;
    color: var(--tp-gray-900, #111827);
    margin-bottom: var(--tp-space-sm, 8px);
    padding-bottom: var(--tp-space-xs, 4px);
    border-bottom: 2px solid var(--tp-red, #E31837);
    display: inline-block;
}

.tp-dict-section-desc {
    font-size: var(--tp-text-base, 16px);
    color: var(--tp-gray-600, #4b5563);
    line-height: 1.7;
    margin-bottom: var(--tp-space-lg, 24px);
    max-width: 720px;
}

.tp-dict-note {
    font-size: var(--tp-text-sm, 14px);
    color: var(--tp-gray-500, #6b7280);
    margin-top: var(--tp-space-md, 16px);
    font-style: italic;
}

/* --- Speed index grid (compact 2-4 columns) --- */
.tp-dict-grid {
    display: grid;
    gap: var(--tp-space-xs, 4px);
}
.tp-dict-grid--speed {
    grid-template-columns: repeat(4, 1fr);
}

.tp-dict-grid-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--tp-gray-200, #e5e7eb);
    border-radius: var(--tp-radius-md, 6px);
    background: white;
    text-decoration: none;
    color: var(--tp-gray-700, #374151);
    font-size: var(--tp-text-sm, 14px);
    transition: all 0.15s ease;
}
.tp-dict-grid-item:hover {
    border-color: var(--tp-red, #E31837);
    color: var(--tp-red, #E31837);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.tp-dict-grid-code {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    font-size: var(--tp-text-base, 16px);
    min-width: 28px;
}
.tp-dict-grid-sep {
    color: var(--tp-gray-400, #9ca3af);
}
.tp-dict-grid-val {
    color: var(--tp-gray-600, #4b5563);
}

/* --- Tables (load index, OEM) --- */
.tp-dict-table-wrap {
    position: relative;
}

.tp-dict-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--tp-gray-300, #d1d5db);
    border-radius: var(--tp-radius-md, 6px);
    font-size: var(--tp-text-sm, 14px);
    margin-bottom: var(--tp-space-sm, 8px);
    background: white;
}
.tp-dict-search:focus {
    outline: none;
    border-color: var(--tp-primary, #1a1a1a);
    box-shadow: 0 0 0 2px rgba(26, 26, 26, 0.1);
}

.tp-dict-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--tp-text-sm, 14px);
}
.tp-dict-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--tp-gray-50, #f9fafb);
    border-bottom: 2px solid var(--tp-gray-200, #e5e7eb);
    font-weight: 600;
    color: var(--tp-gray-700, #374151);
    position: sticky;
    top: 0;
}
.tp-dict-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--tp-gray-100, #f3f4f6);
    color: var(--tp-gray-700, #374151);
}
.tp-dict-table tbody tr:hover {
    background: var(--tp-gray-50, #f9fafb);
}
.tp-dict-table td a {
    color: var(--tp-primary, #1a1a1a);
    text-decoration: none;
    font-weight: 600;
}
.tp-dict-table td a:hover {
    color: var(--tp-red, #E31837);
    text-decoration: underline;
}

/* OEM table: codes column */
.tp-dict-table--oem td:last-child {
    font-family: 'Courier New', monospace;
    font-size: var(--tp-text-sm, 14px);
}
.tp-dict-table--oem td:last-child a {
    font-weight: 400;
}

/* Expand button */
.tp-dict-expand {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: var(--tp-space-xs, 4px);
    border: 1px dashed var(--tp-gray-300, #d1d5db);
    border-radius: var(--tp-radius-md, 6px);
    background: transparent;
    color: var(--tp-gray-600, #4b5563);
    font-size: var(--tp-text-sm, 14px);
    cursor: pointer;
    transition: all 0.15s ease;
}
.tp-dict-expand:hover {
    border-color: var(--tp-gray-500, #6b7280);
    color: var(--tp-gray-900, #111827);
}
.tp-dict-expand[aria-expanded="true"] {
    display: none;
}

/* Search highlight */
.tp-dict-table tr.tp-dict-highlight td {
    background: #fef3c7;
}

/* --- EU labels grid --- */
.tp-dict-eu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--tp-space-md, 16px);
}

.tp-dict-eu-card {
    padding: var(--tp-space-lg, 24px);
    border: 1px solid var(--tp-gray-200, #e5e7eb);
    border-radius: var(--tp-radius-lg, 8px);
    background: white;
}

.tp-dict-eu-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--tp-text-base, 16px);
    font-weight: 700;
    color: var(--tp-gray-900, #111827);
    margin-bottom: var(--tp-space-sm, 8px);
}
.tp-dict-eu-card-title svg {
    color: var(--tp-gray-500, #6b7280);
    flex-shrink: 0;
}

.tp-dict-eu-card-desc {
    font-size: var(--tp-text-sm, 14px);
    color: var(--tp-gray-600, #4b5563);
    line-height: 1.6;
    margin-bottom: var(--tp-space-md, 16px);
}

.tp-dict-eu-scale {
    display: flex;
    gap: 4px;
}

.tp-dict-eu-grade {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--tp-radius-sm, 4px);
    color: white;
    font-weight: 700;
    font-size: var(--tp-text-sm, 14px);
    text-decoration: none;
    transition: transform 0.15s ease;
}
.tp-dict-eu-grade:hover {
    transform: scale(1.1);
    color: white;
}

.tp-dict-eu-scale--noise {
    flex-direction: column;
    gap: 6px;
}
.tp-dict-eu-noise-label {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--tp-radius-sm, 4px);
    background: var(--tp-gray-100, #f3f4f6);
    color: var(--tp-gray-800, #1f2937);
    font-size: var(--tp-text-sm, 14px);
    font-weight: 400;
    border: 1px solid var(--tp-gray-200, #e5e7eb);
}
.tp-dict-eu-noise-label strong {
    font-weight: 700;
}

/* --- Special markings cards --- */
.tp-dict-markings-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--tp-space-md, 16px);
}

.tp-dict-marking-card {
    padding: var(--tp-space-md, 16px) var(--tp-space-lg, 24px);
    border: 1px solid var(--tp-gray-200, #e5e7eb);
    border-radius: var(--tp-radius-lg, 8px);
    background: white;
}

.tp-dict-marking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--tp-space-xs, 4px);
}
.tp-dict-marking-icon {
    font-size: 20px;
}
.tp-dict-marking-code {
    font-size: var(--tp-text-base, 16px);
    color: var(--tp-gray-900, #111827);
}
.tp-dict-marking-desc {
    font-size: var(--tp-text-sm, 14px);
    color: var(--tp-gray-600, #4b5563);
    line-height: 1.6;
}

/* --- CTA final --- */
.tp-dict-cta {
    text-align: center;
    padding: var(--tp-space-2xl, 48px) var(--tp-space-lg, 24px);
    background: var(--tp-gray-50, #f9fafb);
    border-radius: var(--tp-radius-lg, 8px);
    margin-top: var(--tp-space-xl, 32px);
}
.tp-dict-cta-text {
    font-size: var(--tp-text-lg, 18px);
    color: var(--tp-gray-700, #374151);
    margin-bottom: var(--tp-space-lg, 24px);
    line-height: 1.6;
}
.tp-dict-cta-btn {
    display: inline-block;
    padding: 14px 36px;
    background: var(--tp-red, #E31837);
    color: white;
    border-radius: var(--tp-radius-md, 6px);
    font-weight: 700;
    font-size: var(--tp-text-base, 16px);
    text-decoration: none;
    transition: background 0.15s ease;
}
.tp-dict-cta-btn:hover {
    background: var(--tp-gray-900, #111827);
    color: white;
}
.tp-dict-cta-help {
    margin-top: var(--tp-space-md, 16px);
    font-size: var(--tp-text-sm, 14px);
    color: var(--tp-gray-500, #6b7280);
}
.tp-dict-cta-help a {
    color: var(--tp-primary, #1a1a1a);
    text-decoration: underline;
}

/* --- Diagram container — side-by-side layout --- */
.tp-tire-diagram {
    max-width: 960px;
    margin: 0 auto var(--tp-space-xl);
    padding: var(--tp-space-md);
}

.tp-tire-diagram-title {
    text-align: center;
    font-size: var(--tp-text-xl);
    font-weight: 700;
    margin-bottom: var(--tp-space-lg);
    color: var(--tp-gray-900);
}

/* Side-by-side: SVG left (wider), panel right */
.tp-tire-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--tp-space-lg, 24px);
    align-items: start;
}

.tp-tire-svg-wrap {
    position: sticky;
    top: 120px; /* header + TOC */
}

.tp-tire-diagram svg {
    width: 100%;
    height: auto;
    display: block;
}

/* Hybrid mode: image with SVG overlay */
.tp-tire-img-container {
    position: relative;
    width: 100%;
}
.tp-tire-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--tp-radius-lg, 8px);
}
.tp-tire-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
/* Hitbox highlight on hover (image overlay mode) */
.tp-tire-zone:hover .tp-zone-hitbox,
.tp-tire-zone.active .tp-zone-hitbox {
    fill: var(--zone-color);
    opacity: 0.2;
    rx: 4;
}

/* --- Interactive zones (embossed text on tire) --- */
.tp-tire-zone {
    cursor: pointer;
}

/* Default: white embossed text on dark tire */
.tp-zone-text {
    fill: #ddd;
    transition: fill 0.2s ease, filter 0.2s ease;
    pointer-events: all;
    /* Enlarge touch target around each character */
    stroke: transparent;
    stroke-width: 8;
    paint-order: stroke;
}

/* Active: text illuminates in zone color with glow */
.tp-tire-zone:hover .tp-zone-text,
.tp-tire-zone.active .tp-zone-text {
    fill: var(--zone-color);
    filter: url(#zoneGlow);
}

/* Separator text between zones (static) */
.tp-tire-sep {
    pointer-events: none;
}

.tp-tire-zone:focus-visible {
    outline: 2px solid var(--zone-color);
    outline-offset: 2px;
}

/* --- Right panel --- */
.tp-tire-panel {
    display: flex;
    flex-direction: column;
    gap: var(--tp-space-md, 16px);
}

/* --- Legend (vertical list in panel) --- */
.tp-tire-legend {
    display: flex;
    flex-direction: column;
    gap: var(--tp-space-xs, 4px);
}

.tp-tire-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--tp-gray-200, #e5e7eb);
    border-radius: var(--tp-radius-md, 6px);
    background: white;
    cursor: pointer;
    font-size: var(--tp-text-sm, 14px);
    font-family: inherit;
    color: var(--tp-gray-700, #374151);
    transition: all var(--tp-transition-fast, 0.15s) ease;
    line-height: 1.4;
    text-align: left;
    width: 100%;
}

.tp-tire-legend-item:hover,
.tp-tire-legend-item.active {
    border-color: var(--zone-color);
    color: var(--zone-color);
    box-shadow: 0 0 0 1px var(--zone-color);
}

.tp-tire-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--zone-color);
    flex-shrink: 0;
}

.tp-tire-legend-value {
    color: var(--tp-gray-500, #6b7280);
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    margin-left: auto;
}

/* --- Info panel (beside diagram) --- */
.tp-tire-info {
    padding: var(--tp-space-md, 16px) var(--tp-space-lg, 24px);
    background: white;
    border: 2px solid var(--tp-gray-200, #e5e7eb);
    border-left-width: 4px;
    border-left-color: var(--active-color, var(--tp-gray-300));
    border-radius: var(--tp-radius-lg, 8px);
    box-shadow: var(--tp-shadow-sm, 0 1px 2px rgba(0,0,0,0.05));
    transition: border-color var(--tp-transition-fast, 0.15s) ease;
    animation: tp-info-appear 0.2s ease;
}

@keyframes tp-info-appear {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tp-tire-info[hidden] {
    display: none;
}

.tp-tire-info-title {
    font-weight: 700;
    font-size: var(--tp-text-lg, 18px);
    margin-bottom: var(--tp-space-xs, 4px);
    color: var(--active-color, var(--tp-gray-900));
}

.tp-tire-info-text {
    font-size: var(--tp-text-sm, 14px);
    color: var(--tp-gray-700, #374151);
    line-height: 1.7;
}

/* Hint text */
.tp-tire-hint {
    font-size: var(--tp-text-xs, 12px);
    color: var(--tp-gray-400, #9ca3af);
    text-align: center;
    font-style: italic;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .tp-dict-toc {
        top: 60px; /* mobile header height */
    }

    .tp-dict-grid--speed {
        grid-template-columns: repeat(2, 1fr);
    }

    .tp-dict-eu-grid {
        grid-template-columns: 1fr;
    }

    .tp-dict-markings-list {
        grid-template-columns: 1fr;
    }

    /* Diagram: stack vertically on mobile */
    .tp-tire-layout {
        grid-template-columns: 1fr;
        gap: var(--tp-space-md, 16px);
    }

    .tp-tire-svg-wrap {
        position: static;
        max-width: 420px;
        margin: 0 auto;
    }

    .tp-tire-diagram {
        padding: var(--tp-space-sm);
    }

    .tp-tire-diagram-title {
        font-size: var(--tp-text-lg, 18px);
    }

    .tp-tire-legend {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--tp-space-xs, 4px);
    }

    .tp-tire-legend-item {
        font-size: var(--tp-text-xs, 12px);
        padding: 4px 8px;
        width: auto;
    }

    .tp-tire-info {
        padding: var(--tp-space-sm, 8px) var(--tp-space-md, 16px);
    }
}

@media (max-width: 480px) {
    .tp-dict-grid--speed {
        grid-template-columns: 1fr 1fr;
    }

    .tp-tire-legend {
        flex-direction: column;
        align-items: stretch;
    }

    .tp-tire-legend-item {
        justify-content: flex-start;
    }

    .tp-dict-section-title {
        font-size: var(--tp-text-lg, 18px);
    }

    /* Card stack for load index table on mobile */
    .tp-dict-table thead {
        display: none;
    }
    .tp-dict-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        padding: 8px 12px;
        border-bottom: 1px solid var(--tp-gray-200, #e5e7eb);
    }
    .tp-dict-table td {
        border: none;
        padding: 2px 4px;
    }
    .tp-dict-table td:first-child {
        font-weight: 700;
        margin-right: 8px;
    }
    /* Keep OEM table readable */
    .tp-dict-table--oem tbody tr {
        flex-direction: column;
    }
}
