/* styles.css — the pairing site's only stylesheet.
   CSP here is default-src 'none'; style-src 'self': no inline <style>, no
   style="" attributes anywhere in the markup or the JS. Every dynamic
   visual state (hidden/shown, changed/unchanged, over-budget) is a class
   toggle, never an inline style, and this file is the only place a colour
   or a size is written down. */

/* ---- deliberate size decision: no web font -----------------------------
   Devanagari renders from the phone's own system font. A Devanagari
   webfont is well over 100 KB and this page has to open on a mid-range
   Android phone on a slow connection, so the stack below names the
   Devanagari faces that already ship on the common platforms — Noto Sans
   Devanagari and (older) Droid Sans Devanagari on Android, Kohinoor
   Devanagari on iOS, Nirmala UI/Mangal on Windows — and falls back to the
   platform's generic sans-serif for anything else. Nothing is downloaded
   for this. -------------------------------------------------------------- */
:root {
  --font-stack: 'Noto Sans Devanagari', 'Droid Sans Devanagari', 'Kohinoor Devanagari',
    'Nirmala UI', Mangal, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --color-bg: #fbf8f3;
  --color-surface: #ffffff;
  --color-text: #201a12;
  --color-text-muted: #5b5142;
  --color-border: #ddd2bd;
  --color-primary: #b45309;
  --color-primary-text: #ffffff;
  --color-primary-active: #92400e;
  --color-accent: #0f6e5c;
  --color-error: #b3261e;
  --color-error-bg: #fbeceb;
  --color-note-bg: #fbf1de;
  --color-focus: #1d4ed8;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --tap-min: 44px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-stack);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
}

/* ---- header ------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-primary-active);
}

.lang-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.lang-toggle button {
  border: 0;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-stack);
  font-size: 0.85rem;
  padding: var(--space-2) var(--space-3);
  min-height: var(--tap-min);
  cursor: pointer;
}

.lang-toggle button + button {
  border-inline-start: 1px solid var(--color-border);
}

.lang-toggle button[aria-pressed='true'] {
  background: var(--color-primary);
  color: var(--color-primary-text);
  font-weight: 600;
}

/* showScreen() in app.js moves focus to the new screen's <h1> so that a
   screen reader announces the change. That focus is programmatic and is
   never the end of a keyboard journey, so its ring carries no information.
   Chrome on Android draws its default outline for it, and the result is a
   black box around the heading. OBSERVED ON A PHONE 2026-08-19, on the
   first run of this site on real hardware. The focus MOVE stays: it is what
   makes the screen change audible. Only the ring goes, and only for the
   heading that app.js gave tabindex="-1". */
main h1[tabindex='-1']:focus {
  outline: none;
}

.lang-toggle button:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* ---- main / screens ------------------------------------------------- */

main {
  flex: 1;
  padding: var(--space-5) var(--space-4) var(--space-6);
}

main > section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

main > section[hidden] {
  display: none;
}

/* privacy.html and 404.html show both language sections at once, unlike
   the app shell above where only one screen is ever visible. */
.bilingual-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.bilingual-main section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.bilingual-main h2 {
  font-size: 1.2rem;
}

/* ---- index.html, the placeholder home page --------------------------
   Same bilingual shell as privacy.html and 404.html, plus a mark and a
   lead line. No inline style and no <style> block: CSP forbids both. */
.home-main {
  gap: var(--space-6);
  text-align: center;
}

.home-main section {
  align-items: center;
}

.home-mark {
  width: 120px;
  height: 68px;
  align-self: center;
  overflow: visible;
}

.home-mark-arc {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 2;
  stroke-linecap: round;
}

