/* project-state.css - OCA Team Dashboard v2: Project / State-of-the-Project view
 *
 * Aligned to the Data / Dashboards page (css/dashboards.css) so both surfaces
 * share the same OCA visual language: Francois One uppercase eyebrows + titles,
 * Manrope body, sticky header strip with border-bottom, surface-2 body bg,
 * 14px-radius surface-0 cards, red numeric section prefixes.
 *
 * The Project surface retains its functional difference (collapsible H2
 * <details> cards instead of fixed dashboard tiles) so long-form Markdown
 * stays scannable, but every typographic and chromatic token now matches
 * the Data view.
 *
 * All selectors are prefixed .project-state-* and scoped to the panel so
 * nothing bleeds into Feed/Work/Decisions/Departments.
 */

/* -------------------------------------------------------------------------
 * Page shell
 *
 * openProject() in nav-links.js overrides the inline styles set by
 * makeScreenPanel() so the panel becomes a flex column whose header is
 * pinned and whose body scrolls. These rules document the intended layout
 * and act as a guardrail if those inline overrides are ever removed.
 * --------------------------------------------------------------------- */
.project-state-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-2);
  font-family: Manrope, sans-serif;
}

/* -------------------------------------------------------------------------
 * Header strip (mirrors .db-header)
 *
 * Row 1: header-left (eyebrow + title) | spacer | header-right (pill + updated)
 * Row 2: subtext (flex-basis: 100% so it wraps to its own line at full width)
 *
 * align-self: flex-end on header-right matches dashboards.js -- pulls the
 * snapshot pill to the bottom of row 1, baseline-aligned with the title.
 * --------------------------------------------------------------------- */
.project-state-header {
  padding: 20px 28px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-shrink: 0;
  flex-wrap: wrap;
  margin: 0;
}

.project-state-header-left {
  flex-shrink: 1;
  min-width: 0;
  max-width: 720px;
}

.project-state-eyebrow {
  font-family: 'Francois One', sans-serif;
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--red);
  text-transform: uppercase;
  margin: 0;
  line-height: 1.2;
}

.project-state-title {
  font-family: 'Francois One', sans-serif;
  font-size: 28px;
  line-height: 1.05;
  color: var(--ink-1);
  text-transform: uppercase;
  letter-spacing: -0.012em;
  margin: 4px 0 0;
  font-weight: 400;
}

.project-state-subtext {
  flex-basis: 100%;
  font-family: Manrope, sans-serif;
  font-size: 13px;
  color: var(--ink-2);
  margin: 8px 0 0;
  line-height: 1.5;
  max-width: 760px;
}

.project-state-header-spacer { flex: 1; }

.project-state-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: flex-end;
  padding-bottom: 4px;
}

.project-state-snapshot-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--teal);
  color: var(--teal);
  font-family: Manrope, sans-serif;
  font-size: 11.5px;
  font-weight: 600;
}

.project-state-snapshot-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
  flex-shrink: 0;
}

.project-state-updated {
  font-family: Manrope, sans-serif;
  font-size: 12px;
  color: var(--ink-3);
}

/* -------------------------------------------------------------------------
 * Body (scrollable)
 * --------------------------------------------------------------------- */
.project-state-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 28px 32px;
  background: var(--surface-2);
}

.sop-loading {
  color: var(--ink-3);
  font-size: 13px;
  font-family: Manrope, sans-serif;
}

/* -------------------------------------------------------------------------
 * Article + section grid
 * --------------------------------------------------------------------- */
.project-state-article {
  width: 100%;
  font-family: Manrope, sans-serif;
  color: var(--ink-2);
}

.project-state-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 1180px) {
  .project-state-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  /* Lede and the lead Summary card span both columns so the page reads
   * top-down before splitting into the dual-column flow. */
  .project-state-lede,
  .project-state-grid > .project-state-section:first-of-type {
    grid-column: 1 / -1;
  }
}

/* -------------------------------------------------------------------------
 * Lede block (everything before the first H2 in the source markdown)
 * --------------------------------------------------------------------- */
.project-state-lede {
  position: relative;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 18px 20px 16px;
  overflow: hidden;
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}

/* 3px brand-colored top stripe -- mirrors .db-card-stripe so every card on
 * the Project surface carries the same teal/red/coral/navy brand wash as
 * persona cards on the Data view. */
.project-state-lede::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--teal);
  z-index: 1;
}

.project-state-lede:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-pop);
  transform: translateY(-2px);
}

/* The source markdown opens with `# State of the Project` which the page
 * header already displays. Suppress the duplicate H1 inside the lede. */
.project-state-lede h1 { display: none; }

.project-state-lede > p {
  font-family: Manrope, sans-serif;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
  margin: 0 0 10px;
}

.project-state-lede > p:last-child { margin-bottom: 0; }

