/* ==========================================================================
   BuildSignal — Homepage layout (November 2026)
   Features grid, compact Project Opportunities, Owner Portal showcase,
   Client Login fields and the contact form at the bottom. Loaded after
   upgrade.css and client-login.css; uses the existing design tokens only.
   ========================================================================== */

/* ---------- Features ---------- */
.feat-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.feat-card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 24px 22px; transition: transform 0.4s var(--ease), border-color 0.4s var(--ease);
}
.feat-card:hover { transform: translateY(-4px); border-color: rgba(34,211,238,0.35); }
.feat-icon { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: rgba(34,211,238,0.1); color: var(--cyan); margin-bottom: 4px; }
.feat-card h3 { font-size: 1.08rem; }
.feat-card p { color: var(--text-muted); font-size: 0.92rem; line-height: 1.55; }
@media (max-width: 960px) { .feat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .feat-grid { grid-template-columns: 1fr; gap: 12px; }
  .feat-card { padding: 18px; display: grid; grid-template-columns: 44px 1fr; column-gap: 14px; row-gap: 4px; }
  .feat-card:hover { transform: none; }
  .feat-icon { grid-row: 1 / span 2; margin: 0; }
}

/* ---------- Project Opportunities (compact) ---------- */
.opp-layout.opp-compact { margin-bottom: 0; }
.opp-note { margin: 18px 0 26px; padding-left: 14px; border-left: 2px solid var(--border-strong); color: var(--text-muted); font-size: 0.92rem; line-height: 1.6; }

/* ---------- Owner Portal showcase ---------- */
.portal-showcase { background: linear-gradient(180deg, var(--bg), var(--bg-soft) 45%, var(--bg)); border-bottom: 1px solid var(--border); }
.pf-layout { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.5fr); gap: 36px; align-items: start; }
.pf-tabs { display: flex; flex-direction: column; gap: 10px; }
.pf-tab {
  position: relative; display: block; width: 100%; text-align: left; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px 18px; transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.pf-tab:hover { border-color: var(--border-strong); }
.pf-tab strong { display: block; font-family: var(--font-head); font-weight: 600; font-size: 1.02rem; letter-spacing: -0.01em; }
.pf-desc { display: block; margin-top: 6px; color: var(--text-muted); font-size: 0.88rem; line-height: 1.55; }
.pf-tab:not([aria-selected="true"]) .pf-desc { display: none; }
.pf-tab:not([aria-selected="true"]) strong { color: var(--text-muted); }
.pf-tab[aria-selected="true"] {
  border-color: rgba(110,86,248,0.5);
  background: linear-gradient(160deg, rgba(110,86,248,0.12), rgba(34,211,238,0.04) 70%), var(--panel);
  box-shadow: var(--shadow-glow);
}
.pf-tab[aria-selected="true"]::before { content: ""; position: absolute; left: -1px; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad); }

.pf-stage { min-width: 0; }
.pf-frame { position: relative; }
.pf-frame .browser-bar .fc-badge { color: var(--cyan); border-color: rgba(34,211,238,0.3); background: rgba(34,211,238,0.08); }
.pf-panel { margin: 0; }
/* Each screen is a static snapshot of the real portal (/showcase/*.html),
   drawn at its native size and scaled to fit. It is not interactive. */
.pf-viewport { position: relative; overflow: hidden; aspect-ratio: 1280 / 820; background: var(--bg); }
.pf-viewport iframe {
  position: absolute; top: 0; left: 0; width: 1280px; height: 820px; border: 0; background: var(--bg);
  transform-origin: 0 0; transform: scale(var(--pf-s, 0.55)); pointer-events: none;
}
.pf-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.pf-note { margin-top: 12px; font-size: 0.8rem; color: var(--text-faint); text-align: center; }

.pf-extras {
  list-style: none; margin: 30px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 28px; font-size: 0.88rem; color: var(--text-muted);
}
.pf-extras li { position: relative; padding-left: 22px; }
.pf-extras li::before { content: "✓"; position: absolute; left: 0; color: var(--cyan); font-weight: 700; }

@media (max-width: 960px) {
  .pf-layout { grid-template-columns: 1fr; gap: 20px; }
  .pf-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .pf-tab { padding: 12px 14px; }
  .pf-tab strong { font-size: 0.95rem; }
  .pf-tab::before { display: none; }
  .pf-desc { display: none !important; }
  .pf-stage::before { content: attr(data-desc); display: block; margin-bottom: 14px; color: var(--text-muted); font-size: 0.92rem; line-height: 1.55; }
}
@media (max-width: 640px) {
  /* Phones get the portal's own phone layout, in a phone-shaped frame */
  .pf-frame { max-width: 300px; margin: 0 auto; border-radius: 28px; padding: 6px; background: var(--panel-2); border-color: var(--border-strong); }
  .pf-frame .browser-bar { display: none; }
  .pf-viewport { aspect-ratio: 390 / 760; border-radius: 22px; }
  .pf-viewport iframe { width: 390px; height: 760px; }
  .pf-extras { flex-direction: column; align-items: flex-start; max-width: 300px; margin-left: auto; margin-right: auto; }
}

