/* ============================================================
   HypeCity Tycoon — Market Browse Styles
   Phase A · Filter bar, card grid, list view, property detail
   ============================================================ */

/* ── Filter Bar (sticky) ───────────────────────────────────── */
.market-filters {
  position: sticky;
  top: var(--nav-height);
  z-index: 100;
  background: var(--color-surface-elevated);
  border-bottom: 1px solid var(--color-border-subtle);
  padding: var(--space-3) var(--content-padding);
}

.market-filters__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.market-filters__search {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.market-filters__search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-tertiary);
  font-size: var(--text-md);
  pointer-events: none;
}

.market-filters__search-input {
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) 40px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  transition: border-color var(--transition-hover);
  min-height: 44px;
}

.market-filters__search-input:focus {
  border-color: var(--color-primary);
  outline: none;
}

.market-filters__search-input::placeholder {
  color: var(--color-text-disabled);
}

.market-filters__select {
  min-height: 44px;
  min-width: 140px;
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23707070' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 01.753 1.659l-4.796 5.48a1 1 0 01-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--transition-hover);
}

.market-filters__select:focus {
  border-color: var(--color-primary);
  outline: none;
}

/* ── View Toggle ───────────────────────────────────────────── */
.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-toggle__btn {
  min-width: 44px;
  min-height: 36px;
  padding: var(--space-1) var(--space-3);
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--color-text-tertiary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--transition-hover);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.view-toggle__btn:hover {
  color: var(--color-text-secondary);
}

.view-toggle__btn[aria-pressed="true"] {
  background: var(--color-primary);
  color: var(--color-bg);
  font-weight: var(--weight-semibold);
}

.view-toggle__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Results info bar ──────────────────────────────────────── */
.market-results-bar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-3) var(--content-padding);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.market-results-bar__count {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  font-family: var(--font-mono);
}

.market-results-bar__count strong {
  color: var(--color-primary);
}

/* GAME-004: persona lens chip — shown when an active persona is set
   so players know their card scores are personalized. */
.market-persona-lens {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  background: rgba(139, 111, 61, 0.10);
  border: 1px solid rgba(139, 111, 61, 0.35);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}
.market-persona-lens__icon { font-size: 13px; }
.market-persona-lens strong { color: #8B6F3D; font-weight: 600; }
.market-persona-lens__change {
  margin-left: 4px;
  color: var(--color-text-tertiary);
  text-decoration: underline;
}
.market-persona-lens__change:hover { color: #8B6F3D; }

/* ── Card Grid ─────────────────────────────────────────────── */
.market-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--content-padding) var(--space-12);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

/* ── Property Card ─────────────────────────────────────────── */
.prop-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  cursor: pointer;
  transition: all var(--transition-default);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.prop-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  /* ambient brass warmth on hover (Night2) — falls back to the flat ring
     where --glow-brass is undefined (older inline-token pages). */
  box-shadow: 0 0 0 1px var(--color-primary), var(--glow-brass, var(--shadow-card));
}

.prop-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.prop-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.prop-card__location {
  flex: 1;
  min-width: 0;
}

