/* The workstation environment — the depth layer's own material system.
   Companion to web/shell.css (the permanent Table shell): shell.css defines
   the --hz-* material tokens on :root; this file carries them INTO the
   depth layer so a workstation is a working plane inside the same dark
   institutional environment, never a white application inside a dark frame.

   Two mechanisms, deliberately separated:
   1. RETOKENING — the legacy stylesheet and nearly every legacy inline
      style read the CSS custom properties --bg/--fg/--muted/--line/
      --accent/--accent-bg/--focus (plus --danger/--warn added at :root by
      this change). Redefining those properties on #workstation-layer
      re-resolves every var() beneath it: one scope, ~74 workstations.
   2. RECOMPOSITION — structural rules below that reshape the working
      plane, rail, forms, tables, records, and states as materials
      (smoked glass, engraved labels, restrained borders), not merely
      recolored rectangles.

   Palette discipline: every color derives from the seven real HVI brand
   values already committed in web/landing.html — Caviar (#302E2F family
   grounds), Secret Garden (#4F563C glass tint), Garden Gate (#8B9165
   live accents), Antiquarian Brown (#946C46 gold detail), Neutral Ground
   (#E3DACC text), Sommelier (#664747 consequence red), khaki (#BAAE96
   secondary text). No invented hues; dark variants are these values
   darkened, never replaced. */

#workstation-layer {
  /* -- retokening ------------------------------------------------------ */
  --bg: #0b0c0d;              /* Caviar ground, one step above the void   */
  --fg: #e3dacc;              /* Neutral Ground text                      */
  --muted: #a89c86;           /* khaki, lifted for AA on dark             */
  --line: rgba(186, 174, 150, 0.2);   /* khaki hairlines                  */
  --accent: #aeb383;          /* Garden Gate, lifted for dark-ground text */
  --accent-bg: rgba(79, 86, 60, 0.28); /* Secret Garden glass             */
  --focus: #e4c988;           /* the shell's gold focus ring              */
  --danger: #e0938c;          /* Sommelier, lifted to read on Caviar      */
  --warn: #c2a06a;            /* Antiquarian gold                         */

  color: var(--fg);
  background:
    radial-gradient(70% 50% at 50% 0%, rgba(79, 86, 60, 0.16) 0%, transparent 65%),
    #0b0c0d;
}

/* -- the working plane -------------------------------------------------- */

#workstation-layer main {
  /* width:100% matters: with only margin:0 auto inside the column-flex
     layout, main shrink-to-fits its widest child and can exceed the
     viewport on mobile instead of letting content wrap. */
  width: 100%;
  min-width: 0;
  max-width: 74rem;
  margin: 0 auto;
  padding: 1.75rem 2.25rem 3rem;
}

#workstation-layer main > h2:first-of-type,
#workstation-layer #page-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg);
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
}

#workstation-layer .banner {
  background: rgba(79, 86, 60, 0.14);
  border: 1px solid var(--line);
  border-left: 2px solid var(--hz-gold-dim);
  color: var(--muted);
  border-radius: 4px;
}

/* Section wrappers most renderers emit (eyebrow + heading + body) sit on
   a smoked-glass plane. */
#workstation-layer #page-body > div > section,
#workstation-layer #page-body > section {
  background: linear-gradient(165deg, rgba(79, 86, 60, 0.1) 0%, rgba(0, 0, 0, 0.18) 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.75);
}
#workstation-layer #page-body > div > section + section,
#workstation-layer #page-body > section + section {
  margin-top: 1.25rem;
}

#workstation-layer .eyebrow {
  font-family: var(--hz-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--hz-gold);
}

/* -- records, cards, tables --------------------------------------------- */

#workstation-layer .metric-card,
#workstation-layer .commitment-card,
#workstation-layer .incident-panel,
#workstation-layer .incident-card,
#workstation-layer .suite-library-suite,
#workstation-layer .placeholder {
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
  border-radius: 6px;
}
#workstation-layer .metric-card strong { color: var(--fg); }
#workstation-layer .status-badge {
  background: rgba(79, 86, 60, 0.3);
  color: var(--accent);
  border: 1px solid rgba(139, 145, 101, 0.35);
  font-family: var(--hz-mono);
  font-weight: 500;
  letter-spacing: 0.06em;
}
#workstation-layer .record-highlight {
  outline: 2px solid var(--hz-gold);
  outline-offset: 2px;
}

#workstation-layer table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
#workstation-layer th {
  font-family: var(--hz-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--hz-gold);
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}
#workstation-layer td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid rgba(186, 174, 150, 0.1);
  color: var(--fg);
}
#workstation-layer tr:last-child td { border-bottom: none; }
#workstation-layer tr:hover td { background: rgba(79, 86, 60, 0.12); }

/* -- forms and controls -------------------------------------------------- */

#workstation-layer input,
#workstation-layer textarea,
#workstation-layer select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--fg);
  padding: 0.45rem 0.6rem;
  font: inherit;
}
#workstation-layer input::placeholder,
#workstation-layer textarea::placeholder {
  color: rgba(168, 156, 134, 0.6);
}
#workstation-layer input:focus-visible,
#workstation-layer textarea:focus-visible,
#workstation-layer select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--hz-gold-dim);
}

#workstation-layer button,
#workstation-layer input[type="submit"] {
  font: inherit;
  color: var(--fg);
  cursor: pointer;
}
/* Every action control inside the working plane is a material control —
   the browser-default gray slab never appears in this environment.
   Non-submit buttons are the quiet secondary treatment; submit stays the
   filled primary below. */
