/* Yugurten Studio — bibliothèque du matériel
   Même langage que le plan : nuit, mono, une couleur par espace. */

body.lib { background: var(--night); color: var(--on-night); min-height: 100vh; }
.lib ::selection { background: var(--amber); color: var(--ink); }
.lib .hwt { font-family: var(--f-mono); }
.lib .hwbig { font-family: var(--f-sans); font-weight: 900; font-stretch: 62%; }

.libnav { position: sticky; top: 0; z-index: 40; background: var(--night); background: color-mix(in srgb, var(--night) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-night); }
.libnav__in { display: flex; align-items: center; gap: 18px; height: 60px; }
.libnav .brand { color: var(--on-night); }
.libnav__t { color: var(--on-night-2); margin-left: 6px; }
.libnav__back { margin-left: auto; padding: 9px 14px 8px; font-size: 14px; }

/* ---------- hero ---------- */
.lhero { padding-block: clamp(20px, 3vw, 40px) clamp(20px, 2.8vw, 36px); }
.lhero .hero__meta { border-bottom-color: var(--on-night); color: var(--on-night-2); }
.lhero__title { margin: clamp(16px, 2.2vw, 28px) 0 18px; font-weight: 900; font-stretch: 62%; text-transform: uppercase; line-height: 0.84; font-size: clamp(54px, 11vw, 168px); letter-spacing: -0.01em; }
.lhero__lead { color: var(--on-night-2); max-width: 54ch; }

/* ---------- onglets ---------- */
.tabs { position: sticky; top: 60px; z-index: 30; background: var(--night); border-block: 1px solid var(--line-night); }
.tablist { display: grid; grid-template-columns: repeat(4, 1fr); }
.tab {
  display: flex; align-items: center; gap: 12px; padding: 14px 14px 13px; background: none; border: 0; cursor: pointer;
  color: var(--on-night-2); text-align: left; position: relative; border-left: 1px solid var(--line-night);
  transition: color 0.25s var(--ease), background 0.35s var(--ease);
}
.tab:first-child { border-left: 0; }
.tab__l { font-weight: 900; font-stretch: 62%; font-size: 40px; line-height: 0.8; color: var(--tc); opacity: 0.6; transition: opacity 0.25s; }
.tab__t { display: grid; gap: 1px; min-width: 0; }
.tab__t b { font-weight: 680; font-size: 16px; letter-spacing: -0.01em; }
.tab__t .mono { font-size: 10.5px; }
@media (hover: hover) { .tab:hover { color: var(--on-night); } }
.tab[aria-selected="true"] { color: var(--on-night); background: color-mix(in srgb, var(--tc) 18%, var(--night)); }
.tab[aria-selected="true"] .tab__l { opacity: 1; }
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 4px; background: var(--tc); transform: scaleX(0); transform-origin: left; transition: transform 0.4s var(--ease); }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
@media (max-width: 720px) {
  .tablist { grid-template-columns: repeat(4, auto); overflow-x: auto; scrollbar-width: none; }
  .tab { padding: 12px 12px; gap: 8px; }
  .tab__l { font-size: 30px; }
  .tab__t .mono { display: none; }
  .tab__t b { font-size: 14px; }
}

/* ---------- panneaux ---------- */
.lpanel { padding-block: clamp(28px, 4vw, 52px) clamp(36px, 4.5vw, 64px); }
.lpanel[hidden] { display: none; }
.lpanel__head { display: grid; grid-template-columns: auto 1fr; gap: clamp(18px, 3vw, 40px); align-items: end; margin-bottom: clamp(22px, 3vw, 40px); }
.lpanel__letter { font-weight: 900; font-stretch: 62%; line-height: 0.74; font-size: clamp(110px, 17vw, 260px); color: var(--rc); }
.lpanel__head .lead { color: var(--on-night-2); margin: 14px 0 0; }
@media (max-width: 640px) { .lpanel__head { grid-template-columns: 1fr; } .lpanel__letter { font-size: 120px; } }

/* ---------- schéma du Studio B ---------- */
.diagram { position: relative; }
.edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.edge path { fill: none; stroke: var(--amber); stroke-width: 2; stroke-dasharray: 2 8; stroke-linecap: round; opacity: 0.55; animation: flow 1.2s linear infinite; transition: opacity 0.3s; }
.edge circle { fill: var(--amber); opacity: 0.8; }
.edge rect { fill: var(--night); stroke: var(--amber); stroke-width: 1; opacity: 0.9; }
.edge text { font-family: var(--f-mono); font-size: 10.5px; fill: var(--amber); letter-spacing: 0.04em; }
.edge.avail path { stroke-dasharray: 1 7; opacity: 0.7; animation: none; }
.edge.tert path { stroke: var(--on-night-2); stroke-width: 1.2; opacity: 0.8; animation: none; }
.edge.tert circle { fill: var(--on-night-2); }
.diagram.is-focus .edge { opacity: 0.12; }
.diagram.is-focus .edge.is-rel { opacity: 1; }
.diagram.is-focus .edge.is-rel path { opacity: 1; stroke-width: 2.6; }
.diagram.is-focus .node:not(.is-rel), .diagram.is-focus .term:not(.is-rel) { opacity: 0.38; }

