/* ==========================================================================
   Cards - card primitives, value cards, review cards, and project cards
   ========================================================================== */

/*
  Cards contains card-like DS object presentations.

  Current subtypes:
  - Value Cards
  - Review Cards
  - Project Cards

  Future subtypes may include:
  - Sanity Cards

  This file must not redefine shared foundation tokens.
*/

/* Cards - card primitives */
.cd-card-grid {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: var(--space-3, 12px);
}

.cd-card-stack {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: var(--space-3, 12px);
}

.cd-card {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-01, rgba(255,255,255,0.08));
  border-radius: var(--radius-2sm, 8px);
  background: var(--surface-01, rgba(255,255,255,0.024));
}

/* Cards - Value Cards */
/* Value Cards accepted source */

/* Group layout.
   The group owns layout only. It does not own card chrome or card internals. */
.ds-value-card-group {
  width: 100%;
  display: grid;
  gap: var(--space-3);
}

.ds-value-card-group--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ds-value-card-group--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ds-value-card-group--auto {
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}

/* Guidance modifier.
   Used for orientation/workflow card groups where the label should carry
   guidance-blue emphasis. Business meaning remains owned by the consumer. */
.ds-value-card-group--guidance .ds-value-card__label {
  color: var(--guidance-blue);
}

/* Card item */
.ds-value-card {
  width: 100%;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: var(--space-2);
  padding: var(--space-3-5);
  border: 1px solid var(--border-01);
  border-radius: var(--radius-2sm);
  background: var(--surface-01);
}