/* ---------- Form fields (Client Login + Contact) ---------- */
.field { display: flex; flex-direction: column; min-width: 0; }
.field[hidden] { display: none; }
.field-label {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 7px; font-size: 0.86rem; font-weight: 500; color: var(--text);
}
.field-label .optional { font-size: 0.76rem; font-weight: 400; color: var(--text-faint); }
.field input:not(.ms-input), .field textarea {
  width: 100%; min-width: 0; min-height: 48px; padding: 12px 14px;
  background: rgba(255,255,255,0.04); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 1rem; /* 16px stops iOS from zooming into the field */
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field input:not(.ms-input)::placeholder, .field textarea::placeholder { color: var(--text-faint); }
.field input:not(.ms-input):focus, .field textarea:focus {
  outline: none; border-color: var(--cyan); background: rgba(34,211,238,0.04);
  box-shadow: 0 0 0 3px rgba(34,211,238,0.15);
}
.field input:not(.ms-input)[aria-invalid="true"] { border-color: rgba(255,107,74,0.8); }
.field-error { margin: 6px 0 0; font-size: 0.8rem; color: #ff9b85; }
.field-error:empty { display: none; }

/* ---------- Contact: "Get Started" form (bottom of the page) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.contact { border-top: 1px solid var(--border); scroll-margin-top: 72px; }
.contact-head { max-width: 640px; margin: 0 auto 36px; text-align: center; }
.contact-head .eyebrow { margin-bottom: 14px; }
.contact-head h2 { font-size: clamp(1.8rem, 3.2vw, 2.4rem); margin-bottom: 12px; }

.contact-card {
  position: relative; max-width: 780px; margin: 0 auto; padding: 8px 40px 36px;
  background: linear-gradient(180deg, rgba(110,86,248,0.06), rgba(34,211,238,0.015) 220px, transparent 420px), var(--panel);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: 0 40px 80px -40px rgba(0,0,0,0.7), 0 0 0 1px rgba(110,86,248,0.06);
}
.contact-card::before {
  content: ""; position: absolute; top: -1px; left: 32px; right: 32px; height: 2px;
  background: var(--grad); border-radius: 0 0 2px 2px; opacity: 0.9;
}
.contact-form { display: block; }
.contact-form[hidden], .contact-success[hidden] { display: none; }

.cf-section { border: 0; margin: 0; padding: 28px 0; min-width: 0; }
.cf-section + .cf-section { border-top: 1px solid var(--border); }
/* Floated so the legend sits inside the section's padding like a normal heading */
.cf-legend {
  float: left;
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 0; margin-bottom: 20px;
  font-family: var(--font-head); font-size: 1.08rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text);
}
.cf-legend .optional { margin-left: auto; font-family: var(--font-body, inherit); font-size: 0.76rem; font-weight: 400; color: var(--text-faint); }
.cf-legend + * { clear: both; }
.cf-num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad); color: #08090c; font-family: var(--font-mono); font-size: 0.76rem; font-weight: 700;
}
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.field-full { grid-column: 1 / -1; }
.cf-section > .field + .field { margin-top: 18px; }
.field-hint { margin: 7px 0 0; font-size: 0.8rem; color: var(--text-faint); }
.field-hint + .field-error { margin-top: 4px; }