.dgrid { display: grid; grid-template-columns: 0.55fr 1fr 1.1fr 1fr; gap: clamp(36px, 5.5vw, 100px); align-items: start; position: relative; z-index: 2; }
.col { display: grid; gap: 14px; align-content: start; }
.col--cab { align-self: center; padding-top: 120px; }
.col__h { color: var(--on-night-2); margin: 0 0 4px; padding-bottom: 8px; border-bottom: 1px solid var(--line-night); }
.eco { display: grid; gap: 14px; padding: 14px; border: 1.5px solid var(--rc); background: color-mix(in srgb, var(--rc) 14%, var(--night)); position: relative; }
.eco::before { content: "UA"; position: absolute; top: -9px; left: 12px; background: var(--night); padding: 0 6px; font-family: var(--f-mono); font-size: 10.5px; color: var(--rc); letter-spacing: 0.08em; }

.node {
  display: grid; gap: 12px; text-align: left; padding: 12px; cursor: pointer; width: 100%;
  background: var(--night-2); color: var(--on-night); border: 1px solid var(--line-night);
  transition: transform 0.35s var(--ease), border-color 0.25s, background 0.25s, opacity 0.3s;
}
.node:focus-visible { transform: translateY(-3px); border-color: var(--rc); background: color-mix(in srgb, var(--rc) 22%, var(--night-2)); }
@media (hover: hover) { .node:hover { transform: translateY(-3px); border-color: var(--rc); background: color-mix(in srgb, var(--rc) 22%, var(--night-2)); } }
.node.is-rel { border-color: var(--amber); }
.node__art { display: block; }
.node__art .hwsvg { width: 100%; height: auto; max-height: 108px; }
.node--work .node__art .hwsvg { max-height: 120px; }
.node__meta { display: grid; gap: 2px; }
.node__brand { color: var(--on-night-2); }
.node__name { font-weight: 700; font-size: 18px; letter-spacing: -0.015em; line-height: 1.1; }
.node__link { color: var(--amber); }

.term { display: grid; gap: 2px; padding: 14px; border: 1.5px dashed rgba(236, 228, 210, 0.45); text-align: left; background: transparent; color: var(--on-night); transition: opacity 0.3s, border-color 0.25s; }
.term b { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.05; }
.term .mono { color: var(--on-night-2); }
.term--go { cursor: pointer; border-style: solid; border-color: var(--d); background: color-mix(in srgb, var(--d) 18%, var(--night)); }
@media (hover: hover) { .term--go:hover { background: color-mix(in srgb, var(--d) 34%, var(--night)); } }
.term--go .mono:last-child { color: var(--d); }
.term.is-rel { border-color: var(--amber); }

.work { margin-top: clamp(28px, 3.8vw, 48px); }
.work__row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

