/* Page des annonces (view/index.html), affichée dans une iframe du site de l'AFIG.
   Style repris de la page « entreprises » de l'AFIG (https://afig-asso.github.io/entreprises/) :
   bandeau vert, pastilles arrondies, une ligne par offre.
   Les couleurs sont regroupées ici : changer le thème = changer ces variables.
   (Les couleurs des types d'offres, elles, sont dans shared/types.json.) */
:root {
    --afig-50:  #f4fae3;
    --afig-100: #ecf6cf;
    --afig-200: #d6ee8f;
    --afig:     #a2d026;   /* vert AFIG : bandeau */
    --afig-600: #6f8f12;
    --afig-700: #56720c;
    --afig-800: #3e5307;
    --ink:      #1d2a00;   /* texte sur vert AFIG */

    --text:   #1f2328;
    --text-2: #3a4046;
    --muted:  #5b6168;
    --line:   #e6e9e2;
    --line-2: #cfd4cb;

    --radius: 12px;
    --radius-band: 16px;
    --shadow-sm: 0 1px 2px rgba(29, 42, 0, 0.08);
    --shadow-md: 0 6px 20px rgba(29, 42, 0, 0.10);
    --ease: 140ms ease;
    --font: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: transparent; }
body {
    margin: 0 auto;
    max-width: 1250px;
    padding: 0 1rem 2rem;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    accent-color: var(--afig-700);
    -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h3, p { margin: 0; }
a { color: var(--afig-800); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Bandeau vert ---------- */
.toolbar {
    padding: 1rem 1.25rem;
    background:
        radial-gradient(120% 160% at 100% 0%, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 55%),
        var(--afig);
    color: var(--ink);
    border-radius: 0 0 var(--radius-band) var(--radius-band);
    display: grid;
    gap: 0.8rem;
}

.recherche { display: block; }
.search-input {
    width: 100%; height: 44px;
    padding: 0 1rem 0 2.75rem;
    border: 1.5px solid #4a6309;
    border-radius: 999px;
    font-size: 0.95rem;
    background: white no-repeat 1rem 50% / 18px
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6168' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
    box-shadow: 0 2px 6px rgba(29, 42, 0, 0.12);
    transition: box-shadow var(--ease);
}
.search-input::placeholder { color: var(--muted); opacity: 1; }
.search-input:hover { box-shadow: 0 3px 10px rgba(29, 42, 0, 0.18); }
.search-input:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 999px; }

/* Puces de types (générées par script.js) : bouton à bascule, la couleur du type est dans --c */
.puces { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.puce {
    --c: var(--muted);
    display: inline-flex; align-items: center; gap: 0.5rem; min-height: 40px;
    padding: 0 0.95rem 0 0.8rem;
    border: 0; border-radius: 999px;
    background: rgba(255, 255, 255, 0.32);
    font-size: 0.88rem; font-weight: 600; color: var(--ink);
    transition: background-color var(--ease), box-shadow var(--ease);
}
.puce::before {
    content: ""; flex: none; width: 12px; height: 12px; border-radius: 50%;
    background: var(--c); box-shadow: 0 0 0 2px white;
}
.puce:hover { background: rgba(255, 255, 255, 0.6); }
.puce .nb {
    display: inline-flex; align-items: center; justify-content: center; min-width: 1.5rem; height: 1.3rem;
    padding: 0 0.35rem; border-radius: 999px; background: var(--ink); color: var(--afig);
    font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.puce[aria-pressed="true"] { background: white; box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--c); }
.puce.vide { opacity: 0.55; }

/* Listes déroulantes et case « mode édition » en pastilles */
.champs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.6rem; }
.champ { display: inline-flex; min-width: 0; }
.champ select {
    min-height: 40px; max-width: 16rem; padding: 0 2rem 0 0.95rem;
    border: 0; border-radius: 999px;
    font-size: 0.88rem; font-weight: 600; color: var(--ink);
    background-color: rgba(255, 255, 255, 0.32);
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%231d2a00'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.85rem center; background-size: 0.6rem;
    transition: background-color var(--ease);
}
.champ select:hover { background-color: rgba(255, 255, 255, 0.6); }
.champ select option, .champ select optgroup { color: var(--text); background: white; }

.toggle { position: relative; display: inline-flex; margin-left: auto; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.toggle label {
    display: inline-flex; align-items: center; gap: 0.5rem; min-height: 40px;
    padding: 0 0.95rem 0 0.7rem; border-radius: 999px; cursor: pointer;
    font-size: 0.88rem; font-weight: 600; color: var(--ink);
    background: rgba(255, 255, 255, 0.32);
    transition: background-color var(--ease);
}
.toggle label::before {
    content: ""; flex: none; width: 18px; height: 18px; border-radius: 5px;
    border: 2px solid var(--ink); background: white center / 13px no-repeat;
}
.toggle label:hover { background: rgba(255, 255, 255, 0.6); }
.toggle input:checked + label { background: white; box-shadow: var(--shadow-sm); }
.toggle input:checked + label::before {
    background-color: var(--ink);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a2d026' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12l5 5L20 6'/%3E%3C/svg%3E");
}
.toggle:has(input:focus-visible) label { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---------- Compteur ---------- */
.listing-head {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 1.2rem;
    margin: 1rem 0 0.6rem; padding: 0 0.25rem;
}
.listing-summary { color: var(--muted); font-size: 0.9rem; }
.lien-bouton {
    padding: 0; font-size: 0.9rem; color: var(--afig-800);
    background: none; border: none; text-decoration: underline; text-underline-offset: 3px;
}
.lien-bouton[hidden] { display: none; }

/* ---------- Liste : une ligne par offre ---------- */
.liste { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }

.offre {
    display: grid;
    grid-template-columns: minmax(9rem, 11rem) minmax(0, 1fr) auto;
    gap: 0.4rem 2rem;
    align-items: start;
    padding: 1.05rem 1rem 1.1rem;
    border-bottom: 1px solid var(--line);
    transition: background-color var(--ease), box-shadow var(--ease);
}
.offre:hover, .offre:focus-within { background: var(--afig-50); box-shadow: inset 3px 0 0 var(--afig); }

.offre-tete { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; }

/* Étiquette du type : la couleur vient de shared/types.json (variable --c posée par script.js) */
.badge {
    display: inline-flex; align-items: center; min-height: 26px; padding: 0 0.7rem;
    border-radius: 999px;
    font-size: 0.76rem; font-weight: 700; line-height: 1.2;
    color: color-mix(in srgb, var(--c, var(--muted)) 62%, black);
    background: color-mix(in srgb, var(--c, var(--muted)) 14%, white);
    border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 35%, white);
}
.date { font-size: 0.82rem; color: var(--muted); }
.nouveau {
    margin-left: 0.4rem; padding: 0 0.45rem;
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
    color: var(--ink); background: var(--afig); border-radius: 999px;
}

.offre-corps { min-width: 0; }
.titre { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.005em; line-height: 1.3; overflow-wrap: anywhere; }
.titre a { display: inline-block; padding: 2px 0; color: var(--text); text-decoration: underline; text-decoration-color: var(--afig); text-underline-offset: 3px; text-decoration-thickness: 2px; }
.titre a:hover { text-decoration-color: var(--afig-600); }
.qui { margin-top: 0.15rem; font-size: 0.92rem; color: var(--text-2); overflow-wrap: anywhere; }
.qui .lieu { color: var(--muted); }
.commentaire { margin-top: 0.35rem; font-size: 0.84rem; color: var(--muted); max-width: 90ch; overflow-wrap: anywhere; }

.offre-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; white-space: nowrap; }
.lien-externe {
    display: inline-flex; align-items: center; min-height: 34px; padding: 0 0.8rem;
    border: 1.5px solid var(--afig-700); border-radius: 8px; background: white; color: var(--afig-800);
    font-size: 0.8rem; font-weight: 700;
    transition: background-color var(--ease), color var(--ease);
}
.lien-externe:hover { background: var(--afig-800); border-color: var(--afig-800); color: white; text-decoration: none; }
.edition-icones { display: flex; gap: 0.7rem; }
.icon { width: 16px; height: 16px; }

.message-vide {
    margin-top: 1rem; padding: 2.5rem 1.5rem; text-align: center; color: var(--text-2);
    background: var(--afig-50); border-radius: var(--radius);
}
.message-vide[hidden] { display: none; }

.plus { text-align: center; margin-top: 1.25rem; }
.plus button {
    min-height: 40px; padding: 0 1.4rem; border: 0; border-radius: 999px;
    background: var(--ink); color: var(--afig); font-weight: 700;
    transition: background-color var(--ease);
}
.plus button:hover { background: #33470a; }
.plus button[hidden] { display: none; }

/* ---------- Écrans étroits ---------- */
@media (max-width: 760px) {
    body { padding: 0 0.5rem 1.5rem; }
    .toolbar { padding: 0.8rem; }
    .offre { grid-template-columns: 1fr; gap: 0.5rem; padding: 0.9rem 0.5rem; }
    .offre-tete { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 0.2rem 0.7rem; }
    .offre-actions { flex-direction: row; align-items: center; justify-content: flex-start; flex-wrap: wrap; }
    .toggle { margin-left: 0; }
    .champ select { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
