/* ════════════════════════════════════════════════════════
   CORVUS — Page Layout Patterns
   List items, Work items (action / task), Nav stat tiles,
   Portfolio grid, Work matrix, Responsive grid presets, Container

   References SEMANTIC tokens from corvus-tokens.css only.
   Variants follow: danger / warning / success / info / neutral.
   ════════════════════════════════════════════════════════ */

/* ── List items (generic, horizontal) ────────────────── */

.cv-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--cv-color-border);
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}

.cv-list-item:last-child { border-bottom: none; }
.cv-list-item:hover      { background: var(--cv-color-bg-alt); }

.cv-item-body {
  flex: 1;
  min-width: 0;
}

.cv-item-title {
  font-weight: 600;
  font-size: .875rem;
  color: var(--cv-color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv-item-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: .75rem;
  color: var(--cv-color-text-muted);
  margin-top: .25rem;
  align-items: center;
}

.cv-item-status {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.cv-list-item-icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--cv-radius-md);
  border: 1.5px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
}

/* Semantic icon colour utilities — used on .cv-list-item-icon and elsewhere */
.cv-icon-danger  { color: var(--cv-color-danger); }
.cv-icon-warning { color: var(--cv-color-warning); }
.cv-icon-success { color: var(--cv-color-success); }
.cv-icon-info    { color: var(--cv-color-info); }
.cv-icon-neutral { color: var(--cv-color-text-muted); }

/* Simple list item — personal tasks, no semantic icon */
.cv-simple-list-item {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--cv-color-border);
  text-decoration: none;
  color: inherit;
  transition: background .1s;
}

.cv-simple-list-item:last-child { border-bottom: none; }
.cv-simple-list-item:hover      { background: var(--cv-color-bg-alt); }

/* ── Work item — action / task list row ──────────────── */
/* Used inside the work_item_list.html widget. Vertical layout: title above
   metadata row. 3px left border reserved for state indicator. The list
   container uses a 3px gap so adjacent state bars don't merge.
   Variants follow the semantic vocabulary — danger / warning. */

.cv-work-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cv-work-item {
  display: block;
  padding: .75rem .875rem;
  border-left: 3px solid transparent;
  text-decoration: none;
  color: inherit;
  transition: background-color .12s;
}

.cv-work-item:hover { background: var(--cv-color-bg-alt); }

.cv-work-item-danger  { border-left-color: var(--cv-color-danger); }
.cv-work-item-warning { border-left-color: var(--cv-color-warning); }

.cv-work-item-title {
  font-size: .84rem;
  font-weight: 500;
  color: var(--cv-color-text);
  line-height: 1.4;
  margin-bottom: .375rem;
}

.cv-work-item:hover .cv-work-item-title { color: var(--cv-navy); }

.cv-work-meta {
  display: flex;
  gap: .875rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: .72rem;
  color: var(--cv-color-text-muted);
}

.cv-work-meta-item {
  display: inline-flex;
  gap: .3125rem;
  align-items: center;
  white-space: nowrap;
  line-height: 1;
}

.cv-work-meta-item .icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: .65;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cv-work-meta-item .icon svg { width: 100%; height: 100%; }

.cv-work-meta-item .value { font-variant-numeric: tabular-nums; }

/* Due date — only the icon takes the status colour; text stays muted.
   Three states per the locked colour vocabulary:
     due-ok    → blue   (future date, active / on-track)
     due-soon  → amber  (within 7 days)
     overdue   → red    (past due — failed to meet deadline)
   See feedback-color-vocabulary-final in memory. */
.cv-work-meta-item.due-date .icon.due-ok   { color: var(--cv-color-primary); opacity: .85; }
.cv-work-meta-item.due-date .icon.due-soon { color: var(--cv-color-warning); opacity: .9; }
.cv-work-meta-item.due-date .icon.overdue  { color: var(--cv-color-danger);  opacity: .9; }

/* Engagement / assignee — truncate long names */
.cv-work-meta-item.engagement .value,
.cv-work-meta-item.assignee   .value {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
}

/* ── Links (navigation, not actions) ─────────────────── */
/* For inline / standalone links. Actions use .cv-btn (corvus-components.css). */

.cv-link {
  color: var(--cv-color-text-link);
  text-decoration: none;
  transition: color .12s;
}

