/* ============================================================
   layout.css — the app shell: header, weight readout, panel resizing
   ============================================================ */

/* ─── LAYOUT ─────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 16px 10px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 88%, var(--emboss-hi)), var(--surface));
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 6px var(--emboss-lo);
  flex-shrink: 0;
  min-height: 58px;
  z-index: 5;
}
/* Gold rule beneath the header — the banner's stitched edge */
#header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--gold-line);
  opacity: 0.7;
}

#char-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}
#char-name-display {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-shadow: 0 1px 0 var(--emboss-hi);
}
/* ─── WEIGHT READOUT ─────────────────────────────────────── */
/* Bottom left of the inventory view: a zero-height row just above the stash,
   the readout hanging up out of it — the dice dock's trick, upside down. */
#weight-dock {
  position: relative;
  height: 0;
  flex-shrink: 0;
  z-index: 7;
}
#inventory-panel.sheet-view #weight-dock,
#inventory-panel.spell-view #weight-dock,
#inventory-panel.map-view #weight-dock { display: none; }

#weight-indicator {
  position: absolute;
  left: 12px;
  bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 2px;
  padding: 7px 15px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--border2);
  box-shadow: var(--shadow-soft);
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  cursor: default;
  white-space: nowrap;
}
#weight-indicator:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
#weight-indicator .weight-sep  { color: var(--text-dim); margin: 0 1px; }
#weight-capacity               { color: var(--text-dim); }
#weight-indicator .weight-unit { color: var(--text-dim); font-size: 12px; font-weight: 400; margin-left: 4px; }
#weight-indicator[data-level="1"] { border-color: var(--enc-warn); }
#weight-indicator[data-level="1"] #weight-carried { color: var(--enc-warn); }
#weight-indicator[data-level="2"] { border-color: var(--enc-heavy); }
#weight-indicator[data-level="2"] #weight-carried { color: var(--enc-heavy); }

/* The card opens upward from the readout, at once — it is the readout's whole
   explanation, not a tooltip to be waited for. */
#weight-card {
  display: none;
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  width: 260px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: 6px;
  box-shadow: var(--shadow-deep), inset 0 0 0 1px var(--emboss-hi);
  font-size: 11px;
  font-weight: 400;
  white-space: normal;
  pointer-events: none;
}
#weight-indicator:hover #weight-card,
#weight-indicator:focus-visible #weight-card { display: block; }

.weight-card-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.weight-level {
  padding: 6px 8px;
  border-left: 3px solid transparent;
  border-radius: 3px;
  opacity: 0.6;
}
.weight-level + .weight-level { margin-top: 4px; }
.weight-level.current { opacity: 1; background: var(--weight-track); }
.weight-level[data-level="0"].current { border-left-color: var(--enc-ok); }
.weight-level[data-level="1"].current { border-left-color: var(--enc-warn); }
.weight-level[data-level="2"].current { border-left-color: var(--enc-heavy); }
.weight-level-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
}
.weight-level .tip-desc { margin-top: 3px; }

/* ─── MAIN LAYOUT ────────────────────────────────────────── */
#main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative; /* the reopen buttons anchor to its corners */
}

/* ─── SIDE PANEL RESIZING ────────────────────────────────── */
/* Widths live on #app as custom properties so panels.js can set them from one
   place; these are the defaults before anything is stored. */
:root {
  --equip-w: 210px;
  --sidebar-w: 300px;
}

/* The handle straddles the seam between panel and inventory: 7px of grab area
   pulled back by its own negative margins, so it costs no layout width. */
.panel-resizer {
  width: 7px;
  margin: 0 -4px;
  flex-shrink: 0;
  /* Positioned so the z-index actually applies: #inventory-panel is itself
     positioned and comes later in the DOM, so without this it paints over —
     and swallows the clicks on — the half of the handle overlapping it. */
  position: relative;
  z-index: 8;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
  transition: background 0.12s;
}
.panel-resizer:hover,
.panel-resizer.dragging {
  background: color-mix(in srgb, var(--accent) 55%, transparent);
}

#app.equip-collapsed #equip-panel,
#app.equip-collapsed #equip-resizer,
#app.sidebar-collapsed #sidebar,
#app.sidebar-collapsed #sidebar-resizer { display: none; }

/* Round button in the corner the panel folded away from. */
.panel-reopen-btn {
  position: absolute;
  top: 7px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--border2);
  box-shadow: var(--shadow-deep), inset 0 1px 0 var(--emboss-hi);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1;
  z-index: 20;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.panel-reopen-btn:hover { color: var(--accent); border-color: var(--accent); }
.panel-reopen-btn.left  { left: 8px; }
.panel-reopen-btn.right { right: 8px; }
#app.equip-collapsed   #show-equip-btn   { display: flex; }
#app.sidebar-collapsed #show-sidebar-btn { display: flex; }

/* Keep the character tabs clear of whichever button is showing. */
#app.equip-collapsed   #character-tabs { padding-left: 42px; }
#app.sidebar-collapsed #character-tabs { padding-right: 42px; }

