/* Dream Lands — broker-branded subdomain styles */

:root {
  --broker-accent: #1a6b3a;
}

/* ── Hide auth, nav items, and page sections in broker mode ─────────────── */

body.broker-mode .header-bell,
body.broker-mode .header-profile,
body.broker-mode #nav-tools-dropdown,
body.broker-mode .bnav-tab[data-tab="tools"],
body.broker-mode #home-main,
body.broker-mode .for-you-section,
body.broker-mode .site-footer,
body.broker-mode #contact-section,
body.broker-mode #reels-desktop-save,
body.broker-mode .reels-action-save {
  display: none !important;
}

/* ── No-scroll broker home: header + hero + listings rail fill the
   viewport exactly, with the listings rail scrolling horizontally
   instead of the page scrolling vertically. ─────────────────────────── */

html:has(body.broker-mode) {
  height: 100dvh;
  overflow: hidden;
}

body.broker-mode {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

body.broker-mode #site-header {
  flex-shrink: 0;
  position: static;
}

@media (max-width: 768px) {
  body.broker-mode {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }
}

/* ── Broker hero — full-bleed cover background ───────────────────────── */

/* The broker's channel art (inline background-image from JS; accent
   gradient when absent) covers the whole hero. A shade overlay keeps text
   legible and melts the bottom edge into the page background. */
body.broker-mode #hero {
  position: relative;
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: clamp(250px, 42dvh, 430px);
  padding: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.broker-hero-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom,
      rgba(6, 10, 8, .12) 0%,
      rgba(6, 10, 8, .32) 55%,
      var(--bg, #0e1512) 100%),
    linear-gradient(to right,
      rgba(6, 10, 8, .28) 0%,
      transparent 65%);
}

/* Profile column pinned to the hero bottom, above the shade */
.broker-yt-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem 1.1rem;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .broker-yt-body {
    padding: .75rem .75rem .9rem;
  }
}

/* Profile row: avatar + identity over the illustration */
.broker-yt-profile-row {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  position: relative;
}

/* ── Avatar ─────────────────────────────────────────────────────────────── */

.broker-hero-avatar {
  width: clamp(64px, 13dvh, 104px);
  height: clamp(64px, 13dvh, 104px);
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid rgba(255, 255, 255, .92);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
}

.broker-hero-avatar--initials {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--broker-accent);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -.02em;
  user-select: none;
}

/* Identity block beside avatar */
.broker-yt-identity {
  min-width: 0;
}

/* Listings count — replaces the mockup's location line under the title */
.broker-hero-count {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin: .35rem 0 0;
  font-size: .85rem;
  font-weight: 600;
  opacity: .85;
  white-space: nowrap;
}

.broker-hero-count svg {
  opacity: .8;
  flex-shrink: 0;
}

.broker-hero-name {
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 800;
  margin: 0;
  line-height: 1.2;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .5);
}

/* Full-width description line below the profile row */
.broker-hero-tagline {
  font-size: .8rem;
  opacity: .75;
  margin: .55rem 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
}

@media (max-width: 768px) {
  .broker-hero-tagline {
    -webkit-line-clamp: 3;
  }
}

/* ── CTA row ────────────────────────────────────────────────────────────── */

.broker-yt-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: .65rem;
}

.broker-hero-btn {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  font-size: .82rem;
  font-weight: 600;
  padding: .5rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .15s, transform .1s;
}

.broker-hero-btn:active {
  transform: scale(.96);
  opacity: .8;
}

.broker-hero-btn--call {
  background: var(--broker-accent);
  color: #fff;
  box-shadow: 0 2px 12px color-mix(in srgb, var(--broker-accent) 40%, transparent);
}

.broker-hero-btn--wa {
  background: #25d366;
  color: #fff;
  box-shadow: 0 2px 12px rgba(37, 211, 102, .3);
}

.broker-hero-btn--ghost {
  background: transparent;
  color: inherit;
  border: 1.5px solid rgba(128, 128, 128, .35);
  opacity: .85;
}

.broker-hero-btn--ghost:hover {
  background: rgba(128, 128, 128, .1);
  opacity: 1;
}

