/* Shared styles for the TadPOC authentication page (web/login.html).
   Conventions match the app: Target red, #005a9c focus ring, error text (not
   color alone). The app shell (index.html) keeps its own inline styles. */

:root {
  /* Brand (constant in both themes). */
  --target-red: #cc0000;
  --target-dark-red: #aa0000;
  --text-light: #f5f5f5;
  --focus-ring-on-dark: #ffffff;
  /* Theme tokens (light defaults; overridden under [data-theme="dark"]). */
  --bg-off: #f9f9f9;
  --bg-light: #ffffff;
  --text-dark: #333333;
  --text-secondary: #444444;
  --border: #767676;        /* UI border (inputs) */
  --border-soft: #dddddd;   /* decorative border */
  --focus-ring: #005a9c;
  --link: #005a9c;
  --error: #b30000;
  --success-text: #1b5e20;
  --success-border: #2e7d32;
  --field-bg: #ffffff;
  --ts-scale: 1;
  color-scheme: light;
  font-size: calc(100% * var(--ts-scale));
}
:root[data-theme="dark"] {
  --bg-off: #121212;
  --bg-light: #1e1e1e;
  --text-dark: #f2f2f2;
  --text-secondary: #c2c2c2;
  --border: #8a8a8a;
  --border-soft: #3a3a3a;
  --focus-ring: #9ecbf0;
  --link: #7fb6e6;
  --error: #ff8a80;
  --success-text: #8ce0a0;
  --success-border: #2a5a36;
  --field-bg: #2a2a2a;
  color-scheme: dark;
}
:root[data-text-size="85"]  { --ts-scale: 0.85; }
:root[data-text-size="100"] { --ts-scale: 1; }
:root[data-text-size="115"] { --ts-scale: 1.15; }
:root[data-text-size="130"] { --ts-scale: 1.3; }
:root[data-text-size="150"] { --ts-scale: 1.5; }

* {
  box-sizing: border-box;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-off);
  color: var(--text-dark);
  line-height: 1.5;
}

header.site-header {
  background: var(--target-red);
  color: var(--text-light);
  padding: 1rem 1.5rem;
}

.site-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: bold;
}

main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 2rem auto;
  padding: 0 1rem;
}

h1 {
  color: var(--target-red);
  margin-top: 0;
}

.auth-section {
  background: var(--bg-light);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.auth-section h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

label {
  display: block;
  font-weight: bold;
  margin-bottom: 0.35rem;
}

input[type="email"],
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.field {
  margin-bottom: 1rem;
}

.input-with-toggle {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.input-with-toggle input {
  flex: 1;
  margin-bottom: 0;
}
.pw-toggle {
  flex: 0 0 auto;
  white-space: nowrap;
  background: var(--bg-light);
  color: var(--focus-ring);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 0.75rem;
  font-weight: bold;
  cursor: pointer;
}

button.primary {
  width: 100%;
  padding: 0.75rem;
  background: var(--target-red);
  color: var(--text-light);
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}
button.primary:hover { background: var(--target-dark-red); }
button.primary[aria-disabled="true"] { opacity: 0.7; cursor: progress; }

button.link {
  background: none;
  border: none;
  color: var(--focus-ring);
  text-decoration: underline;
  font-size: 1rem;
  padding: 0.25rem 0;
  cursor: pointer;
}

.help {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 0.75rem;
}

.required-note { font-weight: normal; }

/* Field-level error text. Carries "Error:" so meaning is not color-only. */
.field-error {
  color: var(--error);
  font-weight: bold;
  margin: 0.25rem 0 0;
}
.field-error[hidden] { display: none; }

/* Per-form error summary: focusable region, NOT a live region. */
.error-summary {
  border: 2px solid var(--error);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.error-summary[hidden] { display: none; }
.error-summary h3 {
  margin: 0 0 0.5rem;
  color: var(--error);
  font-size: 1rem;
}
.error-summary ul { margin: 0; padding-left: 1.25rem; }
.error-summary a { color: var(--error); }

/* Persistent success confirmation that replaces a completed form. Focus moves
   here so the outcome is durable, not just a transient announcement. */
.success-panel {
  border: 2px solid var(--success-border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
}
.success-panel h3 { margin: 0 0 0.5rem; color: var(--success-text); font-size: 1rem; }
.success-panel p { margin: 0; }

/* Visually hidden but available to assistive tech (the live status regions). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

.site-footer {
  padding: 1rem 1.5rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
}
.site-footer small { font-size: 0.8rem; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--bg-light);
  color: var(--focus-ring);
  font-weight: bold;
  text-decoration: underline;
  border: 2px solid var(--focus-ring);
}
.skip-link:focus { left: 0; }

/* Visible focus indicator (WCAG 2.4.13 / 1.4.11). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}
main:focus { outline: none; }

/* Display preference controls (text size + theme) in the header. */
header.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}
.display-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.text-size-controls { display: inline-flex; gap: 0.25rem; }
.display-btn {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--text-light);
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  min-height: 2.25rem;
}
.display-btn:hover { background: rgba(255, 255, 255, 0.15); }
.display-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.display-btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--text-light); }
.display-btn[aria-pressed="true"]::before { content: "\2713\00a0"; }
/* White focus ring on the red header (the global ring is the blue token). */
.site-header .display-btn:focus-visible { outline-color: var(--focus-ring-on-dark); }
@media (forced-colors: active) {
  .display-btn { border: 1px solid ButtonBorder; }
  .display-btn:focus-visible { outline: 3px solid Highlight; outline-offset: 2px; }
  .display-btn[aria-pressed="true"] { outline: 2px solid CanvasText; outline-offset: -4px; }
  .display-btn:disabled { color: GrayText; border-color: GrayText; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
