/* =============================================================================
   v2-primitives.css — DA FRONT-END REVAMP, Phase 0: Substrate
   -----------------------------------------------------------------------------
   Additive-only file. Nothing in v2-components.css or site.css is edited by
   this file, and no existing view references any class defined here yet — so
   shipping this file changes ZERO existing rendered behavior. It exists so
   Phase 1+ has a documented primitive to assemble screens from instead of
   inventing a bespoke layout per screen (research/03 principle 4).

   Formalizes the token grammar gaps named in
   docs/da-frontend-revamp/research/03-da-redesign-proposal.md §1.3:
     - the raw 9-step spacing scale underneath the existing semantic aliases
     - --content-max-w / --prose-max-w container tokens
   ...plus the primitive anatomies §3 names for Phase 0 (Substrate):
     - skeleton/shimmer, empty state, error state (A9), stepper (A7),
       timeline (A5), list row (A4), content card (A1/A3).

   PALETTE IS LOCKED (PO ruling, INDEX.md §5.2): every color reference below
   resolves to an EXISTING token already defined in site.css. Zero new hex.
   ============================================================================= */

:root {
    /* -------------------------------------------------------------------
       Raw spacing scale (research/03 §1.3 — DAPS's 9-step scale, adopted
       verbatim). The existing semantic aliases (--card-padding,
       --section-gap, --page-padding-x/y in site.css) stay as-is and now
       have a documented raw scale underneath them for any NEW substrate.
       ------------------------------------------------------------------- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* -------------------------------------------------------------------
       Container widths (research/03 §1.3).
       ------------------------------------------------------------------- */
    --content-max-w: 1280px;
    --prose-max-w: 640px; /* DA-specific: contract/legal/duty copy column */
}

/* =============================================================================
   1. .v2-skeleton — the ONE shimmer primitive (DAPS pattern, adopted verbatim).
      Sized via --sk-w / --sk-h / --sk-r so any content shape (card thumbnail,
      text line, avatar circle, list row) reuses the identical shimmer.
      Killed outright under prefers-reduced-motion, not just slowed.
   ============================================================================= */
.v2-skeleton {
    display: block;
    width: var(--sk-w, 100%);
    height: var(--sk-h, 16px);
    border-radius: var(--sk-r, 8px);
    background: linear-gradient(90deg, var(--bg-secondary) 0%, var(--bg-tertiary) 50%, var(--bg-secondary) 100%);
    background-size: 800px 100%;
    animation: v2-shimmer 1.4s infinite linear;
}

@keyframes v2-shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

@media (prefers-reduced-motion: reduce) {
    .v2-skeleton {
        animation: none;
        background: var(--bg-tertiary);
    }
}

/* A stack of skeleton rows/cards, matched to the real grid it will resolve
   to (per research/03 A1/A3: "N cards' worth of shimmer... never a spinner
   in empty space"). */
.v2-skeleton-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.v2-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-5);
}

/* =============================================================================
   2. .v2-empty-state — icon-badge + title + description + one action.
      Distinct name from the legacy `.empty-state` (site.css) so this file
      never changes an existing view's rendering; adopters opt in explicitly.
   ============================================================================= */
.v2-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-3);
    padding: var(--space-12) var(--space-4);
}

.v2-empty-state-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    font-size: 24px;
}

.v2-empty-state-title {
    margin: 0;
    color: var(--text-primary);
}

.v2-empty-state-description {
    margin: 0;
    max-width: 320px;
    color: var(--text-muted);
}

/* =============================================================================
   3. .v2-error-state — Archetype A9, full-screen branded edge state.
      Centered icon, plain-language message, muted explanation, one primary
      path forward (never a dead end), optional secondary action.
   ============================================================================= */
.v2-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-4);
    padding: var(--space-12) var(--space-4);
    max-width: 480px;
    margin: 0 auto;
}

.v2-error-state-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    font-size: 28px;
}

.v2-error-state.v2-error-state--error .v2-error-state-icon {
    color: var(--error);
}

