/* Shared site styles (extracted from index.html, plan Gate 2).
   Palette reworked 2026-09-18 for WCAG 1.4.3 (computed ratios recorded in
   docs/implementation-handoff.md): overweight 4.58:1, healthy 7.00:1,
   underweight 7.56:1, obese 5.75:1, accent on white 6.29:1. */

:root {
    --accent: #4f46e5;
    --accent-strong: #4338ca;
    --text: #333333;
    --text-soft: #555555;
    --muted: #666666;
    --bg-underweight: #e3f2fd;
    --fg-underweight: #0d47a1;
    --bg-healthy: #e8f5e9;
    --fg-healthy: #1b5e20;
    --bg-overweight: #fff3e0;
    --fg-overweight: #b45309;
    --bg-obese: #ffebee;
    --fg-obese: #b71c1c;
    --error-fg: #8a1c1c;
    --error-bg: #fdf2f2;
    --advisory-fg: #7a4b0f;
    --advisory-bg: #fff8ec;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #4f46e5 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text);
}

/* Links: underlined by default (prose); navigation keeps underline on
   hover/focus only, per WCAG 1.4.1's navigation exception. */
a {
    color: var(--accent-strong);
    text-decoration: underline;
    text-underline-offset: 2px;
}

nav {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.logo:hover,
.logo:focus-visible {
    text-decoration: underline;
}

.nav-links {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover,
.nav-links a:focus-visible {
    color: var(--accent);
    text-decoration: underline;
}

.nav-links a[aria-current="page"] {
    font-weight: 700;
    color: var(--accent);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.hero {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

.hero h1 {
    font-size: 2.5em;
    margin-bottom: 15px;
}

.hero p {
    font-size: 1.2em;
}

/* Skip link: visible on keyboard focus, first in tab order. */
.skip-link {
    position: absolute;
    left: 16px;
    top: -48px;
    z-index: 1000;
    background: white;
    color: var(--accent-strong);
    font-weight: 700;
    padding: 10px 18px;
    border-radius: 0 0 10px 10px;
    text-decoration: underline;
    transition: top 0.2s;
}

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

/* Keyboard focus is always clearly visible. */
:focus-visible {
    outline: 3px solid var(--accent-strong);
    outline-offset: 2px;
}

input:focus-visible {
    outline: 3px solid var(--accent-strong);
    outline-offset: 0;
}

.card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
}

h2 {
    color: var(--accent);
    margin-bottom: 20px;
    font-size: 1.8em;
}

/* Scope notice (adult 18+ screening framing) shown before the form. */
.notice {
    background: #eef2ff;
    border-left: 4px solid var(--accent-strong);
    color: #1e1b4b;
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 30px;
    line-height: 1.6;
}

.notice p {
    margin: 0;
}

.unit-toggle {
    border: 2px solid var(--accent);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 30px;
}

.unit-toggle legend {
    font-weight: 700;
    color: var(--accent);
    padding: 0 8px;
}

.unit-choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text);
    margin-right: 30px;
}

.input-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-soft);
}

