/* Preisfuchs — design system, SPEC §11.
   A quiet, warm dark like a well-sorted second-hand bookshop in the evening. The only
   loud element on the page is the price tag on the best offer. Everything else stays
   disciplined: no gradients, no shadows, no decoration that carries no information. */

/* Inter, self-hosted (SPEC §11.2). Licence in fonts/Inter-LICENSE.txt. */
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/Inter-Regular.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/Inter-SemiBold.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/static/fonts/Inter-ExtraBold.woff2") format("woff2");
}

/* Design tokens — SPEC §11.1. Dark is the default, light follows the OS setting. */
:root {
  --bg: #141310;        --surface: #1c1a16;   --surface-2: #24211b;
  --border: #322e26;    --text: #ece7dc;      --muted: #a49b8a;
  --accent: #f2a03d;    --accent-deep: #c97f1e; --accent-ink: #221503;
  --ok: #8fae7e;        --err: #c76f5a;
  --radius: 12px;       --radius-s: 8px;

  --touch: 44px;        /* minimum interactive target, SPEC §11.4 */
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: light) {
  :root { --bg:#f5f2ea; --surface:#fffdf7; --surface-2:#f0ecdf;
          --border:#e2dccc; --text:#211f19; --muted:#6f695c;
          --accent:#b3720e; --accent-deep:#8f5a08; --accent-ink:#fffdf7;
          --ok:#5d7f4e; --err:#a4503c; }
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

/* Visible keyboard focus everywhere, SPEC §11.7 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a {
  color: inherit;
}

/* Prices are always tabular so columns line up, SPEC §11.2 */
.num {
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Layout, SPEC §11.3 ---------------------------------------------------------- */

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px;
}

.wordmark {
  margin: 24px 0;
  font-size: 2rem;
  letter-spacing: -0.02em;
  text-transform: lowercase;
}

.wordmark-plain {
  font-weight: 400;
  color: var(--muted);
}

.wordmark-accent {
  font-weight: 800;
  color: var(--accent);
}

/* --- Search block, SPEC §11.4 ---------------------------------------------------- */

.search {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-field {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  /* Never below 16px — anything smaller makes mobile browsers zoom on focus. */
  font-size: 1.1rem;
}

.search-field::placeholder {
  color: var(--muted);
}

.search-field:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Segmented control: three radios that look like one connected switch. */
.segmented {
  display: flex;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  overflow: hidden;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 0 16px;
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
}

.segmented label:last-of-type {
  border-right: 0;
}

.segmented input:checked + label {
  background: var(--surface-2);
  color: var(--text);
}

.segmented input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.button {
  min-height: var(--touch);
  padding: 0 24px;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-deep);
}

.button[disabled] {
  opacity: 0.6;
  cursor: default;
}

/* --- Results ---------------------------------------------------------------------- */

.results {
  margin-top: 40px; /* generous gap between search block and result, SPEC §11.3 */
}

.results > * + * {
  margin-top: 16px;
}

.loading-line,
.state-text {
  color: var(--muted);
}

.card {
  position: relative;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.card-body {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  align-items: start;
}

.thumb {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-s);
  background: var(--surface-2);
  object-fit: contain;
}

.title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  /* At most two lines, then it is cut off. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.total {
  margin-top: 12px;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.2;
}

.breakdown {
  color: var(--muted);
  font-size: 0.85rem;
}

.offer-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  margin-top: 16px;
  padding: 0 20px;
  border-radius: var(--radius-s);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

.offer-link:hover {
  background: var(--accent-deep);
}

/* The signature: a round price sticker as on a second-hand DVD case. The only element
   on the page that is allowed to stand out. SPEC §11.4. */
.best {
  margin-top: 12px; /* room for the badge hanging over the edge */
}

.badge {
  position: absolute;
  top: -12px;
  left: 16px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  transform: rotate(-4deg);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.35);
}

/* --- Alternatives ----------------------------------------------------------------- */

.alternatives {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.alternative .card-body {
  grid-template-columns: 64px 1fr;
}

.alternative .thumb {
  width: 64px;
  height: 64px;
}

.alternative .total {
  font-size: 1.25rem;
}

/* --- Shop chips and the self-check line ------------------------------------------- */

.chips,
.selfcheck {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.85rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}

.chip.failed .dot {
  background: var(--err);
}

/* Chip inside a card: same shape, no status, no touch target. */
.chip-inline {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8rem;
}

.selfcheck-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.link-button:hover {
  color: var(--text);
}

/* --- All hits per shop ------------------------------------------------------------ */

.shop-hits {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.shop-hits summary {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 20px;
  font-weight: 600;
  cursor: pointer;
}

.hit {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.hit-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hit-condition {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.hit-total {
  margin-left: auto;
  font-weight: 600;
  white-space: nowrap;
}

.hit-note {
  color: var(--muted);
  font-weight: 400;
}

/* --- Skeletons -------------------------------------------------------------------- */

.skeleton {
  height: 148px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    var(--surface-2) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background-image: none;
  }
}

/* --- Login page, SPEC §13 --------------------------------------------------------- */

.login {
  max-width: 420px;
}

.error-text {
  margin: 0;
  color: var(--err);
  font-size: 0.9rem;
}

/* --- Footer ----------------------------------------------------------------------- */

.footer {
  margin-top: 40px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* --- Mobile is the normal case, SPEC §11.3 ---------------------------------------- */

@media (max-width: 640px) {
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .segmented {
    justify-content: stretch;
  }

  .segmented label {
    flex: 1;
    padding: 0 8px;
  }

  .button {
    width: 100%;
  }

  .card-body,
  .alternative .card-body {
    grid-template-columns: 1fr; /* image above the text */
  }

  .alternatives {
    grid-template-columns: 1fr;
  }

  .offer-link {
    width: 100%;
  }
}
