/* =========================================================================
   HNS Costing Flyout — Homznspace
   Custom slide-in flyout + costing enquiry form (replaces BNE Flyout + FF#21)
   Namespaced under #hnsc-root / .hnsc-* so it never collides with the theme.
   ========================================================================= */

:root {
  --hnsc-accent: #ff9900;
  --hnsc-accent-strong: #f57c00;
  --hnsc-accent-ink: #7a3e00;
  --hnsc-gold: #c9a15a;          /* secondary premium accent — dividers, detailing, never CTAs */
  --hnsc-gold-soft: #e4c98c;
  --hnsc-ink: #1c1109;
  --hnsc-ink-soft: #4a3a2c;
  --hnsc-muted: #6f5f52;        /* ≥4.5:1 on cream — safe for placeholders & helper text */
  --hnsc-cream: #fff8ee;
  --hnsc-panel: #ffffff;
  --hnsc-line: rgba(28, 17, 9, 0.12);
  --hnsc-line-strong: rgba(28, 17, 9, 0.22);
  --hnsc-ok: #1a9c5b;
  --hnsc-err: #d63838;
  --hnsc-radius-lg: 20px;    /* mobile sheet top corners */
  --hnsc-radius: 10px;       /* chip list / seg toggle containers */
  --hnsc-radius-sm: 8px;     /* buttons */
  --hnsc-shadow: 24px 0 80px -24px rgba(28, 17, 9, 0.5);
  --hnsc-font: "DidactGothic-Regular", "Segoe UI", system-ui, -apple-system, sans-serif;
  --hnsc-font-display: "DidactGothic-Regular", Georgia, "Times New Roman", serif;
  --hnsc-panel-w: 452px;
}

/* ---- Root / overlay ---------------------------------------------------- */
#hnsc-root { position: fixed; inset: 0; z-index: 2147483000; display: none; }
#hnsc-root.hnsc-open { display: block; }

#hnsc-root .hnsc-overlay {
  position: absolute; inset: 0;
  background: rgba(20, 12, 6, 0.55);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .32s ease;
}
#hnsc-root.hnsc-open .hnsc-overlay { opacity: 1; }

/* ---- Panel (desktop = right slide-in) ---------------------------------- */
#hnsc-root .hnsc-panel {
  position: absolute; top: 0; left: 0; height: 100%;
  width: var(--hnsc-panel-w); max-width: 100vw;
  background: var(--hnsc-panel);
  box-shadow: var(--hnsc-shadow);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .38s cubic-bezier(.22, .61, .36, 1);
  font-family: var(--hnsc-font);
  color: var(--hnsc-ink);
  -webkit-font-smoothing: antialiased;
}
#hnsc-root.hnsc-open .hnsc-panel { transform: translateX(0); }
#hnsc-root .hnsc-panel:focus { outline: none; }

/* ---- Header: a letterhead, not a hero -----------------------------------
   The flyout opens a document ("this project's cost sheet"), so the header
   is built like one: flat ink ground (no gradient/glow), a small monospace
   reference line standing in for a document number, the ACTUAL project name
   as the title (not marketing copy), and a double hairline rule where a
   printed letterhead would sit above the fold line. */
#hnsc-root .hnsc-head {
  position: relative;
  padding: 20px 24px 14px;
  background: var(--hnsc-ink);
  color: var(--hnsc-cream);
  flex: 0 0 auto;
}
#hnsc-root .hnsc-head::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--hnsc-gold);
}
#hnsc-root .hnsc-docmeta {
  margin: 0 0 8px; font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
  font-size: 10.5px; letter-spacing: .03em; color: var(--hnsc-gold-soft);
  font-variant-numeric: tabular-nums;
}
#hnsc-root .hnsc-docmeta .hnsc-dim { color: rgba(228, 201, 140, .55); }
#hnsc-root .hnsc-title {
  margin: 0; font-family: var(--hnsc-font-display); font-weight: 600;
  font-size: 21px; line-height: 1.18; letter-spacing: -0.01em; color: #fff;
  text-wrap: balance;
}
#hnsc-root .hnsc-sub { margin: 6px 0 0; font-size: 12.5px; line-height: 1.4; color: rgba(255, 248, 238, .78); max-width: 40ch; }

