/*
 * Aura theme for the public /app pages (ADR 0025). Mobile first, no JS needed.
 * Tokens mirror the app's Aura palette: Dawn (light) and Dusk (dark) by system setting.
 *
 * Class names used by templates (L4 delete_account.html relies on these):
 *   .skip-link       visible-on-focus link to #main
 *   .page            centred column, max 40rem, safe-area padding
 *   .prose           long-form text (privacy policy)
 *   .notice          boxed message; modifiers .notice--info .notice--error .notice--dev
 *   .field           one label + control + hint + error group
 *   .field__label    <label>
 *   .field__hint     helper text, link with aria-describedby
 *   .field__error    per-field error text (use with aria-invalid on the control)
 *   .input           text/email input, 56px high
 *   .textarea        multi-line input
 *   .button          pill button or link styled as a button, 44px minimum
 *   .counter         character counter text (id="reason-count", filled by app.js)
 *   .error-summary   role="alert" block at the top of the form, tabindex="-1"
 *   .muted           secondary text
 *   .visually-hidden screen-reader-only text
 */

/* Fonts: original files, unrenamed (OFL, Reserved Font Names). */
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Newsreader_400Regular.ttf") format("truetype");
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/DMSans_400Regular.ttf") format("truetype");
}
/* Metric-matched local fallbacks so the swap does not shift layout much. */
@font-face {
  font-family: "Newsreader Fallback";
  src: local("Georgia");
  size-adjust: 94%;
  ascent-override: 103%;
  descent-override: 30%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "DM Sans Fallback";
  src: local("Arial");
  size-adjust: 101%;
  ascent-override: 94%;
  descent-override: 29%;
  line-gap-override: 0%;
}

:root {
  color-scheme: light dark;

  --bg: #f7f5fb;
  --surface: #fbfafd;
  --text: #23223a;
  --text-2: #45445e;
  --text-muted: #686580;
  --border: #e4e0f0;
  --border-input: #686580;
  --btn-bg: #3b8270;
  --btn-text: #ffffff;
  --link: #6656c4;
  --focus: #6656c4;
  --notice-bg: #fce9f0;
  --notice-text: #b04773;
  --field-error: #a9472f;

  --radius-card: 1.125rem;
  --radius-input: 0.75rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;

  --font-display: "Newsreader", "Newsreader Fallback", Georgia, "Times New Roman", serif;
  --font-body: "DM Sans", "DM Sans Fallback", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;

  --step-display: clamp(2rem, 1.6rem + 1.8vw, 2.625rem); /* 34/38 and up */
  --step-title1: clamp(1.625rem, 1.45rem + 0.8vw, 2rem);
  --step-title2: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --step-body: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --step-small: 0.875rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17172e;
    --surface: #1f1f3a;
    --text: #eceaf6;
    --text-2: #d5d2e8;
    --text-muted: #aba7c6;
    --border: #2a2a48;
    --border-input: #aba7c6;
    --btn-bg: #8fcdb0;
    --btn-text: #0e2a26;
    --link: #a995ea;
    --focus: #a995ea;
    --notice-bg: #6e2a48;
    --notice-text: #ee9dbb;
    --field-error: #f0a08c;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-block-size: 100vb;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-body);
  line-height: 1.6;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.page {
  inline-size: 100%;
  max-inline-size: 40rem;
  margin-inline: auto;
  padding-block: max(var(--space-6), env(safe-area-inset-top)) max(var(--space-6), env(safe-area-inset-bottom));
  padding-inline: max(var(--space-4), env(safe-area-inset-left)) max(var(--space-4), env(safe-area-inset-right));
}

main {
  display: block;
}
main:focus {
  outline: none;
}

.footer {
  margin-block-start: var(--space-6);
  padding-block-start: var(--space-4);
  border-block-start: 1px solid var(--border);
  font-size: var(--step-small);
}
.footer p {
  margin: 0;
}

/* Type */
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--text);
  text-wrap: balance;
  margin: 0;
}
h1 {
  font-size: var(--step-display);
  line-height: 1.12;
}
h2 {
  font-size: var(--step-title1);
  line-height: 1.2;
}
h3 {
  font-size: var(--step-title2);
  line-height: 1.25;
}

