/* ================================================================
   assets/styles/calculator/index.css
   Styles du calculateur Create Aeronautics
   Cohérent avec le système « bulle » + tokens globaux (app.css).
   Lisible en thème clair ET sombre.
   ================================================================ */

/* ── TOKENS DU GRAPHE ───────────────────────────────────────────
   Lus en JS via getComputedStyle(.aero-calc) pour dessiner le canvas
   (accent, warn, muted, border, fg). Doivent exister pour les 2 thèmes. */
.aero-calc {
    --aero-fg:     var(--text-light);
    --aero-muted:  var(--muted-light);
    --aero-border: rgba(0, 0, 0, 0.14);
    --aero-accent: var(--violet);
    --aero-warn:   #ef4444;
}

[data-theme="dark"] .aero-calc {
    --aero-fg:     var(--text-dark);
    --aero-muted:  var(--muted-dark);
    --aero-border: rgba(255, 255, 255, 0.16);
    --aero-accent: var(--violet-light);
    --aero-warn:   #f87171;
}

/* Couleur de texte par défaut des bulles en thème clair
   (les bulles ne fixent la couleur qu'en sombre) */
.aero-calc .bulle {
    color: var(--text-light);
}

[data-theme="dark"] .aero-calc .bulle {
    color: var(--text-dark);
}

/* ── EN-TÊTE ────────────────────────────────────────────────────── */
.aero-calc .bulle-header {
    text-align: center;
    gap: 0.5rem;
}

.aero-calc h1 {
    font-family: 'Syne', sans-serif;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-light);
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc h1 {
    color: var(--text-dark);
}

.aero-calc .ac-sub {
    max-width: 62ch;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--muted-light);
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-sub {
    color: var(--muted-dark);
}

/* ── TITRES DE SECTION ──────────────────────────────────────────── */
.aero-calc .ac-h2,
.aero-calc .ac-h3 {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-light);
    transition: color var(--duration-slow);
}

.aero-calc .ac-h2 { font-size: 1.25rem; }
.aero-calc .ac-h3 { font-size: 1.05rem; }

[data-theme="dark"] .aero-calc .ac-h2,
[data-theme="dark"] .aero-calc .ac-h3 {
    color: var(--text-dark);
}

/* Filet accent sous les titres de section principaux */
.aero-calc .ac-h2 {
    display: inline-block;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid var(--violet);
    margin-bottom: 0.35rem;
}

/* ── TEXTES D'AIDE (hint / desc / note) ─────────────────────────── */
.aero-calc .ac-hint,
.aero-calc .ac-desc,
.aero-calc .ac-note,
.aero-calc .ac-cube {
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--muted-light);
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-hint,
[data-theme="dark"] .aero-calc .ac-desc,
[data-theme="dark"] .aero-calc .ac-note,
[data-theme="dark"] .aero-calc .ac-cube {
    color: var(--muted-dark);
}

.aero-calc .ac-desc { margin-bottom: 1rem; }
.aero-calc .ac-hint { margin-bottom: 0.85rem; }
.aero-calc .ac-note { margin-top: 0.85rem; }
.aero-calc .ac-cube { margin-top: 0.4rem; font-style: italic; }

.aero-calc .ac-note b { color: var(--violet); font-weight: 600; }
[data-theme="dark"] .aero-calc .ac-note b { color: var(--violet-light); }

/* ── CONSTANTES (details / summary) ─────────────────────────────── */
.aero-calc .ac-consts {
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 0.25rem 1rem;
    transition: border-color var(--duration-slow), background var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-consts {
    border-color: var(--border-dark);
}

.aero-calc .ac-consts summary {
    cursor: pointer;
    list-style: none;
    padding: 0.75rem 0;
    font-family: 'Syne', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-consts summary {
    color: var(--text-dark);
}

.aero-calc .ac-consts summary::-webkit-details-marker { display: none; }

/* Chevron custom qui pivote à l'ouverture */
.aero-calc .ac-consts summary::before {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid var(--violet);
    border-bottom: 2px solid var(--violet);
    transform: rotate(-45deg);
    transition: transform var(--duration-normal);
    flex-shrink: 0;
}

[data-theme="dark"] .aero-calc .ac-consts summary::before {
    border-color: var(--violet-light);
}

.aero-calc .ac-consts[open] summary::before {
    transform: rotate(45deg);
}

.aero-calc .ac-consts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.85rem;
    padding: 0.5rem 0 1rem;
}

/* ── CHAMPS (label + input) ─────────────────────────────────────── */
.aero-calc .ac-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.aero-calc .ac-field label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-light);
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-field label {
    color: var(--text-dark);
}

/* Unité affichée à droite du label */
.aero-calc .ac-field label .u {
    font-weight: 500;
    font-size: 0.72rem;
    color: var(--muted-light);
    white-space: nowrap;
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-field label .u {
    color: var(--muted-dark);
}

.aero-calc .ac-field input,
.aero-calc .ac-field select,
.aero-calc .ac-controls select {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background-color: var(--nav-bg-light);
    color: var(--text-light);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    outline: none;
    appearance: none;
    transition: border-color var(--duration-normal), box-shadow var(--duration-normal),
                background var(--duration-slow), color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-field input,
[data-theme="dark"] .aero-calc .ac-field select,
[data-theme="dark"] .aero-calc .ac-controls select {
    background-color: var(--nav-bg-dark);
    border-color: var(--border-dark);
    color: var(--text-dark);
}

.aero-calc .ac-field input:focus,
.aero-calc .ac-field select:focus {
    border-color: var(--violet);
    box-shadow: 0 0 0 3px var(--violet-glow);
}

/* Flèche des <select> (reprise de form.css) */
.aero-calc select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%237C3AED' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 0.7rem;
    padding-right: 2.2rem;
    cursor: pointer;
}

[data-theme="dark"] .aero-calc select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23A78BFA' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
}

