/* apply.siaminference.ai: the form pages, the thank-you state, the privacy
   dialog, the 404 pages and the admin pages. One file, no build step;
   scripts/build-apply.ts copies it to dist/apply/assets/apply.css.

   Colours are the Siam brand's, copied as literals from
   src/brands/siam/brand.ts (`css`): the lime #A2ED20 is `primary` (82 85%
   53%), the greys are its cool neutrals (hue 210). Fonts: Anuphan for Thai
   and Geist for Latin, the same files the main site ships, copied from
   @fontsource-variable by the build. */

@font-face {
  font-family: "Anuphan Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 700;
  src: url(/assets/anuphan-thai-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Anuphan Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 700;
  src: url(/assets/anuphan-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/assets/geist-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Native scrollbars, the textarea's resize grip and the dialog's
     backdrop in the dark scheme, as on the main site. */
  color-scheme: dark;
  --bg: #000;
  --fg: hsl(0 0% 97%);
  --fg-2: hsl(210 6% 76%);
  --muted: hsl(210 5% 58%);
  --card: hsl(210 8% 6%);
  --border: hsl(210 8% 14%);
  --border-strong: hsl(210 7% 22%);
  --input: hsl(210 7% 19%);
  --primary: hsl(82 85% 53%);
  --primary-fg: hsl(0 0% 4%);
  --accent: hsl(82 30% 12%);
  --accent-fg: hsl(82 70% 80%);
  --ring: hsl(82 85% 53%);
  --error: hsl(0 80% 72%);
  --radius: 0.25rem;
  --radius-btn: 10px;
  --font-latin: "Geist Variable", "Anuphan Variable", Arial, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-thai: "Anuphan Variable", "Geist Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--fg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-latin);
  font-size: clamp(1rem, 0.95rem + 0.15vw, 1.0625rem);
  line-height: 1.6;
  min-height: 100vh;
}
html:lang(th) body { font-family: var(--font-thai); }
:lang(en) { font-family: var(--font-latin); }

.skip { position: absolute; left: 16px; top: -100px; background: var(--primary); color: var(--primary-fg); padding: 10px 14px; border-radius: var(--radius-btn); z-index: 10; }
.skip:focus { top: 12px; }

/* 16 px gutters on a phone; the column never wider than 44rem. */
.wrap { max-width: 44rem; margin: 0 auto; padding: 0 16px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 600; min-height: 44px; }
.brand img { width: 36px; height: 36px; display: block; }
/* The wordmark as the main site sets it (src/components/BrandLink.tsx):
   "Siam" in the brand colour, Geist on every page, never broken. */
.wordmark { font-family: var(--font-latin); font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.wordmark b { color: var(--primary); font-weight: 600; }
/* A compound that stays on one line (html.ts, keep()). */
.nb { white-space: nowrap; }
.lang { color: var(--fg-2); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; padding: 0 8px; border-radius: var(--radius-btn); }
.lang:hover, .brand:hover { color: var(--primary); }

h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.5rem); line-height: 1.2; margin: 1.5em 0 0.4em; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 2em 0 0.6em; }
.lead { color: var(--fg-2); margin: 0 0 2rem; max-width: 38rem; text-wrap: pretty; }
a { color: var(--primary); }
a:hover { text-decoration-thickness: 2px; }

/* ── Fields ──────────────────────────────────────────────────────────── */
.field, fieldset { margin: 0 0 1.5rem; padding: 0; border: 0; min-width: 0; }
label, legend { display: block; font-weight: 600; margin-bottom: 0.2rem; padding: 0; }
.hint { color: var(--muted); font-size: 0.9375rem; margin: 0 0 0.5rem; }
input[type="text"], input[type="email"], input[type="tel"], input[type="url"], textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--input);
  border-radius: var(--radius);
  font: inherit;
  line-height: 1.5;
}
textarea { min-height: 7.5rem; resize: vertical; }
textarea.tall { min-height: 11rem; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, [type="checkbox"]:focus-visible, [type="file"]:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
.is-invalid input, .is-invalid textarea, .is-invalid .check-grid { border-color: var(--error); }
.err { color: var(--error); font-size: 0.9375rem; margin: 0.35rem 0 0; min-height: 0; }
.err:empty { display: none; }
.form-err { margin: 0 0 1rem; font-weight: 600; }
.counter { color: var(--muted); font-size: 0.875rem; margin: 0.3rem 0 0; text-align: right; font-variant-numeric: tabular-nums; }
.links-grid { display: grid; gap: 0.5rem; }
.links-grid .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Checkboxes: each row a 44 px target. */
.check-grid { display: grid; gap: 2px; border: 1px solid transparent; border-radius: var(--radius); }
@media (min-width: 600px) { .check-grid { grid-template-columns: 1fr 1fr; column-gap: 12px; } }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 8px 4px; font-weight: 400; margin: 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.consent { margin: 0 0 1rem; }
.consent .check { padding: 8px 0; }
.linklike { background: none; border: 0; padding: 0 0 2px; min-height: 44px; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; }
.linklike:hover { text-decoration-thickness: 2px; }

/* Files */
input[type="file"] { color: var(--fg-2); font: inherit; max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit; min-height: 44px; padding: 8px 14px; margin: 0 12px 0 0; cursor: pointer;
  color: var(--fg); background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--radius-btn);
}
.file-list { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; gap: 6px; }
.file-list li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9375rem; overflow-wrap: anywhere; }
.file-list .bar { grid-column: 1 / -1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.file-list .bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }
.file-list .state { color: var(--muted); }
.file-list .done .state { color: var(--accent-fg); }
.file-list .failed .state { color: var(--error); }
.file-list button { min-height: 44px; min-width: 44px; background: none; border: 0; color: var(--fg-2); font: inherit; cursor: pointer; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 10px 20px; border-radius: var(--radius-btn);
  font: inherit; font-weight: 600; cursor: pointer;
  color: var(--fg); background: var(--card); border: 1px solid var(--border-strong);
}
.btn:hover { border-color: var(--primary); }
.btn-primary { color: var(--primary-fg); background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: 0.6; cursor: wait; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin: 1.5rem 0 3rem; }
#turnstile { margin: 0 0 1rem; min-height: 65px; }

