/*
 * Halo : composants. Préfixe at- conservé d'Atelier pour que le balisage des applis reste valable.
 * Couleurs, espaces et rayons viennent uniquement des tokens (tokens.css). Comportements (liste déroulante, compteur) : bundle.js.
 */

/* Page : fond noir et lueur du halo en haut */
html { background: var(--bg); }
body {
  background-color: var(--bg);
  background-image: var(--page-glow);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

/* Styles de texte */
.label { font: 500 12px/1.3 var(--font-ui); color: var(--text-2); letter-spacing: 0; text-transform: none; }
.mono, .readout { font-family: var(--font-mono); font-variant-numeric: tabular-nums slashed-zero; }
.at-display { margin: 0; font: 400 44px/1.1 var(--font-display); letter-spacing: -0.03em; color: var(--text); }
.at-lede { margin: 0; font: 400 17px/1.5 var(--font-ui); color: var(--text-2); }
@media (max-width: 640px) { .at-display { font-size: 32px; } }

/* Focus clavier, partout */
:where(.at-btn, .at-input, .at-bar a, .at-table a, a.at-tag, .at-chip, .at-tile):focus-visible {
  outline: var(--line-strong-width) solid var(--accent);
  outline-offset: 2px;
}

/* Trame de points (zones vides) */
.at-grid {
  background-image: radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 1.5px);
  background-size: var(--layout-dots) var(--layout-dots);
}

/* Bouton : pilule. Principal en blanc (encre en Jour), accent en violet pour ce que lance Claude. */
.at-btn {
  box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  height: 40px; padding: 0 18px;
  border: var(--line-hair) solid transparent; border-radius: var(--radius-pill);
  background: var(--primary); color: var(--on-primary);
  font: 500 14px/1 var(--font-ui); white-space: nowrap;
  text-decoration: none; cursor: pointer;
  transition: background-color 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out, box-shadow 200ms ease-out;
}
.at-btn:hover { background: var(--primary-hover); }
.at-btn--accent { background: var(--accent); color: var(--on-accent); box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 35%, transparent); }
.at-btn--accent:hover { background: var(--accent-hover); }
.at-btn--ghost { background: var(--glass-2); color: var(--text); border-color: var(--line); }
.at-btn--ghost:hover { background: var(--glass-hover); border-color: var(--line-strong); }
.at-btn--danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.at-btn--danger:hover { border-color: var(--danger); }
.at-btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.at-btn--icon { width: 40px; padding: 0; }
.at-btn--sm.at-btn--icon { width: 32px; }
.at-btn:disabled, .at-btn[aria-disabled="true"] {
  background: var(--glass-2); border-color: var(--line); color: var(--text-3); box-shadow: none; cursor: not-allowed;
}
.at-btn svg { width: 16px; height: 16px; stroke-width: 1.6; }

/* Champ : un puits de verre */
.at-field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.at-field__label { font: 500 13px/1.3 var(--font-ui); color: var(--text-2); letter-spacing: 0; text-transform: none; }
.at-input {
  box-sizing: border-box; width: 100%; min-width: 0; height: 40px;
  padding: 0 14px;
  background: var(--glass-2); color: var(--text);
  border: var(--line-hair) solid var(--line); border-radius: var(--radius-1);
  font: 400 15px/1.45 var(--font-ui);
  transition: border-color 120ms ease-out, box-shadow 200ms ease-out, background-color 120ms ease-out;
  -webkit-appearance: none; appearance: none; margin: 0;
}
.at-input::placeholder { color: var(--text-3); }
.at-input:hover { border-color: var(--line-strong); }
.at-input:focus, .at-input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.at-field:focus-within .at-field__label { color: var(--accent-ink); }
.at-input--mono { font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; }
.at-field__help { font: 400 13px/1.4 var(--font-ui); color: var(--text-2); }
.at-field__error { font: 500 13px/1.4 var(--font-ui); color: var(--danger); }
.at-field--error .at-input, .at-input:user-invalid { border-color: var(--danger); }
.at-input:disabled, .at-input[aria-disabled="true"] { background: var(--bg-2); color: var(--text-3); border-color: var(--line); box-shadow: none; cursor: not-allowed; }
.at-input--sm { height: 32px; font-size: 13px; padding: 0 10px; }
textarea.at-input {
  height: auto; min-height: 96px; max-height: 60vh; padding: 10px 14px;
  line-height: 1.55; resize: vertical; field-sizing: content;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}

