/* MyTopo-side custom-map cart page (draft-order checkout flow). */

body.cmc-page > .site-header {
  display: none;
}

/* The [hidden] attribute must win over the flex/grid display rules below,
 * otherwise toggled elements (empty state, total row, checkout panel) stay
 * visible even when JS sets `hidden`. */
.cmc [hidden] {
  display: none !important;
}

.cmc {
  max-width: 1120px;
  margin: 0 auto;
  padding: calc(var(--cfg-topbar-h, 60px) + 32px) 24px 64px;
  box-sizing: border-box;
}

/* ---- Heading + Add Map -------------------------------------------------- */
.cmc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 8px;
}

.cmc__heading {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
}

.cmc__add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid #006ca2;
  border-radius: 8px;
  color: #006ca2;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.cmc__add:hover {
  background: #006ca2;
  color: #fff;
}

/* ---- Empty state -------------------------------------------------------- */
.cmc__empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding: 40px 0;
}

.cmc__empty-text {
  margin: 0;
  font-size: 16px;
  color: #475569;
}

/* ---- Cart rows (reference-style table) ---------------------------------- */
.cmc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cmc-item {
  display: grid;
  grid-template-columns: 56px minmax(120px, 1fr) 92px 124px 96px 74px 32px;
  align-items: center;
  gap: 12px;
  padding: 16px 4px;
  border-bottom: 1px solid #e5e9ec;
}

.cmc-item__thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  background: #eef2f4;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.cmc-item__thumb--empty span {
  font-size: 10px;
  color: #94a3b8;
  text-align: center;
}

.cmc-item__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cmc-item__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.cmc-item__attr {
  font-size: 12.5px;
  color: #64748b;
}

/* First attribute line (base map type) a touch stronger. */
.cmc-item__attr:not(.cmc-item__attr--sub) {
  color: #475569;
}

/* Compact under-title summary (map type / dimensions / private-land overlay).
 * Hidden on desktop + tablet; only the portrait-phone media query reveals it. */
.cmc-item__compact {
  display: none;
}

.cmc-item__ref {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #64748b;
  background: #eef2f4;
  border-radius: 4px;
  padding: 1px 6px;
  width: fit-content;
  font-variant-numeric: tabular-nums;
}

.cmc-item__more {
  margin-top: 6px;
  padding: 0;
  border: none;
  background: none;
  color: #006ca2;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  width: fit-content;
}

.cmc-item__more:hover {
  text-decoration: underline;
}

/* Full-width expandable parameter panel */
.cmc-item__details {
  grid-column: 1 / -1;
  margin: 4px 0 2px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.cmc-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 24px;
  margin: 0;
}

