/* Mac OS 9 Platinum window. Semantic --os-* tokens only. Requires styles/tokens.css + styles/os9.css.
   <section class="os-win is-active" data-os-window aria-labelledby="w1-title" style="--l:20%; --t:80px; --w:480px">
     <header class="os-win__bar">
       <button class="os-win__box os-win__close" type="button" aria-label="Close window"></button>
       <span class="os-win__stripes"></span>
       <h2 class="os-win__title" id="w1-title">Title</h2>
       <span class="os-win__stripes"></span>
       <button class="os-win__box os-win__zoom" type="button" aria-label="Zoom window" aria-pressed="false"></button>
       <button class="os-win__box os-win__collapse" type="button" aria-label="Collapse window" aria-expanded="true"></button>
     </header>
     <div class="os-win__body" style="--h:260px">…</div>
   </section>
   Position props (--l, --t, --w) apply on wide screens only; below 64rem windows stack in the flow.
   Behavior (drag, click-to-focus, boxes): components/os-window.js */

.os-win {
  position: relative;
  z-index: var(--z-window);
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0 5px 5px;
  background: var(--os-face);
  color: var(--os-text);
  border: 1px solid var(--os-outline);
  box-shadow: inset 1px 1px 0 var(--os-hi), inset -1px -1px 0 var(--os-lo), var(--os-win-shadow);
  font-family: var(--font-chrome-text);
  font-size: var(--os-size);
  transform: translate(var(--x, 0px), var(--y, 0px));
}

.os-win[hidden] { display: none; }

@media (min-width: 64rem) {
  .os-win {
    position: absolute;
    left: var(--l, 0);
    top: var(--t, 0);
    width: var(--w, 28rem);
  }
  .os-win.is-zoomed { width: min(calc(100vw - 4rem), 60rem); }
}

/* ---- Title bar ---- */
.os-win__bar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--os-titlebar-h);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.is-dragging .os-win__bar { cursor: grabbing; }

.os-win__stripes {
  flex: 1;
  min-width: 8px;
  height: 11px;
  background: repeating-linear-gradient(to bottom, var(--os-stripe-a) 0 1px, var(--os-stripe-b) 1px 2px);
}

.os-win__title {
  margin: 0 6px;
  max-width: 70%;
  overflow: hidden;
  font-family: var(--font-chrome);
  font-size: var(--os-size);
  font-weight: 400;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Close (left), zoom + collapse (right): square, pressed-in bevel */
.os-win__box {
  position: relative;
  flex: none;
  width: 13px;
  height: 13px;
  padding: 0;
  background: var(--os-face);
  border: 1px solid var(--os-outline);
  box-shadow: inset 1px 1px 0 var(--os-lo), inset -1px -1px 0 var(--os-hi);
  cursor: pointer;
}

.os-win__box:active {
  background: var(--os-face-pressed);
  box-shadow: inset 1px 1px 0 var(--os-outline);
}

.os-win__zoom::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 5px;
  height: 5px;
  border: 1px solid var(--os-outline);
}

.os-win__collapse::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 3px;
  height: 3px;
  border-top: 1px solid var(--os-outline);
  border-bottom: 1px solid var(--os-outline);
}

.os-win__box:focus-visible { outline: 2px solid var(--os-focus); outline-offset: 1px; }

/* ---- Inactive: stripes and boxes go, title greys out, bevel flattens ---- */
.os-win:not(.is-active) { box-shadow: var(--os-win-shadow); }
.os-win:not(.is-active) .os-win__stripes { background: none; }
.os-win:not(.is-active) .os-win__box { visibility: hidden; }
.os-win:not(.is-active) .os-win__title { color: var(--os-text-inactive); }

/* ---- Content ---- */
.os-win__body {
  max-height: var(--h, none);
  overflow: auto;
  padding: var(--space-4);
  background: var(--os-content);
  color: var(--os-text);
  border: 1px solid var(--os-outline);
  box-shadow: -1px -1px 0 var(--os-lo), 1px 1px 0 var(--os-hi);
}

.os-win__body a { color: var(--os-link); }

.os-win.is-collapsed .os-win__body,
.os-win.is-collapsed .os-win__status { display: none; }
.os-win.is-collapsed { padding-bottom: 0; }

/* Optional info/status strip under the title bar */
.os-win__status {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 2px 6px 4px;
  color: var(--os-text-muted);
}

/* ---- OS 9 scrollbar (WebKit/Blink) ---- */
.os-win__body::-webkit-scrollbar { width: 16px; height: 16px; background: var(--os-track); }

.os-win__body::-webkit-scrollbar-track {
  background: var(--os-track);
  border-left: 1px solid var(--os-outline);
  box-shadow: inset 1px 1px 0 var(--os-lo), inset -1px 0 0 var(--os-hi);
}

.os-win__body::-webkit-scrollbar-thumb {
  background:
    repeating-linear-gradient(to bottom, var(--os-thumb-grip-a) 0 1px, var(--os-thumb-grip-b) 1px 2px) center / 7px 8px no-repeat,
    var(--os-thumb);
  border: 1px solid var(--os-outline);
  box-shadow: inset 1px 1px 0 var(--os-thumb-grip-a), inset -1px -1px 0 var(--os-lo);
}

.os-win__body::-webkit-scrollbar-button:single-button {
  display: block;
  width: 16px;
  height: 16px;
  background-color: var(--os-face);
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid var(--os-outline);
  box-shadow: inset 1px 1px 0 var(--os-hi), inset -1px -1px 0 var(--os-lo);
}

.os-win__body::-webkit-scrollbar-button:single-button:vertical:decrement { background-image: var(--os-arrow-up); }
.os-win__body::-webkit-scrollbar-button:single-button:vertical:increment { background-image: var(--os-arrow-down); }
.os-win__body::-webkit-scrollbar-button:single-button:active { background-color: var(--os-face-pressed); box-shadow: inset 1px 1px 0 var(--os-lo); }
.os-win__body::-webkit-scrollbar-corner { background: var(--os-face); }

/* Firefox: no pseudo-elements, colors only */
@supports not selector(::-webkit-scrollbar) {
  .os-win__body { scrollbar-color: var(--os-thumb) var(--os-track); }
}

@media (max-width: 63.99rem), (pointer: coarse) {
  .os-win__bar { cursor: default; touch-action: auto; }
}