.at-field__count {
  justify-self: end; margin-top: -2px; font: 500 11px/1.2 var(--font-mono); color: var(--text-3);
  font-variant-numeric: tabular-nums; opacity: 0; transition: opacity 120ms ease-out;
}
.at-field:focus-within > .at-field__count, .at-field__count.is-near { opacity: 1; }
.at-field__count.is-near { color: var(--warn); }

/* Fichier : le bouton du navigateur prend l'allure d'un bouton Halo, collé au champ. */
input[type="file"].at-input {
  display: flex; align-items: center; height: auto; min-height: 40px; padding: 0 var(--space-1) 0 0;
  color: var(--text-2); font-size: 14px; cursor: pointer;
}
input[type="file"].at-input::file-selector-button {
  align-self: stretch; margin: 0 var(--space-1) 0 0; padding: 0 var(--space-2);
  border: 0; border-right: var(--line-hair) solid var(--line-strong); border-radius: var(--radius-1) 0 0 var(--radius-1);
  background: var(--glass-hover); color: var(--text); font: 500 14px/1 var(--font-ui); cursor: pointer;
  transition: background-color 120ms ease-out;
}
input[type="file"].at-input:hover::file-selector-button { background: var(--raised); }

/* Champ avec icône ou unité :
   <span class="at-control"><svg class="at-control__icon">…</svg><input class="at-input"><span class="at-control__unit">LUFS</span></span> */
.at-control { position: relative; display: flex; align-items: center; min-width: 0; }
.at-control > .at-input { flex: 1; }
.at-control__icon {
  position: absolute; left: calc(var(--space-1) + var(--space-0-5)); width: 16px; height: 16px; pointer-events: none;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; color: var(--text-3);
}
.at-control:focus-within .at-control__icon { color: var(--accent-ink); }
.at-control__icon ~ .at-input { padding-left: calc(var(--space-4) + var(--space-0-5)); }
.at-control__unit {
  position: absolute; right: calc(var(--space-1) + var(--space-0-5)); pointer-events: none;
  font: 500 12px/1 var(--font-mono); color: var(--text-3);
}
.at-control:has(.at-control__unit) > .at-input { padding-right: calc(var(--space-6) + var(--space-0-5)); }