/* TY-01 eyebrow-kicker */
.ds-value-card__label {
  margin: 0;
  color: var(--helper-text);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* TY-09 value-display */
.ds-value-card__value {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

/* TY-02 helper-copy */
.ds-value-card__copy {
  margin: 0;
  color: var(--helper-text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.52;
}

/* Optional child atom; not a global badge. */
.ds-value-card__qualifier {
  width: max-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--guidance-border);
  border-radius: var(--radius-pill);
  background: var(--guidance-surface-soft);
  color: var(--guidance-blue);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

@media (max-width: 760px) {
  .ds-value-card-group--2,
  .ds-value-card-group--3 {
    grid-template-columns: 1fr;
  }

  .ds-value-card__value {
    font-size: 26px;
  }
}


/* Cards - Review Cards */
/* Review Cards accepted source, migrated from Review Reqs */

/*
  Review Cards owns Review-specific surface, section, subsection, item, priority,
  action-stack, summary-row, and empty-state layout.

  It consumes:
  - Typography foundation, including TY-10 review-prose
  - Colour foundation roles
  - Controls for buttons/tabs/action bar
  - Helper Notes for guidance/status notes
  - Value Cards for the separate workflow block
  - Complex Lists for deleted-items composition
  - Section Headers for page header/process eyebrow
*/

.rv-card-surface {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 24px;
  padding: 22px;
  border: 1px solid var(--border-02, rgba(255,255,255,0.14));
  border-radius: var(--radius-lg, 16px);
  background: var(--surface-01, rgba(255,255,255,0.024));
}

.rv-card-section {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.rv-card-section__head {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-01, rgba(255,255,255,0.08));
}

.rv-card-section__copy {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.rv-card-section__title {
  /* consumes TY-08 display-heading at component-appropriate scale */
  margin: 0;
  color: var(--text-primary, #f2eee8);
  font-family: "DM Serif Display", serif;
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.rv-card-section__meta {
  /* consumes TY-04 subtext-meta-copy */
  margin: 0;
  color: var(--text-muted, rgba(255,255,255,0.68));
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.rv-card-section__actions {
  min-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.rv-card-group {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.rv-card-group + .rv-card-group {
  padding-top: 16px;
  border-top: 1px solid var(--border-01, rgba(255,255,255,0.08));
}

.rv-card-group__head {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.rv-card-group__copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.rv-card-group__title {
  /* consumes TY-05 choice-label */
  margin: 0;
  color: var(--text-primary, #f2eee8);
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.rv-card-group__helper {
  /* consumes TY-02 helper-copy */
  margin: 0;
  max-width: 680px;
  color: var(--helper-text, #a9b6bd);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.52;
}

.rv-card-group__count {
  /* consumes TY-07 compact-control-label */
  display: inline-flex;
  padding-top: 3px;
  color: var(--text-muted, rgba(255,255,255,0.68));
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.rv-card-list {
  min-width: 0;
  display: grid;
  gap: 0;
}

.rv-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 140px;
  gap: 18px;
  align-items: start;
  padding: 18px 0;
  border-top: 1px solid var(--border-01, rgba(255,255,255,0.08));
}

.rv-card:first-child {
  border-top: 0;
}

.rv-card-list .rv-card:last-child {
  padding-bottom: 12px;
}

.rv-card__ref {
  /* consumes TY-01 eyebrow-kicker */
  color: var(--text-muted, rgba(255,255,255,0.68));
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.5;
  text-transform: uppercase;
  white-space: nowrap;
}

.rv-card__body {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.rv-card__text {
  /* consumes TY-10 review-prose */
  margin: 0;
  color: var(--text-primary, #f2eee8);
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.72;
}

.rv-card__meta {
  /* consumes TY-04 subtext-meta-copy */
  margin: 0;
  color: var(--text-muted, rgba(255,255,255,0.68));
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.rv-card__priority {
  /* consumes TY-07 compact-control-label */
  display: inline-flex;
  margin: 0 0 4px;
  color: var(--text-muted, rgba(255,255,255,0.68));
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.rv-card__priority--must {
  color: var(--tab-active-underline, #FFC000);
}

.rv-card__priority--should {
  color: var(--tab-active-underline, #FFC000);
  opacity: 0.78;
}

.rv-card__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.rv-card__actions > .bt-btn {
  width: 132px;
}

.rv-card__actions > .bt-btn--text-danger {
  width: 132px;
  align-self: center;
  justify-content: center;
  text-align: center;
}

/* Review Cards - refinement state */
.rv-card--refined-source {
  background: rgba(0,163,136,0.018);
  box-shadow: inset 0 0 0 1px rgba(0,163,136,0.08);
  border-radius: 12px;
  padding-inline: 12px;
}

.rv-card--derived {
  padding-left: 12px;
}

.rv-card--derived .rv-card__ref {
  color: var(--text-muted, rgba(255,255,255,0.68));
}

.rv-card-group--derived {
  margin-left: 28px;
  padding-left: 18px;
  border-left: 1px solid var(--border-01, rgba(255,255,255,0.08));
}

.rv-card-group--derived .rv-card:first-child {
  border-top: 0;
}

.rv-card__provenance {
  margin: 0;
  color: var(--helper-text, #a9b6bd);
  font-family: var(--font, "DM Sans", sans-serif);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.rv-card-state {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--success-note-border, rgba(0,163,136,0.30));
  border-radius: 10px;
  background: var(--success-note-surface, rgba(0,163,136,0.055));
}

.rv-card-state__marker {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--success-note-accent, #00A388);
  border: 1px solid var(--success-note-border, rgba(0,163,136,0.30));
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.rv-card-state__copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.rv-card-state__title {
  margin: 0;
  color: var(--success-note-accent, #00A388);
  font-family: var(--font, "DM Sans", sans-serif);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.25;
}

.rv-card-state__text {
  margin: 0;
  color: var(--helper-text, #a9b6bd);
  font-family: var(--font, "DM Sans", sans-serif);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

/* Review Cards - objective card variant */
.rv-card--objective .rv-card__body {
  gap: 12px;
}

.rv-card-objective {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.rv-card-objective__part {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border-01, rgba(255,255,255,0.08));
}

.rv-card-objective__part:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.rv-card-objective__label {
  margin: 0;
  color: var(--guidance-blue, #6EA8FF);
  font-family: var(--font, "DM Sans", sans-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.25;
  text-transform: uppercase;
}

.rv-card-objective__text {
  margin: 0;
  color: var(--text-primary, #f2eee8);
  font-family: var(--font, "DM Sans", sans-serif);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.72;
}

.rv-card-objective__part--warning .rv-card-objective__label {
  color: var(--guidance-blue, #6EA8FF);
}

.rv-card-objective__clarified {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--success-note-border, rgba(0,163,136,0.30));
  border-radius: 10px;
  background: var(--success-note-surface, rgba(0,163,136,0.055));
}

/* Review Cards consumption of Complex Lists for removed-items rows.
   Complex Lists owns the list/value slot; Review Cards owns the local
   breathing room when that value slot contains a Restore action. */
.rv-card-section > .ds-collapsible-list .ds-complex-list__value {
  padding-inline-end: var(--space-3, 12px);
}

.rv-card-summary {
  min-width: 0;
  display: grid;
}

.rv-card-summary-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border-01, rgba(255,255,255,0.08));
}

.rv-card-summary-row:first-child {
  border-top: 0;
}

.rv-card-summary-row__key {
  /* consumes TY-04 subtext-meta-copy */
  min-width: 0;
  color: var(--text-muted, rgba(255,255,255,0.68));
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.rv-card-summary-row__value {
  /* consumes TY-10 review-prose for longer answer values */
  min-width: 0;
  color: var(--text-primary, #f2eee8);
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.72;
}

.rv-card-empty {
  /* consumes TY-02 helper-copy */
  margin: 0;
  color: var(--helper-text, #a9b6bd);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.52;
}

@media (max-width: 760px) {
  .rv-card-surface {
    padding: 16px;
  }

  .rv-card-section__head {
    display: grid;
  }

  .rv-card-section__actions {
    min-width: 0;
    align-items: flex-start;
  }

  .rv-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .rv-card__actions {
    align-items: flex-start;
  }

  .rv-card__actions > .bt-btn,
  .rv-card__actions > .bt-btn--text-danger {
    width: auto;
  }

  .rv-card-group--derived {
    margin-left: 0;
    padding-left: 12px;
  }

  .rv-card-summary-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* Cards - Project Cards */
.pc-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}

.pc-card__copy {
  min-width: 0;
  display: grid;
  gap: var(--space-2, 8px);
  padding: var(--space-4, 16px);
}

.pc-card__title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  flex-wrap: wrap;
}

.pc-card__title,
.pc-card__title-button {
  min-width: 0;
  margin: 0;
  color: var(--text-primary, #f2eee8);
  font-family: var(--font, "DM Sans", sans-serif);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.pc-card__title-button {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.pc-card__title-button:hover,
.pc-card__title-button:focus-visible {
  color: var(--guidance-blue, #6EA8FF);
}

.pc-card__meta,
.pc-card__readiness {
  min-width: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--text-muted, rgba(255,255,255,0.68));
  font-family: var(--font, "DM Sans", sans-serif);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.pc-card__readiness {
  color: var(--helper-text, #a9b6bd);
}

.pc-card__separator {
  color: var(--text-muted, rgba(255,255,255,0.68));
}

.pc-card__status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid var(--border-01, rgba(255,255,255,0.08));
  border-radius: var(--radius-pill, 999px);
  color: var(--text-muted, rgba(255,255,255,0.68));
  font-family: var(--font, "DM Sans", sans-serif);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.pc-card__actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3, 12px);
  align-items: center;
  padding: 12px var(--space-4, 16px);
  border-top: 1px solid var(--border-01, rgba(255,255,255,0.08));
}

.pc-card__actions-left,
.pc-card__actions-right {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  flex-wrap: wrap;
}

.pc-card__actions-left {
  justify-content: flex-start;
}

.pc-card__actions-right {
  justify-content: flex-end;
}

.pc-card--setup .pc-card__readiness {
  color: var(--helper-text, #a9b6bd);
}

.pc-card--deleted,
.projects-home-card.pc-card--deleted {
  background:
    linear-gradient(180deg, rgba(226,75,74,0.075), rgba(226,75,74,0.035)),
    var(--surface-01, rgba(255,255,255,0.024));
  border-color: var(--error-note-border, rgba(226,75,74,0.28));
}

.pc-card--deleted .pc-card__actions {
  border-top-color: var(--border-01, rgba(255,255,255,0.08));
}

.pc-card--deleted .pc-card__title {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(226,75,74,0.52);
}

.pc-card--deleted .pc-card__status {
  color: var(--error-note-accent, #E24B4A);
  border-color: var(--error-note-border, rgba(226,75,74,0.28));
  background: var(--error-note-surface, rgba(226,75,74,0.055));
}

.pc-card-stack {
  display: grid;
  gap: var(--space-4, 16px);
}

.pc-home-create-row,
.pc-home-empty-inline {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3, 12px);
  flex-wrap: wrap;
}

.pc-home-create-row {
  margin-bottom: var(--space-5, 24px);
}

.pc-home-empty-inline {
  color: var(--helper-text, #a9b6bd);
  font-family: var(--font, "DM Sans", sans-serif);
  font-size: 13px;
  line-height: 1.55;
}

.pc-home-empty-inline p {
  margin: 0;
}

.pc-home-failure-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-3, 12px);
}

.pc-home-failure-note .ds-helper-note__icon {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
}

.pc-home-failure-note .ds-helper-note__copy {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.pc-home-failure-note .ds-helper-note__actions {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  margin-left: var(--space-5, 24px);
}

.pc-home-deleted-collapsible {
  margin-top: var(--space-4, 16px);
}

.pc-home-deleted-collapsible .ds-collapsible-list__body {
  margin-top: var(--space-3, 12px);
}

@media (max-width: 760px) {
  .pc-card__actions {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .pc-card__actions-right,
  .pc-card__actions-left {
    justify-content: flex-start;
  }

  .pc-card__actions-right .bt-btn,
  .pc-card__actions-left .bt-btn,
  .pc-home-create-row .bt-btn,
  .pc-home-empty-inline .bt-btn {
    width: 100%;
    justify-content: center;
  }

  .pc-home-failure-note {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }

  .pc-home-failure-note .ds-helper-note__icon {
    grid-column: 1;
    grid-row: 1;
  }

  .pc-home-failure-note .ds-helper-note__copy {
    grid-column: 2;
    grid-row: 1;
  }

  .pc-home-failure-note .ds-helper-note__actions {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    align-self: stretch;
    margin-left: 0;
    margin-top: var(--space-3, 12px);
  }

  .pc-home-failure-note .ds-helper-note__actions .bt-btn {
    width: 100%;
    justify-content: center;
  }
}