.v2-error-state-title {
    margin: 0;
    color: var(--text-primary);
}

.v2-error-state-description {
    margin: 0;
    max-width: 400px;
    color: var(--text-muted);
}

.v2-error-state-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-2);
}

/* =============================================================================
   4. .v2-stepper — Archetype A7 progress chrome. "Step N of M" + dots, one
      concern per step never rendered by this file (that's the screen's job).
   ============================================================================= */
.v2-stepper {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--section-gap);
}

.v2-stepper-dots {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.v2-stepper-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.v2-stepper-dot.v2-stepper-dot--done {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.v2-stepper-dot.v2-stepper-dot--current {
    background: transparent;
    border: 2px solid var(--accent-primary);
    width: 12px;
    height: 12px;
}

.v2-stepper-label {
    /* mirrors .v2-h3 */
    color: var(--text-primary);
    font-weight: 600;
}

.v2-stepper-count {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* =============================================================================
   5. .v2-timeline — Archetype A5 horizontal state-machine timeline.
      Node = filled (done) / ringed (current) / hollow (upcoming). Phase keys
      and labels are always server-supplied (ContractStatusSummaryService) —
      this file only renders the state class it is given, never derives one.
   ============================================================================= */
.v2-timeline {
    display: flex;
    align-items: flex-start;
    width: 100%;
    overflow-x: auto;
}

.v2-timeline-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 0;
    min-width: 72px;
    gap: var(--space-2);
    text-align: center;
    position: relative;
}

.v2-timeline-node {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-subtle);
    flex-shrink: 0;
    z-index: 1;
}

.v2-timeline-phase--done .v2-timeline-node {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.v2-timeline-phase--current .v2-timeline-node {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 25%, transparent);
}

.v2-timeline-connector {
    position: absolute;
    top: 9px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--border-subtle);
    z-index: 0;
}

.v2-timeline-phase:first-child .v2-timeline-connector {
    display: none;
}

.v2-timeline-phase--done .v2-timeline-connector,
.v2-timeline-phase--current .v2-timeline-connector {
    background: var(--accent-primary);
}

.v2-timeline-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.v2-timeline-phase--current .v2-timeline-label {
    color: var(--text-primary);
    font-weight: 600;
}

/* =============================================================================
   6. .v2-list-row — Archetype A4 row anatomy (review-one, act). Leading
      icon/avatar, title + one metadata line, trailing StatusPill/actions.
      Never a thumbnail grid — that's .v2-content-card's job (§7).
   ============================================================================= */
.v2-list-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--card-radius);
}