/* Liste déroulante : bundle.js remplace le select natif par ce bouton et sa listbox */
.at-select { position: relative; min-width: 0; }
.at-select__native { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.at-select__trigger { display: flex; align-items: center; gap: var(--space-1); text-align: left; cursor: pointer; white-space: nowrap; }
.at-select__trigger.is-placeholder .at-select__value { color: var(--text-3); }
.at-select__value { display: inline-flex; align-items: center; gap: var(--space-1); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.at-select__chevron {
  width: 16px; height: 16px; flex: none; margin-right: -4px; fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round; color: var(--text-2); transition: transform 200ms ease-out;
}
.at-select.is-open .at-select__chevron { transform: rotate(180deg); color: var(--accent-ink); }
.at-select.is-open .at-select__trigger { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.at-select__list {
  /* Placed by bundle.js (fixed, from the trigger's box) so a scrolling table or panel never clips it. */
  position: fixed; z-index: 60; left: 0; top: 0;
  box-sizing: border-box; max-width: min(360px, calc(100vw - var(--space-2))); max-height: 320px;
  margin: 0; padding: var(--space-0-5); list-style: none; overflow-y: auto; overscroll-behavior: contain;
  background: var(--raised); color: var(--text);
  border: var(--line-hair) solid var(--line); border-radius: var(--radius-2); box-shadow: var(--shadow-float);
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  animation: at-pop 120ms ease-out;
}
.at-select__list:focus { outline: none; }
.at-select__list--up { animation-name: at-pop-up; }
@keyframes at-pop { from { opacity: 0; transform: translateY(-4px); } }
@keyframes at-pop-up { from { opacity: 0; transform: translateY(4px); } }
.at-select__option {
  display: flex; align-items: center; gap: var(--space-1); min-height: 36px; padding: 0 10px;
  border-radius: 10px; cursor: pointer; font: 400 14px/1.3 var(--font-ui); white-space: nowrap;
}
.at-select__option.is-active { background: var(--glass-hover); }
.at-select__list:focus .at-select__option.is-active { box-shadow: inset 2px 0 0 var(--accent); }
.at-select__option[aria-selected="true"] { color: var(--accent-ink); font-weight: 500; }
.at-select__option[aria-disabled="true"] { color: var(--text-3); cursor: default; }
.at-select__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.at-select__check {
  width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; visibility: hidden;
}
.at-select__option[aria-selected="true"] .at-select__check { visibility: visible; }
.at-select__group {
  padding: var(--space-1) var(--space-1) var(--space-0-5);
  font: 500 12px/1.3 var(--font-ui); color: var(--text-3);
}
.at-select__dot {
  width: 6px; height: 6px; flex: none; border-radius: var(--radius-dot); background: currentColor; color: var(--text-3);
  box-shadow: 0 0 6px color-mix(in srgb, currentColor 70%, transparent);
}
.at-select__dot--accent { color: var(--accent); }
.at-select__dot--info { color: var(--info); }
.at-select__dot--ok { color: var(--ok); }
.at-select__dot--warn { color: var(--warn); }
.at-select__dot--danger { color: var(--danger); }

/* Case à cocher et bouton radio : <input type="checkbox" class="at-check"> */
.at-check {
  -webkit-appearance: none; appearance: none; flex: none; display: inline-grid; place-content: center;
  width: 18px; height: 18px; margin: 0; vertical-align: -4px; cursor: pointer;
  background: var(--glass-2); border: var(--line-hair) solid var(--line-strong); border-radius: 6px;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}
.at-check[type="radio"] { border-radius: var(--radius-dot); }
.at-check:hover { border-color: var(--text-2); }
.at-check:checked { box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent); }
.at-check:focus-visible { outline: var(--line-strong-width) solid var(--accent); outline-offset: 2px; }
.at-check:checked { background: var(--accent); border-color: var(--accent); }
.at-check:checked::after {
  content: ""; width: 10px; height: 10px; background: var(--on-accent);
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 20%, 86% 6%, 38% 72%);
}
.at-check[type="radio"]:checked::after { width: 6px; height: 6px; clip-path: none; border-radius: var(--radius-dot); }
.at-check:disabled { background: var(--glass-2); border-color: var(--line); cursor: not-allowed; }
.at-check-label { display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; font: 400 15px/1.45 var(--font-ui); }

/* Panneau : verre, grands rayons, pas d'ombre */
.at-panel {
  position: relative; min-width: 0;
  background: var(--glass); color: var(--text);
  border: var(--line-hair) solid var(--line); border-radius: var(--radius-3);
  /* Pas de backdrop-filter : il ferait du panneau le repère des éléments fixes (liste déroulante de bundle.js). */
}
.at-panel__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap;
  padding: 20px 22px 4px;
}
.at-panel__title { margin: 0; font: 500 15px/1.3 var(--font-ui); letter-spacing: -0.005em; text-transform: none; color: var(--text); }
.at-panel__ref { font: 400 12px/1.2 var(--font-mono); color: var(--text-2); font-variant-numeric: tabular-nums; }
.at-panel__body { padding: 16px 22px 22px; }
/* Le panneau qui résume : un liseré au dégradé du halo. Au plus un par écran. */
.at-panel--crochets, .at-panel--halo {
  border-color: transparent;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    linear-gradient(var(--glass), var(--glass)) padding-box,
    conic-gradient(from 180deg, var(--halo-stops)) border-box;
}
.at-card {
  border-radius: var(--radius-2); padding: 14px;
  background: var(--glass-2); border: var(--line-hair) solid var(--line);
}

