/* === "How Deelva works" — 5-step guided tour modal (shared component, R152) ===
   The SAME modal opens from the "How it works" link on both the welcome page
   (index.html) and the app (app.html). It is a 5-step carousel (Welcome cover ->
   5 steps -> Finish cover) with a two-column split, numbered sub-steps, a
   clickable step rail, Back/Next, keyboard arrows, and highlight rings.

   Markup is injected by howitworks.js. Every class is prefixed .hiwm- and all
   brand tokens are scoped to .hiwm-modal so nothing collides with — or leaks
   into — either host page's stylesheet. Recreated from the design handoff. */

.hiwm-modal {
  /* scoped design tokens (from the handoff) */
  --hiwm-charcoal: #0F1F2C;
  --hiwm-charcoal-700: #1F3447;
  --hiwm-forest: #2E5A38;
  --hiwm-forest-700: #234A2D;
  --hiwm-forest-100: #D0E5D5;
  --hiwm-sage-100: #E2EBE0;
  --hiwm-cream: #EFE7D5;
  --hiwm-cream-50: #FBF8F1;
  --hiwm-copy-panel: #ECE3CF;
  --hiwm-mute: rgba(15, 31, 44, 0.55);
  --hiwm-mute-2: rgba(15, 31, 44, 0.34);
  --hiwm-rule: rgba(15, 31, 44, 0.10);
  --hiwm-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --hiwm-shadow-modal: 0 40px 100px -30px rgba(15, 31, 44, 0.55), 0 0 0 1px rgba(15, 31, 44, 0.06);
  --hiwm-shadow-card: 0 12px 28px -16px rgba(15, 31, 44, 0.42), 0 0 0 1px rgba(15, 31, 44, 0.10);
}

/* ---- backdrop + centering layer ------------------------------------- */
.hiwm-backdrop {
  position: fixed; inset: 0; z-index: 9000;
  background: radial-gradient(120% 90% at 30% 0%, rgba(244, 238, 224, 0.92) 0%, rgba(231, 223, 204, 0.92) 55%, rgba(218, 208, 184, 0.94) 100%);
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.hiwm-backdrop.is-open { opacity: 1; pointer-events: auto; }

.hiwm-modal {
  position: fixed; inset: 0; z-index: 9001;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s var(--hiwm-ease);
  font-family: "Satoshi", "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: var(--hiwm-charcoal);
  -webkit-font-smoothing: antialiased;
}
.hiwm-modal.is-open { opacity: 1; pointer-events: auto; }
/* the [hidden] attribute must win over the display rules above */
.hiwm-modal[hidden] { display: none; }
.hiwm-btn[hidden], .hiwm-rail-dot[hidden] { display: none; }

/* ---- card shell ----------------------------------------------------- */
.hiwm-card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--hiwm-cream-50);
  border-radius: 24px; overflow: hidden;
  box-shadow: var(--hiwm-shadow-modal);
  width: min(1060px, 100%);
  height: 680px;
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
}

/* ---- header --------------------------------------------------------- */
.hiwm-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; flex: 0 0 auto;
  border-bottom: 1px solid var(--hiwm-rule);
  background: var(--hiwm-cream-50);
}
.hiwm-brand { display: flex; align-items: center; gap: 10px; }
.hiwm-mark { display: flex; }
.hiwm-word { font-weight: 700; font-size: 18px; letter-spacing: 0.01em; }
.hiwm-word b { color: var(--hiwm-forest); font-weight: 700; }
.hiwm-sep { width: 1px; height: 16px; background: var(--hiwm-rule); }
.hiwm-headlabel {
  font-weight: 700; font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--hiwm-mute);
}
.hiwm-close {
  border: 0; background: var(--hiwm-sage-100); color: var(--hiwm-charcoal);
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background 0.15s ease;
}
.hiwm-close:hover { background: var(--hiwm-forest-100); }

/* ---- slide track ---------------------------------------------------- */
.hiwm-track { position: relative; flex: 1 1 auto; min-height: 0; }
.hiwm-slide {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  transform: translateX(18px);
  transition: opacity 0.42s ease, transform 0.42s ease;
  /* The welcome page's global CSS sets `section { padding: 96px 0 }`. Our slides
     are <section>s, so without this reset that padding shrinks the grid content
     box (border-box) and the columns collapse into a centered band with gaps top
     and bottom. Force padding/margin off so the slide always fills the track. */
  padding: 0; margin: 0;
}
.hiwm-slide.is-active { opacity: 1; pointer-events: auto; transform: none; }
.hiwm-slide.is-prev { transform: translateX(-18px); }

