/* Story Bible — extends premise.css patterns. Specimen-sheet aesthetic.
   Production version: sidebar 280px (matches static/premise.css .pb-app).
   All pb-* classes come from premise.css (loaded globally in app.html). */

.wb-app { display: grid; grid-template-columns: 280px minmax(0, 1fr) 320px; height: 100vh; overflow: hidden; background: var(--paper); }
.wb-app.no-rail { grid-template-columns: 280px minmax(0, 1fr); }
html.sidebar-collapsed .wb-app { grid-template-columns: 60px minmax(0, 1fr) 320px; }
html.sidebar-collapsed .wb-app.no-rail { grid-template-columns: 60px minmax(0, 1fr); }
.wb-app .pb-main {
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding: 28px 36px 40px;
  background: var(--paper);
}
.wb-app #state-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.wb-sheet {
  max-width: 1500px;
  margin: 0 auto;
  padding: 48px 64px 80px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.04), 0 14px 40px rgba(20,18,12,0.15);
  min-width: 0;
}
.wb-mast {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px;
  margin-bottom: 22px;
}
.wb-mast .name {
  font-family: var(--serif); font-weight: 600; font-style: italic;
  font-size: 14px; letter-spacing: 0.04em; color: var(--ink-2);
}
.wb-mast .meta {
  font-family: var(--mono); font-size: 12px; color: var(--ink-4);
  letter-spacing: 0.18em; text-transform: uppercase;
}

.wb-eyebrow {
  font-family: var(--mono); font-size: 12px; color: var(--ink-3);
  letter-spacing: 0.22em; text-transform: uppercase;
  margin-bottom: 6px;
}
.wb-title {
  font-family: var(--serif); font-weight: 600;
  font-size: 48px; line-height: 1; letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0 0 28px;
}

/* Two prose fields — laid out side by side at top */
.wb-prose-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 36px;
  padding: 12px 0 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.wb-prose-grid .pb-field { padding: 8px 0; }

/* template.js puts wb-prose on the .pb-body element */
.pb-body.wb-prose {
  font-family: var(--serif); font-size: 16px; line-height: 1.65; color: var(--ink); text-wrap: pretty;
}
.pb-body.wb-prose[data-field="atmosphere"] {
  font-style: italic; font-size: 16px; color: var(--ink-2);
}
.pb-body.wb-prose.editing { background: rgba(108,93,168,0.04); border-radius: 3px; }

/* Twelve list cells in a 3-column gazetteer */
.wb-lists {
  column-count: 3;
  column-gap: 36px;
  padding-top: 12px;
}
.wb-list {
  break-inside: avoid;
  margin: 0 0 28px;
  padding: 0;
  position: relative;
}
.wb-list-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.wb-list-label {
  font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink); font-weight: 600;
}
.wb-list-count {
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-4); letter-spacing: 0.06em;
}
.wb-list-help {
  display: block;
  font-family: var(--serif); font-style: italic;
  font-size: 13px; color: var(--ink-4); line-height: 1.4;
  margin-bottom: 8px;
}

/* Contenteditable list body */
.wb-list-body {
  font-family: var(--serif);
  font-size: 15px; line-height: 1.6;
  color: var(--ink-2);
  white-space: pre-wrap;
  min-height: 20px;
  padding: 2px 0;
  text-wrap: pretty;
  outline: none;
}
.wb-list-body:focus,
.wb-list-body.editing { background: rgba(108,93,168,0.04); border-radius: 3px; padding: 2px 4px; }

