/*
 * static/css/modals.css — confirm, prompt, recovery-choice, refusal and settings modals.
 *
 * Owner: WP A-13 (Phase 1), B-13 (Phase 2); restyled by the UI overhaul (plan R-106, batch 4 §9 phase 2;
 * docs/plan/specs/ui-overhaul.md §6.12). Every selector is defined once, in one file (I7; T-CSS checks the
 * critical ones). ui/modals.js builds the DOM:
 *   <div class="confirm-modal active"><div class="confirm-panel" role="dialog">…</div></div>
 * The refusal popup (B-13, notices.js) uses .confirm-modal + .confirm-panel.refusal-panel; the
 * settings modal (B-13, settings.js) uses .prompt-modal + .prompt-panel.settings-panel.
 */

/* ============================================================
   CONFIRM / PROMPT SHELL: a 24-radius panel over the scrim, a text button then one filled (or danger) button
   ============================================================ */
.confirm-modal, .prompt-modal { display: none; position: fixed; inset: 0; z-index: var(--z-dialog); background: var(--c-scrim); align-items: center; justify-content: center; padding: var(--space-5); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.confirm-modal.active, .prompt-modal.active { display: flex; animation: overlay-in var(--dur-3) var(--ease-standard); }
.confirm-panel, .prompt-panel { background: var(--c-surface-raised); border-radius: var(--radius-xl); box-shadow: var(--elev-3); padding: var(--space-6); display: grid; gap: var(--space-4); animation: panel-in var(--dur-3) var(--ease-enter); }
.confirm-panel { width: min(440px, 92vw); }
.prompt-panel { width: min(460px, 92vw); }
/* the "!" stays in the DOM; a line icon on a tonal circle (danger for deletes, the accent for the refusal popup) */
.confirm-icon {
    width: 40px; height: 40px; border-radius: var(--radius-pill); display: inline-flex; align-items: center; justify-content: center;
    background: var(--c-danger-container); color: var(--c-danger); font-size: 0; line-height: 0;
}
.confirm-icon::before {
    content: ''; width: 22px; height: 22px; background: currentColor;
    -webkit-mask: var(--icon-alert) center / contain no-repeat; mask: var(--icon-alert) center / contain no-repeat;
}
.confirm-panel h3, .prompt-panel h3 { font: var(--t-title-l); color: var(--c-on); }
.confirm-panel p, .prompt-panel p { color: var(--c-on-2); font: var(--t-body-m); line-height: 1.55; }
.prompt-field { display: grid; gap: 6px; }
.prompt-field label { color: var(--c-on-2); font: var(--t-label-m); }
.prompt-field input { width: 100%; height: 48px; padding: 0 14px; border-radius: var(--radius-md); border: 1px solid var(--c-outline); background: var(--c-surface); color: var(--c-on); font: var(--t-body-l); outline: none; transition: border-color var(--dur-1) var(--ease-standard), box-shadow var(--dur-1) var(--ease-standard); }
/* Same field, drawn rather than native (appearance: none): WebKit's native menulist ignores the padding and radius. */
.prompt-field select { width: 100%; height: 48px; padding: 0 40px 0 14px; border-radius: var(--radius-md); border: 1px solid var(--c-outline); background: var(--c-surface) var(--chev) no-repeat right 12px center / 18px 18px; color: var(--c-on); font: var(--t-body-l); outline: none; transition: border-color var(--dur-1) var(--ease-standard), box-shadow var(--dur-1) var(--ease-standard); appearance: none; -webkit-appearance: none; cursor: pointer; }
.prompt-field input:focus, .prompt-field select:focus { border-color: var(--c-accent); box-shadow: inset 0 0 0 1px var(--c-accent); }
.prompt-error { min-height: 16px; color: var(--c-danger); font: var(--t-body-s); }
.confirm-actions, .prompt-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-1); }
.confirm-danger-btn { color: var(--c-on-danger-fill); background: var(--c-danger-fill); }
.confirm-danger-btn:hover { background: var(--c-danger-fill-hover); }
.prompt-primary-btn { color: var(--c-on-primary); background: var(--c-primary); box-shadow: inset 0 0 0 1px var(--c-primary-edge); }
.prompt-primary-btn:hover { background: var(--c-primary-hover); }

/* Recovery choice: three stacked full-width buttons (filled, neutral, text). */
.recovery-choice-actions { flex-direction: column; align-items: stretch; }
.recovery-choice-actions > .btn:first-child { background: var(--c-primary); color: var(--c-on-primary); box-shadow: inset 0 0 0 1px var(--c-primary-edge); }
.recovery-choice-actions > .btn:first-child:hover { background: var(--c-primary-hover); }
.recovery-choice-actions > .btn:nth-child(2):not(:last-child) { background: var(--c-surface-highest); color: var(--c-on); }

