/* Spare Parts Lookup - the one site stylesheet (UX-DR1). Self-hosted only: no external URL anywhere. */

/* Roboto / Roboto Mono, latin subset, WOFF2 (wwwroot/fonts, see VERSION.txt and LICENSE.txt). */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/roboto-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/roboto-latin-500-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/roboto-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/roboto-mono-latin-400-normal.woff2") format("woff2");
}

:root {
  /* Theme tokens (UX-DR1). */
  --color-accent: #BE0027;
  --color-text: #4A4A4A;
  --color-secondary: #54595F;
  --color-long-text: #000000CC;
  --color-band: #F6F6F6;
  --color-background: #FFFFFF;

  --font-sans: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, Consolas, monospace;

  --focus-ring: 3px solid var(--color-accent);
  --card-max-width: 40rem;
  --gutter: 1rem;
  --logo-max-height: 3.5rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 0;
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
h4 {
  color: var(--color-text);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.75em;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.25rem;
  margin-top: 1.5em;
}

h3,
h4 {
  font-size: 1.0625rem;
  font-weight: 500;
  margin-top: 1.25em;
}

p,
ul,
ol {
  margin: 0 0 1em;
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 2px;
}

strong,
b {
  font-weight: 600;
}

code,
kbd,
samp,
.mono {
  font-family: var(--font-mono);
}

img {
  max-width: 100%;
}

/* Visible accent focus ring on every focusable element (UX-DR8). */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* ---- Shell (UX-DR2): logo top left, one centred card on the band, footer. No site menu. ---- */

.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.shell-header {
  padding: var(--gutter);
}

.shell-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: var(--logo-max-height);
}

.shell-band {
  flex: 1 0 auto;
  background: var(--color-band);
  padding: 2rem var(--gutter);
}

.shell-card {
  max-width: var(--card-max-width);
  margin: 0 auto;
  padding: 1.5rem;
  background: var(--color-background);
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.shell-card > :last-child,
.shell-card > :last-child > :last-child {
  margin-bottom: 0;
}

.shell-footer {
  padding: 1rem var(--gutter) 1.5rem;
  color: var(--color-secondary);
  font-size: 0.875rem;
  text-align: center;
}

.shell-footer p {
  margin: 0 0 0.5em;
}

.shell-company {
  /* The company text may hold line breaks; it is plain encoded text, so they are kept with CSS. */
  white-space: pre-line;
}

.shell-links a {
  display: inline-block;
  min-height: 44px;
  padding: 0.6rem 0.25rem;
}

/* ---- Privacy notice (FR-22) ---- */

.privacy-notice {
  color: var(--color-long-text);
}

/* ---- Human Check (FR-01b, UX-DR3): reason above the widget, widget centred, accent-themed ---- */

.human-check-reason {
  color: var(--color-accent);
  font-weight: 500;
}

.human-check-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.human-check-form noscript p,
.human-check-no-js {
  margin: 0;
  text-align: center;
}

/* altcha.css defines its variables on :root; set on the widget element, these win for everything inside it. */
.human-check-widget {
  display: block;
  width: 100%;
  max-width: 320px;
  --altcha-color-primary: var(--color-accent);
  --altcha-checkbox-outline-color: var(--color-accent);
  --altcha-checkbox-border-color: var(--color-secondary);
}

.human-check-submit {
  min-height: 44px;
  padding: 0.6rem 1.5rem;
  border: 0;
  border-radius: 0.25rem;
  background: var(--color-accent);
  color: var(--color-background);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.human-check-submit:hover {
  filter: brightness(0.92);
}

/* ---- Language (FR-04/05, UX-DR4/5/6): sphere flags, the Language page row and the search-page indicator ---- */

.language-page {
  text-align: center;
}

.language-flags {
  --flag-size: 72px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1.5rem;
  margin: 0;
}

.flag-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  color: var(--color-text);
  font-weight: 500;
}

.flag-button {
  margin: 0;
  padding: 0.25rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* The "sphere": a flat SVG cropped to a circle, a soft rim shade and a light highlight, all CSS. */
.flag {
  position: relative;
  display: block;
  flex: none;
  width: var(--flag-size);
  height: var(--flag-size);
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-band);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.flag img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

.flag::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.6) 0, rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 58%, rgba(0, 0, 0, 0.22) 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.flag-button:hover .flag,
.flag-button:focus-visible .flag {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
}

.flag-button:active .flag {
  animation: flag-press 220ms ease-out;
}

@keyframes flag-press {
  0% {
    transform: translateY(-3px) scale(1.06);
  }

  45% {
    transform: translateY(0) scale(0.94);
  }

  100% {
    transform: translateY(-3px) scale(1.06);
  }
}

/* The compact indicator on the search page: the current flag, then the two others as buttons. */
.language-indicator {
  --flag-size: 44px;
  justify-content: flex-end;
  gap: 0.75rem;
}

.language-indicator-label {
  align-self: center;
  color: var(--color-secondary);
  font-size: 0.875rem;
}

.language-indicator .flag-item {
  gap: 0.25rem;
  font-size: 0.75rem;
}

.language-indicator .flag-button {
  padding: 0;
}

/* The other two Languages: slightly smaller and translucent; hover/focus restores full size and opacity. */
.language-indicator .flag-button .flag {
  opacity: 0.55;
  transform: scale(0.82);
  transition: transform 180ms ease, opacity 180ms ease, box-shadow 180ms ease;
}

.language-indicator .flag-button:hover .flag,
.language-indicator .flag-button:focus-visible .flag {
  opacity: 1;
  transform: scale(1);
}

/* The current Language: a permanent neutral ring (not the accent focus ring) and a bolder name. */
.flag-current .flag {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 0 0 2px var(--color-secondary);
}

.flag-current .flag-name {
  font-weight: 600;
}

.search-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem 1.5rem;
}

.search-header h1 {
  margin: 0;
}

/* ---- Search (FR-08..FR-11, UX-DR7): one Serial field and the accent button, centred; one message area ---- */

.search-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin: 1.5rem 0 0;
}

.search-label {
  font-weight: 500;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
}

.search-input {
  flex: 0 1 16rem;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-secondary);
  border-radius: 0.25rem;
  background: var(--color-background);
  color: var(--color-text);
  font-size: 1.125rem;
  letter-spacing: 0.05em;
  text-align: center;
}

.search-submit,
.search-download-link {
  display: inline-block;
  min-height: 44px;
  padding: 0.6rem 1.5rem;
  border: 0;
  border-radius: 0.25rem;
  background: var(--color-accent);
  color: var(--color-background);
  font: inherit;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.search-submit:hover,
.search-download-link:hover {
  filter: brightness(0.92);
}

.search-messages {
  text-align: center;
}

.search-message {
  margin: 1.25rem 0 0;
  font-weight: 500;
}

.search-error {
  color: var(--color-accent);
}

.search-download {
  margin: 0.75rem 0 0;
}

@media (prefers-reduced-motion: reduce) {
  .flag,
  .language-indicator .flag-button .flag {
    transition: none;
  }

  .flag-button:hover .flag,
  .flag-button:focus-visible .flag {
    transform: none;
  }

  .flag-button:active .flag {
    animation: none;
  }
}

@media (max-width: 480px) {
  .language-flags {
    gap: 1rem;
  }

  .language-indicator {
    gap: 0.5rem;
  }

  .shell-band {
    padding: 1rem 0.5rem;
  }

  .shell-card {
    padding: 1rem;
  }
}
