/* =========================================================
   craigslist redesign — built from the Figma prototype
   Mobile-first. Desktop layout kicks in at 900px.
   ========================================================= */

/* smooth fade between pages (Chrome, Edge, Safari 18+) */
@view-transition {
  navigation: auto;
}

/* BASIC RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* DESIGN TOKENS (light theme) */
:root {
  --background: #faf9fc;
  --surface: #ffffff;
  --surface-raised: #f1eef6;
  --on-surface: #1d1a22;
  --on-surface-medium: #5f5a66;
  --outline: #d7d2de;
  --primary: #5b2a86;
  --on-primary: #ffffff;
  --header: #800080;
  --container: #713471;
  --on-container: #ffffff;
  --thumb: #efe6fa;
  --subnav: #efd1ef;
  --filter-panel: #efefef;
  --filter-heading: #565656;
  --filter-open: #451145;
  --filter-closed: #b76eb7;
  --location-card: #c6c6c6;
  --toggle-track: #c6c6c6;
  --toggle-knob: #665366;
  --scrim: rgba(0, 0, 0, 0.32);
  --error: #b3261e;
  --card-border: #f1eef6;

  /* icons are exported in light colors, dark mode re-tints them */
  --icon-filter: none;
  --icon-muted-filter: none;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --font-body: "Inter", Arial, sans-serif;
  --font-brand: "Source Serif Pro", Georgia, serif;
}

/* DARK THEME — values from the "— Dark" frames in Figma */
:root[data-theme="dark"] {
  --background: #121212;
  --surface: #1e1e1e;
  --surface-raised: #2c2c2c;
  --on-surface: #e6e1e9;
  --on-surface-medium: #a9a4ae;
  --outline: #3e3b43;
  --primary: #cdb4f0;
  --header: #352a4a;
  --container: #352a4a;
  --thumb: #1e1e1e;
  --subnav: #2c2c2c;
  --filter-panel: #2c2c2c;
  --filter-heading: #a9a4ae;
  --filter-open: #352a4a;
  --filter-closed: #352a4a;
  --location-card: #2c2c2c;
  --toggle-track: #3e3b43;
  --toggle-knob: #cdb4f0;
  --error: #f2b8b5;
  --card-border: #3e3b43;

  --icon-filter: brightness(0) invert(83%) sepia(14%) saturate(1200%)
    hue-rotate(212deg);
  --icon-muted-filter: invert(1) brightness(1.05);
}

/* BASE STYLES */
html {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  line-height: 1.5;
  background: var(--background);
  color: var(--on-surface);
  height: 100vh;
  display: flex;
  overflow: hidden;
  flex-direction: column;
  transition:
    background-color 0.25s ease,
    color 0.25s ease;
}

/* prevents header from squeezing when allowing content under to scroll */
body > header {
  flex-shrink: 0;
}

body[data-page="search"] > #main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

img {
  display: block;
}

/* the hidden attribute always wins over display rules below */
[hidden] {
  display: none !important;
}

.icon {
  filter: var(--icon-filter);
}

.icon-muted {
  filter: var(--icon-muted-filter);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 200;
  padding: 8px 16px;
  background: var(--surface);
  color: var(--on-surface);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.skip-link:focus {
  top: 8px;
}

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

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 64px;
  height: 44px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    filter 0.15s ease,
    background-color 0.15s ease,
    transform 0.1s ease;
}

.btn:hover {
  filter: brightness(1.12);
}

.btn:active {
  transform: scale(0.97);
}

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

:root[data-theme="dark"] .btn--primary {
  background: var(--container);
}

.btn--container {
  background: var(--container);
  color: var(--on-container);
}

.btn--outline {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
}

:root[data-theme="dark"] .btn--outline {
  background: transparent;
  border-color: var(--outline);
  color: var(--on-surface);
}

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

/* =========================================================
   HEADER (primary navbar)
   ========================================================= */
.navbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  padding: 21px 16px;
  background: var(--header);
}

.brand {
  display: flex;
  align-items: center;
  gap: 20px;
  color: #ffffff;
  text-decoration: none;
}

.brand__logo {
  width: 38px;
  height: 38px;
}

.brand__logo--desktop {
  display: none;
}

.brand__name {
  font-family: var(--font-brand);
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
}

.menu-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.navbar .menu-btn {
  position: absolute;
  left: 8px;
  top: 16px;
}