/* The thank-you state (shown by the client after a real submission). */
#done p { max-width: 38rem; text-wrap: pretty; }
#done .ref { font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; }
#done .note { color: var(--fg-2); }
#done .partial { color: var(--error); }

/* The privacy notice, a native dialog. */
dialog {
  color: var(--fg); background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--radius);
  width: min(100% - 32px, 40rem); max-height: calc(100vh - 32px); padding: 20px 20px 16px; margin: auto;
}
dialog::backdrop { background: rgb(0 0 0 / 0.7); }
dialog h2 { margin: 0 0 0.75rem; }
dialog ol { padding-left: 1.25rem; margin: 0 0 1rem; }
dialog li { margin: 0 0 0.75rem; }
dialog li b { display: block; }
dialog .basis, dialog .version { color: var(--muted); font-size: 0.9375rem; }
dialog form { margin: 1rem 0 0; }

.foot { margin: 3rem auto 2rem; padding-top: 1rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9375rem; }
/* The footer's and the thank-you page's links: 44 px tap targets. */
.foot a, #done a { display: inline-flex; align-items: center; min-height: 44px; }
.noscript { color: var(--error); margin: 0 0 1rem; }

/* ── Admin (server-rendered, English) ────────────────────────────────── */
.adm-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-family: var(--font-latin); }
.adm-brand { color: var(--fg); text-decoration: none; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; gap: 0.35em; }
.adm-logout { min-height: 44px; display: inline-flex; align-items: center; }
/* The list's table scrolls on its own on a phone; the page never does. */
.adm-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
.adm-logout { color: var(--fg-2); }
.adm-top .wordmark { font-weight: 600; }
.adm .wrap { max-width: 64rem; }
.adm h1 { font-size: 1.75rem; }
.adm-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 1.25rem; }
.adm-tab { padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-btn); color: var(--fg-2); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.adm-tab.is-on { color: var(--primary-fg); background: var(--primary); border-color: var(--primary); }
.adm-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.adm-table th, .adm-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.adm-table th { color: var(--muted); font-weight: 600; }
.adm-status { font-size: 1rem; padding: 2px 10px; border-radius: 999px; background: var(--accent); color: var(--accent-fg); vertical-align: middle; }
.adm-status-rejected, .adm-status-withdrawn { background: hsl(0 30% 14%); color: var(--error); }
.adm-meta, .adm-empty, .adm-none { color: var(--muted); }
.adm-dl { display: grid; gap: 1rem; margin: 1.5rem 0; }
.adm-field dt { color: var(--muted); font-size: 0.875rem; margin: 0 0 2px; }
.adm-field dd { margin: 0; overflow-wrap: anywhere; }
.adm-pre { white-space: pre-wrap; }
.adm-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 1rem 0; }
.adm-note textarea { width: 100%; }
.adm-note button { margin-top: 0.5rem; }
.adm-files { padding-left: 1.25rem; }
.adm-orig { color: var(--fg-2); }
