/*! Title bar and box styling inspired by a free layout by Itinerae (itinerae.neocities.org). */
/* Gradient title-bar boxes + recessed insets. Semantic tokens only (--titlebar-* in styles/tokens.css,
   --os-* in styles/os9.css). Title bar and box styling inspired by a free layout by Itinerae
   (itinerae.neocities.org), rebuilt in our own tokens.

   <div class="tbox-stack">                                   ← optional: stacks boxes 4px apart
     <section class="tbox" aria-labelledby="t1">
       <div class="titlebar-grad">
         <span class="titlebar-grad__ctl" aria-hidden="true"></span>
         <h2 class="titlebar-grad__title" id="t1">Title</h2>
         <span class="titlebar-grad__ctls" aria-hidden="true">
           <span class="titlebar-grad__ctl titlebar-grad__ctl--zoom"></span>
           <span class="titlebar-grad__ctl titlebar-grad__ctl--collapse"></span>
         </span>
       </div>
       <div class="tbox__body">…</div>
     </section>
   </div>

   The corner boxes are DECORATIVE ONLY: aria-hidden, no behavior, no pointer events.
   Inset panel: <div class="inset">…</div> (recessed bevel; nest inside a .tbox__body). */

.tbox-stack {
  display: grid;
  gap: 4px;
}

.tbox {
  background: var(--os-face);
  color: var(--os-text);
  border: 1px solid var(--os-outline);
  box-shadow: 2px 2px 0 var(--os-lo);
}

/* ---- Title bar: blue -> lighter blue, white uppercase chrome text ---- */
.titlebar-grad {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 19px;
  padding: 3px 4px;
  background: linear-gradient(to right, var(--titlebar-from), var(--titlebar-to));
  color: var(--titlebar-text);
  border-bottom: 1px solid var(--titlebar-line);
}

.titlebar-grad__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: inherit;
  font-family: var(--font-chrome);
  font-size: calc(11px * var(--chrome-scale));
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: calc(2.5px + var(--chrome-tracking));
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.titlebar-grad__ctls {
  display: flex;
  gap: 3px;
  flex: none;
}

.titlebar-grad__ctl {
  position: relative;
  flex: none;
  width: 11px;
  height: 11px;
  background: var(--titlebar-ctl);
  border: 1px solid var(--titlebar-ctl-edge);
  pointer-events: none;
}

.titlebar-grad__ctl--zoom::after {      /* small square inside */
  content: "";
  position: absolute;
  left: 1px;
  top: 1px;
  width: 5px;
  height: 5px;
  border: 1px solid var(--titlebar-ctl-edge);
}

.titlebar-grad__ctl--collapse::after {  /* two lines */
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 2px;
  height: 3px;
  border-top: 1px solid var(--titlebar-ctl-edge);
  border-bottom: 1px solid var(--titlebar-ctl-edge);
}

/* CRT on: no color-split text-shadow on the small bar titles (it muddies white-on-blue at 11px) */
body.crt-on .titlebar-grad__title {
  animation: none;
  text-shadow: none;
}

/* ---- Box body: platinum, recessed bevel (dark top/left, light bottom/right) ---- */
.tbox__body {
  padding: 4px;
  background: var(--os-face);
  color: var(--os-text);
  border: 2px solid;
  border-color: var(--os-lo) var(--os-hi) var(--os-hi) var(--os-lo);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.tbox__body > :first-child { margin-top: 0; }
.tbox__body > :last-child { margin-bottom: 0; }

.tbox__faint { color: var(--os-text-muted); }   /* 6.2:1 light, 5.7:1 dark */

/* ---- Recessed inset panel (nested inside a box body) ---- */
.inset {
  position: relative;
  padding: var(--space-4);
  background: var(--surface-alt);
  color: var(--text);
  border: 2px solid;
  border-color: var(--os-lo) var(--os-hi) var(--os-hi) var(--os-lo);
}

.inset--paper { background: var(--surface); }
