/* Repository settings (issue 3494): the ds/overlays modal opened from a row's
 * Settings action. Figma: collapsed 42:8538 (modal 42:8950, 440x529),
 * authors expanded 42:9055. Markup: app/repo-settings.ts (modal, rows,
 * authors), app/repo-unsaved.ts (Confirm Changes, status line, exit guard),
 * app/author-option.ts (author rows, shared with onboarding). Tokens only.
 *
 * Deviations: the close button keeps the ds overlay close look (border on
 * hover only). Unchecked author cards are not drawn at 70% opacity: their
 * text would fall under AA. Proposed, not in Figma: the 160ms open/close of
 * a row and its chevron turn; the status line left of Confirm Changes.
 */

/* ---- Shell (42:8950): 440 wide, heading fixed, body scrolls, footer fixed ---- */
#repo-settings { max-height: calc(100vh - 64px); }
#repo-settings .ui-modal-head { padding: var(--space-6) 80px var(--space-6) 28px; gap: 6px; }
#repo-settings .ui-modal-head .ui-overlay-close { top: 29px; right: 28px; }
#repo-settings .ui-modal-eyebrow { letter-spacing: 0.6px; }
#repo-settings .ui-modal-title { letter-spacing: -0.4px; }
#repo-settings .ui-modal-body { gap: var(--space-5); padding: var(--space-6) 28px var(--space-5); background: var(--surface); }
#repo-settings .ui-modal-foot { display: block; padding: var(--space-4) 28px var(--space-6); }

/* The identity row (42:8962): what the modal is for. */
.repo-identity {
  display: flex; align-items: center; gap: var(--space-2); margin: 0; padding: 10px var(--space-3);
  background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: 400 11px/14px var(--font-mono); color: var(--fg-muted);
}
.repo-identity .gh-mark { flex: none; color: var(--fg-strong); }
.repo-identity-text { min-width: 0; overflow-wrap: anywhere; }
.repo-identity strong { font-weight: 600; color: var(--fg-strong); }