/* ---- step slide: two-column split ----------------------------------- */
/* grid-template-rows: minmax(0,1fr) forces the single row to fill the slide's
   full height regardless of content size or align-content quirks, so both
   columns (and the dark copy panel) always span header-to-footer. */
.hiwm-step { display: grid; grid-template-columns: 1.18fr 1fr; grid-template-rows: minmax(0, 1fr); }
.hiwm-media {
  background: linear-gradient(160deg, #FCFAF4, #F5F0E4);
  padding: 30px; display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--hiwm-rule); min-width: 0; min-height: 0;
}
/* The header and footer carry an opaque background and paint above the
   absolutely-stacked slides, so the brand, step rail, and Back/Next can never be
   covered even if a slide's media is taller than its cell. We do NOT clip the
   media, so the Step 1 "Switch views here" marker (which sits just outside the
   media box) is never cut off. */
.hiwm-foot { position: relative; z-index: 2; }
.hiwm-head { position: relative; z-index: 2; }
.hiwm-copy {
  padding: 34px 42px; background: var(--hiwm-copy-panel);
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
  overflow: auto; min-height: 0;
}
.hiwm-step-eyebrow {
  font-weight: 700; font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--hiwm-forest);
}
.hiwm-step-title {
  font-weight: 700; font-size: 28px; line-height: 1.07; letter-spacing: -0.02em;
  margin: 0; color: var(--hiwm-charcoal);
}