.prop-card__country {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.prop-card__city {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.prop-card__neighborhood {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  margin-top: 2px;
}

.prop-card__score {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 32px;
  padding: 0 var(--space-3);
  background: rgba(139, 111, 61, 0.1);
  border: 1px solid rgba(139, 111, 61, 0.25);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
}

/* GAME-004: persona-weighted score uses a distinct accent so players
   can see at-a-glance that the badge reflects THEIR lens, not the
   one-size-fits-all composite. */
.prop-card__score--persona {
  background: rgba(139, 111, 61, 0.14);
  border-color: rgba(139, 111, 61, 0.55);
  color: #8B6F3D;
  box-shadow: 0 0 0 1px rgba(139, 111, 61, 0.10) inset;
}

/* Day 14 S2 (2/4): representative-total price line, sits between header
   and stats. Visually prominent — green, mono, large — so users can
   compare neighborhoods on absolute price without clicking through. */
.prop-card__total {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
  padding: 2px 0 6px;
  letter-spacing: -0.01em;
}

/* Day 14 S2 (3/4): affordability toggle in filter bar. Two states —
   off (gray border, neutral) / on (filled green chip). Aria-pressed
   drives the visual via the .affordable-toggle--on JS-applied class. */
.affordable-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
}
.affordable-toggle:hover {
  border-color: var(--color-text-tertiary);
  color: var(--color-text-primary);
}
.affordable-toggle--on,
.affordable-toggle[aria-pressed="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-bg);
}
.affordable-toggle--on:hover,
.affordable-toggle[aria-pressed="true"]:hover {
  background: var(--color-primary-hover, #00B86B);
  border-color: var(--color-primary-hover, #00B86B);
  color: var(--color-bg);
}
.affordable-toggle__icon { font-size: 14px; }

/* Day 14 S2 (3/4): unaffordable card visual — only shown when the
   filter is OFF (filter-ON path drops them entirely). Greyed body +
   red shortfall badge + disabled Buy button. */
.prop-card--unaffordable {
  opacity: 0.55;
  filter: grayscale(0.3);
  position: relative;
}
.prop-card--unaffordable .prop-card__total {
  color: var(--color-text-tertiary);
}
.prop-card--unaffordable:hover {
  opacity: 0.85;
}
.prop-card--unaffordable .prop-card__buy-btn[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}
.prop-card__shortfall {
  display: inline-block;
  align-self: flex-start;
  margin-top: 4px;
  padding: 3px 9px;
  background: rgba(229, 90, 90, 0.12);
  border: 1px solid rgba(229, 90, 90, 0.4);
  color: #E55A5A;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.5px;
}

.prop-card__divider {
  height: 1px;
  background: var(--color-border-subtle);
}

.prop-card__stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.prop-card__stat {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.prop-card__stat-value {
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

.prop-card__type {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  padding: 2px var(--space-2);
  background: var(--color-surface-elevated);
  border-radius: var(--radius-sm);
}

.prop-card__footer {
  margin-top: auto;
  font-size: var(--text-sm);
  color: var(--color-primary);
  font-weight: var(--weight-medium);
}

.prop-card__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: auto;
}

.prop-card__actions .btn {
  flex: 1;
  justify-content: center;
  text-align: center;
}

/* ── List View ─────────────────────────────────────────────── */
.market-list {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--content-padding) var(--space-12);
  display: none;
}

.market-list.active {
  display: block;
}

.market-grid.active {
  display: grid;
}

.list-row {
  display: grid;
  grid-template-columns: 1fr 100px 90px 90px 80px;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
  text-decoration: none;
  transition: background var(--transition-hover);
  min-height: 52px;
}

.list-row:hover {
  background: var(--color-surface);
}

.list-row:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.list-row__name {
  min-width: 0;
}

.list-row__neighborhood {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-row__city {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.list-row__price,
.list-row__yield,
.list-row__score {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-align: right;
}

.list-row__score {
  color: var(--color-primary);
  font-weight: var(--weight-bold);
}

.list-row__yield {
  color: var(--color-success);
}

.list-row__price {
  color: var(--color-text-secondary);
}

.list-row__type {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  text-align: right;
}

.list-header {
  display: grid;
  grid-template-columns: 1fr 100px 90px 90px 80px;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-disabled);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--color-border-default);
}

.list-header span:not(:first-child) {
  text-align: right;
}

/* ── Load More / Pagination ────────────────────────────────── */
.market-load-more {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--content-padding) var(--space-16);
  text-align: center;
}

/* ── Skeleton Loading ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-surface-elevated) 50%, var(--color-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.skeleton-line {
  height: 14px;
  border-radius: 3px;
}

.skeleton-line--short { width: 40%; }
.skeleton-line--medium { width: 65%; }
.skeleton-line--long { width: 90%; }

/* ── Empty State ───────────────────────────────────────────── */
.market-empty {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-16) var(--content-padding);
  text-align: center;
}

.market-empty__icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
}

.market-empty__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.market-empty__desc {
  font-size: var(--text-base);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-6);
}

/* ── Property Detail Page ──────────────────────────────────── */
.prop-detail {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-6) var(--content-padding) var(--space-16);
}

.prop-detail__hero {
  margin-bottom: var(--space-8);
}

.prop-detail__breadcrumb {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-4);
}

.prop-detail__breadcrumb a {
  color: var(--color-text-tertiary);
  text-decoration: none;
}

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

.prop-detail__flag {
  font-size: 32px;
  margin-bottom: var(--space-2);
}

.prop-detail__neighborhood {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  letter-spacing: -0.5px;
  margin-bottom: var(--space-1);
}

.prop-detail__city {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}

.prop-detail__score-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: rgba(139, 111, 61, 0.1);
  border: 1px solid rgba(139, 111, 61, 0.25);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
}

.prop-detail__numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.prop-detail__number-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.prop-detail__number-label {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-1);
}

.prop-detail__number-value {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
}

