/* ============================================================
   SCENE STYLE — UI chrome. Owner: agent C (art direction).
   Loaded after the host styles; wins the cascade.
   Direction: quiet drafting-instrument chrome — hairline rules,
   mono microtype, glassy panels, status color reserved for
   meaning. Palette stays on the host variables. System fonts.
   ============================================================ */

::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

button:focus-visible,
.balloon:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------- header ---------------- */
header {
  padding: 16px 22px 34px;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--bg) 92%, transparent) 0%,
    color-mix(in srgb, var(--bg) 55%, transparent) 55%,
    transparent 100%
  );
}
.hgroup .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.64rem;
  letter-spacing: 0.16em;
}
.hgroup .eyebrow::before {
  content: "";
  width: 16px;
  height: 1px;
  background: var(--accent);
}
.hgroup h1 {
  font-size: 1.22rem;
  letter-spacing: -0.015em;
}
.hint {
  font-size: 0.65rem;
  letter-spacing: 0.09em;
  color: color-mix(in srgb, var(--soft) 78%, transparent);
}

/* ---------------- mode toolbar ---------------- */
#modes {
  gap: 0;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
#modes button {
  background: transparent;
  padding: 10px 18px 11px;
  transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
#modes button + button {
  border-left: 1px solid var(--rule);
}
#modes button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.035);
}
#modes button.active {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 0 -2px 0 0 var(--accent);
}
#modes button:focus-visible {
  outline-offset: -2px;
}

/* ---------------- CAD balloons ---------------- */
.balloon {
  --halo: var(--accent);
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-width: 1px;
  font-size: 10.5px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--bg) 45%, transparent),
    0 2px 8px rgba(0, 0, 0, 0.45);
  transition:
    transform 0.14s cubic-bezier(0.2, 0.9, 0.3, 1.35),
    box-shadow 0.14s ease,
    background-color 0.14s ease,
    color 0.14s ease;
}
.balloon.crit { --halo: var(--critical); }
.balloon.open { --halo: var(--open); }
.balloon.gate { --halo: var(--gated); }
.balloon:hover {
  transform: scale(1.18);
}
.balloon.active {
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--halo) 28%, transparent),
    0 2px 10px rgba(0, 0, 0, 0.5);
}
.balloon.hidden { display: none; }

/* ---------------- detail callout ----------------
   Host owns position/width (anchored to the selected balloon,
   left/top set per frame). This styles it as a CAD leader
   note: compact, glassy, status-colored top rule. */
aside {
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--accent);
  border-radius: 4px;
  padding: 12px 13px 13px;
  max-height: 290px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
aside:has(.pill.crit) { border-top-color: var(--critical); }
aside:has(.pill.open) { border-top-color: var(--open); }
aside:has(.pill.gate) { border-top-color: var(--gated); }
aside.show {
  animation: sheetIn 0.18s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}
@keyframes sheetIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}
aside::-webkit-scrollbar { width: 6px; }
aside::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 3px;
}
aside .part-no {
  font-size: 0.58rem;
  letter-spacing: 0.14em;
}
aside h2 {
  font-size: 0.88rem;
  letter-spacing: -0.005em;
  margin: 3px 0 8px;
  line-height: 1.25;
}
aside .pill {
  background: color-mix(in srgb, currentColor 9%, transparent);
  border-radius: 2px;
  font-size: 0.55rem;
  padding: 3px 7px;
  margin-bottom: 9px;
}
aside dl {
  gap: 4px 10px;
  margin: 0 0 9px;
  font-size: 0.7rem;
}
aside dt {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-top: 2px;
}
aside .note {
  font-size: 0.76rem;
  line-height: 1.5;
  padding-top: 8px;
  color: color-mix(in srgb, var(--ink) 90%, var(--soft));
}
aside .close {
  top: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 0.95rem;
  display: grid;
  place-items: center;
  border-radius: 3px;
  transition: color 0.12s ease, background-color 0.12s ease;
}
aside .close:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

/* ---------------- footer legend ---------------- */
footer {
  gap: 22px;
  padding: 14px 22px 12px;
  background: linear-gradient(
    to top,
    color-mix(in srgb, var(--bg) 85%, transparent) 0%,
    transparent 100%
  );
}
.key { gap: 7px; }
.dot {
  width: 8px;
  height: 8px;
  outline: 1px solid rgba(255, 255, 255, 0.08);
  outline-offset: 1px;
}

/* ---------------- error card ---------------- */
#err {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  line-height: 1.7;
}

/* ---------------- reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  .balloon,
  #modes button,
  aside .close {
    transition: none;
  }
  aside.show {
    animation: none;
  }
}

/* touch devices: pointer hints are meaningless at any width */
@media (hover: none) and (pointer: coarse) {
  .hint { display: none; }
}

/* ---------------- small screens ---------------- */
@media (max-width: 700px) {
  /* header: title text costs vertical real estate the model needs more
     than the chrome does — drop it entirely, keep the screen full-bleed */
  header { display: none; }

  /* mode toolbar: one row, four buttons, no wrapping */
  #modes { bottom: 10px; }
  #modes button {
    white-space: nowrap;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    padding: 8px 10px;
  }

  /* footer legend: single row, right-aligned clear of the
     centered toolbar */
  footer {
    gap: 12px;
    font-size: 0.55rem;
    padding: 10px 14px 9px;
    justify-content: flex-end;
    flex-wrap: nowrap;
    white-space: nowrap;
  }
  .key { gap: 5px; flex: none; }

  /* balloons: touch targets */
  .balloon {
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  /* phone: the legend is learnable from the balloons */
  footer { display: none; }
}