input {
    width: 100%;
    max-width: 420px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[aria-invalid="true"] {
    border-color: var(--error-fg);
}

.field-error {
    margin-top: 8px;
    padding: 10px 14px;
    background: var(--error-bg);
    color: var(--error-fg);
    border-radius: 8px;
    font-size: 0.95em;
    line-height: 1.5;
}

/* Live status region: present for assistive tech, visually compact when
   empty, readable when filled. */
.status {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    color: var(--text);
    line-height: 1.5;
}

.status:empty {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.calculate-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #4f46e5 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}

.calculate-btn:hover {
    transform: translateY(-2px);
}

.result {
    margin-top: 30px;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
}

.result h3 {
    margin-bottom: 10px;
}

.result[data-stale="true"] {
    outline: 3px dashed var(--advisory-fg);
    outline-offset: 3px;
}

.bmi-value {
    font-size: 3em;
    font-weight: 700;
    margin: 10px 0;
}

.bmi-category {
    font-size: 1.5em;
    font-weight: 600;
    margin-bottom: 5px;
}

.bmi-range {
    font-size: 1em;
    font-weight: 600;
    margin-bottom: 15px;
}

.bmi-description {
    color: var(--text-soft);
    line-height: 1.6;
    text-align: left;
}

.bmi-description p {
    margin-bottom: 10px;
}

.advisory-note {
    margin: 12px 0;
    padding: 10px 14px;
    background: var(--advisory-bg);
    color: var(--advisory-fg);
    border-radius: 8px;
    font-size: 0.95em;
    line-height: 1.5;
    text-align: left;
}

.result.underweight { background: var(--bg-underweight); color: var(--fg-underweight); }
.result.healthy { background: var(--bg-healthy); color: var(--fg-healthy); }
.result.overweight { background: var(--bg-overweight); color: var(--fg-overweight); }
.result.obese { background: var(--bg-obese); color: var(--fg-obese); }

.chart {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.chart h3 {
    margin-bottom: 15px;
    color: var(--accent);
}

.chart-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin: 5px 0;
    border-radius: 5px;
    font-size: 14px;
}

.chart-item.underweight { background: var(--bg-underweight); color: var(--fg-underweight); }
.chart-item.normal,
.chart-item.healthy { background: var(--bg-healthy); color: var(--fg-healthy); }
.chart-item.overweight { background: var(--bg-overweight); color: var(--fg-overweight); }
.chart-item.obese { background: var(--bg-obese); color: var(--fg-obese); }

.chart-caption {
    margin-top: 15px;
    font-size: 0.9em;
    color: var(--text-soft);
    line-height: 1.5;
}

.info-section {
    margin-top: 30px;
}

.info-section h3 {
    color: var(--accent);
    margin-bottom: 15px;
}

.info-section p {
    line-height: 1.8;
    color: var(--text-soft);
    margin-bottom: 15px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
    gap: 20px;
    margin-top: 30px;
}

.info-card {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border-left: 4px solid var(--accent);
}

.info-card h4 {
    color: var(--accent);
    margin-bottom: 10px;
}

.ad-space {
    min-height: 250px;
    background: #f0f0f0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 14px;
    border: 2px dashed #ddd;
    margin: 30px 0;
}

footer {
    background: rgba(0, 0, 0, 0.2);
    color: white;
    padding: 30px 20px;
    margin-top: 50px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.footer-links a {
    color: white;
    text-decoration: none;
}

.footer-links a:hover,
.footer-links a:focus-visible {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 1.8em;
    }
    .card {
        padding: 25px;
    }
    .nav-links {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 24px 12px;
    }
    .card {
        padding: 18px 14px;
        border-radius: 14px;
    }
    .hero h1 {
        font-size: 1.6em;
    }
    .bmi-value {
        font-size: 2.4em;
    }
    .unit-toggle {
        padding: 10px 12px;
    }
    .unit-choice {
        margin-right: 0;
        display: flex;
    }
}

/* Content pages (about/health-tips/contact/privacy/terms) */
.container.narrow {
    max-width: 900px;
}

.container.form-page {
    max-width: 800px;
}

.page h1 {
    color: var(--accent);
    margin-bottom: 10px;
    font-size: 2.5em;
    line-height: 1.2;
}

.last-updated {
    color: var(--muted);
    font-size: 0.9em;
    margin-bottom: 30px;
}

.page h2 {
    color: var(--accent);
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.6em;
}

.page h3 {
    color: var(--accent-strong);
    margin-top: 20px;
    margin-bottom: 10px;
}

.page p {
    line-height: 1.8;
    color: var(--text-soft);
    margin-bottom: 15px;
}

.page ul {
    margin: 15px 0 15px 30px;
    line-height: 1.8;
}

.page li {
    margin-bottom: 10px;
    color: var(--text-soft);
}

.highlight-box {
    background: #f0f4ff;
    border-left: 4px solid var(--accent);
    padding: 20px;
    margin: 25px 0;
    border-radius: 5px;
}

.highlight-box p {
    margin-bottom: 0;
}

.highlight-box.warn {
    background: var(--bg-overweight);
    border-left-color: var(--fg-overweight);
}

/* Contact form */
.contact-form {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    margin: 30px 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-soft);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus-visible,
.form-group textarea:focus-visible,
.form-group select:focus-visible {
    outline: 3px solid var(--accent-strong);
    outline-offset: 0;
}

.form-group input[aria-invalid="true"],
.form-group textarea[aria-invalid="true"] {
    border-color: var(--error-fg);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.submit-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #4f46e5 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}

.submit-btn:hover {
    transform: translateY(-2px);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.form-status {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    line-height: 1.5;
}

.form-status:empty {
    display: none;
}

.form-status.success {
    background: var(--bg-healthy);
    color: var(--fg-healthy);
}

.form-status.error {
    background: var(--bg-obese);
    color: var(--fg-obese);
}

.contact-info {
    background: #f0f4ff;
    padding: 25px;
    border-radius: 10px;
    margin: 30px 0;
}

.contact-info h2 {
    margin-top: 0;
}

.contact-item {
    margin: 15px 0;
    padding: 10px 0;
}

.contact-item strong {
    color: var(--accent-strong);
}

.faq {
    margin-top: 40px;
}

.faq-item {
    margin-bottom: 25px;
}

.footer-note {
    margin-top: 10px;
    font-size: 0.9em;
    opacity: 0.8;
}

@media (max-width: 480px) {
    .nav-container {
        padding: 0 12px;
    }
    .logo {
        font-size: 1.2em;
    }
    .nav-links {
        gap: 14px;
        font-size: 0.95em;
    }
    .contact-form {
        padding: 20px;
    }
}

.tip-box {
    background: #f0f4ff;
    border-left: 4px solid var(--accent);
    padding: 20px;
    margin: 25px 0;
    border-radius: 5px;
}

.tip-box h3 {
    color: var(--accent);
    margin-top: 0;
}

.warning-box {
    background: var(--bg-overweight);
    border-left: 4px solid var(--fg-overweight);
    padding: 20px;
    margin: 25px 0;
    border-radius: 5px;
}

.warning-box strong {
    color: var(--fg-overweight);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 25px;
    margin: 30px 0;
}

.grid-card {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border-top: 4px solid var(--accent);
}

.grid-card h3 {
    color: var(--accent);
    margin-top: 0;
}

.cta-box {
    background: linear-gradient(135deg, #4f46e5 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin-top: 40px;
}

.cta-box h2 {
    color: white;
    margin-top: 0;
}

.cta-box p {
    color: white;
}

.cta-button {
    display: inline-block;
    padding: 15px 40px;
    background: white;
    color: var(--accent-strong);
    text-decoration: underline;
    border-radius: 10px;
    font-weight: 700;
    margin-top: 20px;
    transition: transform 0.2s;
}

.cta-button:hover {
    transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}