.prop-detail__flags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.prop-detail__flag-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.prop-detail__flag-badge--positive {
  background: rgba(139, 111, 61, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(139, 111, 61, 0.2);
}

.prop-detail__flag-badge--negative {
  background: rgba(255, 71, 71, 0.1);
  color: var(--color-error);
  border: 1px solid rgba(255, 71, 71, 0.2);
}

.prop-detail__flag-badge--neutral {
  background: var(--color-surface-elevated);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-subtle);
}

.prop-detail__section {
  margin-bottom: var(--space-8);
}

/* GAME-006: persona-score explainer panel — sits between header and
   About on the property detail page. Educational; each row shows
   factor + normalized 0-100 bar + weight + contribution + a one-line
   tip with a methodology link (the Game→Pro funnel). */
.persona-score-panel {
  background: rgba(139, 111, 61, 0.04);
  border: 1px solid rgba(139, 111, 61, 0.25);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-8);
}
.persona-score-panel__lede {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: var(--space-2) 0 var(--space-4);
}
.persona-score-panel__footer {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}
.persona-score-panel__footer a {
  color: #8B6F3D;
  text-decoration: none;
}
.persona-score-panel__footer a:hover { text-decoration: underline; }

.persona-score-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.persona-score-row {
  display: grid;
  grid-template-columns: 140px 1fr 60px 50px;
  grid-template-areas:
    "factor bar weight contrib"
    "tip    tip tip    tip";
  gap: var(--space-2) var(--space-3);
  align-items: center;
}
.persona-score-row__factor {
  grid-area: factor;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
}
.persona-score-row__bar {
  grid-area: bar;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.persona-score-row__bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #8B6F3D 0%, #C9A961 100%);
  border-radius: var(--radius-full);
}
.persona-score-row__weight {
  grid-area: weight;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-tertiary);
  text-align: right;
}
.persona-score-row__contrib {
  grid-area: contrib;
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  font-weight: 700;
  color: #8B6F3D;
  text-align: right;
}
.persona-score-row__tip {
  grid-area: tip;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  line-height: 1.5;
  padding-left: 150px;  /* aligns under bar */
}
.persona-score-row__tip a {
  color: #8B6F3D;
  text-decoration: none;
}
.persona-score-row__tip a:hover { text-decoration: underline; }
@media (max-width: 640px) {
  .persona-score-row {
    grid-template-columns: 1fr 50px;
    grid-template-areas:
      "factor contrib"
      "bar    bar"
      "weight weight"
      "tip    tip";
  }
  .persona-score-row__tip { padding-left: 0; }
}

.prop-detail__section-title {
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: var(--space-4);
}

.prop-detail__map-embed {
  width: 100%;
  height: 250px;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.prop-detail__map-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
  filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(1.1);
}

.prop-detail__coming-soon {
  background: var(--color-surface);
  border: 2px dashed var(--color-border-default);
  border-radius: var(--radius-md);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  color: var(--color-text-tertiary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* ── 404 State ─────────────────────────────────────────────── */
.prop-404 {
  text-align: center;
  padding: var(--space-24) var(--content-padding);
}

.prop-404__title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-3);
}

.prop-404__desc {
  font-size: var(--text-md);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-6);
}

/* ── Persona welcome on landing ────────────────────────────── */
.persona-welcome {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-8);
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.persona-welcome__emoji {
  font-size: 40px;
  flex-shrink: 0;
}

.persona-welcome__text {
  flex: 1;
}

.persona-welcome__greeting {
  font-size: var(--text-md);
  color: var(--color-text-primary);
  font-weight: var(--weight-semibold);
}

.persona-welcome__persona {
  font-size: var(--text-sm);
  color: var(--color-primary);
  margin-top: 2px;
}

/* ── Mobile Responsive ─────────────────────────────────────── */
@media (max-width: 640px) {
  .market-filters__inner {
    flex-direction: column;
    align-items: stretch;
  }

  .market-filters__search {
    min-width: 100%;
  }

  .market-filters__select {
    min-width: 100%;
  }

  .view-toggle {
    align-self: flex-start;
  }

  .market-grid {
    grid-template-columns: 1fr;
  }

  .list-row {
    grid-template-columns: 1fr 80px 70px;
  }

  .list-row__yield,
  .list-row__type {
    display: none;
  }

  .list-header span:nth-child(4),
  .list-header span:nth-child(5) {
    display: none;
  }

  .list-header {
    grid-template-columns: 1fr 80px 70px;
  }

  .prop-detail__numbers {
    grid-template-columns: repeat(2, 1fr);
  }

  .prop-detail__neighborhood {
    font-size: var(--text-2xl);
  }

  .persona-welcome {
    flex-direction: column;
    text-align: center;
  }
}