/* ── OUTILS (Hélice / Ballon) ───────────────────────────────────── */
.aero-calc .ac-tool {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

/* ── READOUTS (clé → valeur) ────────────────────────────────────── */
.aero-calc .ac-readout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    background: var(--pill-bg-light);
    transition: background var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-readout {
    background: var(--pill-bg-dark);
}

.aero-calc .ac-rk {
    font-size: 0.8rem;
    color: var(--muted-light);
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-rk {
    color: var(--muted-dark);
}

.aero-calc .ac-rv {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: right;
    white-space: nowrap;
    color: var(--text-light);
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-rv {
    color: var(--text-dark);
}

/* Valeur mise en avant */
.aero-calc .ac-rv.key {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--violet);
}

[data-theme="dark"] .aero-calc .ac-rv.key {
    color: var(--violet-light);
}

.aero-calc .ac-rv small {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted-light);
    margin-left: 0.15rem;
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-rv small {
    color: var(--muted-dark);
}

/* ── CONTRÔLES DU GRAPHE ────────────────────────────────────────── */
.aero-calc .ac-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.1rem;
}

/* ── ZONE GRAPHE ────────────────────────────────────────────────── */
.aero-calc .ac-chart-shell {
    position: relative;
    width: 100%;
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.35);
    transition: background var(--duration-slow), border-color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-chart-shell {
    border-color: var(--border-dark);
    background: rgba(0, 0, 0, 0.18);
}

.aero-calc #aero-chart {
    display: block;
    width: 100%;
}

/* Infobulle suivant le curseur (position gérée en JS) */
.aero-calc .ac-tip {
    position: absolute;
    transform: translate(-50%, -130%);
    padding: 0.3rem 0.55rem;
    border-radius: 8px;
    background: var(--violet);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
    transition: opacity var(--duration-fast);
    z-index: 2;
}

/* ── LÉGENDE ────────────────────────────────────────────────────── */
.aero-calc .ac-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-top: 0.9rem;
}

.aero-calc .ac-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: var(--muted-light);
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-legend span {
    color: var(--muted-dark);
}

.aero-calc .ac-sw {
    width: 1.1rem;
    height: 0.3rem;
    border-radius: 999px;
    flex-shrink: 0;
    background: var(--aero-muted);
}

/* Correspondance avec les couleurs tracées sur le canvas */
.aero-calc .ac-legend span:nth-child(1) .ac-sw {
    background: var(--aero-accent);
}
.aero-calc .ac-legend span:nth-child(2) .ac-sw {
    background: var(--aero-muted);
    height: 0;
    border-top: 2px dashed var(--aero-muted);
}
.aero-calc .ac-legend span:nth-child(3) .ac-sw {
    background: color-mix(in srgb, var(--aero-warn) 45%, transparent);
    height: 0.7rem;
    border-radius: 3px;
}

/* ── VOLUME REQUIS ──────────────────────────────────────────────── */
/* Inputs en ligne, résultat en dessous (comme les sections Hélice/Ballon) */
.aero-calc .ac-vol {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.aero-calc .ac-vol-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
}

/* ── FORMULES ───────────────────────────────────────────────────── */
.aero-calc .ac-formulas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.9rem;
}

.aero-calc .ac-formulas > div {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.3);
    transition: border-color var(--duration-slow), background var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-formulas > div {
    border-color: var(--border-dark);
    background: rgba(0, 0, 0, 0.16);
}

.aero-calc .ac-fk {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted-light);
    transition: color var(--duration-slow);
}

[data-theme="dark"] .aero-calc .ac-fk {
    color: var(--muted-dark);
}

.aero-calc .ac-formulas code {
    font-family: 'DM Mono', ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
    font-size: 0.85rem;
    color: var(--violet);
    word-break: break-word;
}

[data-theme="dark"] .aero-calc .ac-formulas code {
    color: var(--violet-light);
}

/* ── RESPONSIVE ─────────────────────────────────────────────────── */
@media screen and (max-width: 768px) {
    /* Conteneur + bulles plus compacts pour gagner de la largeur utile */
    .aero-calc.bulle-container {
        padding: 0.5rem;
        gap: 0.75rem;
    }

    .aero-calc .bulle {
        padding: 1rem;
    }

    /* Titres un cran plus petits */
    .aero-calc h1 { font-size: 1.35rem; }
    .aero-calc .ac-h2 { font-size: 1.1rem; }
    .aero-calc .ac-h3 { font-size: 1rem; }

    /* Grilles denses : on resserre les colonnes minimales */
    .aero-calc .ac-consts-grid {
        grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
        gap: 0.6rem;
    }

    .aero-calc .ac-controls {
        grid-template-columns: 1fr;
    }

    /* Readout empilé : libellé au-dessus, valeur en dessous */
    .aero-calc .ac-readout {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .aero-calc .ac-rv,
    .aero-calc .ac-rv.key {
        text-align: left;
    }

    .aero-calc .ac-legend {
        gap: 0.4rem 1rem;
    }

    .aero-calc .ac-chart-shell {
        padding: 0.35rem;
    }
}

/* Très petits écrans : formules et constantes sur une seule colonne */
@media screen and (max-width: 420px) {
    .aero-calc .ac-consts-grid,
    .aero-calc .ac-formulas {
        grid-template-columns: 1fr;
    }
}
