/*
 * The Trade-in page (templates/page-tradein.php, assets/js/tradein.js).
 * Loaded after deviceland.css and service.css, whose bands, type, panels
 * and steps it shares; this adds the search field, the device tiles, the
 * questions and the quote.
 *
 * PowerOn's product photos come on white. Multiplied onto the tile's paper
 * the white drops out, so a phone sits on our ground rather than in a white
 * box; the photos are never cropped or recoloured.
 */

.ti-hero {
  padding-top: calc(var(--head-h, 112px) + 56px);
  padding-bottom: 64px;
}

.ti-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(28px, 6vw, 96px);
  align-items: end;
}

.ti-hero .display {
  margin-top: 18px;
}

.ti-hero .lede {
  margin: 0;
  max-width: 30rem;
}

/* ---- Search --------------------------------------------------------------- */
/* The page's one action, so it reads as a field at a glance: a lighter
   surface than the paper, a hairline, a shadow barely there, and a button.
   An underline alone was passed over (owner, Sep 30). */
.ti-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 44px;
  height: 72px;
  padding: 0 10px 0 24px;
  border: 1px solid var(--hair-light-2);
  border-radius: var(--r-md, 10px);
  background: #fffdf9;
  box-shadow: 0 1px 2px rgba(42, 32, 24, 0.04), 0 10px 30px -18px rgba(42, 32, 24, 0.22);
  color: var(--ink);
  transition: border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

.ti-search:hover {
  border-color: var(--hair-dark-2);
}

.ti-search:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(22, 19, 15, 0.06), 0 10px 30px -18px rgba(42, 32, 24, 0.28);
}

.ti-search > svg {
  flex: none;
}

.ti-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.2;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.ti-search input::placeholder {
  color: rgba(22, 19, 15, 0.5);
}

.ti-search-go {
  flex: none;
  height: 52px;
}

.ti-search input::-webkit-search-cancel-button {
  filter: grayscale(1);
}

/* ---- Finder ---------------------------------------------------------------- */
.ti-finder-band {
  padding-top: 56px; padding-bottom: 88px;
  scroll-margin-top: calc(var(--head-h-stuck, 66px) + 16px);
}

.ti-finder {
  min-height: 420px;
}

.ti-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 10px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--muted-fg);
}

.ti-crumb {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.ti-crumb:hover {
  color: var(--ink);
}

.ti-crumb.is-current {
  color: var(--ink);
  cursor: default;
}

.ti-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.015em;
  color: var(--ink);
  outline: none;
}

.ti-count {
  margin: 14px 0 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-fg);
}

.ti-status {
  margin: 20px 0 0;
  max-width: 34rem;
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted-fg);
}

.ti-status a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---- Tiles ------------------------------------------------------------------- */
/* Hairlines drawn by the tiles themselves, so a short last row leaves plain
   paper rather than a filled block where the missing tiles would be. */
.ti-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--hair-light-2);
  border-left: 1px solid var(--hair-light);
}

.ti-tiles li {
  border-right: 1px solid var(--hair-light);
  border-bottom: 1px solid var(--hair-light);
}

.ti-tiles-model {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* A short row of categories spans the full width (five top categories left
   a third of the row empty); long lists keep their regular grid. */
.ti-tiles-category {
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
}

.ti-tiles li {
  display: flex;
  background: var(--paper-2);
}

.ti-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 28px 18px 24px;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: center;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.35s var(--ease);
}

.ti-tile:hover,
.ti-tile:focus-visible {
  background: var(--paper);
}

.ti-tile:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: -2px;
}

.ti-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
}

.ti-art img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.ti-tile-name {
  font-size: 14.5px;
  line-height: 1.35;
}

.ti-tiles-category .ti-tile-name {
  font-family: var(--display);
  font-size: 22px;
  line-height: 1.05;
}

/* A fixed icon height, so a wider tile (a short row spans the full width)
   gains air around the line icon, not a bigger icon. */
.ti-tiles-category .ti-art {
  aspect-ratio: auto;
  height: 76px;
}

.ti-tiles-category .ti-art img {
  width: auto;
  height: 100%;
  max-height: 76px;
}

