/* ============================================
   Steps to KM Calculator — Stylesheet
   ============================================ */

:root {
    --color-bg: #F7F9FC;
    --color-surface: #FFFFFF;
    --color-border: #E3E8F0;
    --color-text: #16213D;
    --color-text-muted: #5B6478;
    --color-primary: #2A5BEB;
    --color-primary-dark: #1E43B8;
    --color-primary-tint: #EAF0FE;
    --color-accent: #16A87E;
    --color-danger: #D64545;
    --color-danger-tint: #FBEAEA;
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --shadow-card: 0 20px 45px -25px rgba(23, 42, 92, 0.35);
    --shadow-soft: 0 8px 24px -12px rgba(23, 42, 92, 0.25);
    --max-width: 1120px;
    --transition-speed: 0.3s;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--color-primary);
    color: #fff;
    padding: 10px 16px;
    border-radius: 0 0 8px 0;
    z-index: 200;
}

.skip-link:focus {
    left: 0;
}


/* Focus visibility */

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
    outline: 3px solid var(--color-primary-dark);
    outline-offset: 2px;
}


/* ---------- Header & Logo ---------- */

.site-header {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--color-border);
    z-index: 100;
    transition: all var(--transition-speed) ease;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-speed) ease;
}

.nav-toggle:hover {
    background-color: var(--color-bg);
}

.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0 auto;
    background: var(--color-text);
    border-radius: 2px;
    transition: all var(--transition-speed) ease;
}

@media (min-width: 860px) {
    .main-nav {
        display: flex;
    }
    .nav-toggle {
        display: none;
    }
}

.main-nav.is-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 24px 20px;
    gap: 14px;
    animation: fadeInDown var(--transition-speed) ease;
}


/* ---------- Animations ---------- */

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-slide-up {
    animation: slideUp 0.6s ease-out forwards;
}


/* ---------- Hero ---------- */

.hero {
    padding: 16px 0 5px;
    text-align: center;
}

.hero-sub {
    max-width: 560px;
    margin: 0 auto;
    font-size: 1.1rem;
    color: var(--color-text-muted);
}


/* ---------- Calculator layout ---------- */

.calculator-section {
    padding: 24px 0 64px;
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
}

@media (min-width: 920px) {
    .calc-grid {
        grid-template-columns: 1.15fr 1fr;
    }
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 28px;
    transition: box-shadow var(--transition-speed) ease, transform var(--transition-speed) ease;
}

.card:hover {
    box-shadow: 0 25px 50px -20px rgba(23, 42, 92, 0.4);
}

.field-group {
    margin-bottom: 18px;
}

.field-group.grow {
    flex: 1 1 160px;
}

.field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

input[type="number"] {
    width: 100%;
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 12px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--color-text);
    min-height: 48px;
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

input[type="number"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-tint);
}

input[type="number"].has-error {
    border-color: var(--color-danger);
    background: var(--color-danger-tint);
}

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 5px;
}

.segmented-sm {
    padding: 4px;
}

.seg-btn {
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 9px 14px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    border-radius: 9px;
    cursor: pointer;
    min-height: 40px;
    transition: all var(--transition-speed) ease;
}

.seg-btn:hover {
    color: var(--color-text);
}

.seg-btn.is-active {
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow-soft);
}

.estimate-panel,
.direction-panel {
    display: none;
}

.estimate-panel.is-active,
.direction-panel.is-active {
    display: block;
    animation: fadeIn var(--transition-speed) ease;
}

.hint {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-top: -6px;
}

.hint strong {
    color: var(--color-primary-dark);
}

.divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 22px 0;
}

.validation-msg {
    background: var(--color-danger-tint);
    color: var(--color-danger);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    margin: 0 0 16px;
    animation: fadeIn var(--transition-speed) ease;
}

.btn-row {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 13px 22px;
    border-radius: var(--radius-md);
    border: 1.5px solid transparent;
    cursor: pointer;
    min-height: 48px;
    transition: all var(--transition-speed) ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    box-shadow: 0 4px 12px rgba(42, 91, 235, 0.3);
}

