/* L'annonce d'emploi : la page annonce.html, et les éléments de l'annonce
   repris sur la candidature (colonne sur ordinateur, panneau sur téléphone).
   Les variables sont préfixées (--ad-) : postuler.css a les siennes. */
:root {
  --ad-ink: #18332f;
  --ad-deep: #102b2a;
  --ad-green: #176a59;
  --ad-paper: #f7f5ed;
  --ad-white: #fffef9;
  --ad-lime: #dcf36b;
  --ad-mint: #e6f0e6;
  --ad-muted: #5f7068;
  --ad-line: #d7ded4;
}

/* ——— Éléments de l'annonce (communs) ——— */
.ad-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 0; }
.ad-fact { padding: 11px 13px; border: 1px solid var(--ad-line); border-radius: 12px; background: var(--ad-white); }
.ad-fact dt { margin: 0 0 3px; color: var(--ad-green); font-size: 12px; font-weight: 800; letter-spacing: .02em; }
.ad-fact dd { margin: 0; color: var(--ad-ink); font-size: 15px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.ad-highlights { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.ad-highlights li { padding: 6px 11px; border-radius: 999px; color: var(--ad-deep); background: var(--ad-mint); font-size: 13px; font-weight: 750; }
.ad-highlights li::before { content: "✓ "; color: var(--ad-green); }
.ad-intro { margin: 0 0 8px; color: var(--ad-ink); font-size: 18px; line-height: 1.6; }
.ad-section { padding: 22px 0 6px; border-top: 1px solid var(--ad-line); }
.ad-section > h2, .ad-section > h3 { margin: 0 0 12px; color: var(--ad-deep); font-size: 22px; line-height: 1.2; letter-spacing: -.025em; }
.ad-entries { display: grid; gap: 14px; margin: 0 0 16px; }
.ad-entry dt { margin: 0 0 2px; color: var(--ad-green); font-size: 13px; font-weight: 800; }
.ad-entry dd { margin: 0; color: var(--ad-ink); font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }
.ad-entry dd.is-multiline { white-space: pre-line; }
.ad-entry dd a { color: var(--ad-green); font-weight: 700; }
.ad-toc-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.ad-toc-list a { display: block; padding: 7px 10px; border-radius: 9px; color: var(--ad-ink); font-size: 14px; font-weight: 650; text-decoration: none; }
.ad-toc-list a:hover, .ad-toc-list a:focus-visible { background: var(--ad-mint); }

/* ——— Page de l'annonce ——— */
.ad-page { margin: 0; color: var(--ad-ink); background: var(--ad-paper); font-family: Inter, "Segoe UI", Arial, sans-serif; font-size: 17px; line-height: 1.55; font-synthesis: none; text-rendering: optimizeLegibility; }
:where(.ad-page) *, :where(.ad-page) *::before, :where(.ad-page) *::after { box-sizing: border-box; }
.ad-page [hidden] { display: none !important; }
:where(.ad-page) a { color: inherit; }
:where(.ad-page) button { font: inherit; cursor: pointer; }
:where(.ad-page) img { display: block; max-width: 100%; }
html:has(.ad-page) { scroll-behavior: smooth; scroll-padding-top: 20px; background: var(--ad-paper); }
.ad-page :focus-visible { outline: 3px solid var(--ad-green); outline-offset: 3px; }
.ad-page .skip-link { position: fixed; z-index: 40; top: 10px; left: 10px; padding: 12px 16px; border-radius: 10px; color: var(--ad-ink); background: var(--ad-lime); font-weight: 750; transform: translateY(-160%); }
.ad-page .skip-link:focus { transform: none; }
.ad-page.is-loading .ad-aside, .ad-page.is-loading .ad-bar { visibility: hidden; }

.ad-topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 72px; padding: 10px max(24px, calc((100vw - 1180px) / 2)); border-bottom: 1px solid rgba(24, 51, 47, .12); }
.ad-brand { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 10px; text-decoration: none; }
.ad-brand-mark { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; color: var(--ad-lime); background: var(--ad-ink); font: 700 22px/1 Georgia, serif; }
.ad-brand-name { font-size: 16px; font-weight: 750; letter-spacing: -.05em; }
.ad-brand-name b { color: var(--ad-green); }
.ad-back { min-width: 0; color: var(--ad-green); font-size: 14px; font-weight: 750; text-align: right; text-decoration: none; }
.ad-back:hover { text-decoration: underline; }

.ad-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 72px; }
.ad-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 56px; align-items: start; }
.ad-main { min-width: 0; max-width: 760px; }

