/* Styles du module js/annot (préfixe dédié, voir docs/DESIGN.md). Réutiliser base.css avant de créer un style.
   Épuré : fond gris, coins arrondis, aucune ombre, aucune bordure ; contrôles en pilules. */

/* ---------- Scène ---------- */
.an-stage { position: relative; display: flex; flex-direction: column; width: 100%; min-width: 0; height: 100%; min-height: 320px; overflow: hidden; contain: inline-size;
  border-radius: var(--radius-card); background: var(--grey-100); color: var(--ink); isolation: isolate; user-select: none; -webkit-user-select: none; }
.an-host { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.an-loading { position: absolute; inset: 0; }
.an-stage.is-fullscreen { border-radius: 0; background: var(--navy-900); }

.an-vp { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; overflow: hidden; outline: none; }
.an-vp:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); border-radius: inherit; }
.an-vp--image { cursor: grab; touch-action: none; }
.an-vp--image.is-grabbing, .an-stage.is-panning .an-vp { cursor: grabbing; }
.an-stage.is-panning .an-ov { pointer-events: none; }

/* Image : le cadre est dimensionné par JS (largeur/hauteur réelles, pas de scale) */
.an-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.an-img { width: 100%; height: 100%; max-width: none; pointer-events: none; -webkit-user-drag: none; image-rendering: auto; }

/* PDF */
.an-vp--pdf { overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--grey-300) transparent; }
.an-vp--pdf.is-grabbing { cursor: grabbing; }
.an-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px 24px 72px; width: max-content; min-width: 100%; }
.an-page { position: relative; flex: none; background: var(--paper); border-radius: 4px; overflow: hidden; }
.an-page::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--grey-50), var(--paper), var(--grey-50)); background-size: 200% 100%; animation: an-sk 1.2s ease-in-out infinite; }
.an-page.is-ready::before { display: none; }
@keyframes an-sk { to { background-position: -200% 0; } }
.an-pcanvas { width: 100%; height: 100%; max-width: none; }

/* Vidéo */
.an-vp--video { background: var(--navy-900); border-radius: var(--radius-card) var(--radius-card) 0 0; cursor: pointer; }
.an-stage.is-fullscreen .an-vp--video { border-radius: 0; }
.an-frame { position: absolute; }
.an-video { width: 100%; height: 100%; max-width: none; object-fit: contain; background: #000; }

/* Audio */
.an-vp--audio, .an-vp--other { display: grid; place-items: center; padding: 32px 16px; }
.an-audio { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 100%; text-align: center; }
.an-audio__icon { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-navy); color: var(--on-accent); }
.an-audio__name { max-width: min(420px, 80vw); }
.an-stage--audio { min-height: 260px; }

