/*
 * Sondages des articles (App\Modules\Poll) : carte du petit sondage, carte
 * du grand sondage, page du sondage et résultats détaillés.
 * Tout est préfixé .hm-poll : la carte est rendue dans .article-content,
 * dont les styles (p, h*, images…) ne doivent pas s'y appliquer.
 */

.hm-poll {
    box-sizing: border-box;
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border-muted-color);
    border-radius: var(--radius-lg);
    background: var(--secondary-bg-color);
    box-shadow: var(--shadow-soft);
    color: var(--text-color);
    line-height: 1.5;
    text-align: left;
}

.hm-poll p {
    margin: 0;
    text-align: left;
    text-indent: 0;
    font-size: 1rem;
}

.hm-poll .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.hm-poll-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.hm-poll-kind {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--accent-text);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hm-poll-badge {
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-pill);
    background: var(--accent-muted-color);
    color: var(--text-color);
    font-size: 0.8rem;
    font-weight: 500;
}

.hm-poll .hm-poll-title,
.hm-poll-page-title {
    margin: 0 0 0.35rem;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
}

.hm-poll-page-title {
    font-size: 1.6rem;
}

.hm-poll .hm-poll-description {
    margin-bottom: 1rem;
    color: var(--text-secondary-color);
}

.hm-poll .hm-poll-help {
    margin: 0.25rem 0;
    color: var(--text-secondary-color);
    font-size: 0.875rem;
}

.hm-poll-required {
    color: var(--danger-color);
}

/* --- Questions --- */

.hm-poll-question {
    min-width: 0;
    margin: 0 0 1.25rem;
    padding: 0;
    border: 0;
}

.hm-poll-question[disabled] {
    opacity: 0.7;
}

.hm-poll-question-label {
    margin-bottom: 0.5rem;
    padding: 0;
    font-weight: 600;
}

.hm-poll-question-number {
    margin-right: 0.25rem;
    color: var(--accent-text);
}

.hm-poll-choices {
    display: grid;
    gap: 0.5rem;
}

