/* NBS Auto - one-screen winter tire finder */

:root {
  --ink: #14171c;
  --ink-2: #252a32;
  --muted: #5b6470;
  --line: #d5dae1;
  --bg: #eceef2;
  --card: #ffffff;
  --accent: #d62828;
  --accent-dark: #a91d1d;
  --green: #16a34a;
  --green-dark: #12813b;
  --ice: #1e5fbf;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4b00;

  --gap: clamp(6px, 1.3vh + 2px, 16px);
  --pad: clamp(10px, 2.2vw, 20px);
  --radius: 14px;
  --control-h: clamp(44px, 6.4vh, 58px);
  --btn-h: clamp(48px, 7.2vh, 62px);

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.3;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

a { color: inherit; }

svg { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; }

:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ---------- Header ---------- */

.top {
  background: var(--ink);
  color: #fff;
  border-bottom: 3px solid var(--accent);
  padding-top: env(safe-area-inset-top);
}

.top__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: calc(var(--gap) * 0.8) var(--pad);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "brand phone"
    "info  info";
  align-items: center;
  gap: calc(var(--gap) * 0.6) 12px;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 0;
}

.brand__logo {
  width: clamp(36px, 5.5vh, 52px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
}

.brand__text { display: flex; flex-direction: column; min-width: 0; }

.brand__name {
  font-weight: 900;
  font-size: clamp(1.2rem, 1rem + 1.2vw, 1.75rem);
  letter-spacing: 0.06em;
  line-height: 1;
}

.brand__tag {
  font-size: clamp(0.72rem, 0.68rem + 0.3vw, 0.9rem);
  color: #c4cad3;
  margin-top: 3px;
}

.top__info {
  grid-area: info;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 14px;
  font-size: clamp(0.78rem, 0.72rem + 0.35vw, 0.95rem);
}

.top__info p { margin: 0; }

.walkin {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.walkin strong {
  background: var(--accent);
  padding: 2px 7px;
  border-radius: 5px;
  text-transform: uppercase;
  font-size: 0.92em;
}

.top__hours { color: #dfe3e8; }

.top__phone {
  grid-area: phone;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  text-decoration: none;
  font-weight: 800;
  font-size: clamp(0.9rem, 0.82rem + 0.4vw, 1.1rem);
  white-space: nowrap;
}

.top__phone:hover { border-color: #fff; }

/* ---------- Notice ---------- */

.notice {
  background: var(--warn-bg);
  color: var(--warn-ink);
  text-align: center;
  font-weight: 700;
  font-size: clamp(0.78rem, 0.74rem + 0.25vw, 0.9rem);
  padding: 4px var(--pad);
}

/* ---------- Main ---------- */

.main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: var(--gap) var(--pad);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--gap);
}

.finder {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20, 23, 28, 0.06), 0 8px 24px rgba(20, 23, 28, 0.07);
  padding: var(--gap) var(--pad);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.finder__head h1 {
  margin: 0;
  font-size: clamp(1.15rem, 0.9rem + 1.6vw, 2rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.finder__sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: clamp(0.85rem, 0.8rem + 0.3vw, 1.05rem);
}

.reset {
  flex: none;
  min-height: 44px;
  min-width: 56px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.reset:hover { border-color: var(--ink); }

/* Size selects */

.finder__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 4px;
  margin: 0;
}

.field { display: flex; flex-direction: column; min-width: 0; }

.field label {
  font-size: clamp(0.7rem, 0.66rem + 0.25vw, 0.85rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 4px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--control-h);
  padding: 0 26px 0 10px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2314171c' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 9px center / 12px 8px;
  color: var(--ink);
  font: inherit;
  font-size: clamp(1rem, 0.9rem + 0.6vw, 1.35rem);
  font-weight: 800;
  cursor: pointer;
}

.field select:hover:not(:disabled) { border-color: #9aa3ae; }

.field select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(214, 40, 40, 0.25);
}

.field select:disabled {
  background-color: #f3f4f6;
  color: #8a929c;
  cursor: not-allowed;
}

.field.is-set select { border-color: var(--ink); }

.sep {
  font-weight: 900;
  font-size: clamp(1.1rem, 1rem + 0.6vw, 1.5rem);
  color: #9aa3ae;
  height: var(--control-h);
  display: flex;
  align-items: center;
  padding: 0 1px;
}

/* P / LT toggle */

.ptype {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.ptype legend {
  float: left;
  padding: 0;
  margin-right: 4px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.ptype label { position: relative; cursor: pointer; }

.ptype input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.ptype span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
}

.ptype input:checked + span {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.ptype input:focus-visible + span {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

/* Sidewall illustration (idle state) */

.stage { display: flex; flex-direction: column; gap: var(--gap); }

.sidewall {
  margin: 0;
  border-radius: 12px;
  padding: clamp(10px, 2.4vh, 26px) 12px clamp(8px, 1.6vh, 16px);
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.05) 0 10px, transparent 10px 22px) top / 100% 7px no-repeat,
    repeating-linear-gradient(90deg, rgba(255,255,255,0.05) 0 10px, transparent 10px 22px) bottom / 100% 7px no-repeat,
    radial-gradient(120% 140% at 50% 120%, #2b3038 0%, #16191e 60%, #0f1114 100%);
  color: #fff;
  text-align: center;
}

.sidewall__size {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(4px, 1.5vw, 14px);
  font-family: "Arial Black", "Segoe UI Black", system-ui, sans-serif;
}

.sw { display: flex; flex-direction: column; align-items: center; }

.sw b {
  font-size: clamp(1.9rem, 1.2rem + 3.6vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.4);
  border-bottom: 3px solid transparent;
  padding: 0 2px 4px;
}

.sw i {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-style: normal;
  font-weight: 800;
  font-size: clamp(0.66rem, 0.62rem + 0.25vw, 0.82rem);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9aa3ae;
  margin-top: 4px;
}

.sw.is-set b { color: #fff; border-bottom-color: var(--accent); }

.sw-sep {
  font-size: clamp(1.6rem, 1rem + 3vw, 2.8rem);
  line-height: 1.1;
  color: rgba(255, 255, 255, 0.35);
}

.sidewall figcaption {
  margin-top: clamp(4px, 1vh, 10px);
  font-size: clamp(0.75rem, 0.7rem + 0.25vw, 0.9rem);
  color: #b9c0c9;
}

/* Results */

.results { display: flex; flex-direction: column; gap: calc(var(--gap) * 0.7); }

.results__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.results__size {
  margin: 0;
  font-size: clamp(0.9rem, 0.85rem + 0.3vw, 1.1rem);
  color: var(--muted);
}

.results__size strong {
  color: var(--ink);
  font-size: 1.15em;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.results__cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: calc(var(--gap) * 0.7);
}

/* Phones: two compact rows per card
   [title ............ $total]
   [$per  per tire     label ] */
.card {
  border: 2px solid var(--line);
  border-left: 6px solid var(--ice);
  border-radius: 12px;
  padding: clamp(6px, 1.2vh, 16px) clamp(10px, 2vw, 18px);
  background: #fff;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  column-gap: 8px;
}

.card--studded { border-left-color: var(--accent); }

.card__body, .price--total { display: contents; }

.card__title { grid-column: 1 / 3; grid-row: 1; align-self: center; }
.price--total > :last-child { grid-column: 3; grid-row: 1; text-align: right; }
.price--total > .price__label { grid-column: 2 / 4; grid-row: 2; text-align: right; }
.price--per {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}
.card__empty { grid-column: 1 / -1; grid-row: 2; }

.card .price__label { text-transform: none; letter-spacing: 0; }
.price--per .price__value { font-size: 1.05rem; }
.price--per .price__cur { display: none; }
.card .card__title { font-size: 0.8rem; letter-spacing: 0.01em; }
.card .price--total .price__cur { font-size: 0.45em; margin-left: 2px; }

.card__title {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: clamp(0.85rem, 0.8rem + 0.35vw, 1.1rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.brand-chip {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  background: #eef2f7;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 2px 8px;
}

.price__label {
  font-size: clamp(0.68rem, 0.64rem + 0.25vw, 0.82rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.price__value {
  font-weight: 900;
  font-size: clamp(1.1rem, 1rem + 0.6vw, 1.45rem);
  line-height: 1.15;
  white-space: nowrap;
}

.price--total .price__value {
  font-size: clamp(1.45rem, 1.2rem + 1.4vw, 2.25rem);
  color: var(--ink);
}

.price__cur {
  font-size: 0.55em;
  font-weight: 800;
  color: var(--muted);
  margin-left: 3px;
}

.price__call {
  font-weight: 800;
  font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.15rem);
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: normal;
}

.card__empty {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* Status (loading / errors / stale data) */

.status {
  margin: 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: #f3f4f6;
  color: var(--ink-2);
  font-size: clamp(0.78rem, 0.74rem + 0.25vw, 0.92rem);
}

.status.is-warn { background: var(--warn-bg); color: var(--warn-ink); }

.status a { font-weight: 800; white-space: nowrap; }

.fineprint {
  margin: 0;
  font-size: clamp(0.7rem, 0.66rem + 0.2vw, 0.82rem);
  color: var(--muted);
  text-align: center;
}

/* ---------- Call to action ---------- */

.cta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--gap) * 0.8);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--btn-h);
  padding: 6px 12px;
  border-radius: 12px;
  text-decoration: none;
  text-transform: uppercase;
  font-weight: 900;
  font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.3rem);
  letter-spacing: 0.03em;
  line-height: 1.1;
  text-align: center;
}

.btn--call {
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.35);
}

.btn--call:hover { background: var(--green-dark); }

.btn--map { background: var(--ink); color: #fff; }

.btn--map:hover { background: var(--ink-2); }

.btn__num {
  display: block;
  font-size: 0.8em;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* ---------- Footer ---------- */

.foot {
  background: var(--ink);
  color: #d4d9df;
  font-size: clamp(0.74rem, 0.7rem + 0.2vw, 0.88rem);
  text-align: center;
  padding: calc(var(--gap) * 0.7) var(--pad) calc(var(--gap) * 0.7 + env(safe-area-inset-bottom));
}

.foot__row {
  margin: 0 auto;
  max-width: 1080px;
  font-style: normal;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 8px;
}

.foot__row + .foot__row { margin-top: 3px; }

.foot a {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  display: inline-block;
  padding: 2px 0;
}

.foot a:hover { text-decoration: underline; }

.foot__walk { color: #fff; font-weight: 700; }

.foot__credit { font-size: 0.9em; color: #9aa3ae; }
.foot__credit a { color: #e4e7eb; }

.foot__muted { color: #9aa3ae; }

/* ---------- Wider screens ---------- */

@media (min-width: 600px) {
  .finder__form { gap: 8px; }
}

@media (min-width: 600px) and (min-height: 521px) {
  .results__cards { grid-template-columns: 1fr 1fr; }
  .card { display: block; }
  .card .card__title { font-size: clamp(0.85rem, 0.8rem + 0.35vw, 1.1rem); letter-spacing: 0.04em; }
  .card .price--total .price__cur { font-size: 0.55em; margin-left: 3px; }
  .price--per { flex-direction: column; gap: 0; white-space: normal; }
  .price--per .price__cur { display: inline; }
  .card__title { margin-bottom: clamp(4px, 0.8vh, 10px); }
  .card__body { display: grid; grid-template-columns: 1fr; gap: 6px; }
  .price { display: flex; flex-direction: column; min-width: 0; }
  .price > * { text-align: left !important; }
  .card__body > *, .price > * { grid-row: auto; grid-column: auto; }
  .card .price__label { text-transform: uppercase; letter-spacing: 0.03em; }
  .price--per .price__value { font-size: clamp(1.1rem, 1rem + 0.6vw, 1.45rem); }
}

@media (min-width: 760px) {
  .top__inner {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand info phone";
    gap: 16px 24px;
  }
  .top__info {
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    text-align: right;
  }
  .btn__num { display: inline; margin-left: 0.35em; font-size: 1em; }
  .btn__num::before { content: "\2014\00a0"; }
}

@media (min-width: 900px) and (min-height: 700px) {
  .finder { padding: calc(var(--gap) * 1.4) calc(var(--pad) * 1.4); }
  :root { --control-h: 60px; }
}

@media (min-width: 1400px) and (min-height: 860px) {
  html { font-size: 112.5%; }
  .main { max-width: 1080px; }
}

/* ---------- Short screens: tighten instead of scrolling ---------- */

@media (max-height: 760px) {
  .sidewall figcaption { display: none; }
}

@media (max-height: 680px) {
  :root { --gap: clamp(5px, 1vh, 10px); }
  .foot__svc { display: none !important; }
  .card__title { margin-bottom: 2px; }
}

@media (max-height: 600px) {
  .finder__sub { display: none; }
  .finder__head { min-height: 44px; display: flex; align-items: center; }
  .brand__tag { display: none; }
  .sw i { margin-top: 2px; }
}

/* Hours stay visible in the footer on the same screen */
@media (max-height: 600px) and (orientation: portrait) {
  .top__hours { display: none; }
  .reset { min-height: 40px; }
  .fineprint { font-size: 0.68rem; }
  .foot { font-size: 0.72rem; padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  .foot__row + .foot__row { margin-top: 1px; }
  .foot a { padding: 0; }
}

/* Short screens: footer items flow as one wrapped block instead of fixed rows */
@media (max-height: 600px), (max-width: 359px) {
  .foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 1px 8px; }
  .foot__row { display: contents; }
}

/* Very narrow phones */
@media (max-width: 359px) {
  :root { --pad: 8px; }
  .finder__head h1 { font-size: 1.02rem; letter-spacing: 0; }
  .card .card__title { font-size: 0.74rem; letter-spacing: 0; gap: 4px; }
  .brand-chip { font-size: 0.68rem; padding: 1px 6px; }
  .sep { font-size: 1rem; }
  .field select { padding: 0 20px 0 7px; background-position: right 6px center; }
  .field label { font-size: 0.66rem; letter-spacing: 0.02em; }
  .top__phone svg { display: none; }
  .btn { font-size: 1rem; gap: 6px; }
}

/* Landscape phones: two columns so everything stays on one screen */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 560px) {
  :root { --gap: 6px; --control-h: 44px; --btn-h: 48px; }
  .top__inner {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand info phone";
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .brand__logo { width: 34px; }
  .brand__tag { display: none; }
  .top__info { flex-direction: column; align-items: flex-end; gap: 0; text-align: right; font-size: 0.74rem; white-space: nowrap; }
  .main { max-width: 1080px; justify-content: flex-start; }
  .finder__head h1 { font-size: 1.1rem; }
  .field select { padding: 0 20px 0 8px; background-position: right 6px center; font-size: 1.05rem; }
  .sep { padding: 0; }
  .finder {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    grid-template-areas:
      "head  stage"
      "form  stage"
      "ptype stage"
      "fine  stage";
    align-content: start;
    column-gap: 16px;
  }
  .finder__head { grid-area: head; }
  .finder__form { grid-area: form; }
  .ptype { grid-area: ptype; }
  .stage { grid-area: stage; }
  .fineprint { grid-area: fine; text-align: left; }
  .price--total .price__value { font-size: 1.5rem; }
  .sw b { font-size: 1.9rem; }
  .btn__num { display: inline; margin-left: 0.35em; font-size: 1em; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .reset, .field select, .top__phone { transition: background-color 0.15s, border-color 0.15s; }
}

@media print {
  .cta, .reset { display: none; }
}