#hnsc-root .hnsc-close {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid rgba(255, 248, 238, .28); background: rgba(255, 248, 238, .08);
  color: var(--hnsc-cream); cursor: pointer; font-size: 18px; line-height: 1;
  display: grid; place-items: center; transition: background .2s, transform .2s;
  touch-action: manipulation;
}
/* expand the tap area to ≥44px without enlarging the visual button */
#hnsc-root .hnsc-close::before { content: ""; position: absolute; inset: -6px; }
@media (hover: hover) {
  #hnsc-root .hnsc-close:hover { background: rgba(255, 248, 238, .2); transform: rotate(90deg); }
}
@media (hover: none) {
  #hnsc-root .hnsc-close:active { background: rgba(255, 248, 238, .22); }
}

/* ---- Progress bar ------------------------------------------------------ */
#hnsc-root .hnsc-progress { height: 3px; background: var(--hnsc-line); flex: 0 0 auto; overflow: hidden; }
#hnsc-root .hnsc-progress i {
  display: block; height: 100%; width: 100%;
  transform: scaleX(.5); transform-origin: left center;
  background: linear-gradient(90deg, var(--hnsc-accent), var(--hnsc-accent-strong));
  transition: transform .35s cubic-bezier(.22, .61, .36, 1);
}

/* ---- Body / form ------------------------------------------------------- */
#hnsc-root .hnsc-body { flex: 1 1 auto; overflow-y: auto; padding: 12px 24px 2px; }
#hnsc-root .hnsc-step { display: none; }
#hnsc-root .hnsc-step.hnsc-active { display: block; animation: hnsc-fade .35s ease; }
@keyframes hnsc-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Spacing rhythm: compact throughout so the whole form fits one view — the
   configuration question still reads as the key one via the bordered list
   itself, not via a large margin around it. */
#hnsc-root .hnsc-field { margin-bottom: 8px; }
#hnsc-root .hnsc-field[data-field="requirement"] { margin-top: 6px; margin-bottom: 10px; }
#hnsc-root .hnsc-field[data-field="loan"] { margin-bottom: 0; }
#hnsc-root .hnsc-label {
  display: block; font-size: 12px; font-weight: 700; letter-spacing: .01em;
  color: var(--hnsc-ink-soft); margin-bottom: 4px;
}
#hnsc-root .hnsc-label .hnsc-opt { color: var(--hnsc-muted); font-weight: 400; }
#hnsc-root .hnsc-req { color: var(--hnsc-accent-strong); }

/* Filled fields with a bold rule — a "write in the box" paper-form cue, tuned
   to be genuinely prominent rather than a field you could miss: a warm tint
   fill so the tap/click target is obvious at a glance, a heavier ink-toned
   base rule (not a pale hairline), and the accent rule thickens further and
   the fill brightens on focus, so the active field is unmistakable. */
#hnsc-root .hnsc-input-line { position: relative; }
#hnsc-root .hnsc-input-line::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2.5px;
  background: var(--hnsc-accent); transform: scaleX(0); transform-origin: left center;
  transition: transform .28s cubic-bezier(.22, .61, .36, 1);
}
#hnsc-root .hnsc-input-line:focus-within::after { transform: scaleX(1); }

#hnsc-root .hnsc-input,
#hnsc-root .hnsc-select {
  width: 100%; box-sizing: border-box;
  height: 46px; padding: 0 12px;   /* 44px min is already cleared here */
  font-family: var(--hnsc-font); font-size: 16px; font-weight: 600; color: var(--hnsc-ink);
  background: var(--hnsc-cream);
  border: none; border-bottom: 2px solid var(--hnsc-ink-soft); border-radius: var(--hnsc-radius-sm) var(--hnsc-radius-sm) 0 0;
  outline: none; transition: border-color .18s, background .18s;
  appearance: none;
}
#hnsc-root .hnsc-input::placeholder { color: var(--hnsc-muted); font-weight: 400; }
#hnsc-root .hnsc-input:focus,
#hnsc-root .hnsc-select:focus { border-bottom-color: transparent; background: #fff4de; }
#hnsc-root .hnsc-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236f5f52' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 34px; cursor: pointer;
}

