/*
 * The dealer site theme, mobile first. Each page sets the brand in :root (themeCss in src/brand.ts):
 * --primary, --primary-dark, --accent, --on-primary, --font-display and --font-body. White text on
 * --primary and --accent has at least 4.5:1 contrast, so each also reads as text on white.
 */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* The scrollbar keeps its room while the dialog locks the page, so the page doesn't shift sideways. */
  scrollbar-gutter: stable;
}

/* While the vehicle dialog is open, the page behind it doesn't scroll. */
html:has(dialog[open]) {
  overflow: hidden;
}

/* A column, so the footer sits at the bottom of a short page. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: #ffffff;
  color: #1f2328;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  /* Each font pair loads only the weights the theme uses, so the browser never fakes bold. */
  font-synthesis: none;
  overflow-wrap: break-word;
}

main {
  flex: 1;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

[hidden] {
  display: none !important;
}

h1,
h2 {
  margin: 0 0 0.75rem;
  color: #14171a;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
}

h1 {
  font-size: clamp(2rem, 1.25rem + 3.5vw, 3.25rem);
}

h2 {
  font-size: clamp(1.375rem, 1.125rem + 1.25vw, 1.875rem);
}

p,
ul,
address {
  margin: 0 0 1rem;
}

address {
  font-style: normal;
}

a {
  color: var(--primary-dark);
  text-underline-offset: 0.15em;
}

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

/* An email address is one word with no break in its text (a <wbr> read as a space in copied text), so a long one may
   break anywhere in a narrow column, and its min-content shrinks too, so it never pushes a column wider than a phone. */
a[href^="mailto:"] {
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Layout */

.wrap {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

/* Read aloud but not shown, for a label whose field says what it is on screen. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.section {
  padding-block: 2.5rem;
}

.section + .section {
  padding-top: 0;
}

.page > *,
.visit > * {
  max-width: 46rem;
}

.page h2 {
  margin-top: 2.5rem;
}

.lead {
  max-width: 46rem;
  font-size: 1.125rem;
}

/* Buttons */

.button,
.header-call,
.lead-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.625rem 1.25rem;
  border: 2px solid var(--primary);
  border-radius: 0.375rem;
  background: var(--primary);
  color: var(--on-primary);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
.header-call:hover,
.lead-form button:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
  color: var(--on-primary);
}

.button-light,
.button-light:hover {
  border-color: #ffffff;
  background: #ffffff;
  color: var(--primary-dark);
}

/* Header */

.site-header {
  border-top: 4px solid var(--primary);
  border-bottom: 1px solid #e3e6ea;
  background: #ffffff;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
  padding-block: 0.75rem;
}

.logo {
  display: flex;
  flex: 1 1 100%;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.logo-icon {
  flex: none;
  width: 3rem;
  height: 3rem;
  object-fit: contain;
}

.logo-icon.badge {
  border-radius: 0.75rem;
}

.logo-name {
  min-width: 0;
  color: var(--primary-dark);
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.125rem;
}

.site-nav a {
  padding-block: 0.5rem;
  color: #1f2328;
  font-weight: 600;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

@media (min-width: 60rem) {
  .header-inner {
    flex-wrap: nowrap;
  }

  .logo {
    flex: 0 1 auto;
  }

  .site-nav {
    margin-left: auto;
  }

  /* The menu and the Call button keep their width, so a long dealer name wraps instead. */
  .site-nav,
  .header-call {
    flex-shrink: 0;
  }

  .header-call {
    white-space: nowrap;
  }
}

/* Home banner. The overlay keeps white text at 4.5:1 or better over any photo. */

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--primary-dark);
  color: #ffffff;
}

.hero-image {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  max-width: none;
  height: 100%;
  object-fit: cover;
  /* The banner prompt puts the subject in the middle band, which a wide strip would otherwise crop. */
  object-position: center 60%;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgb(10 12 15 / 0.8), rgb(10 12 15 / 0.6));
}

.hero-content {
  padding-block: 3.5rem 3rem;
}

.hero h1 {
  max-width: min(18ch, 38rem);
  color: #ffffff;
}

.hero-subhead {
  max-width: 38rem;
  font-size: 1.125rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0 0;
}

.hero :focus-visible,
.site-footer :focus-visible {
  outline-color: #ffffff;
}

@media (min-width: 48rem) {
  .hero-content {
    padding-block: 6rem 5rem;
  }
}

/*
 * On a wide screen the text takes the left of the banner, so the overlay stays at 0.6 or darker up to the text
 * column's right edge (the .wrap's left edge plus its padding and the subhead's 38rem), and fades toward the right,
 * where the photo's subject is. 0.6 keeps white text at 4.5:1 even over a white photo.
 */
@media (min-width: 60rem) {
  .hero::before {
    background: linear-gradient(
      90deg,
      rgb(10 12 15 / 0.8) 0,
      rgb(10 12 15 / 0.6) calc(max(0px, (100% - 72rem) / 2) + 39rem),
      rgb(10 12 15 / 0.15) 100%
    );
  }
}

/* At a glance: short facts as chips that wrap onto more rows, in a light band under the Home banner and as a list on
   About. A chip is never wider than its row, so a long one wraps its own text instead of scrolling the page. */

.glance-strip {
  border-bottom: 1px solid #e3e6ea;
  background: #f4f5f7;
}

.glance {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.glance-strip .glance {
  margin: 0;
  padding-block: 1rem;
}

.glance li {
  max-width: 100%;
  padding: 0.3125rem 0.875rem;
  border: 1px solid #d5d9de;
  border-left: 3px solid var(--accent);
  border-radius: 0.375rem;
  background: #f4f5f7;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
}

.glance-strip .glance li {
  background: #ffffff;
}

/* On a small phone the chips tighten a little, so short ones share a row instead of stacking one per row. */
@media (max-width: 25rem) {
  .glance li {
    padding-inline: 0.625rem;
    font-size: 0.875rem;
  }
}

/* Home: each section set apart by its own band and an accented heading, so they don't run together. */

.home-section {
  padding-block: 3rem;
}

.home-band {
  border-block: 1px solid #e3e6ea;
  background: #f4f5f7;
}

/* The visit block's 46rem cap on its children would squeeze Home's two columns. */
.home-section.visit > .wrap {
  max-width: 72rem;
}

.section-title {
  margin: 0 0 1.25rem;
}

.section-title::before {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  margin-bottom: 0.75rem;
  border-radius: 2px;
  background: var(--accent);
}

.section-more {
  margin: 1.75rem 0 0;
  text-align: center;
}

.button-outline {
  background: transparent;
  color: var(--primary-dark);
}

.visit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem 3rem;
}

.visit-main > * {
  max-width: 40rem;
}

.visit-main address {
  margin-bottom: 1rem;
  font-style: normal;
}

.visit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.hours-card {
  align-self: start;
  padding: 1.25rem 1.5rem;
  border: 1px solid #e3e6ea;
  border-top: 4px solid var(--accent);
  border-radius: 0.5rem;
  background: #f4f5f7;
}

.hours-card .hours-label {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

@media (min-width: 48rem) {
  .home-section {
    padding-block: 4rem;
  }

  /* The hours card's floor keeps a full day name beside a half-hour time, like "Wednesday 10:30am-7:30pm", whole. */
  .visit-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(18.5rem, 1fr);
  }
}

/* Reasons */

.reasons {
  display: grid;
  /* As in .lead-form, minmax(0, 1fr) keeps a long string with no spaces from widening a column. */
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.reason {
  padding: 1.25rem;
  border-top: 4px solid var(--accent);
  border-radius: 0.375rem;
  background: #f4f5f7;
}

.reason h3 {
  margin-top: 0;
  font-size: 1.25rem;
}

.reason p {
  margin: 0;
}

@media (min-width: 48rem) {
  .reasons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Vehicles */

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.vehicle-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0 0 1rem;
  overflow: hidden;
  border: 1px solid #d5d9de;
  border-radius: 0.5rem;
  background: #ffffff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.vehicle-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.08);
}

.vehicle-photo {
  width: 100%;
  margin-bottom: 0.75rem;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: #eef0f2;
}

.vehicle-title,
.vehicle-price,
.vehicle-meta {
  display: block;
  padding-inline: 1rem;
}

.vehicle-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.25;
}

.vehicle-price {
  margin-top: 0.25rem;
  color: var(--primary-dark);
  font-size: 1.125rem;
  font-weight: 600;
}

.vehicle-meta {
  color: #4b535c;
}


/* Inventory page */

.inventory > h2 {
  margin-top: 2.5rem;
}

/* Inventory search: a row of filters, then the result count and Sort by, above the listings. */

.inventory-search {
  margin: 1.5rem 0 1.25rem;
}

.search-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.625rem;
}