.v2-list-row-leading {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.v2-list-row-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.v2-list-row-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.v2-list-row-meta {
    color: var(--text-muted);
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.v2-list-row-trailing {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* =============================================================================
   7. .v2-content-card — Archetype A1/A3 "scan many" card anatomy: fixed-
      aspect thumbnail-or-icon, StatusPill overlay (top-right), 2-line-clamp
      title, one muted meta line, optional teal progress sliver. One shape,
      reused everywhere it appears (contract card, venture card, media card).
   ============================================================================= */
.v2-content-card {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--card-radius);
    overflow: hidden;
}

a.v2-content-card {
    text-decoration: none;
}

.v2-content-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.v2-content-card-media {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-size: 28px;
}

.v2-content-card-media--wide {
    aspect-ratio: 16 / 9;
}

.v2-content-card-status {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
}

.v2-content-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: var(--space-4);
}

.v2-content-card-title {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.9375rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.v2-content-card-meta {
    color: var(--text-muted);
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.v2-content-card-progress {
    height: 3px;
    border-radius: 2px;
    background: var(--bg-tertiary);
    margin-top: 4px;
    overflow: hidden;
}

/* -----------------------------------------------------------------------------
   8. .token-meter — the invitation token dot-meter (DA Front-End Revamp
      Phase 3, research/03 §4.6/§6.B). Renders InvitationTokenMeterResponse
      verbatim: dots filled = TokensUnlocked of TotalTokenSlots; the label
      line echoes the server's NextUnlockMilestoneLabel/Summary/AtUtc, never
      re-deriving milestone meaning. Zero new colors.
   --------------------------------------------------------------------------- */
.token-meter {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.token-meter-dots {
    display: flex;
    gap: var(--space-1);
}

.token-meter-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-subtle);
}

.token-meter-dot--filled {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.token-meter-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.token-meter-muted {
    color: var(--text-muted);
}

.v2-content-card-progress-fill {
    height: 100%;
    background: var(--accent-primary);
}

/* =============================================================================
   9. .v2-wizard-* — Persistent-summary wizard layout (Archetype A7 extension,
      research/03 §4.4). Extracted from Contract/CreateUnified.cshtml's
      bespoke <style> block during the Phase 5 flagship re-skin (DA Front-End
      Revamp) — this is the ONE screen that used it at extraction time, but
      the shape (two-column content + sticky split-summary rail, collapsing
      to a bottom-sheet handle under 900px) is generic to any future guided
      stepper with a persistent running-total panel, so it lives here
      alongside the other numbered primitives rather than in a page-specific
      stylesheet. Token-only; zero new colors. Selector names are UNCHANGED
      from the original inline block — the page's JS (step navigation,
      split-summary mirroring, bottom-sheet expand/collapse) references every
      one of these by class/id and was re-verified against this exact CSS.
   ============================================================================= */
.v2-wizard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: var(--space-6, 24px);
    align-items: start;
}

.v2-wizard-content {
    min-width: 0;
    max-width: var(--prose-max-w, 640px);
}

/* Only the current step is shown; JS toggles this class. Steps 2-5 start
   hidden so the very first paint is Step 1 only (no reflow/flash). */
.v2-wizard-step {
    display: none;
}

.v2-wizard-step.v2-wizard-step--active {
    display: block;
}

.v2-wizard-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem 0;
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-subtle);
    z-index: 5;
}

/* Persistent split summary — desktop: sticky right rail (visible from
   Step 1 onward, per research/03 §4.4 "the number is never a surprise
   at the end"). Mobile: collapses to a bottom-sheet handle (below). */
.v2-wizard-summary {
    position: sticky;
    top: var(--space-6, 24px);
    align-self: start;
}

.v2-wizard-summary-inner {
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--card-radius, 14px);
    padding: var(--space-5, 20px);
}

.v2-wizard-summary-handle {
    display: none;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-weight: 600;
    padding: 0;
    cursor: pointer;
}

.v2-wizard-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
}

.v2-wizard-summary-row:last-of-type {
    border-bottom: none;
}

.v2-wizard-summary-row.muted {
    color: var(--text-muted);
}

.v2-wizard-summary-row.total {
    font-weight: 700;
    font-size: 1rem;
    border-top: 2px solid var(--border-subtle);
    margin-top: 0.35rem;
    padding-top: 0.6rem;
}

.v2-wizard-summary-progress {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    margin: 0.75rem 0;
    overflow: hidden;
}

.v2-wizard-summary-progress-fill {
    height: 100%;
    background: var(--accent-primary);
}

/* Mobile: summary becomes a persistent bottom-sheet handle
   ("NN% allocated ▲"), matching research/03's mobile pattern —
   expand without leaving the current step. */
@media (max-width: 900px) {
    .v2-wizard-layout {
        grid-template-columns: 1fr;
    }

    .v2-wizard-summary {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(70px + env(safe-area-inset-bottom, 0));
        z-index: 20;
        top: auto;
    }

    .v2-wizard-summary-inner {
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -4px 16px var(--shadow-color);
    }

    .v2-wizard-summary-handle {
        display: flex;
        min-height: 44px;
    }

    .v2-wizard-summary-body {
        display: none;
        margin-top: 0.75rem;
    }

    .v2-wizard-summary-body.v2-wizard-summary-body--expanded {
        display: block;
    }
}