/* invalid state */
#hnsc-root .hnsc-field.hnsc-invalid .hnsc-input,
#hnsc-root .hnsc-field.hnsc-invalid .hnsc-select { border-color: var(--hnsc-err) !important; }
#hnsc-root .hnsc-field.hnsc-invalid .hnsc-input-line::after { background: var(--hnsc-err); transform: scaleX(1); }
#hnsc-root .hnsc-error { display: none; color: var(--hnsc-err); font-size: 12px; margin-top: 5px; }
#hnsc-root .hnsc-field.hnsc-invalid .hnsc-error { display: block; }

/* intl-tel-input harmonising — same prominent-field treatment as text inputs */
#hnsc-root .iti { width: 100%; }
#hnsc-root .iti__tel-input,
#hnsc-root .hnsc-field .iti input[type=tel] {
  width: 100%; box-sizing: border-box; height: 46px; padding-left: 48px; padding-right: 12px;
  font-weight: 600;
  background: var(--hnsc-cream);
  border: none; border-bottom: 2px solid var(--hnsc-ink-soft); border-radius: var(--hnsc-radius-sm) var(--hnsc-radius-sm) 0 0;
  font-family: var(--hnsc-font); font-size: 16px;
  font-variant-numeric: tabular-nums;   /* digits keep a fixed width, like ledger figures */
}
#hnsc-root .iti__tel-input:focus { border-bottom-color: transparent; background: #fff4de; }
#hnsc-root .hnsc-field.hnsc-invalid .iti__tel-input { border-bottom-color: var(--hnsc-err) !important; }
/* the flag/dial-code button sits over the tinted input — match its fill so it
   reads as part of the same field, not a separate white patch */
#hnsc-root .iti__selected-country { background: transparent !important; }

/* ---- Yes/No toggle: two joined cells, selected = ink-filled ------------
   A pressed/stamped two-way switch rather than a rounded pill pair — the
   selected state reuses the ink of the header instead of an accent tint. */
#hnsc-root .hnsc-seg {
  display: flex; border: 1.5px solid var(--hnsc-line); border-radius: var(--hnsc-radius); overflow: hidden;
}
#hnsc-root .hnsc-seg label {
  flex: 1; display: flex; align-items: center; justify-content: center;
  height: 40px; border: none; border-radius: 0;   /* 44px min restored on touch screens below */
  background: #fff; cursor: pointer; font-size: 14px; font-weight: 600;
  color: var(--hnsc-ink-soft); transition: background .16s, color .16s;
  user-select: none; touch-action: manipulation;
}
#hnsc-root .hnsc-seg label:first-of-type { border-right: 1px solid var(--hnsc-line); }
#hnsc-root .hnsc-seg input { position: absolute; opacity: 0; pointer-events: none; }
#hnsc-root .hnsc-seg label:hover { background: var(--hnsc-cream); }
/* keyboard focus (radios are visually hidden, so surface focus on the label) */
#hnsc-root .hnsc-seg label:focus-within { outline: 2px solid var(--hnsc-accent); outline-offset: -2px; }
#hnsc-root .hnsc-seg input:checked + label,
#hnsc-root .hnsc-seg label.hnsc-on {
  background: var(--hnsc-ink); color: var(--hnsc-cream);
}

/* ---- Configuration selector: compact pills ------------------------------
   Wraps into 1–2 rows instead of a tall vertical list — the space-efficient
   option for the (usually 4–8 option) BHK/plot choice. Selected state fills
   solid ink rather than a pale accent tint, and a small checkmark appears
   only on the selected pill so unselected ones stay clean text, not a row
   of identical empty radio circles. */
