/* ============================================
   POLISH & A11Y — Phase 7 final de la refonte
   - Contraste AA renforcé (WCAG 2.1)
   - Tailles cibles 44×44px sur tous les éléments tappables
   - Focus visible amélioré (déjà global, ici on cible les éditoriaux)
   - Skip link clavier
   - Print clean
   ============================================ */

/* ─── Skip link (a11y clavier) ─────────────────────────── */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 10000;
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus-visible {
  top: var(--space-4);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Contraste AA — HÔTEL PARTICULIER ────────────────── */
/* muted #7C705F sur bg #F5EFE3 = 4.14:1 → sous AA pour body text.
   On le pousse à #6E6253 → ratio ≈ 4.75:1 ✓.
   On préserve la teinte chaude. */
:root,
:root[data-theme="hotel"] {
  --muted: #6E6253;
}

/* ─── Contraste AA — SALON PARISIEN ───────────────────── */
/* muted #9C7480 sur bg #F6E9E0 = 3.9:1 → renforce à #87616E ≈ 4.7:1 */
:root[data-theme="salon"] {
  --muted: #87616E;
}

/* ─── Contraste AA — ATELIER NOIR (déjà bon) ──────────── */
/* muted #A29881 sur bg #16130F = 7.1:1 ✓ rien à faire */

/* ─── Tap targets 44×44 — chips cliquables ────────────── */
/* Les .ed-chip font 22px de haut, sous le seuil tactile.
   On ajoute un pseudo-élément overlay invisible quand la chip est dans
   une zone interactive (parent button/role=button ou .ed-chip-tap). */
.ed-chip-tap,
button > .ed-chip,
[role="button"] > .ed-chip {
  position: relative;
}
.ed-chip-tap::before,
button > .ed-chip::before,
[role="button"] > .ed-chip::before {
  content: '';
  position: absolute;
  inset: -11px -6px;  /* extends to 44px height min */
  pointer-events: none;
}

/* ─── Tap targets — btn-icon ──────────────────────────── */
/* Beaucoup de .btn-icon font 28-32px. On garantit 36px min visible
   et 44px de zone tap via padding. */
.btn-icon {
  min-width: 36px;
  min-height: 36px;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}
.btn-icon::after {
  /* invisible extender so the effective tap area is 44×44 */
  content: '';
  position: absolute;
  inset: -4px;
}
.btn-icon:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--ink);
}

/* ─── Status dots / progress dots — accessibility helper ── */
.status-dot,
.task-priority-dot {
  position: relative;
}
/* If they're inside a clickable wrapper they need to be reachable too */

/* ─── Focus visible spécifique aux composants éditoriaux ── */
.ed-chip:focus-visible,
.ed-btn:focus-visible,
.admin-theme-card:focus-visible,
.admin-preset:focus-visible,
.admin-card-style:focus-visible,
.dash-task-row:focus-visible,
.dash-upcoming-row:focus-visible,
.dash-kpi-clickable:focus-visible,
.tl-event:focus-visible,
.community-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Sidebar nav focus state distinct from active */
.sidebar .nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ─── Form controls — accessibility refinements ────────── */
.form-input:focus,
.form-select:focus,
textarea.form-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ─── Touch device hint (no hover state for chip extenders) ── */
@media (hover: none) {
  .btn-icon:hover { background: transparent; }
}

/* ─── Reduced data motion: smaller blur radius on hero ──── */
@media (prefers-reduced-motion: reduce) {
  .dash-hero-photo-washes {
    background: var(--surface-tinted) !important;
  }
  .dash-hero-progress-fill,
  .dash-upcoming-fill {
    transition: none !important;
  }
}

/* ─── High contrast preference (Windows) ─────────────────── */
@media (prefers-contrast: more) {
  :root {
    --line: rgba(0, 0, 0, 0.35);
    --line-soft: rgba(0, 0, 0, 0.20);
  }
  :root[data-theme="noir"] {
    --line: rgba(255, 255, 255, 0.35);
    --line-soft: rgba(255, 255, 255, 0.20);
  }
  .ed-chip { border-width: 2px; }
  .btn { border-width: 2px !important; }
}

/* ─── Print final tweaks ──────────────────────────────────── */
@media print {
  body { background: #fff !important; color: #000 !important; }
  .sidebar, .mobile-header, #fab-container, #notif-panel, #toast-container,
  .no-print { display: none !important; }
  #app { padding: 0 !important; max-width: 100% !important; }
  .card { break-inside: avoid; page-break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
  .ed-chip { border-color: #000 !important; color: #000 !important; }
}

/* ─── Selection style (small but premium detail) ─────────── */
::selection {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--ink);
}
:root[data-theme="noir"] ::selection {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--ink);
}

/* ─── Scrollbar styling (subtle premium touch) ───────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 30%, transparent) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 30%, transparent);
  border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 50%, transparent);
}
*::-webkit-scrollbar-track { background: transparent; }

/* ─── LAYOUT INTEGRITY GUARDS ──────────────────────────────
   Several editorial CSS files (dashboard-editorial, pages-editorial) target
   #app directly with id-specificity, which silently overrode the layout
   discipline of .main-content from main.css. Symptoms before this block:
     · Desktop : `#app { margin: 0 auto; max-width: 1440px }` from
       dashboard-editorial.css → contenu centré → la sidebar fixe (left:0)
       recouvrait le début du contenu (laptop + iPad paysage).
     · Mobile  : `#app { padding: <shorthand> }` de pages-editorial.css
       écrasait le padding-top → le contenu glissait sous le .mobile-header.
   This block réaffirme le layout avec la MÊME specificity, chargé en
   dernier, donc la cascade le résout sans !important. */

/* Desktop & laptop : respecter l'offset de la sidebar fixe */
#app {
  margin-left: var(--sidebar-width);
  margin-right: 0;
  max-width: calc(100vw - var(--sidebar-width));
}

/* Tablet / mobile drawer : sidebar off-canvas, header fixe en haut.
   On ré-injecte le padding-top compensant le header (+ safe-area iOS). */
@media (max-width: 1024px) {
  #app {
    margin-left: 0;
    max-width: 100vw;
    padding-top: calc(var(--header-height) + env(safe-area-inset-top, 0px) + var(--space-4));
  }
}

@media (max-width: 640px) {
  #app {
    padding-top: calc(var(--header-height) + env(safe-area-inset-top, 0px) + var(--space-3));
  }
}
