/* Shared WebCheck components for the service pages (home, report, privacy, 404).
   Load after tokens.css. Every color comes from a token so the high-contrast
   modes keep working; the swatches in the display panel are the only exception. */

h3,
h4,
figure,
pre {
  margin: 0;
}

select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--c-primary);
}

a:hover {
  text-decoration-thickness: 2px;
}

/* Shared page shell keeps the footer below short content. */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Top bar ---------- */

.topbar {
  position: relative;
  min-height: 4rem;
  padding: 3px var(--page-gutter) 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}

/* Keep the existing content cap; responsive gutters align the page, bar and footer. */
.topbar__inner {
  width: 100%;
  max-width: calc(var(--page-max, 72rem) - 2rem);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar__home {
  min-width: 0;
  min-height: var(--control-min-height);
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--c-text);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.topbar__logo {
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
}

/* Same name block as the extension side panel: product name + Thai tagline. */
.topbar__brand {
  flex: 1;
  min-width: 0;
}

.topbar__title,
.topbar__subtitle {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__title {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.25;
}

.topbar__subtitle {
  font-size: var(--text-xs);
  line-height: var(--leading-tight);
  color: var(--c-text-muted);
}

/* At 150% the tagline would squeeze the product name; the name matters more,
   so it may wrap instead of being cut to "WebCh…". */
:root[data-font-scale="150"] .topbar__subtitle {
  display: none;
}

:root[data-font-scale="150"] .topbar__title {
  white-space: normal;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

/* Narrow phones: the full product name wraps onto two lines rather than being cut. */
@media (max-width: 26rem) {
  .topbar__title,
  .topbar__subtitle {
    white-space: normal;
    text-overflow: clip;
  }
}

.topbar__actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

:root[data-font-scale="150"] .topbar__logo {
  display: none;
}

:root[data-font-scale="150"] .topbar .icon-button {
  width: 44px;
  height: 44px;
}

/* ---------- Footer ----------
   Shared footer (markup in src/routes/site-footer.ts): one row with the
   copyright on the left and "Powered by NSTDA" on the right; wraps when
   narrow. Body is a flex column, so margin-top: auto keeps it at the bottom
   of short pages. */

.site-footer {
  margin-top: auto;
  padding: var(--space-2) var(--page-gutter);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-muted);
  font-size: var(--text-sm);
}

.site-footer__inner {
  width: 100%;
  max-width: calc(var(--page-max, 72rem) - 2rem);
  min-height: 3rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--space-6);
}

.site-footer__copyright,
.site-footer__powered {
  margin: 0;
}

.site-footer__powered {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.site-footer__powered a {
  min-height: var(--control-min-height);
  display: inline-flex;
  align-items: center;
  color: var(--c-primary);
  font-weight: 700;
}

.site-footer__logo {
  width: auto;
  height: 1.75rem;
}

/* The blue logo would vanish on the contrast modes' black; draw it in the
   mode's foreground colour instead (white, or white on the yellow mode). */
:root[data-contrast="yellow"] .site-footer__logo,
:root[data-contrast="black"] .site-footer__logo {
  filter: brightness(0) invert(1);
}

/* ---------- Buttons ---------- */

.btn {
  min-height: 3rem;
  padding: var(--space-2) var(--space-5);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: var(--leading-tight);
  text-align: center;
  text-decoration: none;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.btn--block {
  width: 100%;
}

.btn--primary {
  background: var(--c-primary);
  color: var(--c-on-primary);
  border-color: var(--c-primary);
}

.btn--primary:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--c-primary-hover);
  border-color: var(--c-primary-hover);
}

.btn--secondary {
  background: var(--c-surface);
  color: var(--c-primary);
  border-color: var(--c-primary);
  border-width: 1px;
}

.btn--secondary:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--c-tint);
}

.btn--small {
  min-height: var(--control-min-height);
  padding: var(--space-1-5) var(--space-4);
  font-size: var(--text-md);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--c-disabled-bg);
  color: var(--c-disabled-text);
  border: 1px dashed var(--c-disabled-border);
  cursor: progress;
}

.icon-button {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--c-navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover,
.icon-button[aria-expanded="true"] {
  background: var(--c-tint);
  border-color: var(--c-border);
}

.icon-button--small {
  color: var(--c-text-muted);
}

/* ---------- Surfaces ---------- */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
}

.badge {
  min-height: 1.5rem;
  padding: 0 var(--space-2-5);
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: var(--leading-tight);
  white-space: nowrap;
  background: var(--c-tint);
  color: var(--c-on-tint);
}

.badge[data-tone="error"] {
  background: var(--c-error-bg);
  color: var(--c-error-text);
}

.badge[data-tone="warning"] {
  background: var(--c-warning-bg);
  color: var(--c-warning-text);
}

.badge[data-tone="notice"] {
  background: var(--c-notice-bg);
  color: var(--c-notice-text);
}

.badge[data-tone="success"] {
  background: var(--c-success-bg);
  color: var(--c-success-text);
}

:root[data-contrast="yellow"] .badge,
:root[data-contrast="black"] .badge {
  border-color: var(--c-fg);
}

.alert,
.note {
  padding: var(--space-3) var(--space-3-5);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2-5);
  font-size: var(--text-md);
  line-height: 1.55;
}