/* =========================================================
   SECONDARY NAVBAR (Back + search)
   ========================================================= */
.subnav {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 63px;
  padding: 4px 16px 3px;
  background: var(--subnav);
}

.subnav__left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.subnav .menu-btn {
  width: 40px;
  height: 40px;
}

:root[data-theme="dark"] .subnav .menu-btn img {
  filter: invert(1);
}

.subnav__back {
  height: 30px;
  min-width: 0;
  padding: 0 16px;
  font-size: 12px;
}

.subnav__title {
  font-size: 20px;
  font-weight: 600;
  line-height: 28px;
  text-transform: uppercase;
}

.subnav .search {
  flex: 1;
  min-width: 0;
}

/* =========================================================
   SEARCH FIELD + SUGGESTIONS
   ========================================================= */
.search {
  position: relative;
}

.search__field {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 16px;
  background: var(--surface-raised);
  border-radius: var(--radius-full);
}

.search__field:focus-within {
  outline: 2px solid var(--primary);
}

.search__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: none;
  border: 0;
  outline: none;
  font-size: 16px;
  line-height: 24px;
}

.search__input::placeholder {
  color: var(--on-surface-medium);
}

/* hide the browser's own clear "x" — we draw our own */
.search__input::-webkit-search-cancel-button {
  display: none;
}

.search__clear {
  display: none;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.search.has-text .search__clear {
  display: block;
}

.search__submit {
  display: none;
}

.subnav .search__field {
  height: 30px;
}

.subnav .search__input {
  font-size: 13px;
}

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  list-style: none;
  background: var(--surface-raised);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.suggestions[hidden] {
  display: none;
}

.suggestions__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-surface-medium);
}

.suggestions a {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  background: var(--outline);
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 24px;
  text-decoration: none;
}

.suggestions a:hover,
.suggestions a:focus-visible {
  filter: brightness(0.95);
}

/* =========================================================
   HOME / DASHBOARD
   ========================================================= */
.home {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  margin-top: 5px;
}

.home__title {
  font-size: 24px;
  font-weight: 700;
  line-height: normal;
}

.home .search__field {
  height: 30px;
}

.categories {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  list-style: none;
}

.category-card {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 96px;
  padding: 24px 40px;
  background: var(--container);
  color: var(--on-container);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 2px rgba(0, 0, 0, 0.25);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition:
    transform 0.2s ease,
    filter 0.2s ease,
    box-shadow 0.2s ease;
}

.category-card:hover {
  filter: brightness(1.15);
  transform: translateY(-3px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.22);
}

.category-card:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.25);
}

.theme-corner {
  display: none;
}

/* =========================================================
   THEME TOGGLE
   ========================================================= */
.toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 114px;
  height: 56px;
  padding: 5px 9px 6px;
  background: var(--toggle-track);
  border: 0;
  border-radius: 40px;
  cursor: pointer;
}

.toggle__knob {
  width: 56px;
  height: 45px;
  background: var(--toggle-knob);
  border-radius: 40px;
  transition: transform 0.2s ease;
}

.toggle[aria-checked="true"] .toggle__knob {
  transform: translateX(-40px);
}

/* =========================================================
   MENU DRAWER
   ========================================================= */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  visibility: hidden;
}

.drawer.is-open {
  visibility: visible;
}

.drawer__scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  background: var(--scrim);
  border: 0;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.drawer__panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 296px;
  max-width: 85vw;
  padding: 24px 16px;
  background: var(--surface);
  border-radius: 0 16px 16px 0;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.drawer.is-open .drawer__scrim {
  opacity: 1;
}

.drawer.is-open .drawer__panel {
  transform: none;
}

.drawer__title {
  padding-left: 16px;
  font-size: 20px;
  font-weight: 700;
}

.drawer__link {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

.drawer__link:hover,
.drawer__link[aria-current="page"] {
  background: var(--surface-raised);
}

.drawer__divider {
  height: 1px;
  background: var(--outline);
  border: 0;
}

.drawer__section {
  padding-left: 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.96px;
  opacity: 0.7;
}

.drawer__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
}

.drawer__row strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
  line-height: normal;
}

.drawer__row small {
  display: block;
  font-size: 12px;
  opacity: 0.7;
}

/* =========================================================
   FILTER CHIPS (desktop sidebar + mobile row)
   ========================================================= */