.inventory-search select {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 2.25rem 0.5rem 0.75rem;
  border: 1px solid #6b737c;
  border-radius: 0.375rem;
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%231f2328' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0.875rem center;
  color: inherit;
  font: inherit;
  font-size: 0.9375rem;
  appearance: none;
  cursor: pointer;
}

.inventory-search select:hover {
  border-color: var(--primary);
}

.search-apply {
  grid-column: 1 / -1;
  justify-self: start;
}

.search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #e3e6ea;
}

.search-count {
  margin: 0;
  font-weight: 600;
}

.search-count a {
  margin-left: 0.5rem;
  font-weight: 400;
}

.search-sort {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.search-sort label {
  font-weight: 600;
  white-space: nowrap;
}

.search-sort select {
  width: auto;
  min-width: 13.5rem;
}

.search-empty {
  max-width: 46rem;
  margin: 0 0 1.5rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid #d5d9de;
  border-radius: 0.5rem;
  background: #f4f5f7;
}

@media (min-width: 48rem) {
  .search-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 60rem) {
  .search-filters {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* About page */

.steps {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

.steps li {
  padding-left: 0.375rem;
}

.steps li + li {
  margin-top: 0.875rem;
}

.steps li::marker {
  color: var(--primary-dark);
  font-family: var(--font-display);
  font-weight: 600;
}

.steps strong {
  font-weight: 600;
}

/* A phone number in the steps and answers keeps to one line, so its link never splits at a phone's width. */
.about a[href^="tel:"] {
  white-space: nowrap;
}

.about h3 {
  margin: 1.75rem 0 0.375rem;
  color: #14171a;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.25;
}

.about h3 + p {
  margin-bottom: 0;
}

/* Questions sits as close to its first question as the other section headings sit to their content, so it reads
   as the heading, not as one more question. */
.about h2 + h3 {
  margin-top: 0.75rem;
}

/* Vehicle dialog. showModal() centers it in the top layer over the backdrop. The dialog scrolls on its own, and the
   close button stays in view while it does. */

.vehicle-dialog {
  width: calc(100% - 2rem);
  max-width: 40rem;
  max-height: calc(100% - 2rem);
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 0.5rem;
  background: #ffffff;
  color: inherit;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.3);
}

.vehicle-dialog::backdrop {
  background: rgb(10 12 15 / 0.65);
}

.dialog-close {
  position: sticky;
  top: 0.75rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  /* A bottom margin of minus its height and top margin takes it out of the flow, so it sits over the photo. */
  margin: 0.75rem 0.75rem -3.5rem auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ffffff;
  color: #14171a;
  box-shadow: 0 1px 6px rgb(0 0 0 / 0.3);
  cursor: pointer;
}

.dialog-close:hover {
  color: var(--primary-dark);
}

/* Hugging the white circle, the ring shows against it whatever the photo behind. */
.dialog-close:focus-visible {
  outline-offset: 0;
}

.dialog-media {
  position: relative;
}

.dialog-photo {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: #eef0f2;
}

/* The right padding is the close button's column: it stays in view as the dialog scrolls, so it never covers text. */
.dialog-body {
  padding: 1.25rem 3.75rem 1.5rem 1.25rem;
}

.dialog-title {
  margin-bottom: 0.25rem;
  font-size: 1.5rem;
}

.dialog-price {
  margin: 0;
  color: var(--primary-dark);
  font-size: 1.25rem;
  font-weight: 600;
}

.dialog-miles {
  margin: 0;
  color: #4b535c;
}

.vehicle-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 1.25rem 0 1.5rem;
  padding-block: 1rem;
  border-block: 1px solid #e3e6ea;
}

.vehicle-details dt {
  color: #4b535c;
  font-size: 0.875rem;
}

.vehicle-details dd {
  margin: 0;
  font-weight: 600;
}

.vehicle-dialog h3 {
  margin: 0 0 1rem;
  color: #14171a;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
}

/* Lead form. The consent text stays at body size and color, never fine print. */

.lead-form {
  display: grid;
  /* minmax(0, 1fr), not an auto column. overflow-wrap: break-word doesn't shrink min-content, so an auto column
     grows to fit a long string with no spaces, such as a long email in the consent note, and the page scrolls
     sideways on a phone. */
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  max-width: 40rem;
  margin-bottom: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.field input,
.field textarea {
  display: block;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #6b737c;
  border-radius: 0.375rem;
  background: #ffffff;
  color: inherit;
  font: inherit;
}

.field textarea {
  min-height: 7rem;
  resize: vertical;
}

.consent {
  position: relative;
  display: block;
  padding-left: 2rem;
  font-size: 1rem;
  line-height: 1.5;
}

.consent input {
  position: absolute;
  top: 0.125rem;
  left: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--primary);
}

.consent-note {
  margin: 0;
  font-size: 1rem;
}

.lead-form button {
  justify-self: start;
}

.lead-success {
  margin: 0;
  font-weight: 600;
}

/* Hours: a day-by-day table, in the visit-us blocks, on Contact and in the footer. */

.hours-block {
  margin-block: 1rem;
}

.hours-label {
  margin: 0 0 0.25rem;
  font-weight: 600;
}

.hours-table {
  border-collapse: collapse;
}

.hours-table th,
.hours-table td {
  padding: 0.125rem 0;
  text-align: left;
  vertical-align: top;
}

.hours-table th {
  padding-right: 1.25rem;
  font-weight: 600;
  white-space: nowrap;
}


.hours-text {
  margin: 0;
}

/* Footer: the logo and a tagline, then Visit, Hours and Pages in columns, then a bottom line with the copyright, the
   dealer identity sentence and the legal links. */

.site-footer {
  border-top: 4px solid var(--primary);
  background: #16191d;
  color: #c3c9cf;
}

.site-footer a {
  color: #ffffff;
  text-decoration-color: rgb(255 255 255 / 0.45);
  text-underline-offset: 0.2em;
}

.site-footer a:hover {
  text-decoration-color: currentColor;
}

/* On a phone the logo, Visit and Hours each take the full width, so a time never splits at its hyphen. */
.footer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem 1.5rem;
  padding-block: 2.75rem 2.25rem;
}

.footer-brand,
.footer-visit,
.footer-hours {
  grid-column: 1 / -1;
}

.footer-brand .logo {
  margin-bottom: 0.75rem;
}

/* A white tile behind the logo, so a dark logo still shows on the dark footer. */
.footer-brand .logo-icon {
  box-sizing: border-box;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.25rem;
  border-radius: 0.625rem;
  background: #ffffff;
}

.footer-brand .logo-name {
  color: #ffffff;
  font-size: 1.25rem;
}

.footer-tagline {
  max-width: 20rem;
  margin: 0;
}

.footer-heading {
  margin: 0 0 0.875rem;
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* The accent, lightened so a dark one still shows on the dark footer. */
.footer-heading::after {
  content: "";
  display: block;
  width: 1.5rem;
  height: 2px;
  margin-top: 0.5rem;
  background: color-mix(in srgb, var(--accent) 55%, #ffffff);
}

.footer-col address {
  font-style: normal;
}

.footer-col p {
  margin: 0.75rem 0 0;
}

.footer-col .hours-table th {
  color: #ffffff;
}

.footer-menu {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-bottom {
  border-top: 1px solid rgb(255 255 255 / 0.12);
  font-size: 0.875rem;
}

.footer-bottom-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: 1.25rem;
}

.copyright {
  max-width: 48rem;
  margin: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

@media (min-width: 36rem) {
  .footer-brand,
  .footer-visit,
  .footer-hours {
    grid-column: auto;
  }
}

@media (min-width: 60rem) {
  /* Visit gets room for a dealer's email; Pages takes only its links' width. Hours gets a floor, so a full day name
     beside its time, half hours included, never splits the time at its hyphen or spills into Pages. */
  .footer-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.5fr) minmax(15rem, 1fr) auto;
    gap: 2.5rem;
  }
}

/* On a phone the footer's links are easy to tap. */
@media (max-width: 35.99rem) {
  .footer-menu {
    gap: 0;
  }

  .footer-menu a,
  .footer-links a,
  .footer-directions {
    display: inline-block;
    padding-block: 0.5rem;
  }
}

/* Privacy Policy and Terms */

.legal h2 {
  font-size: 1.375rem;
}

.legal ul {
  padding-left: 1.25rem;
}
