/*
 * Tech Mansion — Device Surfaces (1.16.0)
 * ----------------------------------------
 * ONE consolidated stylesheet for the two surfaces the user judges:
 * the device card / Latest Devices grid and the single device page.
 * Enqueued AFTER design-system.css so these rules win on equal
 * specificity. Design goal: the Gemini mockups' cleanliness —
 * generous white space, one hairline, soft single shadow, flat
 * tinted spec tiles, deep-navy prices, nothing boxed-in-boxes.
 *
 * Tokens are local to this file (--tmd-*) so legacy layers cannot
 * leak values in.
 */

:root {
  --tmd-ink: #0b1f3a;
  --tmd-body: #33475e;
  --tmd-muted: #71859c;
  --tmd-line: #e3eaf1;
  --tmd-bg: #f5f8fb;
  --tmd-card: #ffffff;
  --tmd-navy: #003366;
  --tmd-navy-deep: #0a2547;
  --tmd-orange: #ff6600;
  --tmd-tile-bg: #f2f6fa;
  --tmd-radius: 20px;
  --tmd-shadow: 0 1px 2px rgba(10, 37, 71, .05), 0 10px 30px -12px rgba(10, 37, 71, .14);
  --tmd-shadow-hover: 0 2px 4px rgba(10, 37, 71, .06), 0 18px 38px -14px rgba(10, 37, 71, .22);
}

/* ============ Device grid (Latest Devices, archive, rails) ============ */

.tm-devices-grid,
.tm-latest-devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 22px;
  align-items: stretch;
}

/* ============ Device card ============ */

.tm-dcard.tm10-card {
  background: var(--tmd-card);
  border: 1px solid var(--tmd-line);
  border-radius: var(--tmd-radius);
  box-shadow: var(--tmd-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform .22s ease, box-shadow .22s ease;
}

.tm-dcard.tm10-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--tmd-shadow-hover);
}

/* Unified product-image stage: fixed ratio, centred contain,
   soft studio gradient, identical on every card. */
.tm-dcard-media.tm13-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(180deg, #fbfdff 0%, #eef3f8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 22px 10px;
  border-bottom: 1px solid var(--tmd-line);
}

.tm-dcard-media.tm13-card-media img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(10, 37, 71, .14));
}

/* Designed placeholder (no real image): glyph + brand, quiet. */
.tm-dcard-ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #9db2c6;
}
.tm-dcard-ph-glyph svg { width: 54px; height: 54px; }
.tm-dcard-ph-rule { width: 34px; height: 2px; border-radius: 2px; background: var(--tmd-line); }
.tm-dcard-ph-brand {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--tmd-muted);
}

/* Compare toggle: quiet pill on the stage, orange only when on. */
.tm13-card-compare {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--tmd-line);
  background: rgba(255, 255, 255, .92);
  color: var(--tmd-navy);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.tm13-card-compare:hover { border-color: var(--tmd-navy); }
.tm13-card-compare[aria-pressed="true"] {
  background: var(--tmd-orange);
  border-color: var(--tmd-orange);
  color: #fff;
}

/* Card body */
.tm-dcard-body.tm10-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 18px;
  flex: 1;
}

.tm10-card-tag {
  align-self: flex-start;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--tmd-navy);
  background: var(--tmd-tile-bg);
  padding: 4px 9px;
  border-radius: 999px;
}

.tm-dcard-title.tm10-card-title {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 800;
  line-height: 1.28;
  color: var(--tmd-ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tm-dcard-title.tm10-card-title a { color: inherit; text-decoration: none; }
.tm-dcard-title.tm10-card-title a:hover { color: var(--tmd-navy); }

/* Spec tiles: flat, tinted, no borders, no nested boxes. */
.tm13-card-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}
.tm13-card-tile {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--tmd-tile-bg);
  border-radius: 12px;
  padding: 9px 11px;
  min-width: 0;
}
.tm13-card-tile-icon { color: var(--tmd-navy); flex: 0 0 auto; display: inline-flex; }
.tm13-card-tile-icon svg { width: 19px; height: 19px; }
.tm13-card-tile-text { display: flex; flex-direction: column; min-width: 0; }
.tm13-card-tile-label {
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--tmd-muted);
}
.tm13-card-tile-value {
  font-size: .82rem;
  font-weight: 700;
  color: var(--tmd-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm10-card-specs { margin: 0; font-size: .86rem; color: var(--tmd-body); line-height: 1.5; }

/* Card footer: price left, quick specs right, one hairline above. */
.tm10-card-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--tmd-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.tm10-card-price {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--tmd-navy-deep);
}
.tm10-card-price span { display: block; font-size: .72rem; font-weight: 600; color: var(--tmd-muted); }
.tm10-card-rating { margin: 0; font-size: .85rem; font-weight: 700; color: var(--tmd-ink); }
.tm10-card-rating .fa-star { color: var(--tmd-orange); }
.tm10-card-rating span { color: var(--tmd-muted); font-weight: 600; }

.tm14-quick-specs {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--tmd-line);
  background: #fff;
  color: var(--tmd-navy);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}
.tm14-quick-specs:hover { border-color: var(--tmd-navy); background: var(--tmd-tile-bg); }