.home-mark-tick {
  stroke: var(--color-text-muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.home-mark-sun {
  fill: var(--color-primary);
}

.home-lead {
  font-size: 1.05rem;
  color: var(--color-text);
}

.home-main p:not(.home-lead) {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

h1 {
  font-size: 1.4rem;
  line-height: 1.3;
  margin: 0;
}

h2 {
  font-size: 1.05rem;
  margin: 0;
}

p {
  margin: 0;
  color: var(--color-text);
}

.note {
  background: var(--color-note-bg);
  border-radius: 8px;
  padding: var(--space-3);
  font-size: 0.92rem;
  color: var(--color-text-muted);
}

.note-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

/* ---- buttons ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: var(--space-3) var(--space-4);
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: var(--font-stack);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: center;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
}

.btn-primary:active {
  background: var(--color-primary-active);
}

.btn-primary:disabled {
  background: var(--color-border);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary-active);
  border-color: var(--color-primary);
}

.btn-text {
  background: transparent;
  color: var(--color-accent);
  font-weight: 500;
  width: auto;
  padding: var(--space-2) var(--space-1);
}

.action-pair,
.action-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Equal visual weight for the two consent actions — neither is a
   secondary/failure-styled option. */
.action-pair .btn {
  background: var(--color-primary);
  color: var(--color-primary-text);
}

.action-pair .btn:active {
  background: var(--color-primary-active);
}

/* ---- spinner ------------------------------------------------------ */

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  animation: spin 0.9s linear infinite;
  align-self: center;
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- confirm screen ------------------------------------------------ */

.confirm-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: var(--space-4);
}

.confirm-fact {
  display: contents;
}

.confirm-fact dt {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.confirm-fact dd {
  margin: 0;
  font-weight: 600;
  word-break: break-word;
}

/* ---- city picker ---------------------------------------------------- */

#city-search {
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-family: var(--font-stack);
  font-size: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
}

.field-label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
}

.city-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.city-item {
  display: block;
  width: 100%;
  min-height: var(--tap-min);
  text-align: start;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-stack);
  font-size: 0.98rem;
  cursor: pointer;
}

.city-item:active {
  background: var(--color-note-bg);
}

.city-states {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.city-state {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
}

.city-state summary {
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
}

.city-state .city-list {
  padding-block-start: var(--space-2);
}

/* ---- settings form --------------------------------------------------- */

.settings-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-block-start: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.settings-group:first-child {
  border-top: 0;
  padding-block-start: 0;
}

.settings-group-heading {
  color: var(--color-primary-active);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  position: relative;
  padding: var(--space-2) 0;
}

.field input[type='text'],
.field input[type='password'],
.field input[type='number'],
.field input[type='time'] {
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font-stack);
  font-size: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}

.field select {
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font-stack);
  font-size: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}

.field input:disabled,
.field select:disabled {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.field input[aria-invalid='true'],
.field select[aria-invalid='true'] {
  border-color: var(--color-error);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-min);
}

.switch-input {
  width: 24px;
  height: 24px;
  flex: none;
}

.field-byte-note {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0;
}

.field-byte-note--over {
  color: var(--color-error);
  font-weight: 600;
}

.field-disabled-note {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0;
}

.field-will-send {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-accent);
  background: #e3f3ef;
  border-radius: 999px;
  padding: 2px var(--space-2);
}

.field--changed input,
.field--changed select {
  border-color: var(--color-accent);
}

.field-error {
  font-size: 0.85rem;
  color: var(--color-error);
  margin: 0;
}

.settings-advanced {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: var(--space-3);
}

.settings-advanced summary {
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
}

.settings-advanced-warn {
  font-size: 0.85rem;
  color: var(--color-error);
  background: var(--color-error-bg);
  border-radius: 8px;
  padding: var(--space-3);
  margin-block: var(--space-3);
}

.settings-changed-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-accent);
  text-align: center;
}

.problem-field-list {
  margin: 0;
  padding-inline-start: var(--space-5);
  color: var(--color-error);
  font-size: 0.9rem;
}

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

.site-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  text-align: center;
}

.site-footer p {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 0;
}

.site-footer a {
  color: var(--color-accent);
  font-size: 0.85rem;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
}

/* ---- small screens guard: never scroll sideways ----------------------- */

@media (max-width: 359px) {
  main {
    padding-inline: var(--space-3);
  }
}