/* ── Find by Property Code — CTA on the main (non-broker) homepage hero ─── */

.broker-code-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .8rem 1.6rem;
  background: transparent;
  color: var(--text, #fff);
  border: 1.5px solid rgba(255, 255, 255, .25);
  border-radius: var(--r-full, 999px);
  font-size: .92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}

.broker-code-cta:hover {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .4);
}

/* ── Powered by — bottom of hero ────────────────────────────────────────── */

.broker-poweredby {
  display: none;
}

body.broker-mode .broker-poweredby {
  display: block;
  text-align: center;
  padding: .55rem 1rem 0;
  font-size: .68rem;
  line-height: 1.5;
  opacity: .4;
  flex-shrink: 0;
}

body.broker-mode .broker-poweredby svg {
  display: inline-block;
  vertical-align: -1px;
  margin-right: .25rem;
}

body.broker-mode .broker-poweredby a {
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

body.broker-mode .broker-poweredby a:hover {
  opacity: .8;
}

/* ── Find by Code — header widget ───────────────────────────────────────── */

.find-code-widget {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  /* icon on right, input expands left */
  gap: 0;
}

/* Icon-only trigger button */
.find-code-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  flex-shrink: 0;
  opacity: .75;
  transition: opacity .15s, background .15s;
}

.find-code-icon-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, .08);
}

.find-code-widget.open .find-code-icon-btn {
  opacity: 1;
}

/* Expanding input panel — hidden by default on desktop, never shown on mobile */
.find-code-expanded {
  display: flex;
  align-items: center;
  overflow: hidden;
  width: 0;
  opacity: 0;
  transition: width .22s ease, opacity .18s ease;
  pointer-events: none;
}

.find-code-widget.open .find-code-expanded {
  width: 190px;
  opacity: 1;
  pointer-events: all;
}

.find-code-hdr-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 .6rem;
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, .1);
  border: 1.5px solid rgba(255, 255, 255, .2);
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: inherit;
  outline: none;
}

.find-code-hdr-input::placeholder {
  font-weight: 400;
  letter-spacing: 0;
  opacity: .5;
}

.find-code-hdr-input:focus {
  border-color: rgba(255, 255, 255, .5);
}

