/*
  Vue « cercles concentriques » de la carte des couches de Bitcoin.

  Chargée par en.html et fr.html à côté de la vue en strates. Elle reprend
  les variables de couleur, les polices et les classes de liens (.edge,
  .edge-label) du document hôte : seuls les éléments propres aux anneaux
  sont stylés ici. Rien ne change tant que .app ne porte pas .mode-rings.
*/

/* ---- Bascule de vue, dans l'en-tête ---------------------------------- */
header {
  flex-wrap: wrap;
  align-items: center;
}

.view-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.view-switch .vs-label {
  font-family: JetBrains Mono, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.view-switch .seg {
  display: flex;
  border: 1px solid var(--line-strong);
}

.view-switch button {
  min-height: 36px;
  padding: 0 14px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line-strong);
  color: var(--fg-dim);
  font-family: Oswald, sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.view-switch button:last-child {
  border-right: none;
}

.view-switch button[aria-pressed='true'] {
  background: var(--fg);
  color: var(--bg);
}

.view-switch button:not([aria-pressed='true']):hover {
  color: var(--fg);
}

.view-switch button:focus-visible,
.type-filters button:focus-visible {
  outline: 2px solid var(--btc);
  outline-offset: 2px;
}

/* ---- Les deux scènes partagent la même cellule de grille -------------
   La scène inactive reste mise en page (visibility, pas display) : la vue
   en strates recalcule ses positions au redimensionnement et a besoin de
   dimensions réelles, sinon elle produit des NaN. */
.app.mode-rings > #stage,
.app:not(.mode-rings) > .rings-stage {
  visibility: hidden;
  pointer-events: none;
  z-index: 0;
}

.app.mode-rings > .rings-stage {
  z-index: 1;
}

/* Arrivée avec #view=rings : la vue en strates attend que rings.js bascule. */
html.pre-rings .app:not(.mode-rings) > #stage {
  visibility: hidden;
}

.rings-stage {
  grid-area: stage;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, light-dark(hsl(0, 0%, 96%), hsl(0, 0%, 11%)) 0%, var(--bg) 60%);
}

.rings-stage > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- Filtres par type ------------------------------------------------ */
.type-filters {
  position: absolute;
  top: 14px;
  left: 18px;
  right: 18px;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.type-filters > * {
  pointer-events: auto;
}

.type-filters .tf-label {
  margin-right: 6px;
  font-family: JetBrains Mono, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.type-filters button {
  --chip: var(--fg-dim);
  min-height: 30px;
  padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--fg-dim);
  font-family: Oswald, sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition:
    color 0.16s ease,
    border-color 0.16s ease;
}

.type-filters button .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chip);
  flex: none;
}

.type-filters button:hover {
  color: var(--fg);
  border-color: var(--chip);
}

.type-filters button[aria-pressed='true'] {
  color: var(--fg);
  border-color: var(--chip);
  box-shadow: inset 0 0 0 1px var(--chip);
}

/* ---- Anneaux --------------------------------------------------------- */
.ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.ring.ring-ln {
  stroke: color-mix(in oklab, var(--cat-lightning) 55%, var(--line));
}

.ring-halo {
  fill: none;
  stroke: hsla(33, 92%, 54%, 0.25);
  stroke-dasharray: 3 5;
}

.ring-label {
  font-family: Oswald, sans-serif;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  fill: var(--fg-dim);
}

.ring-label.ring-label-ln {
  fill: color-mix(in oklab, var(--cat-lightning) 80%, var(--fg));
}

.ring-label-path {
  fill: none;
  stroke: none;
}

/* ---- Nœuds ----------------------------------------------------------- */
.rnode {
  cursor: pointer;
  outline: none;
  transition: opacity 0.2s ease;
}

.rnode .core {
  fill: var(--bg-2);
  stroke: var(--line-strong);
  stroke-width: 1;
  transition:
    fill 0.16s ease,
    stroke 0.16s ease;
}

.rnode .halo {
  fill: none;
  stroke: var(--cat, var(--line));
  stroke-width: 1;
  opacity: 0.55;
  transition:
    opacity 0.16s ease,
    r 0.16s ease,
    stroke-width 0.16s ease;
}

.rnode .symbol {
  font-family: Oswald, sans-serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.02em;
  fill: var(--fg);
  pointer-events: none;
}

.rnode .icon {
  color: var(--fg);
  pointer-events: none;
}

.rnode .name {
  font-family: Oswald, sans-serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  fill: var(--fg);
  pointer-events: none;
}

.rnode .sub {
  font-family: Spectral, Georgia, serif;
  font-style: italic;
  font-size: 11px;
  fill: var(--fg-dimmer);
  pointer-events: none;
}

.rnode:hover .core,
.rnode:focus-visible .core,
.rnode.active .core {
  fill: var(--bg-3);
  stroke: var(--cat, var(--fg-dim));
}

.rnode:hover .halo,
.rnode:focus-visible .halo {
  opacity: 1;
}

.rnode.active .halo {
  opacity: 1;
  stroke-width: 1.5;
}

/* Le focus clavier reste visible même quand le nœud est estompé. */
.rnode:focus-visible .focus-ring {
  stroke: var(--btc);
  stroke-width: 2;
  fill: none;
}