/* numbered sub-steps */
.hiwm-substeps {
  list-style: none; margin: 4px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 11px;
}
.hiwm-substeps li { display: flex; gap: 11px; align-items: flex-start; }
.hiwm-sub-n {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  background: var(--hiwm-forest); color: var(--hiwm-cream-50);
  font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.hiwm-sub-t { font-weight: 500; font-size: 14px; line-height: 1.46; color: var(--hiwm-charcoal-700); }
.hiwm-sub-t b { font-weight: 700; color: var(--hiwm-charcoal); }

/* ---- cover slides (welcome / finish) -------------------------------- */
.hiwm-slide.is-cover { display: flex; align-items: center; justify-content: center; }
.hiwm-cover-inner {
  max-width: 560px; text-align: center; padding: 48px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.hiwm-cover-mark { margin-bottom: 2px; }
.hiwm-cover-eyebrow {
  font-weight: 700; font-size: 11px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--hiwm-forest);
}
.hiwm-cover-title {
  font-weight: 700; font-size: 46px; line-height: 1.0; letter-spacing: -0.03em;
  margin: 0; color: var(--hiwm-charcoal);
}
.hiwm-cover-body {
  font-weight: 500; font-size: 16px; line-height: 1.6;
  color: var(--hiwm-mute); margin: 0; max-width: 440px;
}
.hiwm-cover-cta { margin-top: 10px; padding: 14px 30px; font-size: 15px; }
.hiwm-cover-secondary {
  font-weight: 600; font-size: 13.5px; color: var(--hiwm-mute);
  text-decoration: none; background: none; border: 0; cursor: pointer;
  transition: color 0.15s ease;
}
.hiwm-cover-secondary:hover { color: var(--hiwm-forest); }

/* ---- footer: rail + progress + nav ---------------------------------- */
.hiwm-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 22px; flex: 0 0 auto;
  border-top: 1px solid var(--hiwm-rule); background: var(--hiwm-cream-50);
}
.hiwm-foot-left { display: flex; align-items: center; gap: 16px; }
.hiwm-rail { display: flex; align-items: center; gap: 8px; }
.hiwm-rail-dot {
  border: 0; background: transparent; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.hiwm-rail-n {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  background: var(--hiwm-sage-100); color: var(--hiwm-mute);
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.hiwm-rail-dot:hover .hiwm-rail-n { background: var(--hiwm-forest-100); color: var(--hiwm-forest); }
.hiwm-rail-dot.is-done .hiwm-rail-n { background: var(--hiwm-forest-100); color: var(--hiwm-forest); }
.hiwm-rail-dot.is-active .hiwm-rail-n { background: var(--hiwm-forest); color: #fff; box-shadow: 0 0 0 4px rgba(46, 90, 56, 0.14); }
.hiwm-progress { font-weight: 700; font-size: 12px; letter-spacing: 0.04em; color: var(--hiwm-mute); }
.hiwm-nav { display: flex; align-items: center; gap: 10px; }

/* ---- buttons -------------------------------------------------------- */
.hiwm-btn {
  font-family: inherit; border: 0; cursor: pointer;
  font-weight: 700; font-size: 13.5px; letter-spacing: 0.01em;
  padding: 11px 22px; border-radius: 999px; white-space: nowrap; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}
.hiwm-btn-primary { background: var(--hiwm-forest); color: var(--hiwm-cream-50); }
.hiwm-btn-primary:hover { background: var(--hiwm-forest-700); }
.hiwm-btn-ghost { background: transparent; color: var(--hiwm-mute); box-shadow: inset 0 0 0 1px var(--hiwm-rule); }
.hiwm-btn-ghost:hover { color: var(--hiwm-charcoal); box-shadow: inset 0 0 0 1px var(--hiwm-mute-2); }
.hiwm-btn:disabled { opacity: 0.4; cursor: default; }
.hiwm-btn:active:not(:disabled) { transform: translateY(1px); }

/* ---- focus-visible (keyboard) --------------------------------------- */
.hiwm-close:focus-visible, .hiwm-btn:focus-visible, .hiwm-rail-dot:focus-visible,
.hiwm-cover-secondary:focus-visible {
  outline: 2px solid var(--hiwm-forest); outline-offset: 2px;
}

/* ===================================================================== */
/* shared media building blocks                                          */
/* ===================================================================== */
.hiwm-stack { width: 100%; display: flex; flex-direction: column; gap: 20px; }
.hiwm-stack.is-centered { align-items: center; }

/* framed thumbnail + caption */
.hiwm-views { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; }
.hiwm-thumb { margin: 0; display: flex; flex-direction: column; gap: 9px; }
.hiwm-shot {
  border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; background: #e8e3d4;
  box-shadow: var(--hiwm-shadow-card);
}
.hiwm-shot img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.hiwm-cap { display: flex; flex-direction: column; gap: 1px; }
.hiwm-cap-t { font-weight: 700; font-size: 13px; color: var(--hiwm-charcoal); }
.hiwm-cap-s { font-weight: 500; font-size: 11.5px; color: var(--hiwm-mute); line-height: 1.35; }

/* entry strip (a full-width screenshot bar) + highlight ring */
.hiwm-bar {
  position: relative; border-radius: 12px; overflow: hidden; background: var(--hiwm-cream-50);
  box-shadow: 0 10px 26px -16px rgba(15, 31, 44, 0.4), 0 0 0 1px var(--hiwm-rule);
}
.hiwm-bar img { width: 100%; height: auto; display: block; }
.hiwm-ring {
  position: absolute; border: 3px solid var(--hiwm-forest); border-radius: 999px;
  animation: hiwm-ringpulse 2s ease-in-out infinite; pointer-events: none;
}
@keyframes hiwm-ringpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 90, 56, 0.45); }
  50% { box-shadow: 0 0 0 7px rgba(46, 90, 56, 0); }
}

/* floating "Switch views here" marker (step 1) */
.hiwm-marker {
  position: absolute; top: -12px; left: 50%; transform: translate(-50%, -100%);
  background: var(--hiwm-forest); color: var(--hiwm-cream-50);
  font-weight: 700; font-size: 11px; letter-spacing: 0.02em; white-space: nowrap;
  padding: 5px 12px; border-radius: 999px;
  box-shadow: 0 8px 18px -8px rgba(46, 90, 56, 0.6);
}
.hiwm-marker::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--hiwm-forest);
}