.cv-link:hover { color: var(--cv-color-text-link-hover); text-decoration: underline; }

/* Standalone link with arrow (e.g. "View all →") */
.cv-link-standalone {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .78rem;
  font-weight: 500;
  color: var(--cv-color-text-link);
  text-decoration: none;
}

.cv-link-standalone:hover { color: var(--cv-color-text-link-hover); }

/* Primary navigation link — sidebar / top bar */
.cv-nav-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .875rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--cv-color-text-muted);
  text-decoration: none;
  border-radius: var(--cv-radius-md);
  transition: background .12s, color .12s;
}

.cv-nav-link:hover  { background: var(--cv-color-bg-alt); color: var(--cv-color-text); }
.cv-nav-link.active { color: var(--cv-color-primary); }

/* ── Nav stat tiles (dashboard top row) ──────────────── */

.cv-nav-tile-stat {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-lg);
  padding: .75rem 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, border-color .15s;
}

.cv-nav-tile-stat:hover {
  border-color: var(--cv-color-border-strong);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.cv-nav-tile-icon   { font-size: 1.1rem; color: var(--cv-color-text-muted); }

.cv-nav-tile-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  color: var(--cv-color-text-muted);
}

.cv-nav-tile-number {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--cv-color-text);
  line-height: 1.2;
}

/* ── Portfolio grid & client tiles ───────────────────── */

.cv-portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.cv-client-tile {
  background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--cv-shadow);
  transition: box-shadow .2s ease, border-color .15s;
}

.cv-client-tile:hover {
  border-color: var(--cv-color-border-strong);
  box-shadow: var(--cv-shadow-md);
}

.cv-tile-header      { margin-bottom: 1rem; }
.cv-tile-title       { font-size: .8125rem; font-weight: 500; color: var(--cv-color-text); }
.cv-tile-engagement  { font-size: .6875rem; color: var(--cv-color-text-muted); }

.cv-tile-row {
  display: grid;
  grid-template-columns: 80px 1fr 1fr;
  gap: 1.25rem;
  align-items: center;
}

.cv-donut {
  width: 70px;
  height: 70px;
  position: relative;
}

.cv-donut svg { display: block; }

.cv-donut-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  pointer-events: none;
}

.cv-donut-pct  { font-size: 1rem; font-weight: 600; line-height: 1; }
.cv-donut-text { font-size: .5625rem; color: var(--cv-color-text-muted); margin-top: 2px; }

.cv-audit-label {
  font-size: .625rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--cv-color-text-muted);
  margin-bottom: 4px;
}

.cv-audit-date { font-size: .875rem; font-weight: 500; color: var(--cv-color-text); }

.cv-sparkline {
  height: 40px;
  background: var(--cv-color-bg-alt);
  border-radius: var(--cv-radius-md);
  padding: 4px;
}

.cv-tile-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--cv-color-border);
}

.cv-summary-item  { text-align: center; }

.cv-summary-label {
  font-size: .625rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--cv-color-text-muted);
  margin-bottom: 4px;
}

.cv-summary-value { font-size: 1rem; font-weight: 600; color: var(--cv-color-text); }

.cv-tile-readiness {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--cv-color-border);
}

.cv-tile-frameworks {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--cv-color-border);
  display: flex;
  flex-direction: column;
  gap: .375rem;
}

.cv-fw-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .625rem;
  margin-bottom: 3px;
  color: var(--cv-color-text-muted);
}

.cv-fw-pct { font-weight: 600; flex-shrink: 0; margin-left: .5rem; }

/* ── Work matrix (2-column grid) ─────────────────────── */

.cv-matrix {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .cv-matrix { grid-template-columns: 1fr; }
}

.cv-quadrant-title {
  font-size: .75rem;
  font-weight: 600;
  color: var(--cv-color-text);
  margin-bottom: .75rem;
  padding: 8px 12px;
  background: var(--cv-color-bg-alt);
  border-radius: var(--cv-radius-md);
  border-left: 3px solid var(--cv-color-border-strong);
}

.cv-matrix-card {
  background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-lg);
  overflow: hidden;
  box-shadow: var(--cv-shadow);
}

