/* Vérif' CEV — Principauté de Monaco */

html {
    /* Rouge du drapeau monégasque */
    --mc-red: #CE1126;
    --mc-red-dark: #A50D1F;

    /* même valeur que la meta theme-color dans index.html */
    --main-bg-color: #f5f2ec;
    --card-bg: #ffffff;
    --text: #26221c;
    --text-muted: #6d675e;
    --border: #ddd7cc;
    --input-bg: #ffffff;
    --link-color: #8f1420;
    --title-red: var(--mc-red);
    --success-bg: #eaf4ea;
    --success-border: #b7d7b9;
    --success-text: #1d5b25;
    --error-bg: #fbeceb;
    --error-border: #eeb9b4;
    --error-text: #8c1d18;
    --warning-bg: #fdf3e1;
    --warning-border: #ecd3a2;
    --warning-text: #7a4d10;
    --shadow: 0 1px 3px rgba(35, 25, 10, 0.08), 0 4px 16px rgba(35, 25, 10, 0.06);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}
html,
body {
    margin: 0;
}
body {
    background-color: var(--main-bg-color);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.5;
}
a {
    color: var(--link-color);
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- En-tête du site ---------- */

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background-color: var(--card-bg);
    border-top: 4px solid var(--mc-red);
    border-bottom: 1px solid var(--border);
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}
.brand-logo {
    width: 46px;
    height: 46px;
}
.brand-text {
    display: flex;
    flex-direction: column;
}
.brand-gov {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.brand-name {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--title-red);
}
.brand-tagline {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Structure de page ---------- */

main {
    max-width: 680px;
    margin: 0 auto;
    padding: 20px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.panel {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--shadow);
}
.panel-title {
    margin: 0 0 6px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.2rem;
    font-weight: 600;
}
.panel-intro {
    margin: 0 0 16px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ---------- Boutons et champs de saisie ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 10px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.btn:focus-visible {
    outline: 2px solid var(--title-red);
    outline-offset: 2px;
}
.btn-primary {
    background-color: var(--mc-red);
    color: #ffffff;
}
.btn-primary:hover {
    background-color: var(--mc-red-dark);
}
.btn-ghost {
    background: none;
    border-color: var(--border);
    color: var(--text);
}
.btn-ghost:hover {
    border-color: var(--text-muted);
}
.btn-scan {
    width: 100%;
    font-size: 1.05rem;
}
.btn-scan + .btn-scan {
    margin-top: 10px;
}
.icon {
    width: 22px;
    height: 22px;
}
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border);
}
.area-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background-color: var(--input-bg);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    resize: vertical;
}
textarea:focus-visible {
    outline: 2px solid var(--title-red);
    outline-offset: 1px;
}
.actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}
.actions .btn-primary {
    flex: 1;
}
select,
input[type="file"] {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
}
.advanced {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.advanced summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.advanced-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 0.9rem;
}
.advanced-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.advanced-controls .btn {
    min-height: 40px;
    padding: 6px 16px;
}

/* ---------- Résultat ---------- */

#result {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
#result[hidden] {
    display: none;
}
.banner {
    padding: 14px 16px;
    border: 1px solid;
    border-radius: 12px;
}
.banner p {
    margin: 4px 0 0;
    font-size: 0.92rem;
}
.banner details {
    margin-top: 8px;
    font-size: 0.9rem;
}
.banner summary {
    cursor: pointer;
}
.banner-success {
    background-color: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}
.banner-error {
    background-color: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}