.find-code-go {
  height: 32px;
  padding: 0 .75rem;
  font-size: .8rem;
  font-weight: 700;
  border: 1.5px solid rgba(255, 255, 255, .2);
  border-left: none;
  border-radius: 0 6px 6px 0;
  background: rgba(255, 255, 255, .15);
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.find-code-go:hover {
  background: rgba(255, 255, 255, .25);
}

.find-code-hdr-input.find-code-hdr-error {
  border-color: #e74c3c;
  animation: shake .2s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  75% {
    transform: translateX(4px);
  }
}

/* On mobile: expanded panel never shows inline — icon triggers modal */
@media (max-width: 768px) {
  .find-code-widget.open .find-code-expanded {
    width: 0;
    opacity: 0;
    pointer-events: none;
  }
}

/* ── Find by Code modal ─────────────────────────────────────────────────── */

.code-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.code-modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

/* The site is always dark-themed, so the modal is too — no OS color-scheme
   override (a light-scheme device would otherwise get white-on-white). */
.code-modal {
  background: var(--bg-2, #1c1c1e);
  color: var(--text, #f5f5f7);
  border: 1px solid var(--border, rgba(255, 255, 255, .08));
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .4);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.code-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.code-modal-sub {
  font-size: .82rem;
  opacity: .55;
  margin: -.5rem 0 0;
}

.code-modal-input-row {
  display: flex;
  gap: .5rem;
}

.code-modal-input {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .65rem .9rem;
  border-radius: 10px;
  border: 1.5px solid rgba(128, 128, 128, .3);
  background: transparent;
  color: inherit;
  outline: none;
}

.code-modal-input:focus {
  border-color: var(--broker-accent);
}

.code-modal-go {
  padding: .65rem 1.1rem;
  border-radius: 10px;
  border: none;
  background: var(--broker-accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: .9rem;
}

.code-modal-go:active {
  opacity: .8;
}

.code-modal-error {
  font-size: .82rem;
  color: #e74c3c;
  display: none;
}

.code-modal-error.visible {
  display: block;
}

.code-modal-close {
  position: absolute;
  align-self: flex-end;
  background: none;
  border: none;
  font-size: .8rem;
  cursor: pointer;
  color: inherit;
  line-height: 25px;
}

/* ── Recent Listings rail (broker home) ──────────────────────────────────
   Fills whatever vertical space is left below the hero and scrolls
   horizontally only — the broker home page itself never scrolls. ────── */

.broker-listings {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: .85rem 1.25rem calc(.85rem + env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.broker-listings-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-shrink: 0;
  margin-bottom: .6rem;
}

.broker-listings-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.broker-seeall-link {
  background: none;
  border: none;
  color: var(--broker-accent);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}

.broker-seeall-link:hover {
  text-decoration: underline;
}

.broker-listings-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  /* keep card shadow from being clipped */
}

.broker-listings-scroll::-webkit-scrollbar {
  height: 0;
}

/* Portrait reel cards (same as Explore) sized to the rail height —
   width follows from the 9/16 aspect ratio. */
.broker-listings-scroll .reel-card {
  flex-shrink: 0;
  height: 100%;
  max-height: 320px;
  aspect-ratio: 9 / 16;
  width: auto;
  scroll-snap-align: start;
}

.broker-seeall-tile {
  flex-shrink: 0;
  width: clamp(96px, 22dvh, 130px);
  height: 100%;
  max-height: 320px;
  border-radius: var(--radius, 14px);
  border: 1.5px dashed color-mix(in srgb, var(--broker-accent) 55%, transparent);
  background: color-mix(in srgb, var(--broker-accent) 10%, transparent);
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.3;
  scroll-snap-align: start;
  transition: background .15s;
}

.broker-seeall-tile:hover {
  background: color-mix(in srgb, var(--broker-accent) 20%, transparent);
}

.broker-seeall-tile:active {
  transform: scale(.97);
}

.broker-seeall-tile svg {
  color: var(--broker-accent);
}

/* ── Extra-compact hero for short viewports (older/small phones) ────────── */
@media (max-height: 700px) {
  body.broker-mode #hero {
    min-height: clamp(200px, 34dvh, 280px);
  }

  .broker-yt-body {
    padding-top: 1rem;
  }

  .broker-hero-avatar {
    width: clamp(48px, 8dvh, 64px);
    height: clamp(48px, 8dvh, 64px);
  }

  .broker-yt-actions {
    margin-top: .45rem;
    gap: .4rem;
  }

  .broker-hero-btn,
  .broker-code-cta {
    padding: .38rem .75rem;
    font-size: .76rem;
  }

  body.broker-mode .broker-poweredby {
    padding: .3rem 1rem .15rem;
    font-size: .62rem;
  }

  .broker-listings {
    padding-top: .5rem;
  }
}
/* ── Broker boot: full-page loader ───────────────────────────────────────
   Set pre-paint by an inline <head> script in index.html and cleared by
   nav.js once the broker hero + listings rail are built. Without it the
   generic home page paints during the brokers.json/master.json awaits and
   is then visibly replaced by the broker view.

   The whole of <body> is hidden, header included: the header is not neutral
   chrome on a broker page — applyBrokerBranding rewrites the Dream Lands
   mark's target and body.broker-mode drops the auth controls — so leaving it
   up just moves the visible swap into the header. The spinner hangs off
   <html>::after rather than a node inside <body>, so it survives that. */

html.broker-loading body {
  visibility: hidden;
}

/* Paint the page background on <html> while body is hidden, otherwise the
   loader sits on the browser's default white. */
html.broker-loading {
  background: var(--bg, #0e1512);
}

html.broker-loading::after {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid rgba(255, 255, 255, .18);
  border-top-color: var(--broker-accent, #fff);
  border-radius: 50%;
  animation: broker-boot-spin .9s linear infinite;
  z-index: 9999;
}

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

@media (prefers-reduced-motion: reduce) {
  html.broker-loading::after { animation-duration: 2.4s; }
}