/* Autre fichier */
.an-other { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.an-other__icon { position: relative; width: 84px; height: 84px; border-radius: 24px; display: grid; place-items: center; background: var(--paper); color: var(--ink-2); margin-bottom: 4px; }
.an-other__icon span { position: absolute; bottom: 12px; font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 10px; letter-spacing: .04em; color: var(--ink-3); }
.an-other__icon .icon { width: 30px; height: 30px; margin-top: -12px; }
.an-other__name { max-width: min(460px, 80vw); overflow-wrap: anywhere; }
.an-other .btn { margin-top: 6px; }

/* ---------- Calque d'annotation ---------- */
.an-ov { position: absolute; inset: 0; z-index: 2; touch-action: auto; }
.an-ov.is-active { touch-action: none; }
.an-ov.is-pin { cursor: crosshair; }
.an-ov.is-draw { cursor: crosshair; }
.an-svg { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; overflow: visible; pointer-events: none; }
.an-stroke.is-dim { opacity: .45; }
.an-halo { opacity: .9; }
.an-shapes.is-hl .an-stroke { animation: an-blink .5s ease-in-out 2 alternate; }
@keyframes an-blink { to { opacity: .35; } }
.an-pins { position: absolute; inset: 0; pointer-events: none; }

/* Pastille : même look que .pin (base.css), taille écran constante, centrée sur son point */
.an-pin { position: absolute; z-index: 1; transform: translate(-50%, -50%); pointer-events: auto; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 7px; border: 0; border-radius: var(--radius-pill);
  background: var(--grad-red); color: var(--on-accent); font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 12.5px; line-height: 1;
  outline: 2px solid var(--paper); outline-offset: 0; transition: transform .12s ease; -webkit-tap-highlight-color: transparent; }
.an-pin span { transform: translateX(-.5px); }
.an-pin:hover { transform: translate(-50%, -50%) scale(1.12); }
.an-pin:focus-visible { outline: 2px solid var(--paper); box-shadow: 0 0 0 4px var(--focus); }
.an-pin--admin { background: var(--grad-navy); }
.an-pin--done { background: var(--grey-300); color: var(--ink); }
.an-pin.is-hl { z-index: 3; transform: translate(-50%, -50%) scale(1.18); box-shadow: 0 0 0 6px rgba(236, 21, 70, .28); }
.an-pin--admin.is-hl { box-shadow: 0 0 0 6px rgba(43, 53, 70, .28); }
.an-pin--draft { z-index: 4; pointer-events: none; background: var(--paper); color: var(--red-500); outline: 2px solid var(--red-500); font-size: 15px; }
.an-pin--draft::after { content: ""; position: absolute; inset: -2px; border-radius: inherit; border: 2px solid var(--red-500); animation: an-pulse 1.4s ease-out infinite; }
@keyframes an-pulse { from { transform: scale(1); opacity: .8; } to { transform: scale(1.9); opacity: 0; } }
.an-ov.is-active .an-pin:not(.an-pin--draft) { pointer-events: auto; }

/* ---------- Contrôles flottants (zoom, page) ---------- */
.an-float { position: absolute; z-index: 5; display: inline-flex; align-items: center; gap: 2px; padding: 4px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .92); color: var(--ink); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.an-float--zoom { right: 12px; bottom: 12px; }
.an-float--page { left: 12px; bottom: 12px; padding: 0 14px; height: 40px; font-family: var(--font-ui); font-size: 13px; color: var(--ink-2); }
.an-zlabel { min-width: 58px; height: 32px; padding: 0 6px; border: 0; border-radius: var(--radius-pill); background: none; cursor: pointer; font-family: var(--font-ui); font-size: 12.5px; color: var(--ink-2); }
.an-zlabel:hover { background: var(--grey-100); color: var(--ink); }

.an-pbtn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--radius-pill); background: none; color: inherit; cursor: pointer; flex: none; -webkit-tap-highlight-color: transparent; }
.an-pbtn:hover { background: var(--grey-100); }
.an-pbtn .icon { width: 18px; height: 18px; }
.an-pbtn--text { width: auto; min-width: 40px; padding: 0 10px; font-family: var(--font-ui); font-size: 12.5px; }

/* ---------- Lecteur (vidéo / audio) ---------- */
.an-ctrls { position: relative; z-index: 5; display: flex; flex-direction: column; gap: 4px; padding: 6px 12px 10px; background: var(--grey-100); }
.an-ctrls__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.an-ctrls__grp { display: flex; align-items: center; gap: 2px; min-width: 0; }
.an-pbtn--main { width: 40px; height: 40px; background: var(--grad-navy); color: var(--on-accent); margin-right: 6px; }
.an-pbtn--main:hover { background: var(--grad-navy); filter: brightness(1.2); }
.an-time { margin-left: 8px; font-family: var(--font-ui); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.an-time b { font-weight: 400; color: var(--ink); }
.an-ctrls .an-pbtn:not(.an-pbtn--main):hover { background: var(--grey-200); }

.an-track { position: relative; height: 26px; cursor: pointer; touch-action: none; outline: none; margin: 0 2px; }
.an-track:focus-visible .an-track__rail { box-shadow: 0 0 0 2px var(--focus); }
.an-track__rail { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: var(--radius-pill); background: var(--grey-300); overflow: hidden; transition: height .12s, margin .12s; }
.an-track:hover .an-track__rail, .an-track.is-scrubbing .an-track__rail { height: 6px; margin-top: -3px; }
.an-track__buf { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(38, 48, 63, .14); }
.an-track__played { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--grad-navy); border-radius: inherit; }
.an-track__knob { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--navy-500); outline: 2px solid var(--paper); pointer-events: none; z-index: 3; transform: scale(.85); transition: transform .12s; }
.an-track:hover .an-track__knob, .an-track.is-scrubbing .an-track__knob { transform: scale(1); }
.an-track__tip { position: absolute; bottom: calc(100% + 2px); transform: translateX(-50%); padding: 3px 8px; border-radius: var(--radius-pill); background: var(--navy-900); color: var(--on-accent);
  font-family: var(--font-ui); font-size: 11.5px; pointer-events: none; opacity: 0; transition: opacity .12s; white-space: nowrap; }
.an-track:hover .an-track__tip { opacity: 1; }
@media (hover: none) { .an-track__tip { display: none; } }