.chip {
  flex-shrink: 0;
  padding: 6px 10px;
  background: none;
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  cursor: pointer;
}

.chip:hover {
  background: var(--surface-raised);
}

.chip[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

:root[data-theme="dark"] .chip[aria-pressed="true"] {
  background: var(--container);
  border-color: var(--container);
}

.chip--sort {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

:root[data-theme="dark"] .chip--sort {
  border-color: var(--outline);
  color: var(--on-surface);
}

.mobile-filters {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  padding: 2px 8px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

/* keep filter and sort controls above cards on mobile */
.results__toolbar,
.mobile-filters {
  flex-shrink: 0;
}

.mobile-filters::-webkit-scrollbar {
  display: none;
}

/* =========================================================
   SEARCH RESULTS
   ========================================================= */

.results {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: scroll;
}

.results-page {
  flex: 1;
  padding: 14px 6px 32px;

  /* min height lets content shrink into available space */
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.results-page__heading {
  padding: 0 14px 18px;
  font-size: 16px;
  font-weight: 700;
  line-height: normal;
}

.filters {
  display: none;
}

.results__toolbar {
  display: none;
}

.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px 5px;
  list-style: none;

  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
}

.listing-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-decoration: none;
  transition:
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.listing-card:hover {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  transform: translateY(-3px);
}

.listing-card {
  animation: rise 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.listing-card__thumb img {
  transition: transform 0.2s ease;
}

.listing-card:hover .listing-card__thumb img {
  transform: scale(1.15) rotate(-4deg);
}

.listing-card:hover .listing-card__thumb--photo img {
  transform: scale(1.05);
}

.listing-card__thumb {
  display: grid;
  place-items: center;
  height: 160px;
  background: var(--thumb);
}

.listing-card__thumb img {
  width: 40px;
  height: 40px;
}

.listing-card__thumb--photo {
  display: block;
  overflow: hidden;
}

.listing-card__thumb--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.listing-card__body {
  padding: 12px 16px 0 0;
}

.listing-card__price {
  font-size: 13px;
  font-weight: 600;
  line-height: 28px;
  color: var(--primary);
}

.listing-card__title {
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
}

.listing-card__meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 16px;
  color: var(--on-surface-medium);
}

.listing-card__meta img {
  width: 16px;
  height: 16px;
}

.empty-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--on-surface-medium);
}

.empty-state__action {
  display: flex;
  width: max-content;
  margin: 16px auto 0;
}

.empty-state strong {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
  color: var(--on-surface);
}

/* LOADING STATE */
.progress {
  height: 4px;
  overflow: hidden;
  background: var(--surface-raised);
}

.progress__bar {
  width: 40%;
  height: 100%;
  background: var(--primary);
  animation: progress 0.9s ease-in-out infinite;
}

@keyframes progress {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

.loading {
  display: grid;
  place-content: center;
  gap: 8px;
  min-height: 50vh;
  text-align: center;
}

.loading strong {
  font-size: 18px;
}

.loading p {
  font-size: 14px;
  color: var(--on-surface-medium);
}

.loading p span {
  font-weight: 600;
  color: var(--on-surface);
}

/* =========================================================
   PAGE BAR (mobile "Back | Listing details")
   ========================================================= */
.page-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface);
}

.page-bar .btn {
  width: 80px;
}

.page-bar__title {
  font-size: 16px;
  font-weight: 700;
  line-height: normal;
}

/* =========================================================
   LISTING DETAILS
   ========================================================= */
.listing {
  flex: 1;
  display: flex;
  flex-direction: column;

  min-height: 0;
  overflow-y: auto;
}

/* only applies to front layer of children in listing */
.listing > * {
  flex-shrink: 0;
}

.listing__layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

.listing__thumb {
  display: grid;
  place-items: center;
  height: 260px;
  background: var(--surface-raised);
  border-radius: var(--radius-md);
}

.listing__thumb img {
  width: 48px;
  height: 48px;
}

.listing__thumb--photo {
  overflow: hidden;
}