.cv-matrix-card-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--cv-color-border);
  font-size: .6875rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--cv-color-text-muted);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cv-matrix-card-count { font-size: .6875rem; font-weight: 400; text-transform: none; }

.cv-matrix-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--cv-color-border);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
}

.cv-matrix-item:last-child { border-bottom: none; }
.cv-matrix-item:hover      { background: var(--cv-color-bg-alt); }

.cv-item-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--cv-radius-md);
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .875rem;
  font-weight: 600;
  flex-shrink: 0;
  line-height: 1;
}

/* Semantic icon variants — replaces .cv-item-icon.red/.amber/.blue/.green */
.cv-item-icon-danger  { border-color: var(--cv-color-danger);  color: var(--cv-color-danger); }
.cv-item-icon-warning { border-color: var(--cv-color-warning); color: var(--cv-color-warning); }
.cv-item-icon-info    { border-color: var(--cv-color-info);    color: var(--cv-color-info); }
.cv-item-icon-success { border-color: var(--cv-color-success); color: var(--cv-color-success); }

.cv-item-content { flex: 1; min-width: 0; }

/* ── Responsive grid presets ─────────────────────────── */

.cv-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); }
.cv-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.cv-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); }
.cv-gap-lg { gap: 1.25rem; }

@media (max-width: 1024px) {
  .cv-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .cv-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .cv-grid-4,
  .cv-grid-3,
  .cv-grid-2 { grid-template-columns: 1fr; }
}

/* ── Container & page wrapper ────────────────────────── */

.cv-container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.cv-page {
  padding: 1.75rem 0 3rem;
}

/* ════════════════════════════════════════════════════════
   PAGE SHELL — top bar + collapsible sidebar + main area

   Grid layout:
       ┌──────────────────────────────────────┐
       │ TOPBAR  (fixed, 56px)                │
       ├──────────┬───────────────────────────┤
       │ SIDEBAR  │ MAIN  (scrollable)        │
       │ 16rem    │                           │
       │   ↕      │                           │
       │ 3.5rem   │                           │
       └──────────┴───────────────────────────┘

   Markup:
       <div class="cv-shell">
         <header class="cv-topbar">…</header>
         <aside class="cv-sidebar">…</aside>
         <main class="cv-main">…</main>
       </div>

   Mobile / responsive behaviour (drawer + burger) is deferred — TBD.
   ════════════════════════════════════════════════════════ */

.cv-shell {
  display: grid;
  grid-template-rows: 3.5rem 1fr;
  grid-template-columns: 16rem 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
  background: var(--cv-color-bg);
}

.cv-shell.cv-sidebar-collapsed {
  grid-template-columns: 3.5rem 1fr;
}

/* ── Top bar ─────────────────────────────────────────── */

.cv-topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: var(--cv-color-bg-card);
  border-bottom: 1px solid var(--cv-color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.cv-topbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.05rem;
  color: var(--cv-color-text);
  text-decoration: none;
  letter-spacing: -.01em;
  /* Width matches expanded sidebar so brand aligns with sidebar edge */
  min-width: calc(16rem - 1.25rem);
}

.cv-shell.cv-sidebar-collapsed .cv-topbar-brand {
  min-width: calc(3.5rem - 1.25rem);
}

.cv-topbar-brand-mark {
  color: var(--cv-color-primary);
  font-size: 1.2rem;
}

.cv-topbar-context {
  /* The breadcrumb area or page-context line */
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.cv-topbar-actions {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-shrink: 0;
}

/* User-menu trigger — person icon + name. NOT an avatar circle. */
.cv-topbar-user {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem .625rem;
  border-radius: var(--cv-radius-md);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--cv-color-text);
  font-size: .85rem;
  font-weight: 500;
  font-family: inherit;
  transition: background .12s;
}

.cv-topbar-user:hover {
  background: var(--cv-color-bg-alt);
}

.cv-topbar-user i.bi-person {
  font-size: 1rem;
  color: var(--cv-color-text-muted);
}

.cv-topbar-user i.bi-chevron-down {
  font-size: .7rem;
  color: var(--cv-color-text-muted);
  margin-left: .15rem;
}

/* ── Sidebar ─────────────────────────────────────────── */