.hm-poll-choice {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-muted-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
    cursor: pointer;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.hm-poll-choice:hover {
    border-color: var(--accent-color);
}

.hm-poll-choice:has(input:checked) {
    border-color: var(--accent-color);
    background: var(--accent-muted-color);
}

.hm-poll-choice input,
.hm-poll-scale-value input {
    accent-color: var(--accent-color);
}

.hm-poll-scale {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.hm-poll-scale-label {
    color: var(--text-secondary-color);
    font-size: 0.875rem;
}

.hm-poll-scale-values {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.hm-poll-scale-value {
    position: relative;
    cursor: pointer;
}

.hm-poll-scale-value input {
    position: absolute;
    opacity: 0;
    inset: 0;
    cursor: pointer;
}

.hm-poll-scale-value span {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--border-muted-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
    font-weight: 600;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.hm-poll-scale-value:hover span {
    border-color: var(--accent-color);
}

.hm-poll-scale-value input:checked + span {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
    color: var(--inverted-text-color);
}

.hm-poll-scale-value input:focus-visible + span {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.hm-poll .hm-poll-text {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    resize: vertical;
}

.hm-poll-identity {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.hm-poll-identity .form-input {
    width: 100%;
    box-sizing: border-box;
}

/* --- Actions, erreurs, confidentialité --- */

.hm-poll-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    margin: 1rem 0;
}

/* Couleur imposée : un bouton-lien rendu dans .article-content prendrait la
   couleur des liens (read.css), identique au fond du bouton. */
.hm-poll-actions .form-button,
.hm-poll-actions .form-button:hover {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--inverted-text-color);
    text-decoration: none;
}

.hm-poll-actions .form-button[disabled] {
    opacity: 0.6;
    cursor: progress;
}

.hm-poll-button-secondary {
    padding: 0.7rem 1.25rem;
    border: 1px solid var(--border-muted-color);
    border-radius: var(--radius-sm);
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.hm-poll-button-secondary:hover {
    border-color: var(--accent-color);
}

.hm-poll .hm-poll-error {
    margin: 0.5rem 0;
    color: var(--danger-text-color);
    font-weight: 500;
}

/* Zone d'erreur toujours présente (annonce fiable), sans place quand vide */
.hm-poll .hm-poll-error:empty {
    margin: 0;
}

.hm-poll-form .info-banner ul {
    margin: 0.25rem 0 0;
    padding-left: 1.2rem;
}

.hm-poll-privacy {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.75rem;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--accent-muted-color);
    color: var(--text-secondary-color);
}

.hm-poll-privacy iconify-icon {
    flex-shrink: 0;
    margin-top: 0.15rem;
    color: var(--accent-text);
}

.hm-poll-privacy p {
    font-size: 0.8rem;
}

.hm-poll-privacy p + p {
    margin-top: 0.3rem;
}

/* Couleur du texte plutôt que l'accent : l'accent sur ce fond teinté
   n'atteint pas le contraste minimal (4,5:1), surtout en thème sombre. */
.hm-poll-privacy a.link {
    color: var(--text-color);
    text-decoration: underline;
}

.hm-poll .hm-poll-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin: 0.75rem 0 0;
    color: var(--text-secondary-color);
}

.hm-poll .hm-poll-status:empty {
    display: none;
}

/* --- Résultats --- */

.hm-poll-results {
    display: grid;
    gap: 0.6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hm-poll-result-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.25rem;
}

.hm-poll-result-value {
    flex-shrink: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.hm-poll-result-value small {
    color: var(--text-secondary-color);
    font-weight: 400;
}

.hm-poll-bar {
    height: 0.5rem;
    overflow: hidden;
    border-radius: var(--radius-pill);
    background: var(--border-muted-color);
}

.hm-poll-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--text-secondary-color);
    transition: width 0.6s var(--transition-timing);
}

.hm-poll-result.is-leading .hm-poll-bar span {
    background: var(--accent-color);
}

.hm-poll .hm-poll-average {
    margin-bottom: 0.5rem;
}

.hm-poll-peek {
    margin-top: 0.75rem;
}

.hm-poll-peek summary {
    margin-bottom: 0.75rem;
    color: var(--accent-text);
    cursor: pointer;
}

.hm-poll-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-top: 1rem;
    color: var(--text-secondary-color);
    font-size: 0.875rem;
}

.hm-poll-footer:empty {
    display: none;
}

/* --- Carte du grand sondage --- */

.hm-poll-survey {
    display: flex;
    gap: 1.25rem;
}

.hm-poll-survey-icon {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius-md);
    background: var(--accent-muted-color);
    color: var(--accent-text);
    font-size: 1.75rem;
}

.hm-poll-survey-body {
    flex: 1;
    min-width: 0;
}

.hm-poll-survey .hm-poll-actions {
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .hm-poll {
        padding: 1rem;
    }

    .hm-poll-survey-icon {
        display: none;
    }
}

/* --- Pages du sondage et des résultats --- */

.hm-poll-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.hm-poll-page-wide {
    max-width: 960px;
}

.hm-poll-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.hm-poll-full {
    margin-top: 1rem;
    padding: 1.75rem 2rem;
}

.hm-poll-full .hm-poll-question {
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-muted-color);
}

.hm-poll-section-title {
    margin: 2rem 0 1rem;
    font-size: 1.2rem;
}

.hm-poll-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.hm-poll-meta div {
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-md);
    background: var(--bg-color);
}

.hm-poll-meta dt {
    color: var(--text-secondary-color);
    font-size: 0.8rem;
}

.hm-poll-meta dd {
    margin: 0;
    font-weight: 600;
}

.hm-poll-response {
    margin-bottom: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-color);
}

.hm-poll-response-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary-color);
    font-size: 0.85rem;
}

.hm-poll-response dl {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) 2fr;
    gap: 0.35rem 1rem;
    margin: 0;
}

.hm-poll-response dt {
    color: var(--text-secondary-color);
}

.hm-poll-response dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.hm-poll-text-answer {
    white-space: pre-line;
}

@media (max-width: 600px) {
    .hm-poll-full {
        padding: 1.25rem;
    }

    .hm-poll-response dl {
        grid-template-columns: 1fr;
    }

    .hm-poll-response dd {
        margin-bottom: 0.4rem;
    }
}

/* --- Bloc du sondage dans l'éditeur (poll-editor.js) --- */

.hm-poll-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    box-sizing: border-box;
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--secondary-bg-color);
    box-shadow: var(--shadow-pop);
    color: var(--text-color);
}