.listing__thumb img.listing__photo {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.listing__thumb img.listing__photo--inset {
  max-width: 92%;
  max-height: 92%;
}

.listing__info {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.listing__title {
  font-size: 26px;
  font-weight: 700;
  line-height: normal;
}

.listing__price {
  font-size: 22px;
  font-weight: 700;
  line-height: normal;
}

.listing__meta {
  font-size: 13px;
}

.listing__desc {
  display: flex;
  flex-direction: column;
  gap: 1em;
  font-size: 15px;
  line-height: normal;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 49px;
  padding: 0 20px;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--radius-full);
  font-size: 16px;
  font-weight: 500;
}

:root[data-theme="dark"] .tag {
  background: var(--container);
}

.listing__facts {
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
}

.listing__facts p {
  font-size: 16px;
  line-height: 24px;
}

.location-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
}

.location-card h2 {
  font-size: 18px;
  font-weight: 700;
}

.location-card__text {
  display: contents;
}

.location-card__map {
  order: 1;
  display: grid;
  place-items: center;
  height: 160px;
  background: var(--surface-raised);
}

.location-card__map > img {
  width: 40px;
  height: 40px;
}

.location-card__map.has-map {
  display: block;
  overflow: hidden;
}

.location-card__leaflet {
  width: 100%;
  height: 100%;
  font-family: var(--font-body);
}

.location-card__leaflet .leaflet-marker-icon {
  width: 40px;
  height: 40px;
}

:root[data-theme="dark"] .location-card__leaflet .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9);
}