/* ---- Step 1: Map/Grid toggle (recreated in markup) + previews ------- */
.hiwm-s1 { gap: 22px; }
.hiwm-s1-toggle { position: relative; display: flex; justify-content: center; padding-top: 6px; }
.hiwm-seg {
  display: inline-flex; gap: 5px; background: var(--hiwm-cream); border-radius: 15px; padding: 6px;
  box-shadow: inset 0 0 0 1px var(--hiwm-rule);
}
.hiwm-seg-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent;
  color: var(--hiwm-mute); font-family: inherit; font-weight: 700; font-size: 15px;
  padding: 10px 20px; border-radius: 11px; cursor: default;
}
.hiwm-seg-btn.is-on {
  background: #fff; color: var(--hiwm-charcoal);
  box-shadow: 0 2px 6px -2px rgba(15, 31, 44, 0.25), 0 0 0 1px var(--hiwm-rule);
}
.hiwm-seg-btn svg { flex: none; }

/* ---- Step 2 / 3: entry strip + two drawer snippets ------------------ */
.hiwm-s3 .hiwm-bar { max-width: 76%; margin-inline: auto; }
/* snippets here show content fully (no crop) on a cream card */
.hiwm-s2 .hiwm-shot, .hiwm-s3 .hiwm-shot { background: var(--hiwm-cream-50); }
.hiwm-s2 .hiwm-shot img, .hiwm-s3 .hiwm-shot img { object-fit: contain; object-position: center; }

/* ---- Step 4: verdict entry + offer-strategy strip ------------------- */
.hiwm-s4 { gap: 18px; align-items: center; }
.hiwm-s4 .hiwm-bar { max-width: 78%; margin-inline: auto; }
.hiwm-offer { margin: 0; display: flex; flex-direction: column; gap: 9px; width: 100%; }
.hiwm-offer-shot { border-radius: 12px; overflow: hidden; background: var(--hiwm-cream-50); box-shadow: var(--hiwm-shadow-card); }
.hiwm-offer-shot img { width: 100%; height: auto; display: block; }
.hiwm-s4 .hiwm-cap, .hiwm-s5 .hiwm-cap { align-items: center; text-align: center; }

/* ---- Step 5: big property image + printable one-pager --------------- */
.hiwm-s5 { gap: 12px; align-items: center; }
.hiwm-hero { margin: 0; display: flex; flex-direction: column; gap: 8px; width: 80%; }
.hiwm-one { margin: 0; display: flex; flex-direction: column; gap: 8px; width: 42%; }
.hiwm-one-shot { border-radius: 12px; overflow: hidden; background: var(--hiwm-cream-50); box-shadow: var(--hiwm-shadow-card); }
.hiwm-one-shot img { width: 100%; height: auto; display: block; }

/* ===================================================================== */
/* mobile: full-screen sheet, media over copy, fits one screen no-scroll */
/* ===================================================================== */
@media (max-width: 880px) {
  .hiwm-modal { padding: 0; }
  .hiwm-card {
    width: 100%; height: 100vh; height: 100dvh;
    max-height: 100vh; max-height: 100dvh; border-radius: 0;
  }
  /* slim header that clears the status bar / notch */
  .hiwm-head { padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 10px; }
  .hiwm-sep, .hiwm-headlabel { display: none; }
  .hiwm-word { font-size: 14px; }
  .hiwm-close { width: 28px; height: 28px; }

  /* stack the split: media on top, copy below */
  .hiwm-step { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: hidden; }
  .hiwm-media { border-right: 0; border-bottom: 1px solid var(--hiwm-rule); padding: 12px 14px; }
  .hiwm-copy { padding: 14px 18px 16px; gap: 9px; overflow: hidden; }
  .hiwm-step-eyebrow { font-size: 10.5px; }
  .hiwm-step-title { font-size: 21px; line-height: 1.08; }
  .hiwm-substeps { gap: 9px; margin-top: 3px; }
  .hiwm-sub-t { font-size: 13.5px; line-height: 1.42; }
  .hiwm-sub-n { width: 21px; height: 21px; font-size: 11px; }

  /* compact the media compositions */
  .hiwm-stack { gap: 11px; }
  .hiwm-s1 { gap: 11px; }
  .hiwm-s5 { gap: 9px; }
  .hiwm-views { gap: 10px; }
  .hiwm-shot { aspect-ratio: 16 / 10; }
  .hiwm-cap-t { font-size: 11.5px; }
  .hiwm-cap-s { font-size: 10px; line-height: 1.3; }
  .hiwm-seg-btn { padding: 8px 14px; font-size: 13px; }
  .hiwm-seg-btn svg { width: 15px; height: 15px; }
  .hiwm-marker { display: none; }
  .hiwm-s3 .hiwm-bar { max-width: 88%; }
  .hiwm-s4 .hiwm-bar { max-width: 86%; }
  /* step 5: show the big property image alone so the slide fits */
  .hiwm-one { display: none; }
  .hiwm-hero { width: 94%; }

  /* covers */
  .hiwm-cover-inner { padding: 24px; gap: 14px; }
  .hiwm-cover-title { font-size: 30px; }
  .hiwm-cover-body { font-size: 14px; }
  .hiwm-cover-cta { padding: 12px 26px; font-size: 14px; }

  /* footer compaction */
  .hiwm-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); gap: 10px; }
  .hiwm-progress { display: none; }
  .hiwm-rail-dot { width: 23px; height: 23px; }
  .hiwm-rail-n { width: 21px; height: 21px; font-size: 11px; }
  .hiwm-btn { padding: 9px 17px; font-size: 13px; }
}