/* ============================================================
   REFUSAL POPUP (A5; R-79: "Edit & retry" + "Close")
   ============================================================ */
.refusal-panel .confirm-icon { color: var(--c-accent-text); background: var(--c-accent-container); }
.refusal-panel .confirm-icon::before { -webkit-mask-image: var(--icon-info); mask-image: var(--icon-info); }
.refusal-panel p { color: var(--c-on-2); }

/* ============================================================
   SETTINGS (PA-8: detected zone and place, overrides, precise location): sections separated by space only
   ============================================================ */
.settings-panel { width: min(520px, 94vw); max-height: 88vh; max-height: 88dvh; overflow-y: auto; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
.settings-section { display: grid; gap: var(--space-2); }
.settings-detected { color: var(--c-on-3); font: var(--t-body-s); }
.settings-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 40px; color: var(--c-on); font: var(--t-label-l); cursor: pointer; }
/* the precise-location checkbox, drawn as the shared switch (still a checkbox) */
.settings-toggle-row input[type="checkbox"] {
    appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 36px; height: 20px; margin: 0;
    border-radius: var(--radius-pill); background: var(--c-surface-highest); box-shadow: inset 0 0 0 1px var(--c-outline); cursor: pointer;
    transition: background-color var(--dur-2) var(--ease-standard);
}
.settings-toggle-row input[type="checkbox"]::before {
    content: ''; position: absolute; left: 4px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--c-on-3); transition: transform var(--dur-2) var(--ease-standard), background-color var(--dur-2) var(--ease-standard);
}
.settings-toggle-row input[type="checkbox"]:checked { background: var(--c-accent); box-shadow: none; }
.settings-toggle-row input[type="checkbox"]:checked::before { transform: translateX(16px); background: var(--c-bg); }
/* R-110 (Ray 2026-11-13: "Time and place" fits a Mac's window without inner scrolling, nothing shrunk): the
   precise-location note and the save error stay in the DOM as live regions but take no room while empty. */
.settings-section.settings-precise-section { gap: 0; }
.settings-precise-section > .settings-detected:not(:empty) { margin-top: var(--space-2); }
.settings-footer { display: grid; }
.settings-footer > .prompt-error:empty { min-height: 0; }
.settings-footer > .prompt-error:not(:empty) { margin-bottom: var(--space-2); }
/* R-118 (privacy.md §5.1): Settings → Account ("Delete my account": a heading, one line with the privacy policy link,
   the danger button) and its confirm dialog, whose field label prints the username in monospace */
.settings-danger { display: grid; gap: var(--space-3); justify-items: start; }
.settings-danger-title { color: var(--c-on); font: var(--t-title-m); }
.settings-danger-text a { color: var(--c-accent-text); text-underline-offset: 2px; }
.settings-danger-text a:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; border-radius: 2px; }
.account-delete-name { color: var(--c-on); font-family: var(--font-mono); font-weight: 600; overflow-wrap: anywhere; }
.account-delete-field > .prompt-error:empty { min-height: 0; }
/* R-120: with room for two panes (settings.js SETTINGS_WIDE_QUERY), the tab list's column (pro.css .settings-side)
   beside the panel; each pane brings its own padding. Narrower, the title and one row of tabs sit over the panel. */
@media (min-width: 700px) {
    .settings-panel { width: min(760px, 94vw); grid-template-columns: 208px minmax(0, 1fr); gap: 0; padding: 0; }
}

@media (max-width: 560px) {
    .confirm-panel, .prompt-panel { padding: var(--space-5); }
    .confirm-actions, .prompt-actions { flex-wrap: wrap; }
}
/* Forced colours: the icon is a mask; the switch-drawn checkbox keeps a border and a system-coloured knob. */
@media (forced-colors: active) {
    .confirm-icon::before, .refusal-panel .confirm-icon::before { forced-color-adjust: none; background: ButtonText; }
    .settings-toggle-row input[type="checkbox"] { border: 1px solid ButtonText; }
    .settings-toggle-row input[type="checkbox"]::before { forced-color-adjust: none; background: ButtonText; }
    .settings-toggle-row input[type="checkbox"]:checked { forced-color-adjust: none; background: Highlight; border-color: Highlight; }
    .settings-toggle-row input[type="checkbox"]:checked::before { background: HighlightText; }
    .prompt-field select:focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }   /* a border tint */
}
