/* Accessibility and narrow-screen refinements, layered after the existing theme. */

.skip-link { position: fixed; z-index: 100; inset-block-start: .5rem; inset-inline-start: .5rem; padding: .75rem 1rem; background: #f2f2ef; color: #101112; font-weight: 800; transform: translateY(-150%); }
.skip-link:focus-visible { transform: none; outline: 3px solid var(--amber); outline-offset: 2px; }
#app:focus-visible { outline: 3px solid var(--amber); outline-offset: -3px; }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

footer, .site-about strong, .site-about .game-attribution { color: #b6b8ba; }
@media (width > 700px) {
  .topbar { block-size: auto; min-block-size: 4rem; }
}

/* Let the page title, tabs, and forms respond to enlarged system text. */
.page-head > div:first-child { min-inline-size: 0; }
.page-head h1, .page-head p { overflow-wrap: anywhere; }
.class-tabs, .slot-tabs { scrollbar-width: thin; scrollbar-color: #85888c #202125; }
.class-scroll-hint { display: none; margin: 0; color: #b6b8ba; font-size: .6875rem; }
.toolbar, .toolbar .search { min-inline-size: 0; max-inline-size: 100%; }
.toolbar .search { inline-size: 100%; }
.toolbar .search input { flex: 1 1 0; inline-size: 0; }

/* A real table remains readable with keyboard and touch scrolling. */
.table-scroll-hint { margin: 0 0 .25rem; color: #c3c5c8; font-size: .6875rem; }
.table-wrap { --table-compare-width: 4.875rem; max-block-size: min(75vh, 48rem); overscroll-behavior: contain; scrollbar-width: thin; }
.table-wrap:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.table-wrap table { border-collapse: separate; border-spacing: 0; }
.table-wrap caption { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.table-wrap thead th { position: sticky; inset-block-start: 0; z-index: 3; background: #202125; }
.table-wrap tbody tr { cursor: default; }
.table-wrap tbody th[scope=row] { position: sticky; inset-inline-start: 0; z-index: 2; background: #171819; padding-block: 15px; color: inherit; font-size: inherit; text-transform: none; }
.table-wrap tbody tr:hover th[scope=row] { background: #1c1d20; }
.table-wrap:has(.compare-cell) tbody th[scope=row] { inset-inline-start: var(--table-compare-width); }
.table-wrap :is(.compare-cell, .compare-table-heading) { inline-size: var(--table-compare-width); min-inline-size: var(--table-compare-width); }
.table-wrap .compare-cell { position: sticky; inset-inline-start: 0; z-index: 2; background: #171819; }
.table-wrap thead .compare-table-heading { inset-inline-start: 0; z-index: 4; }
.table-wrap:has(.compare-cell) thead th:nth-child(2) { inset-inline-start: var(--table-compare-width); z-index: 4; }
.table-wrap:not(:has(.compare-cell)) thead th:first-child { inset-inline-start: 0; z-index: 4; }
.table-wrap tbody tr:hover .compare-cell { background: #1c1d20; }
.table-weapon-open { position: relative; border: 0; background: transparent; color: inherit; padding: 0; font: inherit; text-align: start; }
.table-weapon-open:hover { color: var(--red); text-decoration: underline; }

.compare-check:focus-within { outline: 3px solid var(--amber); outline-offset: 2px; }
.map-filter-group label, .map-vehicle-filter > label { white-space: normal; }
.map-vehicle-filter > label > span:not(.map-vehicle-count) { overflow-wrap: anywhere; }

/* The native dialog is a transparent full-screen shell for the existing panels. */
dialog#overlay:not([open]) { display: none !important; }
dialog#overlay[open] { position: fixed; inset: 0; margin: 0; padding: 0; border: 0; inline-size: 100vw; max-inline-size: none; block-size: 100dvh; max-block-size: none; overflow: hidden; overscroll-behavior: contain; background: transparent; color: var(--text); }
dialog#overlay::backdrop { background: #000b; overflow: hidden; overscroll-behavior: contain; }
dialog#overlay[open].map-overlay { background: transparent; }
dialog#overlay[open] .shade { background: transparent; }
body.modal-open { overflow: visible; }

/* Errors stay visible beside their fields and include text as well as a border. */
.form-feedback-error, .field-error { color: var(--text); font-size: .75rem; line-height: 1.45; }
.form-feedback-error { border-inline-start: 3px solid var(--red); background: #351b20; padding: .5rem .625rem; margin-block: .5rem; }
.field-error { display: block; margin-block-start: .25rem; }
.form-feedback-status { color: #d9e4dd; font-size: .8125rem; line-height: 1.45; margin-block: .5rem; }
.form-feedback-error[hidden], .form-feedback-status[hidden], .field-error[hidden] { display: none !important; }
:is(input, select, textarea):is(.user-invalid-fallback, :user-invalid) { border-color: var(--red); box-shadow: inset 3px 0 var(--red); }
.report-update { flex-wrap: wrap; }
.report-update .form-feedback { flex: 0 0 100%; order: 2; }

@media (max-width: 700px) {
  .loadout-class-row .class-tabs, .class-tabs { flex-wrap: nowrap; overflow-x: auto; min-inline-size: 0; max-inline-size: 100%; }
  .loadout-class-row .class-scroll-hint { grid-column: 1; }
  .class-tabs[data-more-start="true"] + .class-scroll-hint, .class-tabs[data-more-end="true"] + .class-scroll-hint { display: block; }
  .toolbar > label:not(:first-child) { min-inline-size: 0; max-inline-size: 100%; }
  .toolbar select { max-inline-size: 100%; }
  .edit-grid { grid-template-columns: minmax(0, 1fr); }
  .edit-field, .edit-field > label, .edit-field :is(input, select, textarea),
  .edit-modal form { min-inline-size: 0; max-inline-size: 100%; }
  .map-objective-toolbar > span { display: block; flex-basis: 100%; }
  .map-filters { min-inline-size: 0; }
  .map-filter-panel { max-inline-size: calc(100vw - 24px); }
  .map-controls { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); right: calc(10px + env(safe-area-inset-right, 0px)); }
  .map-notices, .map-notices:has(.map-help[open]) {
    left: calc(10px + env(safe-area-inset-left, 0px));
    bottom: calc(10px + 34px + 8px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100% - 20px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    max-height: calc(100% - 80px - env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 600px) {
  .toolbar > label:not(:first-child) { min-inline-size: min(100%, 6.25rem); }
  .toolbar select { padding-inline: .5rem; }
}

@media (pointer: coarse) {
  /* Give the checkbox more clearance from the card's open button. */
  .weapon-card .compare-check { margin-inline-end: -1px; padding-inline-end: 5px; }
  /* A weapon name can use the spare space inside its table row. */
  .table-weapon-open::after { content: ''; position: absolute; inset: -.75rem 0; }
}

@media (forced-colors: active) {
  .brand-mark, .button:not(.secondary), .class-tabs button.active, .slot-tabs button.active,
  .view-switch button.active, .map-mode-tabs button[aria-pressed=true] { color: ButtonText; border: 2px solid ButtonText; }
  .sort-header.active, .class-tabs button.active, .slot-tabs button.active,
  .section-nav button.active, .compare-check:has(input:checked) { outline: 2px solid Highlight; outline-offset: -2px; }
  .table-wrap tbody th[scope=row], .table-wrap .compare-cell, .table-wrap thead th { background: Canvas; }
  .bar, .bar i, .bar .bar-base, .bar .bar-change { border: 1px solid CanvasText; }
  .form-feedback-error, .field-error { color: CanvasText; border-color: CanvasText; }
  :is(input, select, textarea):is(.user-invalid-fallback, :user-invalid) { border-color: Highlight; outline: 1px solid Highlight; }
  :is(button, input, select, textarea, summary, a, .table-wrap):focus-visible { outline: 3px solid Highlight; }
}

@media (prefers-reduced-motion: reduce) {
  .skip-link, .weapon-card, .map-card, .map-cover img, .comparison-column,
  .map-objective-marker[data-action=map-point] { transition: none; animation: none; }
  .weapon-card:hover { transform: none; }
}
