/* =============================================================================
   SJC Kiosk Case Search — Styles
   Design tokens match JCC Components (#005ea2, #1b2b85, #dfe1e2, #565c65)
   No custom font-size declarations — inherits from usa-prose / site globals.
   WCAG 2.1 AA compliant.
   ============================================================================= */

/* ── Layout helpers ───────────────────────────────────────────────────────── */

#ks-login-section {
  max-width: 480px;
}

.ks-header-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #dfe1e2;
}

/* ── Menu (landing page) ──────────────────────────────────────────────────── */

.ks-menu {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.ks-menu li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #dfe1e2;
}

.ks-menu li:last-child {
  border-bottom: none;
}

/* Button styled as a link */
.ks-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #005ea2;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  font: inherit;
}

.ks-link-btn:hover {
  color: #1b2b85;
  text-decoration-thickness: 2px;
}

.ks-link-btn:focus-visible {
  outline: 3px solid #005ea2;
  outline-offset: 3px;
  border-radius: 2px;
}

.ks-example {
  color: #565c65;
  font-style: italic;
  white-space: nowrap;
}

/* ── Back button ──────────────────────────────────────────────────────────── */

.ks-back-btn {
  background: none;
  border: none;
  color: #005ea2;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  font: inherit;
  padding: 0;
  margin-bottom: 1.25rem;
  display: inline-block;
}

.ks-back-btn:hover {
  color: #1b2b85;
}

.ks-back-btn:focus-visible {
  outline: 3px solid #005ea2;
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.ks-btn {
  display: inline-block;
  padding: 0.625rem 1.5rem;
  font-weight: bold;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
  min-width: 44px;
  font: inherit;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ks-btn:focus-visible {
  outline: 3px solid #005ea2;
  outline-offset: 3px;
}

.ks-btn--primary {
  background-color: #005ea2;
  color: #ffffff;
  border-color: #005ea2;
  margin-top: 1rem;
}

.ks-btn--primary:hover {
  background-color: #1b2b85;
  border-color: #1b2b85;
}

.ks-btn--primary:disabled {
  background-color: #aab5c3;
  border-color: #aab5c3;
  cursor: not-allowed;
}

.ks-btn--secondary {
  background-color: transparent;
  color: #005ea2;
  border-color: #005ea2;
}

.ks-btn--secondary:hover {
  background-color: #e8f0f8;
}

/* ── Form fields ──────────────────────────────────────────────────────────── */

.ks-form {
  max-width: 560px;
}

.ks-field {
  margin-bottom: 1rem;
}

.ks-field label {
  display: block;
  font-weight: bold;
  color: #1b2b85;
  margin-bottom: 0.375rem;
}

.ks-field input[type="text"],
.ks-field input[type="email"],
.ks-field input[type="number"],
.ks-field input[type="password"],
.ks-field select,
.ks-field textarea {
  display: block;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #565c65;
  border-radius: 4px;
  background-color: #ffffff;
  box-sizing: border-box;
}

.ks-field input:focus,
.ks-field select:focus,
.ks-field textarea:focus {
  outline: 3px solid #005ea2;
  outline-offset: 2px;
}

.ks-checkbox-row {
  margin-bottom: 1rem;
}

.ks-checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: bold;
  color: #1b2b85;
}

.ks-checkbox-row input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}