.an-markers { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.an-marker { position: absolute; top: 50%; transform: translate(-50%, -50%); pointer-events: auto; cursor: pointer; display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 4px; border: 0; border-radius: var(--radius-pill); background: var(--grad-red); color: var(--on-accent);
  font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 10.5px; line-height: 1; outline: 2px solid var(--grey-100); transition: transform .12s; }
.an-marker:hover, .an-marker.is-hl { transform: translate(-50%, -50%) scale(1.2); z-index: 1; }
.an-marker--admin { background: var(--grad-navy); }
.an-marker--done { background: var(--grey-300); color: var(--ink); }
.an-marker--draft { width: 4px; min-width: 0; height: 18px; padding: 0; background: var(--red-500); outline: 0; pointer-events: none; z-index: 2; border-radius: 2px; }

.an-volbox { display: inline-flex; align-items: center; gap: 2px; }
.an-vol { -webkit-appearance: none; appearance: none; width: 72px; height: 4px; margin: 0 8px 0 2px; border-radius: var(--radius-pill); cursor: pointer;
  background: linear-gradient(90deg, var(--navy-500) var(--v, 100%), var(--grey-300) var(--v, 100%)); }
.an-vol::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--navy-500); border: 0; }
.an-vol::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--navy-500); border: 0; }

/* plein écran : contrôles sombres sous la vidéo */
.an-stage.is-fullscreen .an-ctrls { background: var(--navy-900); color: var(--on-dark); }
.an-stage.is-fullscreen .an-time, .an-stage.is-fullscreen .an-time b { color: var(--on-dark); }
.an-stage.is-fullscreen .an-ctrls .an-pbtn:not(.an-pbtn--main):hover { background: rgba(255, 255, 255, .1); }
.an-stage.is-fullscreen .an-track__rail { background: rgba(255, 255, 255, .2); }
.an-stage.is-fullscreen .an-track__played { background: var(--paper); }
.an-stage.is-fullscreen .an-track__knob { background: var(--paper); outline-color: var(--navy-900); }
.an-stage.is-fullscreen .an-pbtn--main { background: var(--paper); color: var(--navy-900); }
.an-stage.is-fullscreen .an-marker { outline-color: var(--navy-900); }

/* ---------- Barre d'outils (createToolbar) ---------- */
.an-toolbar { display: inline-flex; align-items: center; flex-wrap: nowrap; gap: 2px; padding: 4px; border-radius: var(--radius-pill); background: var(--grey-100); max-width: 100%;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.an-toolbar::-webkit-scrollbar { display: none; }
.an-toolbar > * { flex: none; }
.an-tool { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 36px; height: 36px; padding: 0 9px; border: 0; border-radius: var(--radius-pill);
  background: none; color: var(--ink-2); cursor: pointer; font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 14px; -webkit-tap-highlight-color: transparent; }
.an-tool:hover { background: var(--grey-200); color: var(--ink); }
.an-tool[aria-pressed="true"] { background: var(--grad-navy); color: var(--on-accent); }
.an-tool[data-tool="pin"] { padding: 0 14px 0 11px; }
.an-tool:disabled { opacity: .35; cursor: default; background: none; }
.an-tool__label { line-height: 1; }
.an-tsep { width: 1px; height: 20px; margin: 0 4px; background: var(--rule); flex: none; }
.an-swatches { display: inline-flex; align-items: center; gap: 0; }
.an-swatch { display: inline-grid; place-items: center; width: 30px; height: 36px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: var(--radius-pill); }
.an-swatch__dot { width: 18px; height: 18px; border-radius: 50%; transition: transform .12s; }
.an-swatch:hover .an-swatch__dot { transform: scale(1.12); }
.an-swatch[aria-pressed="true"] .an-swatch__dot { outline: 2px solid var(--ink); outline-offset: 2px; }
.an-swatch__dot--ec1546 { background: var(--grad-red); }
.an-swatch__dot--2b3546 { background: var(--grad-navy); }
.an-swatch__dot--ffffff { background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--grey-300); }
.an-swatch__dot--f5c400 { background: #f5c400; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .an-stage { min-height: 260px; }
  .an-pin { min-width: 30px; height: 30px; font-size: 13.5px; }
  .an-vol { display: none; }
  .an-ctrls { padding: 4px 8px 8px; }
  .an-ctrls__row .an-pbtn { width: 40px; height: 40px; }
  .an-pbtn--text { min-width: 44px; }
  .an-tool { min-width: 40px; height: 40px; }
  .an-swatch { width: 34px; height: 40px; }
  .an-pages { padding: 12px 12px 64px; gap: 12px; }
  .an-float--zoom { right: 8px; bottom: 8px; }
  .an-float--page { left: 8px; bottom: 8px; }
}
@media (max-width: 420px) {
  .an-tool[data-tool="pin"] .an-tool__label { display: none; }
  .an-tool[data-tool="pin"] { padding: 0 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .an-pin--draft::after, .an-page::before, .an-shapes.is-hl .an-stroke { animation: none; }
  .an-pin, .an-marker, .an-track__knob, .an-track__rail { transition: none; }
}