@media (max-width: 1000px) {
  .edges { display: none; }
  .dgrid { grid-template-columns: 1fr; gap: 28px; }
  .col--cab { display: none; }
  .col--src, .col--eco, .col--out { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .col .col__h { grid-column: 1 / -1; }
  .eco { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .term--go { grid-column: 1 / -1; }
  .work__row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .col--src, .col--out, .eco, .work__row { grid-template-columns: 1fr; }
}

/* ---------- scènes D / A ---------- */
.scene-wrap { max-width: 520px; }
.scene { width: 100%; height: auto; overflow: visible; }
.sigscene .zone { fill: none; stroke: var(--rc); stroke-opacity: 0.45; stroke-width: 1.2; stroke-dasharray: 3 5; }
.sigscene .zone__t { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.12em; fill: var(--rc); }
.sigscene .term-box { fill: none; stroke: rgba(236, 228, 210, 0.45); stroke-width: 1.5; stroke-dasharray: 4 4; }
.sigscene .tb { font-family: var(--f-sans); font-weight: 700; font-size: 16px; fill: var(--on-night); }
.sigscene .sig-dest { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.08em; fill: var(--amber); }
.hot { cursor: pointer; outline: none; }
.hot > *:not(text) { transition: transform 0.35s var(--ease), filter 0.25s; transform-box: fill-box; transform-origin: center; }
.hot:focus-visible > *:not(text) { transform: translateY(-3px); filter: drop-shadow(0 0 0 var(--amber)) brightness(1.18); }
@media (hover: hover) { .hot:hover > *:not(text) { transform: translateY(-3px); filter: drop-shadow(0 0 0 var(--amber)) brightness(1.18); } }
.hot:focus-visible > *:not(text) { filter: drop-shadow(0 0 3px var(--amber)); }
.hot__t { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; fill: var(--on-night); paint-order: stroke; stroke: var(--night); stroke-width: 4px; }
.hot:focus-visible .hot__t { fill: var(--amber); }
@media (hover: hover) { .hot:hover .hot__t { fill: var(--amber); } }
.scene-note { margin-top: 14px; color: var(--on-night-2); }

/* ---------- instruments ---------- */
.lpanel--day { background: var(--paper); color: var(--ink); }
.lpanel--day .lead { color: var(--ink-2); }
.lpanel--day .lpanel__letter { color: var(--c); }
.inst-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: clamp(150px, 17vw, 240px); gap: 12px; grid-auto-flow: dense; }
.inst {
  position: relative; overflow: hidden; border: 0; padding: 0; cursor: pointer; text-align: left;
  background: var(--bg); color: var(--fg); isolation: isolate;
  transition: transform 0.45s var(--ease);
}
.inst:focus-visible { transform: translateY(-4px) rotate(-0.5deg); }
@media (hover: hover) { .inst:hover { transform: translateY(-4px) rotate(-0.5deg); } }
.inst--big { grid-column: span 2; grid-row: span 2; }
.inst--tall { grid-row: span 2; }
.inst--wide { grid-column: span 2; }
.inst__art { position: absolute; inset: 0; display: grid; place-items: center; z-index: 0; }
.inst__art .hwsvg { height: 112%; width: auto; transition: transform 0.7s var(--ease); color: var(--fg); }
.inst--wide .inst__art .hwsvg { height: 135%; width: 100%; }
.inst--big .inst__art .hwsvg { height: 104%; transform: rotate(-12deg) translate(4%, 4%); }
@media (hover: hover) { .inst--big:hover .inst__art .hwsvg { transform: rotate(-6deg) translate(4%, 2%) scale(1.04); } }
.inst--tall .inst__art .hwsvg { transform: rotate(8deg); }
@media (hover: hover) { .inst--tall:hover .inst__art .hwsvg { transform: rotate(2deg) scale(1.05); } }
.inst--sq .inst__art .hwsvg, .inst--wide .inst__art .hwsvg { height: 112%; }
@media (hover: hover) { .inst--wide:hover .inst__art .hwsvg, .inst--sq:hover .inst__art .hwsvg { transform: scale(1.06) rotate(-2deg); } }
.inst__meta { position: absolute; left: 14px; bottom: 12px; right: 14px; z-index: 1; display: grid; gap: 1px; mix-blend-mode: normal; }
.inst__meta b { font-weight: 850; font-stretch: 62%; text-transform: uppercase; font-size: clamp(24px, 2.6vw, 38px); line-height: 0.9; letter-spacing: -0.005em; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); }
.inst__meta .mono { opacity: 0.85; }
.inst .hwsvg * { vector-effect: none; }
@media (max-width: 900px) { .inst-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 180px; } .inst--big { grid-column: span 2; grid-row: span 2; } .inst--wide { grid-column: span 2; } }