.cv-sidebar {
  grid-area: sidebar;
  background: var(--cv-color-bg-card);
  border-right: 1px solid var(--cv-color-border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .2s ease;
  display: flex;
  flex-direction: column;
  padding: .75rem 0;
}

.cv-sidebar-section {
  padding: .25rem .5rem;
  margin-bottom: .25rem;
}

.cv-sidebar-section-label {
  display: block;
  padding: .5rem .75rem .375rem;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cv-color-text-muted);
}

.cv-shell.cv-sidebar-collapsed .cv-sidebar-section-label {
  /* Hide section labels when collapsed — section breaks are implied by spacing */
  visibility: hidden;
  height: .5rem;
  padding: 0;
}

/* Sidebar link — extends the .cv-nav-link concept with sidebar-specific
   sizing and an active-state left border. */
.cv-sidebar-link {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem .75rem;
  margin: 1px 0;
  border-left: 3px solid transparent;
  border-radius: 0 var(--cv-radius-md) var(--cv-radius-md) 0;
  color: var(--cv-color-text-muted);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
  overflow: hidden;
}

.cv-sidebar-link:hover {
  background: var(--cv-color-bg-alt);
  color: var(--cv-color-text);
}

.cv-sidebar-link.active {
  background: var(--cv-color-primary-soft);
  border-left-color: var(--cv-navy);
  color: var(--cv-color-text);
  font-weight: 600;
}

.cv-sidebar-link i {
  font-size: 1rem;
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
  color: var(--cv-color-text-muted);
}

.cv-sidebar-link:hover i,
.cv-sidebar-link.active i {
  color: var(--cv-color-text);
}

/* Inline count badge inside sidebar link */
.cv-sidebar-link-count {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.125rem;
  padding: 0 .35rem;
  border-radius: var(--cv-radius-full);
  background: var(--cv-color-bg-alt);
  color: var(--cv-color-text-muted);
  font-size: .65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.cv-sidebar-link.active .cv-sidebar-link-count {
  background: var(--cv-navy);
  color: var(--cv-text-on-dark);
}

/* ── Workflow step states (for in-flow wizards) ──────── */
/* A workflow section in the sidebar represents the steps of a multi-step
   flow. Each step is one of three states:
     - .cv-sidebar-link-done    completed; muted text + success check icon; still clickable
     - .cv-sidebar-link.active  current step (reuses base .active styling)
     - .cv-sidebar-link-pending not yet reached; muted, low-opacity, not clickable */

.cv-sidebar-link-done {
  color: var(--cv-color-text-muted);
}

.cv-sidebar-link-done i {
  color: var(--cv-color-success);
}

.cv-sidebar-link-pending {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.cv-sidebar-link-pending i {
  color: var(--cv-color-text-muted);
}

/* Tight, low-emphasis dot for the current step's icon */
.cv-sidebar-link.active .cv-sidebar-link-step-dot {
  font-size: .55rem;
}

/* When collapsed — hide labels and counts, show icon only */
.cv-shell.cv-sidebar-collapsed .cv-sidebar-link-label,
.cv-shell.cv-sidebar-collapsed .cv-sidebar-link-count {
  display: none;
}

.cv-shell.cv-sidebar-collapsed .cv-sidebar-link {
  justify-content: center;
  padding: .55rem .25rem;
}

/* Collapse toggle button at the bottom of the sidebar */
.cv-sidebar-toggle {
  margin-top: auto;
  border-top: 1px solid var(--cv-color-border);
  padding: .5rem;
  display: flex;
  justify-content: flex-end;
}

.cv-shell.cv-sidebar-collapsed .cv-sidebar-toggle {
  justify-content: center;
}

/* ── Main content area ──────────────────────────────── */

.cv-main {
  grid-area: main;
  overflow-y: auto;
  padding: 1.5rem 2rem 3rem;
  min-width: 0;                /* allow children to shrink within the grid track */
}

/* Page header inside .cv-main — pairs with breadcrumbs in topbar */
.cv-main-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--cv-color-border);
}

.cv-main-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.6rem;
  letter-spacing: -.02em;
  line-height: 1.2;
  color: var(--cv-color-text);
  margin: 0 0 .25rem;
}

.cv-main-subtitle {
  font-size: .85rem;
  color: var(--cv-color-text-muted);
}

.cv-main-header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