.hm-poll-dialog::backdrop {
    background: rgb(0 0 0 / 60%);
    overflow: hidden;
    overscroll-behavior: contain;
}

/* Le défilement de la fenêtre ne se propage pas à la page derrière */
.hm-poll-dialog:modal,
.hm-poll-dialog-body {
    overscroll-behavior: contain;
}

.hm-poll-dialog form {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 48px);
}

.hm-poll-dialog-head,
.hm-poll-dialog-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
}

.hm-poll-dialog-head {
    border-bottom: 1px solid var(--border-muted-color);
}

.hm-poll-dialog-head h2 {
    margin: 0;
    font-size: 1.2rem;
}

.hm-poll-dialog-foot {
    border-top: 1px solid var(--border-muted-color);
}

.hm-poll-dialog-body {
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.hm-poll-dialog fieldset {
    margin: 0 0 1.25rem;
    padding: 0;
    border: 0;
}

.hm-poll-dialog legend {
    margin-bottom: 0.5rem;
    padding: 0;
    font-weight: 600;
}

.hm-poll-dialog label {
    display: block;
}

.hm-poll-dialog .form-input,
.hm-poll-dialog select {
    width: 100%;
    box-sizing: border-box;
    margin: 0.25rem 0 0.75rem;
    font: inherit;
}

.hm-poll-dialog .hm-poll-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-bottom: 0.75rem;
}

.hm-poll-dialog .hm-poll-inline label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.hm-poll-format-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.hm-poll-dialog .hm-poll-format-choice label {
    display: block;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border-muted-color);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.hm-poll-format-choice label:has(input:checked) {
    border-color: var(--accent-color);
    background: var(--accent-muted-color);
}

.hm-poll-format-choice small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary-color);
}

.hm-poll-editor-question {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-muted-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
}

.hm-poll-editor-question-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.hm-poll-editor-tools {
    display: flex;
    gap: 0.25rem;
}

.hm-poll-icon-button {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border-muted-color);
    border-radius: var(--radius-sm);
    background: none;
    color: inherit;
    cursor: pointer;
}

.hm-poll-icon-button:hover:not([disabled]) {
    border-color: var(--accent-color);
}

.hm-poll-icon-button[disabled] {
    opacity: 0.35;
    cursor: default;
}

.hm-poll-editor-choice {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.hm-poll-editor-choice .form-input {
    margin: 0.2rem 0;
}

.hm-poll-link-button {
    padding: 0.25rem 0;
    border: 0;
    background: none;
    color: var(--accent-text);
    font: inherit;
    cursor: pointer;
}

.hm-poll-dialog-notice {
    margin: 0 0 1rem;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--accent-muted-color);
    font-size: 0.9rem;
}

.hm-poll-dialog-error {
    color: var(--danger-text-color);
    font-weight: 500;
}

.hm-poll-dialog-error:not(:empty) {
    margin-bottom: 1rem;
}

@media (max-width: 600px) {
    .hm-poll-format-choice {
        grid-template-columns: 1fr;
    }
}

/* --- Listes des espaces éditeur et admin --- */

.hm-poll-list-item {
    margin-bottom: 1rem;
}

.hm-poll-list-title {
    margin: 0.25rem 0 0.5rem;
    font-size: 1.15rem;
}

.hm-poll-list-meta {
    margin: 0.25rem 0;
    color: var(--text-secondary-color);
    font-size: 0.9rem;
}

.hm-poll-list-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-top: 0.75rem;
}

/* --- Page du sondage : traduction, discrète dans l'en-tête de la carte --- */

.hm-poll-header-side {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.hm-poll-translate {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem 0.6rem;
}

.hm-poll-translate .article-translate-button {
    padding: 0.2rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary-color);
}

.hm-poll-translate .article-translate-original {
    font-size: 0.8rem;
}

.hm-poll-translate #google-translate-element .goog-te-gadget,
.hm-poll-translate #google-translate-element select.goog-te-combo {
    font-size: 0.8rem !important;
}

.hm-poll-translate #google-translate-element select.goog-te-combo {
    padding: 0.2rem 0.5rem;
}

/* --- Mouvements réduits --- */

@media (prefers-reduced-motion: reduce) {
    .hm-poll-bar span,
    .hm-poll-choice,
    .hm-poll-scale-value span {
        transition: none;
    }
}