#hnsc-root .hnsc-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  max-height: 96px; overflow-y: auto; padding: 2px 2px 4px;   /* safety net for very long plot lists */
}
#hnsc-root .hnsc-chip {
  position: relative; display: inline-flex; align-items: center; min-height: 38px;   /* 44px min restored on touch screens below */
  box-sizing: border-box; padding: 7px 16px; border: 1.5px solid var(--hnsc-line);
  border-radius: 999px; background: #fff; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--hnsc-ink-soft);
  transition: background .16s, border-color .16s, color .16s; touch-action: manipulation;
}
#hnsc-root .hnsc-chip:hover { border-color: var(--hnsc-line-strong); }
#hnsc-root .hnsc-chip input { position: absolute; opacity: 0; }
/* Space is always reserved (no width/margin animation — layout-thrash free);
   only transform + opacity animate the reveal. */
#hnsc-root .hnsc-chip-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 12px; margin-right: 6px; flex: 0 0 auto; color: var(--hnsc-cream);
  transform: scale(0); opacity: 0; transform-origin: center;
  transition: transform .18s cubic-bezier(.22, .61, .36, 1), opacity .18s;
}
#hnsc-root .hnsc-chip-check svg { width: 12px; height: 12px; flex: 0 0 auto; }
#hnsc-root .hnsc-chip.hnsc-on {
  background: var(--hnsc-ink); border-color: var(--hnsc-ink); color: var(--hnsc-cream); font-weight: 700;
}
#hnsc-root .hnsc-chip.hnsc-on .hnsc-chip-check { transform: scale(1); opacity: 1; }
#hnsc-root .hnsc-chip:focus-within { outline: 2px solid var(--hnsc-accent); outline-offset: 2px; }

/* ---- Footer / actions -------------------------------------------------- */
#hnsc-root .hnsc-foot { flex: 0 0 auto; padding: 8px 24px 12px; border-top: 1px solid var(--hnsc-line); background: #fff; }
#hnsc-root .hnsc-actions { display: flex; gap: 10px; }

#hnsc-root .hnsc-btn {
  flex: 1; height: 46px; border: none; border-radius: var(--hnsc-radius-sm); cursor: pointer;
  font-family: var(--hnsc-font); font-size: 16px; font-weight: 700; letter-spacing: .01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .12s, box-shadow .2s, background .18s; touch-action: manipulation;
}
#hnsc-root .hnsc-btn:focus-visible,
#hnsc-root .hnsc-close:focus-visible {
  outline: 3px solid var(--hnsc-accent); outline-offset: 2px;
}
/* flat fill, not a glossy gradient — a pressed/stamped button, not a hero CTA */
#hnsc-root .hnsc-btn-primary {
  color: #fff; background: var(--hnsc-accent);
  box-shadow: inset 0 -2px 0 0 rgba(0, 0, 0, .12), 0 6px 16px -8px rgba(28, 17, 9, .45);
}
#hnsc-root .hnsc-btn-primary:hover { background: var(--hnsc-accent-strong); }
#hnsc-root .hnsc-btn-primary:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 0 rgba(0, 0, 0, .12); }
#hnsc-root .hnsc-btn-ghost {
  flex: 0 0 auto; padding: 0 20px; background: transparent; color: var(--hnsc-ink-soft);
  border: 1.5px solid var(--hnsc-line);
}
#hnsc-root .hnsc-btn-ghost:hover { border-color: var(--hnsc-line-strong); }
#hnsc-root .hnsc-btn[disabled] { opacity: .65; cursor: not-allowed; }

#hnsc-root .hnsc-spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  animation: hnsc-spin .7s linear infinite; display: none;
}
#hnsc-root .hnsc-loading .hnsc-spin { display: inline-block; }
#hnsc-root .hnsc-loading .hnsc-btn-label { display: none; }
@keyframes hnsc-spin { to { transform: rotate(360deg); } }

#hnsc-root .hnsc-consent { margin: 6px 2px 0; font-size: 10.5px; color: var(--hnsc-muted); line-height: 1.4; text-align: center; }
#hnsc-root .hnsc-consent a { color: var(--hnsc-accent-strong); }