.location-card__directions {
  order: 3;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

.location-card address {
  order: 2;
  font-size: 14px;
  font-style: normal;
}

.contact-bar {
  position: sticky;
  bottom: 0;
  z-index: 1000;
  margin-top: auto;
  padding: 12px 16px 16px;
  background: var(--surface);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

/* =========================================================
   CONTACT SELLER
   ========================================================= */
.contact {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.contact__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

.contact__title {
  font-size: 24px;
  font-weight: 700;
  line-height: normal;
}

.contact__intro {
  font-size: 15px;
}

.contact__about {
  font-size: 14px;
  color: var(--on-surface-medium);
}

.contact__about a {
  font-weight: 600;
  color: var(--primary);
}

.message-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-form label {
  font-size: 14px;
  font-weight: 600;
}

.message-form textarea {
  height: 220px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  font-size: 16px;
  resize: vertical;
}

.message-form textarea::placeholder {
  color: var(--on-surface);
  opacity: 0.5;
}

.message-form textarea:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

.message-form.has-error textarea {
  border-color: var(--error);
  outline-color: var(--error);
}

.message-form__hint {
  font-size: 12px;
}

.message-form__error {
  font-size: 12px;
  font-weight: 600;
  color: var(--error);
}

.message-form .btn {
  margin-top: 8px;
}

/* MESSAGE SENT DIALOG */
.dialog {
  width: min(361px, calc(100% - 32px));
  margin: auto;
  padding: 16px;
  background: var(--surface);
  color: var(--on-surface);
  border: 0;
  border-radius: var(--radius-lg);
}

.dialog::backdrop {
  background: var(--scrim);
}

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

.dialog h2 {
  font-size: 24px;
  font-weight: 700;
  line-height: normal;
}

/* =========================================================
   404 PAGE
   ========================================================= */
.not-found {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 16px;
  text-align: center;
}

.not-found .not-found__code {
  font-size: 96px;
  font-weight: 700;
  line-height: 1;
  color: var(--primary);
}

.not-found h1 {
  font-size: 24px;
  font-weight: 700;
}

.not-found p {
  max-width: 36ch;
  color: var(--on-surface-medium);
}

.not-found__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

/* =========================================================
   DESKTOP (900px and up)
   ========================================================= */
@media (min-width: 900px) {
  .mobile-only {
    display: none !important;
  }

  /* header */
  .navbar {
    justify-content: flex-start;
    height: 108px;
    padding: 21px 61px;
  }

  .brand {
    gap: 35px;
  }

  .brand__logo--mobile {
    display: none;
  }

  .brand__logo--desktop {
    display: block;
    width: 66px;
    height: 66px;
  }

  .brand__name {
    font-size: 36px;
  }

  /* secondary navbar */
  .subnav {
    justify-content: space-between;
    min-height: 72px;
    padding: 12px 61px;
  }

  .subnav__left {
    gap: 41px;
  }

  .subnav__back {
    width: 101px;
    height: 42px;
    font-size: 14px;
  }

  .subnav .search {
    flex: 0 1 456px;
  }

  .subnav .search__field {
    height: 48px;
  }

  .subnav .search__input {
    font-size: 16px;
  }

  /* home */
  .home {
    flex: 1;
    justify-content: center;
    align-items: center;
    gap: 60px;
    margin: 0;
    padding: 48px 118px 120px;
  }

  .home__title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .home .search {
    display: flex;
    align-items: center;
    gap: 19px;
    width: min(792px, 100%);
  }

  .home .search__field {
    flex: 1;
    height: 74px;
  }

  .home .search__submit {
    display: inline-flex;
    width: 143px;
    height: 48px;
  }

  .home .suggestions {
    right: 162px;
  }

  .home > nav {
    align-self: stretch;
  }

  .categories {
    grid-template-columns: repeat(3, 1fr);
    gap: 108px 80px;
    max-width: 1204px;
    margin: 0 auto;
    overflow: hidden;
  }

  .category-card {
    height: 154px;
    font-size: 36px;
  }

  .theme-corner {
    display: block;
    position: fixed;
    right: 42px;
    bottom: 42px;
  }

  /* search results */
  .results {
    gap: 32px;
    overflow: hidden;
  }

  .results-page {
    display: flex;
    gap: 48px;
    padding: 24px 75px 32px;
    flex-direction: row;
  }

  .results-page__heading {
    display: none;
  }

  .filters {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 0 0 345px;
    align-self: flex-start;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    padding: 20px 45px 24px;
    background: var(--filter-panel);
    border-radius: var(--radius-md);
  }

  .filters__heading {
    font-size: 16px;
    font-weight: 500;
    line-height: 38px;
    letter-spacing: 4.8px;
    color: var(--filter-heading);
  }

  .filter-group {
    display: flex;
    flex-direction: column;
    gap: 11px;
  }

  .filter-group + .filter-group {
    margin-top: -4px;
  }

  .filter-group__header {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    background: var(--filter-closed);
    color: #ffffff;
    border: 0;
    border-radius: var(--radius-lg);
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
    text-align: left;
    cursor: pointer;
  }

  .filter-group__header[aria-expanded="true"] {
    background: var(--filter-open);
    padding-left: 13px;
  }

  .filter-group__options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 2px;
  }

  .filter-group__options[hidden] {
    display: none;
  }

  .results__toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .results__toolbar .btn {
    height: 48px;
  }

  .results__count {
    font-size: 14px;
    color: var(--on-surface-medium);
  }

  .listing-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
  }

  .listing-card {
    padding: 0;
    border-color: transparent;
  }

  :root[data-theme="dark"] .listing-card {
    border-color: var(--outline);
  }

  .listing-card__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px 16px;
  }

  .listing-card__price {
    font-size: 20px;
  }

  .listing-card__title {
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
  }

  /* listing details */
  .listing__layout {
    flex-direction: row;
    gap: 45px;
    padding: 30px 60px 40px;
  }

  .listing__media {
    display: flex;
    flex-direction: column;
    gap: 43px;
    flex: 0 0 433px;
  }

  .listing__thumb {
    height: 583px;
    background: var(--thumb);
  }

  .listing__thumb img {
    width: 40px;
    height: 40px;
  }

  .listing__facts {
    display: flex;
  }

  .listing__info {
    flex: 1;
    min-width: 0;
    gap: 28px;
  }

  .listing__title {
    font-size: 48px;
    line-height: 56px;
    padding: 25px 0 18px;
  }

  .listing__price {
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
  }

  .listing__desc {
    font-size: 16px;
    line-height: 24px;
    gap: 24px;
  }

  .location-card {
    flex-direction: row;
    align-items: flex-end;
    align-self: flex-end;
    gap: 22px;
    width: min(570px, 100%);
    margin-top: 32px;
    padding: 18px 19px;
    background: var(--location-card);
  }

  .location-card__text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 18px;
    flex: 0 0 145px;
  }

  .location-card__directions {
    order: 0;
  }

  .location-card address {
    order: 0;
    text-align: right;
    line-height: 20px;
  }

  .location-card__text .btn {
    width: 100%;
    height: 48px;
    padding: 0 12px;
    border-radius: var(--radius-md);
  }

  .location-card__map {
    flex: 1;
    height: 205px;
    background: var(--thumb);
    border-radius: var(--radius-sm);
  }

  /* contact seller */
  .contact__body {
    flex: 1;
    min-height: 0;
    width: min(880px, 100% - 64px);
    margin: 0 auto;
    gap: 13px;
    padding: 25px 0;
  }

  .contact__title {
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
  }

  .contact__intro {
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
  }

  .message-form {
    flex: 1;
    min-height: 0;
  }

  .message-form label {
    flex: 1;
    min-height: 80px;
    position: absolute;
    width: 1px;
    height: auto;
    overflow: hidden;
    clip: rect(0 0 0 0);
    resize: none;
  }

  .message-form textarea {
    height: 333px;
    padding: 12px 12px 12px 16px;
    border-radius: var(--radius-sm);
  }

  .message-form textarea::placeholder {
    color: var(--on-surface-medium);
    opacity: 1;
  }

  .message-form__hint {
    color: var(--on-surface-medium);
  }

  .message-form .btn {
    align-self: flex-end;
    width: 194px;
    height: 48px;
    margin-top: 32px;
  }

  .dialog {
    width: 880px;
    max-width: calc(100% - 64px);
    min-height: 462px;
    place-items: center;
  }

  .dialog[open] {
    display: grid;
  }

  .dialog__inner {
    align-items: center;
    gap: 40px;
    width: 350px;
  }

  .dialog h2 {
    font-size: 48px;
    line-height: 56px;
  }

  .dialog p {
    display: none;
  }

  .dialog .btn {
    width: 144px;
    height: 48px;
  }
}