.project-state-lede > p > strong {
  color: var(--red);
  font-weight: 700;
}

.project-state-lede > hr { display: none; }

.project-state-lede > blockquote {
  margin: 14px 0 0;
  padding: 12px 14px;
  background: var(--teal-soft);
  border-left: 3px solid var(--teal);
  border-radius: 0 8px 8px 0;
  color: var(--ink-2);
  font-family: Manrope, sans-serif;
  font-size: 13px;
  line-height: 1.55;
}
.project-state-lede > blockquote p { margin: 0 0 6px; }
.project-state-lede > blockquote p:last-child { margin-bottom: 0; }
.project-state-lede > blockquote strong { color: var(--teal); font-weight: 700; }

/* -------------------------------------------------------------------------
 * Collapsible H2 section card (mirrors .db-card visual treatment)
 *
 * Each card wears a 3px brand-colored top stripe (teal / red / coral / navy)
 * driven by data-accent set in nav-links.js. Mirrors the persona-colored
 * .db-card-stripe pattern on the Data view, so the Project surface carries
 * the same sustained brand wash as cards on Dashboards.
 * --------------------------------------------------------------------- */
.project-state-section {
  --accent: var(--teal);
  position: relative;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin: 0;
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}

.project-state-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  z-index: 2;
}

.project-state-section[data-accent="teal"]  { --accent: var(--teal); }
.project-state-section[data-accent="red"]   { --accent: var(--red); }
.project-state-section[data-accent="coral"] { --accent: var(--coral); }
.project-state-section[data-accent="navy"]  { --accent: var(--navy); }

.project-state-section:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-pop);
  transform: translateY(-2px);
}

.project-state-section[open] {
  box-shadow: var(--shadow-pop);
}
.project-state-section[open]:hover {
  transform: translateY(-2px);
}

/* Header (summary) -- styled to mirror .db-section-head spacing/typography.
 *
 * align-items: center keeps mixed-height items (chevron 11, num 14, title 22,
 * chip pill 18) visually centered as a row rather than baseline-aligning a
 * 22px title against an 11px glyph.
 *
 * Padding 16/12 (top/bottom) optically centers the title within the card:
 *   - Francois One has a high ascender, so caps occupy the upper portion of
 *     the line box (cap-center sits ~3px above line-box-center).
 *   - The 3px brand stripe at the top adds visual weight above the content.
 *   - Together, padding-top needs to be ~4px heavier than padding-bottom to
 *     bring the cap-center onto the card's perceived visual midline. */
.project-state-section__header {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 12px;
  user-select: none;
  transition: background .12s ease;
}
.project-state-section__header::-webkit-details-marker { display: none; }
.project-state-section__header:hover { background: var(--hover); }

.project-state-section__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1;
  transition: transform .15s ease;
  flex-shrink: 0;
}
.project-state-section[open] > .project-state-section__header > .project-state-section__chevron {
  transform: rotate(90deg);
}

/* Brand-colored numeric prefix lifted from .db-section-num. The leading
 * "N." in the source H2 (e.g. "## 5. System state") is parsed out by
 * nav-links.js and rendered in its own span. Inherits the section accent
 * color so the number visually anchors to the top stripe. */
.project-state-section__num {
  font-family: 'Francois One', sans-serif;
  font-size: 14px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0;
  flex-shrink: 0;
  line-height: 1;
}

.project-state-section__title {
  flex: 1;
  min-width: 0;
  font-family: 'Francois One', sans-serif;
  font-size: 22px;
  color: var(--ink-1);
  text-transform: uppercase;
  letter-spacing: -0.005em;
  line-height: 1;
  font-weight: 400;
}

/* Chip wears the section's brand color so every card carries a colored
 * status hint -- the dense brand wash the Data view gets from per-card
 * persona avatars. */
.project-state-section__chip {
  flex-shrink: 0;
  font-family: Manrope, sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  padding: 3px 10px;
  background: var(--surface-1);
  color: var(--ink-2);
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.project-state-section[data-accent="teal"]  .project-state-section__chip {
  background: var(--teal-soft);
  color: var(--teal);
  border-color: var(--teal-soft);
}
.project-state-section[data-accent="red"]   .project-state-section__chip {
  background: rgba(159, 10, 55, .12);
  color: var(--red);
  border-color: rgba(159, 10, 55, .25);
}
.project-state-section[data-accent="coral"] .project-state-section__chip {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: var(--coral-soft);
}
.project-state-section[data-accent="navy"]  .project-state-section__chip {
  background: rgba(40, 48, 68, .10);
  color: var(--navy);
  border-color: rgba(40, 48, 68, .20);
}

/* Body -- 20px horizontal matches summary; 14px top is tight against the
 * separator border, 18px bottom matches the .db-card-body rhythm. */
.project-state-section__body {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--separator);
  color: var(--ink-2);
  font-family: Manrope, sans-serif;
  font-size: 14px;
  line-height: 1.65;
}