#workstation-layer main button:not([type="submit"]) {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.4rem 0.85rem;
  color: var(--accent);
}
#workstation-layer main button:not([type="submit"]):hover {
  border-color: rgba(139, 145, 101, 0.5);
  color: #e9e3d5;
}
#workstation-layer button[type="submit"],
#workstation-layer input[type="submit"] {
  background: rgba(79, 86, 60, 0.42);
  border: 1px solid rgba(139, 145, 101, 0.5);
  color: #e9e3d5;
  border-radius: 4px;
  padding: 0.45rem 1rem;
}
#workstation-layer button[type="submit"]:hover,
#workstation-layer input[type="submit"]:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(139, 145, 101, 0.35) inset;
}
#workstation-layer button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#workstation-layer label { color: var(--muted); }
#workstation-layer .field-stack > span:first-child,
#workstation-layer .incident-stack label { color: var(--muted); }

/* -- states --------------------------------------------------------------
   Loading, empty, error, success, locked: legible, materially consistent,
   never a bare browser-default paragraph on white. */

#workstation-layer .status-message { color: var(--muted); }
#workstation-layer .auth-error,
#workstation-layer [role="alert"] {
  color: var(--danger);
}
#workstation-layer .placeholder {
  border-style: dashed;
  color: var(--muted);
}
#workstation-layer .suite-empty-note { color: var(--muted); }
#workstation-layer .suite-library-workstations button {
  background: rgba(0, 0, 0, 0.24);
  border-color: var(--line);
  color: var(--fg);
}
#workstation-layer .suite-library-workstations button:hover {
  background: var(--accent-bg);
}

/* -- the rail: suite-first navigation ------------------------------------
   web/suiteNav.js reorganizes the legacy flat <nav> into this structure at
   runtime: a pinned spine (Return to the Table, active context), a Recent
   group, then one <details class="rail-suite"> per real Suite Library
   entry holding only that suite's workstation buttons. The flat wall of
   every workstation is gone; a suite opens to reveal its own domain. */

#workstation-layer nav {
  width: 250px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.12) 100%);
  padding: 1.4rem 0.6rem 2rem;
  overflow-y: auto;
  max-height: calc(100vh - var(--hz-top-inset, 7.8rem));
  position: sticky;
  top: 0; /* the layer's own padding places it; it can slide up under the chrome band */
}
#workstation-layer nav h2 {
  color: var(--hz-gold);
  font-family: var(--hz-mono);
  letter-spacing: 0.14em;
  font-weight: 500;
}
#workstation-layer nav button:hover { background: var(--accent-bg); }
#workstation-layer nav button[aria-current="page"] {
  background: rgba(79, 86, 60, 0.35);
  color: #e9e3d5;
  border-left: 2px solid var(--hz-gold);
  border-radius: 3px;
}

.rail-spine {
  display: grid;
  gap: 0.35rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}
#workstation-layer nav .rail-table-btn {
  font-family: var(--hz-mono);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  color: var(--hz-gold);
  border: 1px solid var(--hz-glass-border);
  background: rgba(194, 160, 106, 0.08);
  min-height: 40px;
}
#workstation-layer nav .rail-table-btn:hover {
  border-color: var(--hz-gold-glow);
  background: rgba(194, 160, 106, 0.14);
}

.rail-suite {
  border: 0;
  margin: 0.1rem 0;
}
.rail-suite > summary {
  list-style: none;
  cursor: pointer;
  font-family: var(--hz-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 0.5rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 36px;
}
.rail-suite > summary::-webkit-details-marker { display: none; }
.rail-suite > summary::before {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1px solid var(--hz-gold-dim);
  border-bottom: 1px solid var(--hz-gold-dim);
  transform: rotate(-45deg);
  transition: transform 0.12s ease;
  flex: none;
}
.rail-suite[open] > summary::before { transform: rotate(45deg); }
.rail-suite[open] > summary { color: var(--hz-gold); }
.rail-suite > summary:hover { background: var(--accent-bg); color: var(--fg); }
.rail-suite > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rail-suite .rail-suite-locked {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  margin-left: auto;
}
.rail-suite-body {
  padding: 0.1rem 0 0.4rem 0.9rem;
  display: grid;
  gap: 1px;
}
.rail-recent-label {
  font-family: var(--hz-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.25rem 0.5rem;
}

/* While the rail is suite-first, the legacy flat group headers are
   retired by suiteNav.js at runtime (source markup untouched). */
#workstation-layer nav.rail-grouped > h2,
#workstation-layer nav.rail-grouped > button[data-page] {
  display: none;
}

/* -- scrollbars, selection, motion --------------------------------------- */

#workstation-layer ::selection { background: var(--hz-gold-dim); color: #0b0c0d; }
#workstation-layer nav::-webkit-scrollbar,
#workstation-layer::-webkit-scrollbar { width: 10px; }
#workstation-layer nav::-webkit-scrollbar-thumb,
#workstation-layer::-webkit-scrollbar-thumb {
  background: rgba(186, 174, 150, 0.18);
  border-radius: 5px;
}

@media (prefers-reduced-motion: reduce) {
  .rail-suite > summary::before { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  #workstation-layer #page-body > div > section,
  #workstation-layer #page-body > section {
    background: #101112;
  }
}

/* -- responsive ----------------------------------------------------------- */

@media (max-width: 1024px) {
  #workstation-layer main { padding: 1.25rem 1.25rem 2.5rem; }
}
@media (max-width: 640px) {
  #workstation-layer nav {
    width: 100%;
    max-height: none;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  #workstation-layer main { padding: 1rem 0.9rem 2rem; }
  #workstation-layer #page-body > div > section,
  #workstation-layer #page-body > section { padding: 1.1rem 1rem; }
}