/* ============ Single device page (real tm13/tm14 hooks) ============ */

/* Hero: one white card; photo stage + titles + bento inside. */
.tm13-hero.tm-device-single-hero {
  background: var(--tmd-card);
  border: 1px solid var(--tmd-line);
  border-radius: 24px;
  box-shadow: var(--tmd-shadow);
  overflow: hidden;
}
.tm13-media-frame {
  background: linear-gradient(180deg, #fbfdff 0%, #edf2f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  border-radius: 18px;
}
.tm13-media-frame img {
  max-height: 340px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 16px 20px rgba(10, 37, 71, .16));
}
.tm13-title.tm-device-single-title {
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem);
  font-weight: 800;
  line-height: 1.12;
  color: var(--tmd-ink);
  letter-spacing: -.01em;
}
.tm13-subtitle { color: var(--tmd-muted); font-size: 1rem; }
.tm13-pill {
  border: 1px solid var(--tmd-line);
  background: var(--tmd-tile-bg);
  color: var(--tmd-navy);
  border-radius: 999px;
  font-weight: 700;
}

/* At-a-glance bento: flat tinted cards, hover lift, no nested boxes. */
.tm13-bento-card {
  background: var(--tmd-tile-bg);
  border: 0;
  border-radius: 16px;
  box-shadow: none;
  transition: transform .2s ease, background .2s ease;
}
.tm13-bento-card:hover { transform: translateY(-3px); background: #e9eff6; }
.tm13-bento-label {
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--tmd-muted);
}
.tm13-bento-main { color: var(--tmd-ink); font-weight: 800; }
.tm13-bento-sub { color: var(--tmd-body); }
.tm13-bento-icon { color: var(--tmd-navy); }

/* Sub-nav: floating white pill bar (works with the 1.14 scroll-spy). */
.tm13-subnav {
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--tmd-line);
  border-radius: 999px;
  box-shadow: var(--tmd-shadow);
}

/* Spec groups: white cards, hairline ROWS inside — never boxed tiles. */
.tm13-spec-card {
  background: var(--tmd-card);
  border: 1px solid var(--tmd-line);
  border-radius: 18px;
  box-shadow: var(--tmd-shadow);
  overflow: hidden;
  margin-bottom: 18px;
}
.tm13-spec-card-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--tmd-line);
  background: #fff;
}
.tm13-spec-card-head h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--tmd-ink);
}
.tm13-spec-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--tmd-tile-bg);
  color: var(--tmd-navy);
  flex: 0 0 auto;
}
.tm13-spec-grid { margin: 0; padding: 6px 20px 12px; }
.tm13-spec-row {
  display: grid;
  grid-template-columns: minmax(120px, 34%) 1fr;
  gap: 8px 18px;
  padding: 10px 0;
  border-bottom: 1px solid var(--tmd-line);
}
.tm13-spec-row:last-child { border-bottom: 0; }
.tm-device-spec-label {
  font-size: .82rem;
  font-weight: 700;
  color: var(--tmd-muted);
  margin: 0;
}
.tm-device-spec-value {
  font-size: .94rem;
  font-weight: 550;
  color: var(--tmd-ink);
  margin: 0;
  line-height: 1.55;
}
/* Nested sub-groups read as an indented continuation, not a new box. */
.tm-device-spec-pair-group > .tm-device-spec-value-group { padding-left: 0; }
.tm-device-spec-value-group .tm13-spec-grid { padding: 0; }
.tm-device-spec-value-group .tm13-spec-row { border-bottom: 0; padding: 4px 0; }

/* Sidebar cards + price */
.tm13-side-card {
  background: var(--tmd-card);
  border: 1px solid var(--tmd-line);
  border-radius: 18px;
  box-shadow: var(--tmd-shadow);
}
.tm13-side-price,
.tm-device-offer-price {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--tmd-navy-deep);
}
.tm13-btn--primary {
  background: var(--tmd-navy);
  border-color: var(--tmd-navy);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
}
.tm13-btn--primary:hover { background: var(--tmd-navy-deep); }
.tm13-btn--ghost {
  border: 1px solid var(--tmd-line);
  border-radius: 999px;
  color: var(--tmd-navy);
  font-weight: 700;
  background: #fff;
}

/* Scores (only rendered when real scores exist) */
.tm14-scores {
  background: var(--tmd-card);
  border: 1px solid var(--tmd-line);
  border-radius: 18px;
  box-shadow: var(--tmd-shadow);
}
.tm14-score-track { background: var(--tmd-tile-bg); border-radius: 999px; }
.tm14-score-fill { background: var(--tmd-orange); border-radius: 999px; }

/* Mobile sticky price + compare bar (real hook: .tm10-stickybar) */
.tm10-stickybar {
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--tmd-line);
  border-radius: 999px;
  box-shadow: var(--tmd-shadow-hover);
}
.tm10-stickybar-price { font-weight: 800; color: var(--tmd-navy-deep); }
.tm10-stickybar-btn {
  background: var(--tmd-navy);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .tm-dcard.tm10-card, .tm13-bento-card { transition: none; }
  .tm-dcard.tm10-card:hover, .tm13-bento-card:hover { transform: none; }
}