.ti-tiles-category .ti-tile {
  padding-top: 34px; padding-bottom: 28px;
}

/* ---- A model ------------------------------------------------------------------ */
.ti-model-head {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--hair-light-2);
}

.ti-model-head .ti-art {
  aspect-ratio: 1 / 1;
}

.ti-model-head .ti-count {
  margin: 0 0 10px;
}

.ti-model-body {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: start;
  padding-top: 32px;
}

.ti-group {
  margin: 0 0 30px;
  padding: 0;
  border: 0;
}

.ti-group legend {
  margin-bottom: 12px;
  padding: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-fg);
}

.ti-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ti-choice {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--hair-light-2);
  border-radius: var(--r-pill);
  background: transparent;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease), color 0.3s var(--ease);
}

.ti-choice:hover {
  border-color: var(--ink);
}

.ti-choice[aria-checked='true'] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.ti-choice:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

.ti-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  cursor: pointer;
}

.ti-check input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--ink);
}

.ti-help {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted-fg);
}

.ti-condition-more {
  margin: -14px 0 30px;
}

.ti-condition-more summary {
  display: inline-flex;
  font-size: 13px;
  color: var(--muted-fg);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  list-style: none;
}

.ti-condition-more summary::-webkit-details-marker {
  display: none;
}

.ti-condition-detail {
  margin-top: 14px;
  padding: 18px 20px;
  border-left: 2px solid var(--ember-deep);
  background: var(--paper);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--muted-fg);
}

.ti-condition-detail p {
  margin: 0 0 8px;
  color: var(--ink);
}

.ti-condition-detail ul {
  margin: 0;
  padding-left: 18px;
}

/* ---- The quote ------------------------------------------------------------------ */
.ti-quote {
  position: sticky;
  top: calc(var(--head-h-stuck, 66px) + 24px);
  padding: 30px 30px 28px;
  border: 1px solid var(--hair-light);
  border-radius: var(--r-lg);
  background: var(--paper);
}

.ti-quote-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-fg);
}

.ti-quote-value {
  display: block;
  margin-top: 12px;
  font-family: var(--display);
  font-size: clamp(48px, 5vw, 68px);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  transition: opacity 0.3s var(--ease);
}

.ti-quote-waiting {
  margin: 14px 0 0;
  font-family: var(--display);
  font-size: clamp(26px, 2.4vw, 32px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: rgba(22, 19, 15, 0.62);
  text-wrap: balance;
}

.ti-quote-value.is-pending {
  opacity: 0.35;
}

.ti-quote-note {
  margin: 14px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted-fg);
}

.ti-quote-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
  margin-top: 24px;
}

.ti-fine {
  margin: 36px 0 0;
  max-width: 62rem;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted-fg);
}

/* ---- Small screens ------------------------------------------------------------ */
@media (max-width: 900px) {
  .ti-model-body {
    grid-template-columns: 1fr;
  }

  .ti-quote {
    position: static;
  }
}

@media (max-width: 820px) {
  .ti-hero {
    padding-top: calc(var(--head-h, 96px) + 32px);
    padding-bottom: 44px;
  }

  .ti-hero-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .ti-search {
    margin-top: 32px;
    height: 60px;
    padding: 0 8px 0 18px;
  }

  .ti-search input {
    font-size: 16px;
  }

  .ti-search-go {
    height: 44px;
    padding-left: 18px; padding-right: 18px;
  }

  .ti-finder-band {
    padding-top: 40px; padding-bottom: 64px;
  }
}

@media (max-width: 560px) {
  .ti-tiles,
  .ti-tiles-model {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ti-tile {
    padding: 20px 12px 18px;
  }

  .ti-tiles-category .ti-tile-name {
    font-size: 19px;
  }

  .ti-tiles-category .ti-art {
    height: 56px;
  }

  /* Two columns: an odd last category takes the whole row rather than
     leaving an empty cell beside it. */
  .ti-tiles-category li:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .ti-tiles-category .ti-tile {
    padding-top: 24px; padding-bottom: 20px;
  }

  .ti-model-head {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 18px;
  }

  .ti-quote {
    padding: 24px 22px;
  }
}