/* -------------------------------------------------------------------------
 * Body content typography
 *
 * Tightened type scale across the page: 28 / 22 / 14 / 13 / 12 / 11 / 10.5.
 * H3 maps to the .db-stat-label / .db-card-persona-label Francois One
 * uppercase tier (12px) -- the same label rhythm Dashboards uses for
 * sub-section heads inside cards.
 * --------------------------------------------------------------------- */
.project-state-section__body h3 {
  font-family: 'Francois One', sans-serif;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 16px 0 6px;
  padding: 0;
  border: none;
  font-weight: 400;
  line-height: 1.25;
}
.project-state-section__body > *:first-child { margin-top: 0; }
.project-state-section__body > *:last-child  { margin-bottom: 0; }

.project-state-section__body h4 {
  font-family: 'Francois One', sans-serif;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 14px 0 4px;
  font-weight: 400;
  line-height: 1.25;
}

.project-state-section__body p {
  margin: 0 0 10px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.65;
}
.project-state-section__body p:last-child { margin-bottom: 0; }

.project-state-section__body ul,
.project-state-section__body ol {
  margin: 4px 0 12px;
  padding-left: 22px;
}

.project-state-section__body li {
  margin-bottom: 5px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.55;
}

.project-state-section__body strong { color: var(--ink-1); font-weight: 700; }
.project-state-section__body em { color: var(--ink-2); font-style: italic; }

.project-state-section__body a {
  color: var(--teal);
  text-decoration: none;
}
.project-state-section__body a:hover {
  text-decoration: underline;
  color: var(--ink-1);
}

.project-state-section__body code {
  background: var(--surface-1);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.88em;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--teal);
  border: 1px solid var(--border);
}

.project-state-section__body pre {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 12px;
  line-height: 1.5;
}
.project-state-section__body pre code {
  background: none;
  padding: 0;
  border: none;
  border-radius: 0;
  color: var(--ink-2);
}

/* Tables -- matched to dashboards db- card visual weight */
.project-state-section__body table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
  margin: 10px 0;
  font-family: Manrope, sans-serif;
}
.project-state-section__body th {
  border-bottom: 1px solid var(--separator);
  padding: 8px 10px;
  text-align: left;
  background: transparent;
  font-family: 'Francois One', sans-serif;
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
.project-state-section__body td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  color: var(--ink-2);
  vertical-align: top;
  line-height: 1.55;
  font-size: 13px;
}
.project-state-section__body tr:last-child td { border-bottom: none; }
.project-state-section__body tr:nth-child(even) td { background: var(--surface-2); }

.project-state-section__body hr {
  border: none;
  border-top: 1px solid var(--separator);
  margin: 14px 0;
}

.project-state-section__body blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--separator);
  color: var(--ink-3);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}
.project-state-section__body blockquote p { margin: 0 0 4px; }
.project-state-section__body blockquote p:last-child { margin-bottom: 0; }

/* -------------------------------------------------------------------------
 * Legacy fallback: flat single-article render (only used if
 * _buildCollapsibleSections throws). Mirrors the styled section bodies so
 * the visual language stays consistent in the failure case.
 * --------------------------------------------------------------------- */
.project-state-article > h1 {
  font-family: 'Francois One', sans-serif;
  font-size: 24px;
  color: var(--ink-1);
  text-transform: uppercase;
  letter-spacing: -0.012em;
  margin: 0 0 12px;
  font-weight: 400;
  line-height: 1.05;
}
.project-state-article > h2 {
  font-family: 'Francois One', sans-serif;
  font-size: 20px;
  color: var(--ink-1);
  text-transform: uppercase;
  letter-spacing: -0.005em;
  margin: 22px 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}
.project-state-article > h3 {
  font-family: 'Francois One', sans-serif;
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-1);
  margin: 16px 0 4px;
  font-weight: 400;
}

/* -------------------------------------------------------------------------
 * Responsive: narrow viewports (mirror dashboards.css)
 * --------------------------------------------------------------------- */
@media (max-width: 640px) {
  .project-state-header { padding: 16px 16px 14px; }
  .project-state-body   { padding: 18px 16px 24px; }
  .project-state-title  { font-size: 22px; }
  .project-state-header-right { align-self: flex-start; padding-bottom: 0; }
  .project-state-lede            { padding: 16px 16px 14px; }
  .project-state-section__header { padding: 16px 16px 12px; }
  .project-state-section__body   { padding: 14px 16px 16px; }
}

/* -------------------------------------------------------------------------
 * Dark mode tweaks
 * --------------------------------------------------------------------- */
html[data-theme="dark"] .project-state-section__header:hover {
  background: var(--hover-strong);
}
html[data-theme="dark"] .project-state-section__body tr:nth-child(even) td {
  background: var(--surface-1);
}
