/* calc/assets/css/calculators/braking-distance.css */

/* --- Theme: Danger / Road --- */
:root {
    --brake-primary: #991B1B; /* Red 800 */
    --brake-accent: #EF4444;  /* Red 500 */
    --brake-bg: #FEF2F2;      /* Red 50 */
    --road-asphalt: #334155;
    --road-wet: #1E293B;
    --road-snow: #E2E8F0;
    --road-ice: #F1F5F9;
}

.calc-header { margin-bottom: 32px; }
.subtitle { color: var(--text-secondary); margin-top: 8px; }

/* Grid */
.calc-grid { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: start; }
@media (min-width: 900px) { .calc-grid { grid-template-columns: 1.2fr 0.8fr; } }

/* Inputs */
.calc-inputs { gap: 24px; }
.input-group { margin-bottom: 24px; }
.input-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }

.input-wrapper { position: relative; display: flex; align-items: center; }
.input-wrapper input, .input-wrapper select {
    width: 100%; padding: 16px; padding-right: 40px;
    font-size: 16px; font-weight: 500;
    border: 1px solid #E5E7EB; border-radius: 12px;
    outline: none; transition: border 0.2s;
    font-family: var(--font-main); background: #fff; appearance: none;
}
.input-wrapper input:focus, .input-wrapper select:focus {
    border-color: var(--brake-accent); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.suffix, .select-arrow { position: absolute; right: 16px; color: var(--text-secondary); pointer-events: none; }
.select-arrow { display: flex; align-items: center; }
.helper-text { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

.row-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Range Slider */
.range-wrapper { margin-top: 10px; padding: 0 4px; }
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; height: 20px; width: 20px; border-radius: 50%;
    background: var(--brake-accent); cursor: pointer; margin-top: -8px;
    border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%; height: 4px; cursor: pointer; background: #E5E7EB; border-radius: 2px;
}

/* --- Result Card --- */
.card--danger { background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%); border: none; overflow: hidden; position: relative; }
@media (min-width: 900px) { .sticky-card { position: sticky; top: 24px; } }

/* Killer Feature: Road Animation */
.road-container {
    height: 160px; background: var(--road-asphalt);
    border-radius: 12px; position: relative; margin-bottom: 24px;
    overflow: hidden;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
    transition: background-color 0.5s ease;
}

.road-surface {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}

/* Разметка */
.road-surface::after {
    content: ''; position: absolute; top: 50%; left: 0; width: 100%; height: 2px;
    margin-top: -1px;
    background: repeating-linear-gradient(90deg, rgba(255,255,255,0.6) 0, rgba(255,255,255,0.6) 20px, transparent 20px, transparent 40px);
    transition: background 0.3s;
}
.road-surface.is-light::after {
    background: repeating-linear-gradient(90deg, rgba(51, 65, 85, 0.3) 0, rgba(51, 65, 85, 0.3) 20px, transparent 20px, transparent 40px);
}

.car-icon {
    position: absolute; top: 50%; left: 10px; font-size: 32px;
    transform: translateY(-50%) scaleX(-1);
    transition: left 0.8s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 2;
    filter: drop-shadow(2px 4px 4px rgba(0,0,0,0.2));
}

.skid-marks {
    position: absolute; top: 55%; left: 20px; height: 6px;
    background: #171717; opacity: 0.5; width: 0;
    transform: translateY(-50%);
    transition: width 0.8s cubic-bezier(0.25, 1, 0.5, 1);
    border-radius: 4px;
    z-index: 1;
}