/* ---- Success state ----------------------------------------------------- */
#hnsc-root .hnsc-success { display: none; flex: 1 1 auto; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 34px 30px; }
#hnsc-root.hnsc-done .hnsc-body,
#hnsc-root.hnsc-done .hnsc-foot,
#hnsc-root.hnsc-done .hnsc-progress { display: none; }
#hnsc-root.hnsc-done .hnsc-success { display: flex; }
#hnsc-root .hnsc-check {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--hnsc-ok);
  display: grid; place-items: center; margin-bottom: 20px;
  box-shadow: 0 10px 22px -10px rgba(26, 156, 91, .55);
  animation: hnsc-pop .5s cubic-bezier(.22, 1, .36, 1);
}
#hnsc-root .hnsc-check svg { width: 38px; height: 38px; color: #fff; }
@keyframes hnsc-pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
#hnsc-root .hnsc-success h3 { margin: 0 0 8px; font-family: var(--hnsc-font-display); font-weight: 600; font-size: 24px; }
#hnsc-root .hnsc-success p { margin: 0 0 22px; font-size: 14.5px; color: var(--hnsc-ink-soft); line-height: 1.55; max-width: 320px; }
#hnsc-root .hnsc-success .hnsc-wa {
  display: inline-flex; align-items: center; gap: 9px; height: 50px; padding: 0 24px;
  border-radius: var(--hnsc-radius-sm); background: #25d366; color: #fff; font-weight: 700; font-size: 15px;
  text-decoration: none; box-shadow: 0 8px 18px -10px rgba(37, 211, 102, .6);
}
#hnsc-root .hnsc-success .hnsc-wa svg { width: 20px; height: 20px; }

/* ---- Mobile = bottom sheet -------------------------------------------- */
@media (max-width: 560px) {
  #hnsc-root .hnsc-panel {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100%; height: auto;
    max-height: 92vh; max-height: 92dvh;   /* dvh tracks the real viewport under mobile browser chrome */
    border-radius: var(--hnsc-radius-lg) var(--hnsc-radius-lg) 0 0;
    transform: translateY(100%);
  }
  #hnsc-root.hnsc-open .hnsc-panel { transform: translateY(0); }
  #hnsc-root .hnsc-head { border-radius: var(--hnsc-radius-lg) var(--hnsc-radius-lg) 0 0; padding-top: 24px; }
  #hnsc-root .hnsc-grab {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 3px; background: rgba(255, 248, 238, .4);
  }
  /* keep the submit bar clear of the home indicator / gesture bar */
  #hnsc-root .hnsc-foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}
/* Landscape phones: the sheet can fill the height; let the body scroll */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  #hnsc-root .hnsc-panel { max-height: 100dvh; }
  #hnsc-root .hnsc-head { padding-top: 14px; padding-bottom: 10px; }
  #hnsc-root .hnsc-sub { display: none; }  /* reclaim vertical space */
  #hnsc-root .hnsc-chips { max-height: 110px; }
}
@media (min-width: 561px) { #hnsc-root .hnsc-grab { display: none; } }

/* Restore the 44px touch-target minimum on touch screens; the compact 38–42px
   controls above are sized for mouse/desktop precision, not fingers. */
@media (pointer: coarse) {
  #hnsc-root .hnsc-input,
  #hnsc-root .hnsc-select,
  #hnsc-root .iti__tel-input,
  #hnsc-root .hnsc-seg label { min-height: 44px; }
  #hnsc-root .hnsc-chip { min-height: 44px; }
}

/* Roomier panel on desktop/large screens — 452px reads cramped past 1024px. */
@media (min-width: 1024px) {
  :root { --hnsc-panel-w: 488px; }
  #hnsc-root .hnsc-head { padding: 26px 30px 18px; }
  #hnsc-root .hnsc-body, #hnsc-root .hnsc-foot { padding-left: 30px; padding-right: 30px; }
  #hnsc-root .hnsc-title { font-size: 23px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #hnsc-root .hnsc-panel, #hnsc-root .hnsc-overlay,
  #hnsc-root .hnsc-check, #hnsc-root .hnsc-step { animation: none !important; transition: none !important; }
}