.btn-ghost {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-ghost:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-small {
    padding: 10px 16px;
    font-size: 0.88rem;
    min-height: 42px;
    background: var(--color-primary-tint);
    color: var(--color-primary-dark);
    border-color: transparent;
}

.btn-small:hover {
    background: #dbe6fd;
}


/* ---------- Result card ---------- */

.result-card {
    background: linear-gradient(180deg, #16213D 0%, #1B2C52 100%);
    color: #fff;
    border: none;
}

.result-eyebrow {
    font-size: 0.85rem;
    color: #9FB3E8;
    margin-bottom: 6px;
}

.result-main {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.6rem, 6vw, 3.4rem);
    margin: 0 0 4px;
    color: #fff;
    transition: transform var(--transition-speed) ease;
}

.result-unit {
    font-size: 1.2rem;
    font-weight: 500;
    color: #9FB3E8;
}

.result-equivalent {
    color: #C4D1F2;
    margin-bottom: 22px;
}

.result-equivalent strong {
    color: #fff;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 12px 10px;
    text-align: center;
    transition: background var(--transition-speed) ease;
}

.stat:hover {
    background: rgba(255, 255, 255, 0.12);
}

.stat-label {
    display: block;
    font-size: 0.72rem;
    color: #9FB3E8;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-weight: 700;
    font-size: 1.05rem;
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 4px;
}

.result-actions .btn-small {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.result-actions .btn-small:hover {
    background: rgba(255, 255, 255, 0.2);
}

.copy-feedback {
    min-height: 1.2em;
    font-size: 0.85rem;
    color: #8FE3B8;
    margin: 6px 0 0;
    transition: opacity var(--transition-speed) ease;
}

.progress-block {
    margin-top: 22px;
}

.progress-heading {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
}

.progress-figures {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #C4D1F2;
    margin-bottom: 8px;
}

.progress-figures strong {
    color: #fff;
}

.progress-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #4C7BF5, #16A87E);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-caption {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: #C4D1F2;
}

.disclaimer {
    margin: 20px 0 0;
    font-size: 0.78rem;
    color: #8593B8;
}


/* ---------- Table section ---------- */

.table-section,
.formula-section,
.stride-section,
.faq-section {
    padding: 48px 0;
    border-top: 1px solid var(--color-border);
}

.section-lead {
    max-width: 640px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 360px;
}

th,
td {
    text-align: left;
    padding: 12px 18px;
    font-size: 0.95rem;
    transition: background-color var(--transition-speed) ease;
}

thead th {
    background: var(--color-primary-tint);
    color: var(--color-primary-dark);
    font-weight: 600;
}

tbody tr:nth-child(even) {
    background: var(--color-bg);
}

tbody tr:hover td {
    background: var(--color-primary-tint);
}

tbody td:first-child {
    font-weight: 600;
}


/* ---------- Formula section ---------- */

.formula-line {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-primary-dark);
    background: var(--color-primary-tint);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    display: inline-block;
    transition: transform var(--transition-speed) ease;
}

.formula-line:hover {
    transform: scale(1.02);
}


/* ---------- Stride list ---------- */

.stride-list {
    padding-left: 20px;
    color: var(--color-text-muted);
}

.stride-list li {
    margin-bottom: 8px;
}

.stride-list strong {
    color: var(--color-text);
}


/* ---------- FAQ ---------- */

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.faq-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 4px 18px;
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.faq-item:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-soft);
}

.faq-item summary {
    cursor: pointer;
    padding: 14px 0;
    font-weight: 600;
    color: var(--color-text);
    list-style: none;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: "+";
    float: right;
    color: var(--color-primary);
    font-size: 1.2rem;
    transition: transform var(--transition-speed) ease;
}

.faq-item[open] summary::after {
    content: "–";
    transform: rotate(180deg);
}

.faq-item p {
    padding-bottom: 14px;
    margin: 0;
    animation: fadeIn var(--transition-speed) ease;
}


/* ---------- Footer & Footer Logo ---------- */

.site-footer {
    background: #16213D;
    color: #C4D1F2;
    padding: 36px 0;
    margin-top: 24px;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    color: #fff;
}

.footer-logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.footer-links a {
    color: #C4D1F2;
    font-size: 0.9rem;
    transition: color var(--transition-speed) ease;
}

.footer-links a:hover {
    color: #fff;
    text-decoration: none;
}

.footer-copy {
    width: 100%;
    font-size: 0.8rem;
    color: #8593B8;
    margin: 0;
    text-align: center;
}

@media (min-width: 640px) {
    .footer-copy {
        width: auto;
        text-align: right;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    .progress-fill {
        transition: none;
    }
    .animate-fade-in,
    .animate-slide-up {
        animation: none;
    }
}