.stop-marker {
    position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
    background: #EF4444; color: #fff;
    font-size: 10px; font-weight: 800; padding: 2px 6px;
    border-radius: 4px; z-index: 0;
    writing-mode: vertical-rl; text-orientation: mixed;
    height: 60px; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.road-ruler {
    position: absolute; bottom: 8px; left: 0; width: 100%;
    display: flex; justify-content: space-between; padding: 0 20px;
    font-size: 10px; color: rgba(255,255,255,0.5); font-family: monospace;
    pointer-events: none;
}
.road-surface.is-light + .road-ruler { color: rgba(0,0,0,0.4); }

/* Data */
.result-data { text-align: center; }
.result-data h2 { font-size: 14px; text-transform: uppercase; color: #7F1D1D; letter-spacing: 1px; margin-bottom: 8px; }
.main-value { font-size: 48px; font-weight: 800; color: #991B1B; line-height: 1; margin-bottom: 16px; }
.main-value small { font-size: 18px; font-weight: 600; opacity: 0.8; }

.breakdown { display: flex; justify-content: center; gap: 16px; font-size: 13px; color: #7F1D1D; flex-wrap: wrap; }
.break-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.react { background: #FCA5A5; }
.dot.brake { background: #DC2626; }

.summary-divider { height: 1px; background: rgba(0,0,0,0.1); margin: 24px 0; }

.impact-box {
    background: rgba(220, 38, 38, 0.1); border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: 8px; padding: 12px;
    display: flex; gap: 12px; align-items: center; text-align: left;
}
.impact-icon { font-size: 24px; }
.impact-text { font-size: 13px; line-height: 1.4; color: #7F1D1D; }

/* --- INFO WRAPPER --- */
.info-wrapper {
    padding: 60px 0 60px 0;
    margin-top: 60px;
    border-top: 1px solid rgba(0,0,0,0.06);
    margin-bottom: 20px;
}
.info-wrapper .container { max-width: 800px; margin: 0 auto; }

/* Headings */
.icon-heading {
    display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px;
    font-size: 24px; font-weight: 800; color: var(--text-primary); line-height: 1.3;
}
.header-icon {
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: 48px; border-radius: 14px; background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04); flex-shrink: 0; margin-top: -4px;
}
.header-icon svg { width: 24px; height: 24px; stroke-width: 2px; }

/* Colors */
.red-icon svg { color: #DC2626; }
.dark-icon svg { color: #1F2937; }

/* Formulas */
.formulas-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 48px;
}
.formula-card {
    background: #fff; border: 1px solid rgba(0,0,0,0.04);
    box-shadow: 0 4px 20px rgba(0,0,0,0.03); border-radius: 24px; padding: 24px;
    display: flex; flex-direction: column; transition: transform 0.3s;
}
.formula-card:hover { transform: translateY(-4px); }

.formula-header { margin-bottom: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.formula-card h3 { margin: 0; font-size: 18px; font-weight: 700; color: var(--text-primary); }

.badge-red { background: #FEE2E2; color: #991B1B; padding: 6px 12px; border-radius: 99px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge-dark { background: #F3F4F6; color: #1F2937; padding: 6px 12px; border-radius: 99px; font-size: 11px; font-weight: 700; text-transform: uppercase; }

.math-expression {
    background: #FEF2F2; border: 1px solid #FEE2E2; padding: 12px;
    border-radius: 12px; font-weight: 700; color: #991B1B; text-align: center;
    margin-bottom: 16px; font-size: 15px; font-family: monospace;
}
.formula-card p { font-size: 14px; color: var(--text-secondary); margin: 0; line-height: 1.5; }

/* Divider */
.soft-divider { border: none; height: 1px; background: linear-gradient(90deg, transparent, #E5E7EB, transparent); margin: 48px 0; }

/* Description */
.calc-description p { font-size: 16px; line-height: 1.7; color: var(--text-secondary); margin-bottom: 24px; }
.calc-description ul { color: var(--text-secondary); margin-bottom: 24px; padding-left: 20px; line-height: 1.6; }
.calc-description li { margin-bottom: 8px; }

/* Small Headings */
.small-heading { margin-top: 40px; margin-bottom: 16px; font-size: 20px; }
.small-heading .header-icon { width: 40px; height: 40px; }
.small-heading .header-icon svg { width: 20px; height: 20px; }

/* FAQ */
.faq-brake-style .faq-item {
    background: #fff; border: 1px solid #E5E7EB; border-radius: 12px;
    margin-bottom: 12px; overflow: hidden; transition: all 0.2s;
}
.faq-brake-style .faq-item[open] { border-color: #FCA5A5; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.1); }

.faq-brake-style summary.faq-question {
    padding: 16px 20px; cursor: pointer; font-weight: 600; color: var(--text-primary);
    list-style: none; position: relative; display: flex; justify-content: space-between;
    align-items: center;
}
.faq-brake-style .faq-item[open] summary.faq-question { color: #991B1B; background: #FEF2F2; }

.faq-question::after { content: '+'; font-size: 20px; color: var(--text-secondary); }
.faq-brake-style .faq-item[open] summary.faq-question::after { content: '−'; color: #991B1B; }

.faq-answer { padding: 20px; color: var(--text-secondary); line-height: 1.6; font-size: 15px; }

/* --- MOBILE ADAPTATION (Исправлено) --- */
@media (max-width: 900px) {
    /* Сетка в одну колонку */
    .formulas-grid { grid-template-columns: 1fr; gap: 16px; }
    
    /* Уменьшаем заголовки */
    .icon-heading { font-size: 20px; gap: 12px; margin-bottom: 20px; }
    .header-icon { width: 40px; height: 40px; border-radius: 12px; }
    .header-icon svg { width: 20px; height: 20px; }
    
    /* Центрируем карточки с формулами */
    .formula-card { 
        padding: 24px; 
        text-align: center; 
        align-items: center; /* Центровка flex-элементов */
    }
    
    /* Центруем шапку формулы */
    .formula-header {
        align-items: center; /* Центровка бейджа и заголовка */
        width: 100%;
        text-align: center;
    }
    
    /* Центруем математическое выражение */
    .math-expression {
        width: 100%;
        max-width: 300px; /* Ограничиваем ширину для красоты */
        margin-left: auto;
        margin-right: auto;
    }
    
    .info-wrapper { margin-top: 40px; padding-top: 40px; }
}