.ks-fieldset {
  border: 1px solid #dfe1e2;
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.ks-fieldset legend {
  font-weight: bold;
  color: #1b2b85;
  padding: 0 0.25rem;
}

.ks-year-range {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.ks-year-range .ks-field {
  flex: 1;
  min-width: 120px;
  margin-bottom: 0;
}

.ks-required {
  color: #d63e04;
}

/* ── Feedback ─────────────────────────────────────────────────────────────── */

.ks-error {
  color: #d63e04;
  font-weight: bold;
  margin: 0.5rem 0;
  min-height: 1.25em;
}

.ks-status {
  color: #565c65;
  margin: 0.75rem 0;
  min-height: 1.25em;
}

.ks-disclaimer {
  font-size: 0.875em;
  color: #565c65;
  border-left: 4px solid #dfe1e2;
  padding-left: 1rem;
  margin-bottom: 1.5rem;
}

/* ── Results table ────────────────────────────────────────────────────────── */

.ks-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  border: 1px solid #dfe1e2;
  table-layout: auto;
}

.ks-table caption {
  text-align: left;
  font-weight: bold;
  padding: 0.5rem 0;
}

.ks-table thead {
  background-color: #162e51 !important;
}

.ks-table th {
  background-color: #162e51 !important;
  color: #ffffff !important;
  font-weight: bold;
  text-align: left;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.ks-table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid #dfe1e2;
  vertical-align: top;
}

.ks-table tbody tr:nth-child(even) {
  background-color: #f9f9f9;
}

.ks-table tbody tr:hover {
  background-color: #e8f0f8;
}

/* ── Form instructions ────────────────────────────────────────────────────── */

.ks-form-instructions {
  margin-bottom: 1rem;
}

/* Heading focus — programmatic focus after view navigation; show outline so
   sighted keyboard users can confirm where focus landed (WCAG 2.4.7). */
.ks-view h2:focus,
.ks-view h2:focus-visible {
  outline: 3px solid #005ea2;
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Pagination ───────────────────────────────────────────────────────────── */

/* Pagination nav is now outside <table>; add top margin to separate visually. */
.ks-pagination-nav {
  margin-top: 0.5rem;
}

#ks-party-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  justify-content: center;
  padding: 1rem 0;
}

.ks-page-btn {
  min-width: 44px;
  height: 44px;
  padding: 0 0.75rem;
  background-color: #ffffff;
  color: #005ea2;
  border: 1px solid #005ea2;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-weight: bold;
  transition: background-color 0.15s;
}

.ks-page-btn:hover {
  background-color: #e8f0f8;
}

.ks-page-btn:focus-visible {
  outline: 3px solid #005ea2;
  outline-offset: 3px;
}

.ks-page-btn--active {
  background-color: #005ea2;
  color: #ffffff;
  cursor: default;
}

.ks-page-dots {
  display: inline-flex;
  align-items: center;
  height: 44px;
  color: #565c65;
  padding: 0 0.5rem;
}

/* ── Typeahead ────────────────────────────────────────────────────────────── */

.ks-typeahead-wrap {
  position: relative;
}

.ks-typeahead-dropdown {
  position: absolute;
  z-index: 999;
  top: 100%;
  left: 0;
  right: 0;
  background-color: #ffffff;
  border: 2px solid #005ea2;
  border-top: none;
  border-radius: 0 0 4px 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

.ks-typeahead-option {
  padding: 0.625rem 1rem;
  cursor: pointer;
}

.ks-typeahead-option:hover,
.ks-typeahead-active {
  background-color: #e8f0f8;
  color: #1b2b85;
}

/* ── Case Summary sections ────────────────────────────────────────────────── */

.ks-summary-section {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 2px solid #dfe1e2;
}

.ks-summary-section:first-child {
  border-top: none;
  padding-top: 0;
}

.ks-summary-section h3 {
  color: #1b2b85;
  margin-bottom: 0.75rem;
}

.ks-summary-table {
  overflow-x: auto;
  display: block;
}

/* ── Accessibility helpers ────────────────────────────────────────────────── */

.ks-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media screen and (max-width: 40em) {
  .ks-menu li {
    flex-direction: column;
    gap: 0.25rem;
  }

  .ks-form {
    max-width: 100%;
  }

  .ks-year-range {
    flex-direction: column;
    gap: 1rem;
  }

  .ks-btn--primary {
    width: 100%;
    text-align: center;
  }

  .ks-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* ── High contrast mode ───────────────────────────────────────────────────── */

@media (prefers-contrast: high) {
  .ks-field input,
  .ks-field select {
    border-width: 2px;
  }

  .ks-btn {
    border-width: 3px;
  }

  .ks-typeahead-dropdown {
    border-width: 3px;
  }
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ks-btn,
  .ks-link-btn,
  .ks-page-btn {
    transition: none;
  }
}

/* ── Print ────────────────────────────────────────────────────────────────── */

@media print {
  #ks-login-section,
  #ks-logout-btn,
  .ks-back-btn,
  #ks-party-form,
  #ks-summary-form,
  #ks-party-pagination {
    display: none !important;
  }

  .ks-table thead {
    background-color: #000000 !important;
  }
}