/* Indicateur */
.at-readout { display: grid; gap: 6px; min-width: 0; }
.at-readout__label { font: 500 13px/1.3 var(--font-ui); letter-spacing: 0; text-transform: none; color: var(--text-2); }
.at-readout__value {
  font: 300 40px/1 var(--font-display); letter-spacing: -0.035em; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.at-readout__unit { margin-left: 6px; font: 400 15px/1 var(--font-ui); letter-spacing: 0; color: var(--text-3); }
.at-readout__delta { font: 500 13px/1.4 var(--font-mono); color: var(--text-2); }
.at-readout__delta--ok { color: var(--ok); }
.at-readout__delta--danger { color: var(--danger); }
.at-readout--accent .at-readout__value { color: var(--accent-ink); }

/* Jauge : piste arrondie à segments, allumée au dégradé du halo */
.at-gauge { display: grid; gap: 8px; min-width: 0; }
.at-gauge__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-1); }
.at-gauge__label { font: 500 13px/1.3 var(--font-ui); letter-spacing: 0; text-transform: none; color: var(--text-2); }
.at-gauge__value { font: 500 13px/1.2 var(--font-mono); color: var(--text); font-variant-numeric: tabular-nums; }
.at-gauge__track { display: flex; gap: 3px; height: 8px; }
.at-gauge__seg { flex: 1 1 0; background: var(--glass-hover); border-radius: var(--radius-pill); }
.at-gauge__seg.is-on { background: var(--accent); box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 50%, transparent); }
.at-gauge--ok .at-gauge__seg.is-on { background: var(--ok); box-shadow: none; }
.at-gauge--warn .at-gauge__seg.is-on { background: var(--warn); box-shadow: none; }
.at-gauge--danger .at-gauge__seg.is-on { background: var(--danger); box-shadow: none; }
.at-gauge__seg.is-target { box-shadow: inset 0 0 0 var(--line-hair) var(--text-2); }

/* Étiquette de statut : pilule et voyant lumineux */
.at-tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  border-radius: var(--radius-pill); background: var(--glass-2); color: var(--text-2);
  font: 500 12px/1 var(--font-ui); white-space: nowrap; text-decoration: none;
}
.at-tag::before {
  content: ""; width: 6px; height: 6px; border-radius: var(--radius-dot); background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.at-tag--plain::before { display: none; }
.at-tag--accent { background: var(--accent-bg); color: var(--accent-ink); }
.at-tag--info { background: var(--info-bg); color: var(--info); }
.at-tag--ok { background: var(--ok-bg); color: var(--ok); }
.at-tag--warn { background: var(--warn-bg); color: var(--warn); }
.at-tag--danger { background: var(--danger-bg); color: var(--danger); }
.at-tag--live::before { animation: at-pulse 1.6s ease-in-out infinite; }
@keyframes at-pulse { 50% { opacity: 0.35; } }

/* Tableau : sans fond d'en-tête, des filets fins */
.at-table-wrap { overflow-x: auto; min-width: 0; }
.at-table {
  width: 100%; border-collapse: collapse;
  font: 400 14px/1.4 var(--font-ui); color: var(--text); font-variant-numeric: tabular-nums;
}
.at-table th {
  text-align: left; padding: 10px 12px;
  background: transparent; color: var(--text-2);
  font: 500 12px/1.2 var(--font-ui); letter-spacing: 0; text-transform: none;
  border-bottom: var(--line-hair) solid var(--line);
}
.at-table td { padding: 10px 12px; border-bottom: var(--line-hair) solid var(--line); vertical-align: baseline; }
.at-table tr:hover td { background: var(--glass); }
.at-table td.num, .at-table td.id { font-family: var(--font-mono); font-size: 13px; }
.at-table .num { text-align: right; }
.at-table td.id { color: var(--text-3); }
.at-table tr[aria-selected="true"] td { background: var(--accent-bg); }
.at-table tr[aria-selected="true"] td:first-child { box-shadow: inset var(--line-strong-width) 0 0 var(--accent); }
.at-table a { color: var(--accent-ink); text-underline-offset: 2px; }

/* Barre d'outil : transparente, navigation en pilules */
.at-bar {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  min-height: 64px; padding: 0 var(--space-2);
  background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--text);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: var(--line-hair) solid var(--line);
}
.at-bar__name {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 0; font: 500 16px/1 var(--font-display); letter-spacing: -0.01em; color: var(--text);
}
.at-bar__name::before {
  content: ""; width: 16px; height: 16px; border-radius: var(--radius-dot);
  background: conic-gradient(var(--halo-stops));
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 60%, transparent);
}
.at-bar__nav { display: flex; gap: 4px; flex-wrap: wrap; }
.at-bar__nav a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
  border-radius: var(--radius-pill);
  font: 500 14px/1 var(--font-ui); letter-spacing: 0; text-transform: none;
  color: var(--text-2); text-decoration: none;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}