p,
ul,
ol {
  margin-block: 0 var(--space-4);
}
ul,
ol {
  padding-inline-start: 1.25rem;
}
li + li {
  margin-block-start: var(--space-2);
}

a {
  color: var(--link);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.08em;
}
a:hover {
  text-decoration-thickness: 0.14em;
}

.muted {
  color: var(--text-muted);
  font-size: var(--step-small);
}

.prose h1 {
  margin-block-end: var(--space-2);
}
.prose h2 {
  margin-block: var(--space-6) var(--space-3);
}
.prose h3 {
  margin-block: var(--space-5) var(--space-2);
}
.prose p,
.prose li {
  color: var(--text-2);
  max-inline-size: 38rem;
}
.prose p.muted {
  margin-block-end: var(--space-5);
}

/* Focus and skip link */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  inset-block-start: var(--space-2);
  z-index: 10;
  min-block-size: 2.75rem;
  display: inline-flex;
  align-items: center;
  padding-inline: var(--space-4);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-input);
  transform: translateY(-200%);
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Notices */
.notice {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
}
.notice h1 {
  font-size: var(--step-title1);
  line-height: 1.2;
  margin-block-end: var(--space-3);
}
.notice > :last-child {
  margin-block-end: 0;
}
.notice--error {
  background: var(--notice-bg);
  border-color: var(--notice-text);
  color: var(--notice-text);
}
.notice--error h1,
.notice--error a {
  color: var(--notice-text);
}
.notice--dev {
  border-style: dashed;
  border-color: var(--border-input);
  color: var(--text-2);
}

/* Form */
.field {
  margin-block-end: var(--space-4);
}
.field__label {
  display: block;
  margin-block-end: var(--space-2);
  color: var(--text);
  font-size: 1rem;
}
.field__hint {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--step-small);
}
.field__error {
  margin: var(--space-2) 0 0;
  color: var(--field-error);
  font-size: var(--step-small);
}
.input,
.textarea {
  display: block;
  inline-size: 100%;
  padding-inline: var(--space-4);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem; /* never below 16px: avoids iOS zoom on focus */
  line-height: 1.4;
}
.input {
  block-size: 3.5rem;
}
.textarea {
  min-block-size: 8rem;
  padding-block: var(--space-3);
  resize: vertical;
}
.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--field-error);
  border-width: 2px;
}
.counter {
  display: block;
  margin-block-start: var(--space-2);
  color: var(--text-muted);
  font-size: var(--step-small);
  text-align: end;
}

.error-summary {
  margin-block-end: var(--space-5);
  padding: var(--space-4);
  border: 2px solid var(--field-error);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--field-error);
}
.error-summary h2 {
  font-size: var(--step-title2);
  color: inherit;
  margin-block-end: var(--space-2);
}
.error-summary ul {
  margin: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  padding: var(--space-3) var(--space-6);
  border: 0;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 150ms ease;
}
.button:hover {
  opacity: 0.92;
}
.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.notice--error .button {
  color: var(--btn-text);
}
form .button {
  inline-size: 100%;
  min-block-size: 3.5rem;
}

/* Forced colours: keep borders and focus visible */
@media (forced-colors: active) {
  .input,
  .textarea,
  .notice,
  .error-summary {
    border: 1px solid CanvasText;
  }
  .button {
    border: 1px solid ButtonText;
  }
}

/* Breakpoints */
@media (min-width: 600px) {
  .page {
    padding-block-start: max(3rem, env(safe-area-inset-top));
  }
  .notice {
    padding: var(--space-6);
  }
  form .button {
    inline-size: auto;
    min-inline-size: 12rem;
  }
}
@media (min-width: 1024px) {
  .page {
    padding-block-start: max(4.5rem, env(safe-area-inset-top));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --text: #000;
    --text-2: #000;
    --text-muted: #333;
    --link: #000;
  }
  .skip-link,
  form,
  .button {
    display: none !important;
  }
  .page {
    max-inline-size: none;
    padding: 0;
  }
  a[href^="mailto:"]::after {
    content: " (" attr(href) ")";
  }
}