/* ---------- popup ---------- */
.hw { border: 0; padding: 0; background: transparent; color: var(--on-night); width: min(1080px, 94vw); max-height: 92vh; max-height: 92dvh; overflow: visible; }
.hw::backdrop { background: rgba(8, 8, 7, 0.88); backdrop-filter: blur(3px); }
.hw[open] { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); animation: hwin 0.5s var(--ease); max-height: 92vh; max-height: 92dvh; }
@keyframes hwin { from { opacity: 0; transform: translateY(24px) scale(0.98); } }
.hw__stage { position: relative; display: grid; place-items: center; min-height: 380px; padding: 56px 28px 36px; overflow: hidden; }
.hw__stage::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1.2px); background-size: 20px 20px; opacity: 0.5; }
.hw__stage.is-instr::before { background-image: radial-gradient(rgba(0, 0, 0, 0.14) 1px, transparent 1.2px); }
.hw__room { position: absolute; top: 14px; left: 18px; right: 18px; display: flex; align-items: center; gap: 12px; z-index: 1; }
.hw__letter { font-weight: 900; font-stretch: 62%; font-size: 44px; line-height: 0.8; }
.hw__art { position: relative; z-index: 1; width: 100%; display: grid; place-items: center; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.35)); }
.hw__art .hwsvg { width: 100%; max-width: 560px; height: auto; max-height: 56vh; max-height: 56dvh; }
.hw__art .hwinstr { max-width: 340px; color: var(--fg, currentColor); }
.hw__panel { background: var(--night-2); border: 1px solid var(--line-night); border-left: 0; padding: 18px 26px 28px; overflow-y: auto; max-height: 92vh; max-height: 92dvh; }
.hw__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.hw__count { color: var(--on-night-2); }
.hw__nav { display: flex; gap: 6px; }
.hw__btn { width: 38px; height: 38px; display: grid; place-items: center; background: none; border: 1px solid var(--line-night); color: var(--on-night); cursor: pointer; font-size: 16px; transition: background 0.2s, border-color 0.2s; }
@media (hover: hover) { .hw__btn:hover:not(:disabled) { background: var(--on-night); color: var(--night); } }
.hw__btn:disabled { opacity: 0.3; cursor: default; }
.hw__brand { color: var(--on-night-2); margin: 0 0 6px; }
.hw__name { margin: 0 0 16px; font-weight: 800; letter-spacing: -0.035em; line-height: 0.98; font-size: clamp(32px, 3.6vw, 52px); text-wrap: balance; }
.hw__role { margin: 0 0 22px; font-size: 17px; line-height: 1.5; color: var(--on-night); max-width: 46ch; }
.hw__specs { margin: 0 0 22px; display: grid; border-top: 1px solid var(--line-night); }
.hw__specs div { display: grid; grid-template-columns: 9.5em 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-night); }
.hw__specs dt { color: var(--on-night-2); padding-top: 2px; }
.hw__specs dd { margin: 0; font-size: 15px; font-weight: 520; }
.hw__conn .mono { margin: 0 0 10px; color: var(--on-night-2); }
.hw__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-l { display: inline-flex; gap: 8px; align-items: baseline; padding: 8px 12px 7px; border: 1px solid var(--amber); background: none; color: var(--on-night); font-size: 14.5px; font-weight: 560; cursor: pointer; transition: background 0.2s, color 0.2s; }
.chip-l .mono { color: var(--amber); margin: 0; }
@media (hover: hover) {
  button.chip-l:hover { background: var(--amber); color: var(--ink); }
  button.chip-l:hover .mono { color: var(--ink); }
}
.chip-l--static { border-style: dashed; cursor: default; }

@media (max-width: 820px) {
  .hw[open] { grid-template-columns: 1fr; overflow-y: auto; }
  .hw__stage { min-height: 260px; padding-top: 52px; }
  .hw__panel { border-left: 1px solid var(--line-night); border-top: 0; max-height: none; overflow: visible; }
  .hw__art .hwsvg { max-height: 36vh; max-height: 36dvh; }
  /* La fiche défile en entier : les boutons précédent / suivant / fermer restent accessibles en haut */
  .hw__panel { padding-top: 0; }
  .hw__top { position: sticky; top: 0; z-index: 3; margin: 0 -26px 18px; padding: 10px 26px; background: var(--night-2); border-bottom: 1px solid var(--line-night); }
  .hw__btn { width: 44px; height: 44px; }
  .hw__specs div { grid-template-columns: 7.5em 1fr; }
}

.lib .book__band { margin-top: 0; }
.libfoot { padding-block: 28px; border-top: 1px solid var(--line-night); color: var(--on-night-2); }
.libfoot p { margin: 0; }

@keyframes flow { to { stroke-dashoffset: -20; } }
@media (prefers-reduced-motion: reduce) { .edge path { animation: none; } .hw[open] { animation: none; } }

/* Mobile : en-tête et onglets sur une ligne */
.libnav__back, .tab__t b { white-space: nowrap; }
@media (max-width: 720px) {
  .libnav__t { display: none; }
  .libnav__back { padding: 8px 12px 7px; font-size: 13px; }
  .tablist { grid-template-columns: repeat(4, max-content); }
  .tab__t b { font-size: 14px; }
}
@media (max-width: 480px) {
  .tablist { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tab { padding: 10px 3px; gap: 4px; justify-content: center; }
  .tab__l { font-size: 22px; }
  .tab__t b { font-size: 11px; }
}

/* Fiche ouverte depuis l'accueil : mêmes polices que la bibliothèque */
.hw .hwt { font-family: var(--f-mono); }
.hw .hwbig { font-family: var(--f-sans); font-weight: 900; font-stretch: 62%; }