.ad-head { padding-bottom: 22px; }
.ad-employer { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 16px; text-decoration: none; }
.ad-employer img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.ad-employer b, .ad-employer small { display: block; }
.ad-employer b { color: var(--ad-ink); font-size: 16px; line-height: 1.25; }
.ad-employer small { color: var(--ad-muted); font-size: 14px; }
.ad-employer:hover b { text-decoration: underline; }
.ad-urgent { display: inline-block; margin: 0 0 10px; padding: 5px 11px; border-radius: 999px; color: #7a2a12; background: #ffe2d6; font-size: 13px; font-weight: 800; }
.ad-head h1 { margin: 0 0 18px; color: var(--ad-deep); font-size: clamp(30px, 4.2vw, 46px); line-height: 1.08; letter-spacing: -.045em; overflow-wrap: anywhere; }
.ad-response { margin: 14px 0 0; color: var(--ad-green); font-size: 15px; font-weight: 750; }
.ad-response::before { content: "◷ "; }

.ad-aside { position: sticky; top: 20px; display: grid; gap: 18px; }
.ad-apply-card { padding: 22px; border: 1px solid var(--ad-line); border-radius: 20px; background: var(--ad-white); box-shadow: 0 14px 40px rgba(16, 43, 42, .07); }
.ad-apply-card p { margin: 0 0 16px; color: var(--ad-muted); font-size: 14px; line-height: 1.5; }
.ad-apply-card .ad-apply-title { margin-bottom: 4px; color: var(--ad-ink); font-size: 17px; font-weight: 800; }
.ad-apply { display: flex; min-height: 54px; align-items: center; justify-content: center; gap: 10px; padding: 12px 18px; border-radius: 14px; color: var(--ad-lime); background: var(--ad-deep); font-size: 16px; font-weight: 800; text-align: center; text-decoration: none; }
.ad-apply:hover { background: #18403c; }
.ad-share { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.ad-share button, .ad-share a, .ad-secondary, .ad-bar-share { display: flex; min-height: 44px; align-items: center; justify-content: center; padding: 8px 12px; border: 1px solid var(--ad-line); border-radius: 12px; color: var(--ad-ink); background: var(--ad-white); font-size: 14px; font-weight: 700; text-decoration: none; }
.ad-share button:hover, .ad-share a:hover, .ad-secondary:hover, .ad-bar-share:hover { background: var(--ad-mint); }
.ad-toc { padding: 16px 12px; border-radius: 18px; background: rgba(230, 240, 230, .55); }
.ad-toc-title { margin: 0 10px 6px; color: var(--ad-muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.ad-bar { display: none; }

/* Ordinateur : la colonne tient dans la fenêtre ; seul le sommaire défile. */
@media (min-width: 901px) {
  .ad-aside { max-height: calc(100dvh - 40px); grid-template-rows: auto minmax(0, 1fr); }
  .ad-toc { overflow: auto; overscroll-behavior: contain; }
}
@media (min-width: 901px) and (max-height: 480px) {
  .ad-toc { display: none; }
}

.ad-closed { max-width: 640px; margin: 40px auto; padding: 34px; border: 1px solid var(--ad-line); border-radius: 22px; background: var(--ad-white); text-align: center; }
.ad-closed h1 { margin: 0 0 10px; color: var(--ad-deep); font-size: clamp(26px, 4vw, 34px); line-height: 1.15; letter-spacing: -.035em; }
.ad-closed p { margin: 0 0 22px; color: var(--ad-muted); }
.ad-closed-actions { display: grid; gap: 10px; }

.ad-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px; padding: 22px max(24px, calc((100vw - 1180px) / 2)); border-top: 1px solid var(--ad-line); color: var(--ad-muted); font-size: 13px; }
.ad-footer a:not(.ad-brand) { color: var(--ad-ink); font-weight: 700; text-decoration: none; }

.ad-toast { position: fixed; z-index: 50; right: 18px; bottom: 18px; max-width: min(420px, calc(100% - 36px)); padding: 14px 18px; border-radius: 12px; color: #fff; background: var(--ad-deep); box-shadow: 0 10px 34px rgba(16, 41, 31, .22); opacity: 0; visibility: hidden; transform: translateY(12px); transition: opacity .2s ease, transform .2s ease, visibility .2s; }
.ad-toast.is-visible { opacity: 1; visibility: visible; transform: none; }

/* Téléphone et tablette : une colonne ; « Postuler » dans une barre en bas,
   toujours visible ; la carte de candidature et le partage en fin d'annonce. */
@media (max-width: 900px) {
  .ad-shell { width: min(100% - 32px, 720px); padding: 22px 0 40px; }
  .ad-layout { display: block; }
  .ad-aside { position: static; margin-top: 26px; }
  .ad-toc { display: none; }
  .ad-apply-card .ad-apply { display: none; }
  .ad-bar { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; display: flex; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(24, 51, 47, .12); background: rgba(247, 245, 237, .97); backdrop-filter: blur(14px); }
  .ad-bar[hidden] { display: none; }
  .ad-bar .ad-apply { flex: 1 1 auto; min-height: 52px; }
  .ad-bar-share { flex: 0 0 auto; min-height: 52px; padding: 8px 16px; }
  .ad-page { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  html:has(.ad-page) { scroll-padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .ad-toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
  /* La note d'envoi différé (envoi-differe.js) passe au-dessus de la barre. */
  .ad-page:has(.ad-bar:not([hidden])) [data-pending-notice] { bottom: calc(86px + env(safe-area-inset-bottom)) !important; }
}

@media (max-width: 560px) {
  .ad-topbar { min-height: 62px; padding: 8px 16px; }
  .ad-brand-mark { width: 36px; height: 36px; font-size: 20px; }
  .ad-brand-name { font-size: 15px; }
  .ad-back { font-size: 13px; }
  .ad-head h1 { margin-bottom: 14px; font-size: 28px; line-height: 1.12; letter-spacing: -.035em; }
  .ad-employer { margin-bottom: 12px; }
  .ad-employer img { width: 42px; height: 42px; }
  .ad-facts { grid-template-columns: 1fr 1fr; gap: 6px; }
  .ad-fact { padding: 9px 11px; }
  .ad-fact dd { font-size: 14px; }
  .ad-intro { font-size: 17px; }
  .ad-section > h2, .ad-section > h3 { font-size: 20px; }
  .ad-closed { padding: 26px 20px; }
}

/* Aperçu dans l'éditeur d'offre : pas de barre du haut ni de pied de page. */
.is-preview .ad-topbar, .is-preview .ad-footer { display: none; }
.is-preview .ad-shell { padding-top: 18px; }

/* ——— Candidature (postuler.html) : l'annonce reste lisible ——— */
.apply-ad-kicker { margin: 0 0 4px; color: var(--ad-green); font-size: 11px; font-weight: 850; letter-spacing: .13em; }
.ad-reopen { min-height: 44px; padding: 9px 16px; border: 0; border-radius: 999px; color: var(--ad-deep); background: var(--ad-lime); font: inherit; font-size: 14px; font-weight: 850; cursor: pointer; }
.ad-reopen:hover { filter: brightness(.96); }
.offer-summary-actions { display: grid; gap: 8px; }
.offer-summary-actions .offer-summary-link { border: 0; font: inherit; font-size: 14px; font-weight: 850; cursor: pointer; }
.offer-summary-actions .offer-summary-link.is-secondary { border: 1px solid var(--ad-line); background: #fff; }
.apply-ad h2 { margin: 0 0 16px; color: var(--ad-deep); font-size: 24px; line-height: 1.15; letter-spacing: -.035em; }
.apply-ad .ad-facts, .ad-sheet .ad-facts { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.apply-ad .ad-intro, .ad-sheet .ad-intro { margin-top: 16px; font-size: 16px; }
.apply-ad .ad-section > h3, .ad-sheet .ad-section > h3 { font-size: 18px; }
.apply-ad .ad-entry dd, .ad-sheet .ad-entry dd { font-size: 15px; }
/* Contour de focus foncé : contraste suffisant sur les fonds clairs. */
.application-topbar :focus-visible, .offer-summary-actions :focus-visible, .apply-ad:focus-visible, .apply-ad :focus-visible, .ad-sheet :focus-visible { outline: 3px solid var(--ad-green); outline-offset: 3px; }
.ad-sheet-body:focus-visible { outline-offset: -3px; }

/* Ordinateur : deux colonnes, l'annonce à droite, collante et défilante. */
@media (min-width: 1100px) {
  .apply-has-ad .application-shell { width: min(1340px, calc(100% - 48px)); }
  .apply-has-ad .apply-columns { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 34px; align-items: start; }
  .apply-has-ad [data-open-ad] { display: none; }
  /* La carte de l'offre, plus étroite à côté de la colonne. */
  .apply-has-ad .offer-summary { grid-template-columns: 132px minmax(0, 1fr); gap: 8px 20px; }
  .apply-has-ad .offer-summary-image { grid-row: span 2; }
  .apply-has-ad .offer-summary-actions { grid-column: 2; justify-self: start; }
  .apply-ad { position: sticky; top: 18px; max-height: calc(100vh - 36px); overflow: auto; overscroll-behavior: contain; padding: 24px 24px 10px; border: 1px solid var(--ad-line); border-radius: 20px; background: var(--ad-white); box-shadow: 0 14px 40px rgba(16, 43, 42, .07); }
}
@media (max-width: 1099px) {
  .apply-ad { display: none !important; }
  /* Téléphone et tablette : la barre du haut reste visible, avec « Revoir l'annonce » ;
     ce qui reçoit le focus ou le défilement s'arrête sous elle. */
  .apply-has-ad .application-topbar { position: sticky; z-index: 25; top: 0; background: rgba(245, 244, 236, .97); backdrop-filter: blur(12px); }
  html:has(body.apply-has-ad) { scroll-padding-top: 84px; }
}

/* Le panneau de l'annonce, plein écran sur téléphone. */
.ad-sheet { width: min(760px, calc(100% - 32px)); max-width: none; height: min(92dvh, 940px); max-height: none; margin: auto; padding: 0; overflow: hidden; border: 0; border-radius: 20px; color: var(--ad-ink); background: var(--ad-paper); box-shadow: 0 24px 80px rgba(10, 34, 32, .3); }
.ad-sheet[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.ad-sheet::backdrop { background: rgba(10, 34, 32, .6); }
.ad-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 16px 18px 12px; border-bottom: 1px solid var(--ad-line); background: var(--ad-white); }
.ad-sheet-head h2 { margin: 0; color: var(--ad-deep); font-size: 20px; line-height: 1.2; letter-spacing: -.025em; }
.ad-sheet-close { flex: 0 0 44px; width: 44px; height: 44px; border: 0; border-radius: 50%; color: var(--ad-deep); background: var(--ad-mint); font: inherit; font-size: 26px; line-height: 1; cursor: pointer; }
.ad-sheet-body { overflow: auto; overscroll-behavior: contain; padding: 16px 18px 6px; }
.ad-sheet-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--ad-line); background: var(--ad-white); }
.ad-sheet-foot .submit-button { width: 100%; }
@media (max-width: 760px) {
  .ad-sheet { width: 100%; height: 100dvh; border-radius: 0; }
  /* Autant de colonnes que de boutons visibles (un seul en candidature spontanée). */
  .offer-summary-actions { grid-column: 1 / -1; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .offer-summary-actions .offer-summary-link { grid-column: auto; width: auto; min-width: 0; padding: 12px 10px; font-size: 13px; }
}

/* Téléphone en paysage : le panneau prend tout l'écran, le × suffit pour fermer. */
@media (max-height: 500px) {
  .ad-sheet { width: 100%; height: 100dvh; border-radius: 0; }
  .ad-sheet-head { padding: 10px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left)); }
  .ad-sheet-body { padding: 14px max(18px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
  .ad-sheet-foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html:has(.ad-page) { scroll-behavior: auto; }
  .ad-toast { transition: none; }
}