.alert {
  border-color: var(--c-error-border);
  background: var(--c-error-bg);
  color: var(--c-text);
}

.alert__icon {
  margin-top: 0.1875rem;
  color: var(--c-error-text);
}

.alert__body {
  min-width: 0;
  display: grid;
  gap: 0.125rem;
  justify-items: start;
}

.alert__title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--c-error-text);
  overflow-wrap: anywhere;
}

.alert__text {
  overflow-wrap: anywhere;
}

.note {
  background: var(--c-tint);
  color: var(--c-on-tint);
}

.note svg {
  margin-top: 0.1875rem;
}

.note[data-tone="warning"] {
  background: var(--c-warning-bg);
  color: var(--c-warning-text);
}

.note[data-tone="notice"] {
  background: var(--c-notice-bg);
  color: var(--c-notice-text);
}

.note[data-tone="success"] {
  background: var(--c-success-bg);
  color: var(--c-success-text);
}

:root[data-contrast="yellow"] .note,
:root[data-contrast="black"] .note {
  border-color: var(--c-fg);
}

/* ---------- Spinner ---------- */

.spinner {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  border: 3px solid var(--c-tint);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

:root[data-contrast="yellow"] .spinner,
:root[data-contrast="black"] .spinner {
  border-color: var(--c-surface);
  border-top-color: var(--c-fg);
}

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

/* ---------- Display settings popover ---------- */

.popover {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 20;
  width: min(22rem, calc(100vw - 2 * var(--page-gutter)));
  max-height: calc(100vh - 6rem);
  overflow: auto;
  padding: var(--space-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  display: grid;
  gap: var(--space-4);
}

.popover__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.popover__title {
  font-size: var(--text-xl);
  font-weight: 700;
}

.field {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  display: grid;
  gap: var(--space-2);
}

.field__label {
  padding: 0;
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.4;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}

.tile {
  position: relative;
  min-height: 4rem;
  padding: var(--space-1-5) var(--space-1);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  cursor: pointer;
}

.tile input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.tile:hover {
  border-color: var(--c-selected-border);
}

.tile:has(input:checked) {
  background: var(--c-selected-bg);
  color: var(--c-selected-text);
  border-color: var(--c-selected-border);
  box-shadow: inset 0 0 0 1px var(--c-selected-border);
}

.tile:has(input:focus-visible) {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.tile__glyph {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
}

.tile__glyph--sm {
  font-size: var(--text-sm);
}

.tile__glyph--lg {
  font-size: var(--text-heading-lg);
}

.tile__label {
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: var(--leading-tight);
  text-align: center;
}

/* Swatches preview each mode, so their colors stay fixed on purpose. */
.swatch {
  width: 2.5rem;
  height: 2rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-md);
  font-weight: 700;
}

.swatch--normal {
  background: #FFFFFF;
  color: #050505;
  border: 1px solid #C9CED6;
}

.swatch--yellow {
  background: #050505;
  color: #FFFB00;
  border: 1px solid #FFFB00;
}

.swatch--black {
  background: #050505;
  color: #FFFFFF;
  border: 1px solid #FFFFFF;
}

/* ---------- Criteria list (native <details>) ----------
   Used for the WCAG 2.2 criteria that need a manual check. */

.criteria-details > summary {
  min-height: var(--control-min-height);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
  list-style: none;
}

.criteria-details > summary::-webkit-details-marker {
  display: none;
}

.criteria-details > summary::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--duration-fast) ease;
}

.criteria-details[open] > summary::before {
  transform: rotate(45deg);
}

.criteria-details > summary:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
  border-radius: 4px;
}

.criteria-list {
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-2);
}

.criteria-list li {
  display: grid;
}

.criteria-list a {
  font-weight: 600;
  color: inherit;
  overflow-wrap: anywhere;
}

.criteria-list__summary {
  font-size: var(--text-sm);
  line-height: 1.45;
}

/* ---------- Link field ---------- */

.link-field__input {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: var(--control-min-height);
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text);
}

.link-field__input:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--c-focus);
}

/* ---------- Text inputs ---------- */

.input {
  width: 100%;
  min-height: var(--control-min-height);
  padding: 0 var(--space-3-5);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: var(--text-base);
  transition: border-color var(--duration-fast) ease;
}

.input::placeholder {
  color: var(--c-text-muted);
  opacity: 1;
}

.input:hover {
  border-color: var(--c-primary);
}

.input.is-error,
.input[aria-invalid="true"] {
  border: 2px solid var(--c-error-text);
}

/* ---------- Copyable code ----------
   Both HTML and selectors use this component; data-copy is the JS hook. */

.code-block {
  position: relative;
}

.code-block__code {
  min-height: var(--control-min-height);
  padding: var(--space-2-5) 3rem var(--space-2-5) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code-block__copy {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--c-text-muted);
  cursor: pointer;
}

.code-block__copy:hover,
.code-block__copy:focus-visible {
  color: var(--c-primary);
  background: var(--c-surface);
}

.code-block__feedback:not(.sr-only) {
  display: block;
  margin-top: var(--space-1-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--c-error-text);
}

/* Keep colour feedback; reduced motion only stops movement. */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }

  .criteria-details > summary::before {
    transition: none;
  }
}
