/* apple-setup.css — Studio's Apple setup form, which apple-setup.js builds.

   Every colour, type size and control size is a role `styles.css` declares on
   `:root` and again under `[data-theme="dark"]`, so there is no dark block here.
   The one literal is the dialog's backdrop, because a custom property does not
   reach `::backdrop` in every browser this page supports. Spacing follows
   Studio's scale (4, 8, 12, 16, 24), and the form takes Studio's wide width,
   560 points (`StudioFormWidth.wide`).

   Nothing here is written from script. The shell's CSP (`style-src 'self'`)
   refuses style attributes, so state arrives as a class, `hidden`, `disabled`
   or `aria-pressed`, and these rules draw it. */

/* `styles.css` already hides `[hidden]`; repeated for the elements below that set
   a display of their own, so this file does not lean on another's rule. */
.apple-setup-dialog [hidden] { display: none !important; }

/* ---------------------------------------------------------------- the card */

/* A native modal `<dialog>` in the top layer: a card on the panel surface with a
   hairline and Studio's 12-point radius, cross-faded in over a 40% black scrim,
   with no blur and no shadow. The header and footer stay put; the body scrolls. */
.apple-setup-dialog {
  width: min(560px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.apple-setup-dialog[open] { display: flex; animation: apple-setup-in .3s ease-in-out; }
.apple-setup-dialog::backdrop { background: rgba(0, 0, 0, .4); }
@keyframes apple-setup-in { from { opacity: 0; } }
.apple-setup-frame { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* `StudioFormView`'s header: the title, the "Working" indicator while the form finds
   apps or saves, and the close button, which waits while it does. */
.apple-setup-head { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 24px 24px 0; }
.apple-setup-title { flex: 1 1 auto; min-width: 0; margin: 0; font: var(--type-h1); overflow-wrap: anywhere; }
.apple-setup-close { width: var(--icon-button); height: var(--icon-button); flex: 0 0 var(--icon-button); display: grid; place-items: center; padding: 0; color: var(--ink); background: transparent; border: 0; border-radius: var(--radius-icon); font-size: 17px; line-height: 1; cursor: pointer; }
.apple-setup-close:hover:not(:disabled) { background: var(--hover); }
.apple-setup-close:disabled { color: var(--muted); cursor: progress; }

/* Studio's small loading indicator. Neutral, as Studio's is: orange is kept for a
   chat turn at work. */
.apple-setup-spinner { width: 12px; height: 12px; flex: 0 0 12px; display: inline-block; border: 1.5px solid var(--line-strong); border-top-color: var(--loading); border-radius: 50%; animation: apple-setup-spin .8s linear infinite; }
@keyframes apple-setup-spin { to { transform: rotate(360deg); } }

.apple-setup-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 16px; padding: 16px 24px; }
.apple-setup-intro { margin: 0; color: var(--ink-soft); font: var(--type-small); }

/* ------------------------------------------------------------ the sections */

/* The key, the app and its group: one column, 16 points apart, as Studio's
   `StudioAppleBaseFieldsView` stacks them. The Mac note keeps its heading 8 above. */
.apple-setup-section { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.apple-setup-section > * { max-width: 100%; }
.apple-setup-mac { gap: 8px; }
.apple-setup-heading { margin: 0; color: var(--ink); font: var(--type-h3); }
.apple-setup-caption { margin: 0; color: var(--muted); font: var(--type-caption); }
.apple-setup-small { margin: 0; color: var(--ink-soft); font: var(--type-small); }
.apple-setup-help { margin: 0; color: var(--ink-soft); font: var(--type-caption); }

/* `StudioAppleFileFieldView`: the file's title with Choose beside it, the chosen
   name (or ".p8"), then where the file comes from. */
.apple-setup-file { align-self: stretch; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.apple-setup-file-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.apple-setup-file-title { min-width: 0; color: var(--ink); font: var(--type-small-strong); }
.apple-setup-file-name { margin: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: var(--muted); font: var(--type-caption); overflow-wrap: anywhere; }

/* `StudioLabeledFieldView`: the title in eyebrow type over the field. */
.apple-setup-field { align-self: stretch; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.apple-setup-eyebrow { margin: 0; color: var(--muted); font: var(--type-eyebrow); letter-spacing: var(--eyebrow-tracking); }
.apple-setup-input { width: 100%; height: var(--control-height); padding: 0 12px; color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-button); font: var(--type-body); }
.apple-setup-input:focus { border-color: var(--selected-line-strong); }
.apple-setup-input::placeholder { color: var(--muted); }
.apple-setup-input:disabled { color: var(--muted); background: var(--chip); cursor: progress; }

/* Studio's Secondary button with its `studioLabel` — Choose and Find apps — drawn at
   its own width on the leading edge. Disabled, it is muted ink on the chip. */
.apple-setup-action { flex: 0 0 auto; height: var(--control-height); padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--ink); background-color: var(--selected-fill); border: 1px solid var(--selected-line); border-radius: var(--radius-button); font: var(--type-caption-strong); white-space: nowrap; cursor: pointer; }
.apple-setup-action:hover:not(:disabled) { background-image: linear-gradient(var(--hover), var(--hover)); }
.apple-setup-action:active:not(:disabled) { background-image: linear-gradient(var(--pressed), var(--pressed)); }
.apple-setup-action:disabled { color: var(--muted); background-color: var(--chip); border-color: transparent; cursor: not-allowed; }

/* The App and TestFlight group choices, one under another in the same column. */
.apple-setup-choices { align-self: stretch; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.apple-setup-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }

/* `StudioChoiceRowView`: unchosen, the muted surface with no edge; chosen, Studio's
   raised neutral fill, a neutral edge and primary ink, with the mark filled and
   ticked so the state is not carried by the edge alone. The note on a chosen row
   takes `--ink-soft`, because `--muted` falls under 4.5:1 there (TechPlan.md § The
   design system is Studio's). */
.apple-setup-choice { width: 100%; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px; color: var(--ink); text-align: left; background: var(--panel-muted); border: 1px solid transparent; border-radius: var(--radius-button); cursor: pointer; }
.apple-setup-choice:hover:not(:disabled) { background-image: linear-gradient(var(--hover), var(--hover)); }
.apple-setup-choice.selected { background: var(--selected-fill); border-color: var(--selected-line-strong); }
.apple-setup-choice:disabled { cursor: not-allowed; opacity: .48; }
.apple-setup-choice-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.apple-setup-choice-title { color: var(--ink); font: var(--type-label); overflow-wrap: anywhere; }
.apple-setup-choice.selected .apple-setup-choice-title { color: var(--selected-ink); }
.apple-setup-choice-note { color: var(--muted); font: var(--type-caption); overflow-wrap: anywhere; }
.apple-setup-choice.selected .apple-setup-choice-note { color: var(--ink-soft); }
.apple-setup-choice-mark { width: 16px; height: 16px; flex: 0 0 16px; display: grid; place-items: center; box-sizing: border-box; border: 1.5px solid var(--muted); border-radius: 50%; }
.apple-setup-choice.selected .apple-setup-choice-mark { background: var(--selected-ink); border-color: var(--selected-ink); }
.apple-setup-choice.selected .apple-setup-choice-mark::after { content: "✓"; color: var(--selected-fill); font: var(--type-caption-strong); line-height: 1; }

/* ------------------------------------------------------------- the footer */

/* Messages sit directly above the actions they are about and scroll within Studio's
   180 points (`formMessageMaximumHeight`), so the actions never leave. */
.apple-setup-foot { flex: 0 0 auto; display: flex; flex-direction: column; gap: 12px; padding: 0 24px 24px; }
.apple-setup-messages { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

/* `StudioAppleRejectionView` and `StudioFormErrorView`: the danger family's muted
   fill under its own ink. A refusal's reasons follow its sentence, a line each. */
.apple-setup-rejection { display: flex; flex-direction: column; gap: 8px; padding: 12px; color: var(--bad-ink); background: var(--bad-bg); border-radius: var(--radius-button); font: var(--type-small); }
.apple-setup-rejection-message { margin: 0; }
.apple-setup-reasons { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.apple-setup-reason::before { content: "• "; }
.apple-setup-error { margin: 0; padding: 12px; color: var(--bad-ink); background: var(--bad-bg); border-radius: var(--radius-button); font: var(--type-small); }

/* Studio's dialog buttons: equal shares of the row, 28 points, body type — the
   dismissal in the Cancel role and the answer in the primary orange. */
.apple-setup-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.apple-setup-button { height: var(--control-height); min-width: 0; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid transparent; border-radius: var(--radius-button); font: var(--type-body); white-space: nowrap; text-overflow: ellipsis; cursor: pointer; transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
.apple-setup-button.cancel { color: var(--ink); background-color: var(--panel-muted); border-color: var(--line); }
.apple-setup-button.cancel:hover:not(:disabled) { background-image: linear-gradient(var(--hover), var(--hover)); }
.apple-setup-button.primary { color: var(--on-primary); background: var(--primary); }
.apple-setup-button.primary:hover:not(:disabled) { background: var(--primary-hover); }
.apple-setup-button.primary:active:not(:disabled) { background: var(--primary-pressed); }
.apple-setup-button:disabled { color: var(--muted); background: var(--chip); background-image: none; border-color: transparent; cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
  .apple-setup-dialog[open] { animation: none; }
  .apple-setup-spinner { animation: none; border-top-color: var(--loading); }
}

@media (max-width: 560px) {
  .apple-setup-head { padding: 20px 16px 0; }
  .apple-setup-body { padding: 12px 16px; }
  .apple-setup-foot { padding: 0 16px 20px; }
}