/* intermediate widths (tablet / short laptop): stack but keep the card framed */
@media (min-width: 881px) and (max-width: 940px) {
  .hiwm-step { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .hiwm-media { border-right: 0; border-bottom: 1px solid var(--hiwm-rule); }
}

/* ---- short desktop windows ------------------------------------------ */
/* A non-maximized, zoomed, or 16:9 laptop window can be short. The card is
   tuned for ~680px tall; when there's less room we reclaim the outer margin
   and compact the content so it still fits with the footer visible. The media
   gets overflow:hidden so it can never paint over the footer. Guarded to
   >880px so the mobile full-screen sheet keeps its own rules. */
@media (min-width: 881px) and (max-height: 760px) {
  .hiwm-modal { padding-top: 24px; padding-bottom: 24px; }
  .hiwm-card { max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); }
  .hiwm-head { padding: 13px 22px; }
  .hiwm-foot { padding: 12px 22px; }
  .hiwm-media { padding: 18px; }
  .hiwm-copy { padding: 22px 34px; gap: 12px; }
  .hiwm-step-title { font-size: 23px; }
  .hiwm-substeps { gap: 9px; }
  .hiwm-sub-t { font-size: 13.5px; line-height: 1.4; }
  .hiwm-stack { gap: 13px; }
  .hiwm-s1 { gap: 13px; }
  .hiwm-s1-toggle { padding-top: 0; }
  .hiwm-views { gap: 12px; }
  .hiwm-hero { width: 62%; }
  .hiwm-one { width: 32%; }
  .hiwm-cover-inner { padding: 36px; gap: 14px; }
  .hiwm-cover-title { font-size: 38px; }
  .hiwm-cover-body { font-size: 15px; line-height: 1.5; }
}
@media (min-width: 881px) and (max-height: 540px) {
  .hiwm-modal { padding-top: 14px; padding-bottom: 14px; }
  .hiwm-card { max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); }
  .hiwm-head { padding: 10px 18px; }
  .hiwm-foot { padding: 9px 18px; }
  .hiwm-media { padding: 12px 14px; }
  .hiwm-copy { padding: 16px 28px; gap: 9px; }
  .hiwm-step-eyebrow { font-size: 10.5px; }
  .hiwm-step-title { font-size: 20px; line-height: 1.1; }
  .hiwm-substeps { gap: 8px; }
  .hiwm-sub-t { font-size: 13px; line-height: 1.36; }
  .hiwm-sub-n { width: 22px; height: 22px; font-size: 11px; }
  .hiwm-stack { gap: 9px; }
  .hiwm-s1 { gap: 9px; }
  .hiwm-one { display: none; }          /* drop the one-pager; hero alone, like mobile */
  .hiwm-hero { width: 66%; }
  .hiwm-cover-inner { padding: 22px; gap: 10px; }
  .hiwm-cover-title { font-size: 28px; }
  .hiwm-cover-body { font-size: 13.5px; line-height: 1.4; }
  .hiwm-cover-cta { margin-top: 4px; padding: 11px 24px; font-size: 14px; }
}

/* ---- reduced motion ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .hiwm-backdrop, .hiwm-modal { transition: opacity 0.001s linear; }
  .hiwm-slide { transition: none; transform: none; }
  .hiwm-ring { animation: none; }
  .hiwm-btn:active:not(:disabled) { transform: none; }
}