.rnode .focus-ring {
  fill: none;
  stroke: none;
}

/* Bitcoin au centre */
.rnode.btc .core {
  fill: var(--bg-3);
  stroke: var(--btc);
}

.rnode.btc .symbol {
  font-size: 40px;
  fill: var(--btc);
}

.rnode.btc .halo {
  stroke: hsla(33, 92%, 54%, 0.35);
}

.rnode.btc .name {
  font-size: 14px;
  letter-spacing: 0.18em;
}

/* Lightning */
.rnode.ln .symbol {
  fill: var(--cat-lightning);
}

/* Sélection : les autres nœuds s'estompent, les voisins gardent leur anneau. */
.app.has-active .rnode:not(.active):not(.related) {
  opacity: 0.22;
}

.app.has-active .rnode.related .core {
  stroke: var(--cat, var(--line-strong));
}

/* Filtre : les nœuds hors type sortent de la scène (et du clavier). */
.rnode.filtered {
  opacity: 0.1;
  pointer-events: none;
}

.redge.filtered {
  opacity: 0.05;
}

/* ---- Liens ----------------------------------------------------------- */
.rings-stage .edge-label {
  pointer-events: none;
}

.rings-stage .edge-label rect {
  fill: var(--bg);
  stroke-width: 1;
}

/* ---- Appel à l'action mobile (même style que la vue en strates) ------ */
.rings-stage .node-cta {
  left: 0;
  top: 0;
}

/* ---- Mobile ---------------------------------------------------------- */
@media (max-width: 768px) {
  header {
    gap: 10px 16px;
  }

  /* Le sélecteur de vue reste petit, à droite du titre, sur la même ligne. */
  header {
    flex-wrap: nowrap;
    align-items: center;
  }

  header > div {
    min-width: 0;
  }

  .view-switch {
    flex-shrink: 0;
    margin-left: auto;
  }

  .view-switch .vs-label {
    display: none;
  }

  .view-switch button {
    min-height: 30px;
    padding: 0 9px;
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  .type-filters {
    top: 10px;
    left: 10px;
    right: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    pointer-events: auto;
  }

  .type-filters .tf-label {
    display: none;
  }

  .type-filters button {
    flex: none;
    min-height: 34px;
  }

  .rnode .name {
    font-size: 10px;
    letter-spacing: 0.08em;
  }

  .rnode .sub {
    display: none;
  }

  .rnode .symbol {
    font-size: 14px;
  }

  .rnode.btc .symbol {
    font-size: 28px;
  }

  .rnode.btc .name {
    font-size: 11px;
  }

  .ring-label {
    font-size: 9.5px;
    letter-spacing: 0.12em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rnode,
  .rnode .core,
  .rnode .halo,
  .type-filters button {
    transition: none;
  }
}

/* ---- Lecteurs d'écran et légende mobile ------------------------------ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.ring-legend {
  display: none;
  position: absolute;
  left: 14px;
  right: 14px;
  top: auto;
  bottom: 12px;
  z-index: 6;
  font-family: Spectral, Georgia, serif;
  font-size: 12px;
  line-height: 1.5;
  color: var(--fg-dim);
}

.ring-legend .rl-intro {
  display: block;
  font-family: JetBrains Mono, monospace;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dimmer);
  margin-bottom: 2px;
}

.ring-legend ol {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: ring;
}

.ring-legend li {
  counter-increment: ring;
  font-family: Oswald, sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
}

.ring-legend li::before {
  content: counter(ring) ' ';
  font-family: JetBrains Mono, monospace;
  color: var(--fg-dimmer);
}

.rings-stage.compact .ring-legend {
  display: block;
}

.rings-stage.compact .ring-label {
  display: none;
}

/* Libellé de lien sans place libre : masqué plutôt que superposé. */
.rings-stage .edge-label.no-room {
  display: none;
}

/* ---- Bitcoin : le logo classique au centre ------------------------------ */
.rnode.btc .core {
  fill: none;
  stroke: none;
}

.btc-logo-disc {
  fill: var(--btc);
}

.btc-logo-b {
  fill: #fff;
}

/* ---- Lightning : une couronne de nœuds autour de Bitcoin --------------- */
.ring.ring-ln {
  stroke: none;
}

.rnode.ln .core {
  display: none;
}

/* Zone cliquable : une bande sur la couronne, pas le disque entier. */
.crown-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 24;
  pointer-events: stroke;
  cursor: pointer;
}

.crown-links {
  fill: none;
  stroke: var(--cat-lightning);
  stroke-opacity: 0.4;
  stroke-width: 1;
  pointer-events: none;
  transition: stroke-opacity 0.15s ease;
}

.crown-dots circle {
  fill: var(--cat-lightning);
  pointer-events: none;
}

.rnode.ln:hover .crown-links,
.rnode.ln:focus-visible .crown-links,
.rnode.ln.active .crown-links {
  stroke-opacity: 0.85;
}

.rnode.ln .halo {
  fill: none;
  stroke: color-mix(in oklab, var(--cat-lightning) 45%, transparent);
}

/* Petit téléphone : le titre se resserre pour laisser la place au sélecteur. */
@media (max-width: 420px) {
  header h1 {
    font-size: 22px;
  }
}