/* ---- Accordion rows (42:8970) ---- */
.repo-secs { display: flex; flex-direction: column; min-width: 0; }
.repo-sec { border-bottom: 1px solid var(--border-strong); }
.repo-sec > summary {
  display: flex; align-items: center; gap: var(--space-4); padding: var(--space-5) 0;
  list-style: none; cursor: pointer; border-radius: var(--radius-sm);
}
.repo-sec > summary::-webkit-details-marker { display: none; }
.repo-sec > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.repo-sec-text { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-width: 0; }
.repo-sec-title { font: 600 13px/20px var(--font-mono); color: var(--fg-strong); }
.repo-sec-title::first-letter { text-transform: uppercase; }
.repo-sec-value { font: 400 11px/18px var(--font-mono); color: var(--fg-muted); overflow-wrap: anywhere; }
.repo-sec-value:empty { display: none; }
/* The toggle (secondary icon-only S): bordered closed, filled open (42:9923). */
.repo-sec-toggle {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px;
  background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--radius-sm); color: var(--fg-strong);
}
.repo-sec-toggle svg { transition: transform 160ms var(--ease-out, ease-out); }
.repo-sec > summary:hover .repo-sec-toggle { background: var(--surface-sunken); }
.repo-sec[open] .repo-sec-toggle { background: var(--surface-disabled); border-color: var(--surface-disabled); }
.repo-sec[open] .repo-sec-toggle svg { transform: rotate(180deg); }
.repo-sec-body { display: grid; gap: var(--space-3); padding: 0 0 var(--space-5); min-width: 0; }
.repo-sec-body .choice-list { margin-top: 0; }
/* Opening a row slides it open where the browser can animate to auto. */
@supports (interpolate-size: allow-keywords) {
  #repo-settings { interpolate-size: allow-keywords; }
  .repo-sec::details-content { height: 0; overflow: clip; transition: height 160ms var(--ease-out, ease-out), content-visibility 160ms allow-discrete; }
  .repo-sec[open]::details-content { height: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .repo-sec-toggle svg { transition: none; }
  .repo-sec::details-content { transition: none; }
}

/* ---- Pull request authors (42:9055) ---- */
.repo-authors-set { display: grid; gap: var(--space-4); margin: 0; padding: 0; border: 0; min-width: 0; }
.repo-authors-mode { display: grid; gap: var(--space-2); }
.repo-authors-mode .dd { display: flex; width: 100%; }
.repo-authors-mode .dd-button { width: 100%; height: 40px; border-radius: var(--radius); font: 400 14px/21px var(--font-sans); color: var(--fg-secondary); }
.repo-authors-help { margin: 0; font: var(--type-meta); color: var(--fg-muted); }
.repo-authors-scan, .repo-authors-set > p.muted { margin: 0; font: var(--type-meta); color: var(--fg-muted); }
.repo-authors-refresh { margin: 0; }
.repo-authors-refresh .btn svg { width: 14px; height: 14px; }
.repo-authors-error { flex-basis: 100%; margin: 0; font-size: var(--text-sm); color: var(--danger-fg); }

/* An author row (author-option.ts): a card per author, checkbox, initials, name and figures. */
.author-options { display: grid; gap: var(--space-2); }
/* A picked author is a green box with a white check (Figma 42:9935, #10b981). AA: light fills
 * --control-on (#047857, as a picked radio) since #10b981 is 2.5:1 on white; dark keeps the
 * design system's --brand fill with its dark check. */
.author-options { --check-fill: var(--control-on); --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5'/%3E%3C/svg%3E"); }
.author-options input.checkbox { border-radius: 3px; }
:root[data-theme="dark"] .author-options { --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230b0f0e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .author-options { --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230b0f0e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5'/%3E%3C/svg%3E"); }
}
.author-option {
  display: flex; align-items: center; gap: var(--space-3); min-height: 59px; padding: var(--space-3);
  background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--radius); cursor: pointer;
}
.author-option:hover:not(:has(input:disabled)) { border-color: var(--hover-border); }
.author-option:has(input:checked) { background: var(--surface-raised); }
.author-option:has(input:disabled) { cursor: not-allowed; }
.author-option > input { flex: none; margin: 0; }
.author-avatar {
  display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: var(--radius-md);
  font: 600 9px var(--font-mono); background: var(--success-bg); color: var(--success-fg);
}
.author-avatar[data-tint="1"] { background: var(--warning-bg); color: var(--warning-fg); }
.author-avatar[data-tint="2"] { background: var(--info-bg); color: var(--info-fg); }
.author-avatar[data-tint="3"] { background: var(--type-violet-bg); color: var(--type-violet-fg); }
.author-avatar[data-tint="4"] { background: var(--type-review-bg); color: var(--type-review-fg); }
.author-option-text { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--space-1); row-gap: 2px; min-width: 0; }
.author-option-name { font: 600 13px/18px var(--font-sans); color: var(--fg-strong); overflow-wrap: anywhere; }
.author-option-meta { flex-basis: 100%; font: var(--type-body-sm); color: var(--fg-muted); }

/* Onboarding's nested row (1:19947, issue 3590): no card, no avatar, mono 11. */
.author-option-compact { min-height: 0; gap: var(--space-2); padding: var(--space-2) 0; background: none; border: 0; border-radius: 0; font: 400 11px/16px var(--font-mono); color: var(--fg); }
.author-option-compact:has(input:checked) { background: none; }
.author-option-compact .author-avatar { display: none; }
.author-option-compact .author-option-text { flex: 1 1 auto; flex-wrap: nowrap; }
.author-option-compact .author-option-name { font: 700 11px/16px var(--font-mono); }
.author-option-compact .author-option-meta { flex-basis: auto; margin-left: auto; font: inherit; white-space: nowrap; }

/* ---- Review level (issue 3495, Figma 42:11823): the scope choice (not in
 * Figma), three tier cards, the add-on switches, when add-ons run, the price.
 * Markup: levelCardFields in app/review-level.ts. Deviations: the selected
 * border and name use --control-on / --live-text, not #10b981 / #059669
 * (below AA at this size); helper text is --fg-muted, not #979ca6. ---- */
#repo-level, #repo-level [data-repo-level-body] { display: grid; gap: var(--space-4); min-width: 0; }
/* The scope choice (not in Figma): compact, as the accordion's other choices. */
.level-scope.choice-list { margin: 0; }
.level-scope .choice { padding: var(--space-3); font: var(--type-body-sm); }
.level-scope .choice strong { font: 600 12px/18px var(--font-sans); }
.level-scope .choice .muted { font: var(--type-meta); color: var(--fg-muted); }
.level-fields { display: grid; gap: var(--space-6); min-width: 0; }
.level-fields[hidden] { display: none; }
.level-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin: 0; padding: 0; border: 0; min-width: 0; }
.level-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); min-width: 0;
  padding: 30px var(--space-4) var(--space-4); text-align: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--radius-xl);
  transition: border-color .15s ease, background-color .15s ease;
}
.level-card:hover:not(:has(input:disabled, input:checked)) { border-color: var(--hover-border); }
.level-card:has(input:checked) { padding: 29px 15px 15px; background: var(--accent-tint); border: 2px solid var(--control-on); }
.level-card:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.level-card:has(input:disabled) { cursor: not-allowed; }
/* The radio is the card's selected dot (42:11837): drawn only when picked, still focusable when not. */
.level-card-input { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); }
.level-card .level-card-input:not(:checked) { opacity: 0; }
.level-card-name { font: 700 10px/15px var(--font-sans); letter-spacing: 1px; text-transform: uppercase; color: var(--fg-muted); }
.level-card:has(input:checked) .level-card-name { color: var(--live-text); }
.level-card-price { display: flex; align-items: baseline; justify-content: center; gap: var(--space-1); min-height: 28px; white-space: nowrap; }
.level-card-price:empty { display: none; }
.level-card-price strong { font: 700 13px/28px var(--font-mono); letter-spacing: -0.08px; color: var(--fg-strong); }
.level-unit { font: 400 10px/15px var(--font-sans); color: var(--fg-muted); }
.level-card-blurb { font: 400 10px/12.5px var(--font-sans); color: var(--fg-muted); }
/* Strong is the default (kept from the old picker's DEFAULT chip; not in Figma). */
.level-card-default { position: absolute; top: 6px; right: 8px; font: var(--type-micro); color: var(--fg-muted); }
.level-tiers { display: grid; gap: var(--space-3); min-width: 0; }
.level-included { margin: 0; font: var(--type-meta); color: var(--fg-muted); }
.level-addons { display: grid; gap: var(--space-3); }
.level-addon {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3);
  background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--radius); cursor: pointer;
}
.level-addon:hover:not(:has(input:disabled)) { border-color: var(--hover-border); }
.level-addon:has(input:disabled) { cursor: not-allowed; }
.level-addon-text { display: flex; flex-direction: column; min-width: 0; }
.level-addon-title { font: 600 12px/18px var(--font-sans); color: var(--fg-secondary); }
.level-addon-help { font: 400 11px/16.5px var(--font-sans); color: var(--fg-muted); }
.level-addon-price { font: 400 11px/16.5px var(--font-sans); color: var(--fg-muted); }
.level-addon-price:empty { display: none; }
.level-addon-price strong { font: 700 11px/16.5px var(--font-mono); color: var(--fg-strong); }
.level-fields .choice-legend { margin-bottom: var(--space-2); }
.level-fields .level-preview { margin: 0; font: var(--type-body-sm); color: var(--fg-strong); }
.level-fields .level-preview:has(strong:empty) { display: none; }
[data-repo-level-body] > p.muted, .repo-level-status { margin: 0; font: var(--type-meta); color: var(--fg-muted); }
.repo-level-status { color: var(--danger-fg); }
.repo-level-status:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .level-card { transition: none; } }

/* ---- Footer (42:8995): the status line left of Confirm Changes ---- */
.repo-settings-foot { display: flex; align-items: center; justify-content: center; gap: var(--space-3); }
.repo-settings-foot .btn-primary { flex: 0 1 251px; min-width: 0; height: 44px; justify-content: center; border-radius: var(--radius-lg); }
.repo-save-status { flex: 1 1 0; min-width: 0; margin: 0; font: var(--type-meta); color: var(--fg-muted); }
.repo-save-status[data-tone="warning"] { color: var(--warning-fg); font-weight: 600; }
.repo-save-status[data-tone="success"] { color: var(--success-fg); }
.repo-save-status[data-tone="danger"] { color: var(--danger-fg); font-weight: 600; }

/* The exit guard, above the settings modal. */
.repo-unsaved { z-index: calc(var(--z-overlay) + 1); }
.repo-unsaved .ui-modal-foot > .btn-primary { flex: 0 1 auto; }