/* Empty state */
.wb-empty {
  max-width: 950px; margin: 0 auto;
  padding: 80px 64px;
  display: flex; flex-direction: column; gap: 22px;
}
.wb-empty .wb-eyebrow { margin-bottom: 0; }
.wb-empty h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: 44px; letter-spacing: -0.025em; line-height: 1.05;
  margin: 0; color: var(--ink);
}
.wb-empty .lede {
  font-family: var(--serif); font-style: italic;
  font-size: 18px; line-height: 1.55; color: var(--ink-3);
  text-wrap: pretty; max-width: 56ch;
}
.wb-empty .premise-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 20px 22px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.7) inset,
    0 1px 3px rgba(20,17,12,0.04),
    0 6px 16px -10px rgba(20,17,12,0.10);
}
.wb-empty .premise-card .row {
  font-family: var(--mono); font-size: 12px; color: var(--ink-4);
  letter-spacing: 0.12em; text-transform: uppercase;
  display: flex; gap: 8px; align-items: center;
}
.wb-empty .premise-card .ll {
  font-family: var(--serif); font-size: 17px; line-height: 1.45;
  color: var(--ink); font-weight: 500; margin: 0;
  text-wrap: pretty;
}
.wb-empty .premise-card .open {
  align-self: flex-end;
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-3); letter-spacing: 0.06em;
}
.wb-empty .actions { display: flex; gap: 10px; align-items: center; }
.wb-empty .actions .pb-btn { height: 38px; padding: 0 18px; font-size: 13.5px; }

/* Inner scroll containers — scrollable but no visible scrollbar track */
.wb-sheet,
.wb-empty {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.wb-sheet::-webkit-scrollbar,
.wb-empty::-webkit-scrollbar {
  display: none;
}

/* Build estimate badge */
.est {
  font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-4);
}

/* topbar + mast reflow instead of clipping at narrow widths */
.pb-topbar { flex-wrap: wrap; gap: 4px 12px; }
.pb-topbar .crumbs { min-width: 0; }
.wb-mast { flex-wrap: wrap; gap: 4px 16px; }

/* let the two-column prose grid and its fields shrink, not overflow */
.wb-prose-grid { min-width: 0; }
.wb-prose-grid > * { min-width: 0; }

/* RAIL mode-change: below 1100px the right rail stacks under main. */
@media (max-width: 1100px) {
  .wb-app:not(.no-rail) { grid-template-columns: 280px minmax(0, 1fr); }
  html.sidebar-collapsed .wb-app:not(.no-rail) { grid-template-columns: 60px minmax(0, 1fr); }
  .wb-rail {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
  }
}

/* NARROW: auto-collapse the sidebar to the existing 60px icon-rail. */
@media (max-width: 899px) {
  .wb-app,
  .wb-app.no-rail { grid-template-columns: 60px minmax(0, 1fr); }

  /* stack the two-column prose grid */
  .wb-prose-grid { grid-template-columns: 1fr; gap: 18px; }
  /* step the multi-column lists down from 3 to 2 */
  .wb-lists { column-count: 2; column-gap: 24px; }

  .wb-sheet { padding: 32px 24px 48px; max-width: 100%; }
  .pb-topbar { padding: 12px 20px; }
}

/* lists to a single column on phones */
@media (max-width: 560px) {
  .wb-lists { column-count: 1; }

  /* Pregeneration / intro state (.pb-empty-state.wb-empty): on a ~378px phone the
     outer pb-main (36px) + wb-empty (64px) padding, plus non-shrinking flex
     children, forced ~474px width and clipped the headline. Trim padding, let
     everything shrink, make the headline fluid, and stack the action full-width. */
  .wb-app .pb-main { padding-left: 16px; padding-right: 16px; overflow-x: hidden; }
  .wb-empty {
    padding: 40px 16px;          /* was 80px 64px */
    max-width: 100%;
    min-width: 0;
  }
  .wb-empty * { min-width: 0; }  /* allow flex descendants to shrink below content */
  .wb-empty h1 {
    font-size: clamp(1.6rem, 8vw, 2.4rem);   /* was fixed 44px */
    line-height: 1.15;
    overflow-wrap: anywhere;
  }
  .wb-empty .premise-card { padding: 16px; }
  .wb-empty .premise-card .row { flex-wrap: wrap; }
  .wb-empty .actions { flex-direction: column; align-items: stretch; }
  .wb-empty .actions .pb-btn { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
  .wb-sheet { padding: 24px 16px 40px; max-width: 100%; }
  .pb-topbar { padding: 12px 14px; }
}