@media (max-width: 899px) {
  .desktop-only {
    display: none !important;
  }
  .home {
    flex: 1;
    min-height: 0;
  }

  .home > nav {
    min-height: 0;
    overflow-y: auto;
  }

  .home > .search,
  .home__title {
    flex-shrink: 0;
  }
}

/* =========================================================
   ASSIGNMENT 11 — LIVE SEARCH, LOADING STATES, MICRO-INTERACTIONS
   ========================================================= */

/* --- Animation 1: search field focus glow ---
   Purpose: makes it obvious where you're typing. The ring eases in instead of snapping. */
.search__field {
  outline: 2px solid transparent;
  box-shadow: 0 0 0 0 transparent;
  transition:
    outline-color 0.2s ease,
    box-shadow 0.25s ease,
    background-color 0.2s ease;
}

.search__field:focus-within {
  outline-color: var(--primary);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 18%, transparent);
  background: var(--surface);
}

/* --- Animation 2: suggestions panel drops in ---
   Purpose: ties the panel to the field it came from, so new results read as a response to typing. */
.suggestions {
  max-height: min(70vh, 460px);
  overflow-y: auto;
  gap: 2px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--outline);
  transform-origin: top center;
  animation: drop-in 0.18s ease-out;
}

@keyframes drop-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}

.suggestions__label {
  padding: 8px 8px 2px;
}

.suggestions a.suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  height: auto;
  min-height: 44px;
  padding: 6px 8px;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 20px;
  color: var(--on-surface);
  /* Animation 3: highlight slides in on hover/arrow keys — shows which suggestion Enter will open */
  transition:
    background-color 0.15s ease,
    transform 0.15s ease;
}

.suggestions a.suggestion:hover,
.suggestions a.suggestion.is-active {
  background: var(--surface-raised);
  transform: translateX(3px);
  filter: none;
}

.suggestion__thumb {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  background: var(--thumb);
  border-radius: var(--radius-sm);
}

.suggestion__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.suggestion__thumb img.icon {
  width: 22px;
  height: 22px;
}

.suggestion__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.suggestion__title {
  overflow: hidden;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.suggestion__title mark {
  background: none;
  color: var(--primary);
  font-weight: 700;
}

.suggestion__meta {
  font-size: 12px;
  line-height: 16px;
  color: var(--on-surface-medium);
}

.suggestion--category {
  font-size: 14px;
}

.suggestion__count {
  margin-left: auto;
  padding: 0 8px;
  background: var(--surface-raised);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--on-surface-medium);
}

.suggestions a.suggestion--all {
  justify-content: center;
  margin-top: 6px;
  border-top: 1px solid var(--outline);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 600;
  color: var(--primary);
}

.suggestions__empty {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 8px;
  font-size: 14px;
  color: var(--on-surface-medium);
}

.suggestions__empty strong {
  color: var(--on-surface);
  font-size: 15px;
}