.banner-warning {
    background-color: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

/* Carte du document, présentée comme un titre officiel */

.doc-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.doc-card[hidden] {
    display: none;
}
.doc-band {
    padding: 16px 20px;
    background-color: var(--mc-red);
    /* léger motif de losanges, clin d'œil aux armes des Grimaldi */
    background-image:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 12px, transparent 12px 24px),
        repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.05) 0 12px, transparent 12px 24px);
    color: #ffffff;
}
.doc-country {
    margin: 0;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    opacity: 0.9;
}
.doc-title {
    margin: 2px 0 0;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.25rem;
    font-weight: 600;
}
.doc-body {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 18px 20px;
}
.portrait {
    margin: 0;
}
.portrait img {
    display: block;
    width: 110px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

/* Listes « libellé : valeur » (carte et détails techniques) */

.fields {
    flex: 1;
    min-width: 230px;
    margin: 0;
}
.field {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.field:last-child {
    border-bottom: 0;
}
.field-label {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.field-value {
    margin: 2px 0 0;
    font-size: 1.02rem;
    overflow-wrap: anywhere;
}
.object-table {
    width: 100%;
    margin-top: 4px;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.object-table th,
.object-table td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: left;
}
.object-table th {
    background-color: var(--main-bg-color);
    font-weight: 600;
}
.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

/* Contrôles de la chaîne de confiance (détails techniques) */

.check-list {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
}
.check {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.check:last-child {
    border-bottom: 0;
}
.check-mark {
    flex: none;
    width: 1.2em;
    text-align: center;
    font-weight: 700;
}
.check-ok .check-mark {
    color: var(--success-text);
}
.check-warn .check-mark {
    color: var(--warning-text);
}
.check-fail .check-mark {
    color: var(--error-text);
}
.check strong {
    font-size: 0.92rem;
}
.check-detail {
    margin: 1px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}
.tech summary {
    cursor: pointer;
    font-weight: 600;
}
.tech #tech-content {
    margin-top: 8px;
}

/* ---------- Comment ça marche ---------- */

.how ol {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
}
.how li {
    display: flex;
    gap: 12px;
    counter-increment: step;
}
.how li::before {
    content: counter(step);
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--mc-red);
    color: #ffffff;
    font-weight: 700;
}

/* ---------- Pied de page ---------- */

.site-footer {
    max-width: 680px;
    margin: 0 auto;
    padding: 12px 16px 32px;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}
.site-footer p {
    margin: 6px 0;
}

/* ---------- Scanner QR ---------- */

#scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
#scanner-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
#scanner-frame {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* limite l'assombrissement hors zone à l'aperçu */
}
#scanner-video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
#scanner-guide {
    position: absolute;
    pointer-events: none;
    /* assombrit ce qui est hors de la zone analysée */
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
    /* coins du cadre de visée */
    background-image:
        linear-gradient(#ffffff, #ffffff), linear-gradient(#ffffff, #ffffff),
        linear-gradient(#ffffff, #ffffff), linear-gradient(#ffffff, #ffffff),
        linear-gradient(#ffffff, #ffffff), linear-gradient(#ffffff, #ffffff),
        linear-gradient(#ffffff, #ffffff), linear-gradient(#ffffff, #ffffff);
    background-position:
        left top, left top,
        right top, right top,
        left bottom, left bottom,
        right bottom, right bottom;
    background-size:
        28px 4px, 4px 28px,
        28px 4px, 4px 28px,
        28px 4px, 4px 28px,
        28px 4px, 4px 28px;
    background-repeat: no-repeat;
}
#scanner-guide[hidden] {
    display: none;
}
#scanner-zoom {
    margin-top: 12px;
    width: min(60%, 320px);
    accent-color: #ffffff;
}
#scanner-zoom[hidden] {
    display: none;
}
#scanner-camera {
    margin-top: 12px;
    max-width: min(80%, 320px);
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font-size: 0.9rem;
}
#scanner-camera[hidden] {
    display: none;
}
#scanner-status {
    margin-top: 16px;
    padding: 0 20px;
    color: #ffffff;
    font-size: 0.95rem;
    text-align: center;
}
#scanner-close {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
}
#scanner-close:hover {
    background: rgba(255, 255, 255, 0.3);
}
@media (max-width: 600px) {
    #scanner-close {
        top: 12px;
        right: 12px;
        width: 48px;
        height: 48px;
        font-size: 28px;
    }
}