.cmc-detail {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cmc-detail__k {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cmc-detail__v {
  font-size: 13px;
  color: #0f172a;
  word-break: break-word;
}

.cmc-item__date {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  color: #475569;
}

.cmc-item__date-t {
  color: #94a3b8;
}

.cmc-item__spec {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  color: #475569;
}

.cmc-item__spec-line:not(:first-child) {
  color: #94a3b8;
}

/* Quantity stepper */
.cmc-item__qty {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  height: 34px;
  width: fit-content;
}

.cmc-qty__btn {
  border: none;
  background: #f8fafc;
  color: #334155;
  width: 28px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cmc-qty__btn:hover:not(:disabled) {
  background: #eef2f4;
}

.cmc-qty__btn:disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}

.cmc-qty__input {
  width: 32px;
  border: none;
  border-left: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  text-align: center;
  font-size: 14px;
  color: #0f172a;
  background: #fff;
  pointer-events: none;
}

.cmc-item__price {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  text-align: right;
  white-space: nowrap;
}

.cmc-item__actions {
  display: flex;
  justify-content: flex-end;
}

.cmc-item__remove {
  border: none;
  background: none;
  padding: 6px;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
}

.cmc-item__remove:hover {
  color: #c0180c;
  background: #fdf0ee;
}

/* ---- Total footer row --------------------------------------------------- */
.cmc-total {
  display: flex;
  align-items: baseline;
  gap: 32px;
  justify-content: flex-end;
  padding: 16px 4px;
  background: #f6f8f9;
  border-radius: 8px;
  margin-top: 4px;
}

.cmc-total__label {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin-right: auto;
  padding-left: 8px;
}

.cmc-total__count {
  font-size: 13px;
  color: #64748b;
}

.cmc-total__amount {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  padding-right: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---- Two-column body: cart rows (left) + checkout panel (right) --------- */
.cmc__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
  margin-top: 20px;
}

.cmc__main {
  min-width: 0;
}

/* ---- Checkout (contact + proceed) --------------------------------------- */
.cmc-summary {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 20px;
  box-sizing: border-box;
  position: sticky;
  top: calc(var(--cfg-topbar-h, 60px) + 24px);
}

.cmc-summary__note {
  margin: 0 0 16px;
  font-size: 12px;
  color: #64748b;
}

.cmc-summary__error {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fdf0ee;
  border: 1px solid #f8c9c4;
  color: #8b2017;
  font-size: 13px;
}

.cmc-summary__checkout {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.cmc-summary__lock {
  margin: 14px 0 0;
  font-size: 11.5px;
  color: #94a3b8;
  text-align: center;
}

/* ---- Responsive -------------------------------------------------------- */
/* Below ~1080px the 7-column row needs the full page width, so drop the right
 * sidebar to its own row (checkout goes under the cart). */
@media (max-width: 1080px) {
  .cmc__body {
    grid-template-columns: 1fr;
  }
  .cmc-summary {
    position: static;
    max-width: 420px;
  }
}

/* On phones collapse each row into a stacked card. */
@media (max-width: 720px) {
  .cmc-item {
    grid-template-columns: 64px 1fr auto;
    grid-template-areas:
      "thumb main price"
      "thumb spec price"
      "thumb date qty"
      "thumb actions actions";
    row-gap: 6px;
    column-gap: 12px;
    align-items: start;
  }
  .cmc-item__thumb { grid-area: thumb; }
  .cmc-item__main { grid-area: main; }
  .cmc-item__spec { grid-area: spec; }
  .cmc-item__date { grid-area: date; }
  .cmc-item__qty { grid-area: qty; }
  .cmc-item__price { grid-area: price; }
  .cmc-item__actions { grid-area: actions; justify-content: flex-start; }
}

/* Portrait phones ONLY (explicitly not tablets — those stay on the layouts
 * above).  A compact four-column card:
 *   col 1  — preview image at the top, quantity stepper directly below it
 *            (both fill the column edge-to-edge so there's no dead gap beside
 *            the thumbnail)
 *   col 2  — map name (bold), then a compact summary in a smaller font (map
 *            type, dimensions, and the private-land overlay only when added),
 *            then the map ID, then "show more" for the rest
 *   col 3  — order date and line price stacked at the TOP of the card (both
 *            live in row 1: date hugs the top, price the bottom of the 64px
 *            row, so they read one-after-the-other level with the title)
 *   col 4  — a slim column holding just the delete button
 * Placed after the 720px block so its grid template wins at phone widths; the
 * per-element grid-area tokens are inherited from that block. */
@media (max-width: 600px) and (orientation: portrait) {
  .cmc-item {
    /* Narrow left column that the thumb + (shrunk) stepper both fill exactly, so
     * there's no dead space beside a 64px thumb.  col 3 (date/price) and col 4
     * (trash) hug their content; minmax(0,1fr) lets the middle column absorb the
     * slack without overflowing long titles. */
    grid-template-columns: 72px minmax(0, 1fr) auto auto;
    /* Row 1 is pinned to the 64px preview height so the quantity stepper (row 2)
     * sits immediately beneath the image.  main / actions span both rows; the
     * date + price are BOTH placed in row 1 / col 3 (see below) so they stack at
     * the top of the card no matter how tall the middle column grows. */
    grid-template-rows: 64px auto;
    grid-template-areas:
      "thumb  main    meta    actions"
      "qty    main    .       actions";
    column-gap: 12px;
    row-gap: 8px;
    align-items: start;
    padding-bottom: 20px;
  }

  /* Middle column = title + compact summary + map ID + "Show more".  The
   * verbose attribute lines and the whole spec column collapse into the compact
   * summary above; the full breakdown stays behind "Show more".  The ID chip is
   * kept visible (above "Show more") so the map is identifiable at a glance. */
  .cmc-item__compact {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 3px;
  }
  .cmc-item__compact-line {
    font-size: 12.5px;
    color: #64748b;
  }
  .cmc-item__main .cmc-item__attr,
  .cmc-item__spec {
    display: none;
  }
  /* Map ID sits just above "Show more" in the middle column. */
  .cmc-item__ref {
    margin-top: 4px;
  }

  /* Preview fills the full width of the left column (no dead space beside it). */
  .cmc-item__thumb {
    align-self: start;
    justify-self: stretch;
    width: 100%;
    height: 64px;
  }

  /* Quantity stepper pinned to the top of row 2 — i.e. directly below the
   * preview image (only the 8px row-gap between them) — and stretched to the
   * same full column width as the thumbnail.  The buttons shrink and the value
   * flexes to fill so the whole control lines up under the preview. */
  .cmc-item__qty {
    align-self: start;
    justify-self: stretch;
    width: 100%;
  }
  .cmc-item__qty .cmc-qty__btn {
    width: 24px;
  }
  .cmc-item__qty .cmc-qty__input {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Date + price both live in the single 64px row-1 col-3 cell ("meta"), left
   * aligned and stacked at the TOP of the card: the date hugs the top of the
   * cell (level with the title) and the price the bottom, so they read
   * one-after-the-other near the top no matter how tall the middle column grows
   * (row 1 is fixed at 64px, so the middle column's growth spills into row 2 and
   * never pushes this pair down). */
  .cmc-item__date {
    grid-area: meta;
    align-self: start;
    justify-self: start;
  }
  .cmc-item__price {
    grid-area: meta;
    align-self: end;
    justify-self: start;
    text-align: left;
  }

  /* Slim last column: trash pinned to the top. */
  .cmc-item__actions {
    align-self: start;
    justify-content: center;
  }
}