.suggestions a.suggestions__tip {
  display: inline;
  height: auto;
  padding: 0;
  background: none;
  font-size: inherit;
  font-weight: 600;
  color: var(--primary);
  text-decoration: underline;
}

/* --- Search page loading: progress bar + skeleton cards --- */
body[data-page="search"] #loading:not([hidden]) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#loading > * {
  flex-shrink: 0;
}

#loading .loading {
  min-height: 0;
  padding: 24px 16px 16px;
}

.skeleton-grid {
  flex: none;
  padding: 0 12px 24px;
  overflow: visible;
}

.skeleton-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
}

/* shimmer = "content is on its way" */
.skeleton,
.listing-card__thumb--photo.is-loading,
.listing__thumb--photo.is-loading,
.listing__layout.is-loading .listing__title,
.listing__layout.is-loading .listing__price,
.listing__layout.is-loading .listing__desc,
.listing__layout.is-loading address {
  background: linear-gradient(
    90deg,
    var(--surface-raised) 25%,
    color-mix(in srgb, var(--surface-raised) 55%, var(--surface)) 50%,
    var(--surface-raised) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.2s linear infinite;
}

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

.skeleton--thumb {
  height: 160px;
}

.skeleton--line {
  height: 12px;
}

.skeleton--short {
  width: 40%;
  height: 16px;
}

.skeleton--mid {
  width: 65%;
}

#loading.has-error .progress__bar {
  animation: none;
  width: 100%;
  background: var(--error);
}

.loading__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  text-align: center;
  animation: rise 0.3s ease both;
}

.loading__error p {
  font-size: 14px;
  color: var(--on-surface-medium);
}

/* photos fade in once loaded instead of popping in */
.listing-card__thumb--photo img,
.listing__thumb--photo img {
  transition:
    opacity 0.3s ease,
    transform 0.2s ease;
}

.listing-card__thumb--photo.is-loading img,
.listing__thumb--photo.is-loading img {
  opacity: 0;
}

/* --- Listing details skeleton --- */
.listing__layout.is-loading .listing__title {
  width: 60%;
  height: 32px;
  color: transparent;
}

.listing__layout.is-loading .listing__price {
  width: 30%;
  height: 24px;
  color: transparent;
}

.listing__layout.is-loading .listing__desc {
  height: 110px;
}

.listing__layout.is-loading address {
  display: block;
  width: 70%;
  height: 40px;
}

.listing__layout.is-loading .listing__thumb > img {
  opacity: 0.3;
}

.listing__layout.is-loaded .listing__info > * {
  animation: rise 0.35s ease both;
}

.listing__layout.is-loaded .listing__info > :nth-child(2) {
  animation-delay: 40ms;
}

.listing__layout.is-loaded .listing__info > :nth-child(3) {
  animation-delay: 80ms;
}

.listing__layout.is-loaded .listing__info > :nth-child(4) {
  animation-delay: 120ms;
}

[data-contact-link][aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.55;
}

/* --- Map loading overlay --- */
.location-card__map.has-map {
  position: relative;
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 500; /* above Leaflet panes */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--surface-raised);
  font-size: 14px;
  color: var(--on-surface-medium);
  transition: opacity 0.3s ease;
}

.map-loading.is-done {
  opacity: 0;
  pointer-events: none;
}

.map-loading.is-error {
  padding: 16px;
  text-align: center;
}

.map-status {
  padding: 16px;
  font-size: 14px;
  text-align: center;
  color: var(--on-surface-medium);
}

/* --- Spinner (contact button, map) --- */
.spinner {
  display: inline-block;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.map-loading .spinner {
  color: var(--primary);
}

/* --- Contact form sending state --- */
.btn.is-busy {
  gap: 10px;
  cursor: progress;
}

.btn:disabled {
  opacity: 0.75;
  filter: none;
  transform: none;
}

.message-form textarea {
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}

.message-form textarea:focus {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent);
}

.message-form textarea:read-only {
  opacity: 0.6;
}

.message-form__error:not([hidden]) {
  animation: rise 0.25s ease both;
}

/* --- Message-sent dialog scales in so the confirmation is noticed --- */
.dialog[open] {
  animation: pop-in 0.22s ease-out;
}

.dialog[open]::backdrop {
  animation: fade-in 0.22s ease-out;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation-duration: 0.01ms !important;
  }
}