/* Selects: same look as the text fields, custom chevron */
.field select {
  width: 100%; min-width: 0; min-height: 48px; padding: 12px 42px 12px 14px;
  appearance: none; -webkit-appearance: none; color-scheme: dark; cursor: pointer;
  background: rgba(255,255,255,0.04) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 16px center;
  color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 1rem; transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.field select:invalid { color: var(--text-faint); }
.field select option, .field select optgroup { background: var(--panel-2); color: var(--text); }
.field select:focus { outline: none; border-color: var(--cyan); background-color: rgba(34,211,238,0.04); box-shadow: 0 0 0 3px rgba(34,211,238,0.15); }
.field select[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: rgba(255,107,74,0.8); }
.field input:not(.ms-input):hover, .field select:hover, .field textarea:hover, .ms-control:hover { border-color: rgba(255,255,255,0.24); }

/* Searchable multi-select */
.ms { position: relative; }
.ms-control {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 48px; padding: 6px 40px 6px 8px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: text; transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.ms.is-open .ms-control, .ms-control:focus-within { border-color: var(--cyan); background: rgba(34,211,238,0.04); box-shadow: 0 0 0 3px rgba(34,211,238,0.15); }
.ms.is-invalid .ms-control { border-color: rgba(255,107,74,0.8); }
.ms-chips { display: contents; list-style: none; }
.ms-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 5px 4px 5px 10px;
  font-size: 0.85rem; font-weight: 500; line-height: 1.2; color: var(--text);
  background: linear-gradient(120deg, rgba(110,86,248,0.22), rgba(34,211,238,0.14));
  border: 1px solid rgba(110,86,248,0.45); border-radius: 100px;
}
.ms-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-x {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer;
}
.ms-x:hover, .ms-x:focus-visible { background: rgba(255,255,255,0.12); color: var(--text); outline: none; }
.ms-input {
  flex: 1 0 120px; min-width: 0; min-height: 34px; padding: 4px 6px;
  background: transparent; border: 0; outline: none; color: var(--text); font: inherit; font-size: 1rem;
}
.ms-input::placeholder { color: var(--text-faint); }
.ms-caret {
  position: absolute; right: 16px; top: 20px; width: 12px; height: 8px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center;
  transition: transform 0.2s;
}
.ms.is-open .ms-caret { transform: rotate(180deg); }
.ms-list {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 264px; overflow-y: auto; overscroll-behavior: contain; margin: 0; padding: 6px; list-style: none;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.65);
}
.ms-list[hidden] { display: none; }
.ms-opt {
  display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 9px 10px;
  border-radius: 8px; font-size: 0.95rem; color: var(--text); cursor: pointer;
}
.ms-opt:hover, .ms-opt.is-active { background: rgba(255,255,255,0.06); }
.ms-check {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s, border-color 0.15s;
}
.ms-opt[aria-selected="true"] .ms-check {
  border-color: transparent; background: var(--grad) center / cover;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='%2308090c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"), var(--grad);
  background-repeat: no-repeat; background-position: center; background-size: 12px, cover;
}
.ms-empty { padding: 10px; font-size: 0.88rem; color: var(--text-faint); }

/* Footer of the form */
.cf-footer { padding-top: 26px; border-top: 1px solid var(--border); }
.cf-submit { gap: 10px; min-height: 56px; font-size: 1.02rem; }
.cf-submit[aria-busy="true"] svg { display: none; }
.cf-fine { margin: 14px 0 0; text-align: center; font-size: 0.86rem; color: var(--text-muted); }
.cf-error {
  margin: 0 0 16px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.9rem;
  color: #ffb4a3; background: rgba(255,107,74,0.1); border: 1px solid rgba(255,107,74,0.35);
}
.cf-error[hidden] { display: none; }

/* Success screen */
.contact-success { text-align: center; padding: 44px 8px 12px; }
.cs-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; margin-bottom: 20px;
  border-radius: 50%; color: #08090c; background: var(--grad); box-shadow: var(--shadow-glow);
}
.contact-success h3 { font-size: 1.5rem; margin-bottom: 10px; outline: none; }
.contact-success > p { max-width: 460px; margin: 0 auto; color: var(--text-muted); overflow-wrap: anywhere; }
.cs-summary {
  display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; max-width: 460px; margin: 26px auto 0; padding: 18px 20px;
  text-align: left; font-size: 0.9rem; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.cs-summary:empty { display: none; }
.cs-summary dt { color: var(--text-faint); }
.cs-summary dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.contact-success .cl-link { margin-top: 22px; }

@media (max-width: 640px) {
  .contact-head { text-align: left; margin-bottom: 26px; }
  .contact-card { padding: 4px 18px 24px; border-radius: var(--radius-md); }
  .contact-card::before { left: 20px; right: 20px; }
  .cf-section { padding: 24px 0; }
  .cf-legend { margin-bottom: 16px; font-size: 1.02rem; }
  .field-grid { grid-template-columns: 1fr; gap: 16px; }
  .ms-list { max-height: 228px; }
  .cs-summary { grid-template-columns: 1fr; gap: 2px; }
  .cs-summary dd + dt { margin-top: 10px; }
}

/* ---------- Footer: two columns of links on phones ---------- */
@media (max-width: 640px) {
  .footer-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; }
  .footer-cols > div:last-child { grid-column: 1 / -1; }
  .footer-cols > div:last-child h5 { margin-top: 8px; }
  .footer-cols > div:last-child { display: flex; flex-wrap: wrap; gap: 0 22px; }
  .footer-cols > div:last-child h5 { flex-basis: 100%; }
}