.at-bar__nav a:hover { color: var(--text); background: var(--glass-2); }
.at-bar__nav a[aria-current="page"] { color: var(--text); background: var(--glass-hover); }
.at-bar__meta { margin-left: auto; font: 400 13px/1 var(--font-mono); color: var(--text-2); }

/* --- Composants propres à Halo : ce que fait Claude --- */

/* Le halo : la présence de Claude. Tailles : --sm (24), défaut (64), --lg (132). */
.at-halo { position: relative; width: 64px; height: 64px; flex: none; }
.at-halo::before, .at-halo::after { content: ""; position: absolute; border-radius: 50%; }
.at-halo::before { inset: 0; background: conic-gradient(from 90deg, var(--halo-stops)); filter: blur(12px); opacity: 0.75; animation: at-halo-spin 14s linear infinite; }
.at-halo::after { inset: 14%; background: radial-gradient(circle at 35% 30%, #ffffff 0%, #d9d3ff 18%, var(--accent) 55%, #241c4d 100%); box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.35); animation: at-halo-breathe 5s ease-in-out infinite; }
.at-halo--sm { width: 24px; height: 24px; }
.at-halo--sm::before { filter: blur(5px); }
.at-halo--lg { width: 132px; height: 132px; }
.at-halo--lg::before { filter: blur(18px); }
.at-halo--idle::before, .at-halo--idle::after { animation: none; }
@keyframes at-halo-spin { to { transform: rotate(360deg); } }
@keyframes at-halo-breathe { 0%, 100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.06); opacity: 1; } }

/* Barre de demande : on parle à Claude */
.at-ask {
  box-sizing: border-box; width: 100%; max-width: 720px;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 20px;
  border-radius: var(--radius-pill); background: var(--glass-2); border: var(--line-hair) solid var(--line-strong);
  box-shadow: var(--shadow-glow);
}
.at-ask:focus-within { border-color: var(--accent); }
.at-ask__input { flex: 1; min-width: 0; height: 44px; background: transparent; border: 0; outline: none; color: var(--text); font: 400 16px/1.4 var(--font-ui); }
.at-ask__input::placeholder { color: var(--text-3); }
.at-ask .at-btn { width: 44px; height: 44px; padding: 0; }

/* Suggestion : une pilule à cliquer */
.at-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: var(--radius-pill); border: var(--line-hair) solid var(--line); background: var(--glass);
  color: var(--text-2); font: 400 13px/1 var(--font-ui); text-decoration: none; cursor: pointer;
}
.at-chip:hover { color: var(--text); background: var(--glass-hover); }

/* Journal : ce qui a été fait, heure à gauche */
.at-feed { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }
.at-feed__item { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; }
.at-feed__time { font: 400 12px/1.6 var(--font-mono); color: var(--text-2); font-variant-numeric: tabular-nums; }
.at-feed__text { margin: 0; font: 400 14px/1.45 var(--font-ui); color: var(--text); }
.at-feed__meta { margin: 2px 0 0; font: 400 12px/1.4 var(--font-ui); color: var(--text-2); }

/* Tuile d'espace : un service et sa ligne du moment */
.at-tile {
  display: flex; flex-direction: column; gap: 8px; min-height: 84px; padding: 14px; box-sizing: border-box;
  border-radius: 18px; border: var(--line-hair) solid var(--line); color: inherit; text-decoration: none;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}
.at-tile:hover { background: var(--glass); border-color: var(--line-strong); }
.at-tile__name { display: flex; align-items: center; gap: 8px; font: 500 14px/1.2 var(--font-ui); }
.at-tile__name::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tile, var(--accent)); box-shadow: 0 0 10px var(--tile, var(--accent)); }
.at-tile__line { font: 400 12px/1.4 var(--font-ui); color: var(--text-2); }

/* Aides de mise en page */
.at-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.at-stack { display: grid; gap: var(--space-2); }

@media (prefers-reduced-motion: reduce) {
  .at-btn, .at-input, .at-bar__nav a, .at-tile, .at-check, .at-field__label, .at-field__count, .at-select__chevron { transition: none; }
  .at-select__list { animation: none; }
  .at-tag--live::before, .at-halo::before, .at-halo::after { animation: none; }
}
