/* ==========================================================================
   EDICOLA DIGITALE — DEMO EXPERIENCE ("Prenota una demo")
   $100M Apple Cupertino + Editorial Standard (BP-017, BP-041, RULE-PILL-001)
   Modern Web Guidance: dark-mode, dark-mode-toggle, validate-input-after-interaction,
   select-menu-interaction, accessible-error-announcement, brand-consistent-forms
   ========================================================================== */

@font-face {
  font-family: Poppins;
  src: url(assets/Poppins-Regular.ttf);
  font-display: swap;
}
@font-face {
  font-family: Poppins;
  src: url(assets/Poppins-SemiBold.ttf);
  font-weight: 600;
  font-display: swap;
}

/* 1. Color Scheme & Theme Tokens (Scoped to demo.html root + #demo section) */
:root:has(> head > meta[name="color-scheme"]) {
  color-scheme: light dark;

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }
}

.demo-root {
  /* Raw palette tokens */
  --ed-bg-light: #faf7f2;
  --ed-bg-dark: #090a09;
  --ed-surface-light: #ffffff;
  --ed-surface-dark: #111311;
  --ed-input-light: #faf8f4;
  --ed-input-dark: #161916;
  --ed-text-light: #111210;
  --ed-text-dark: #f7f5f0;
  --ed-muted-light: #57564f;
  --ed-muted-dark: #b5b3ab;
  --ed-hairline-light: rgba(17, 18, 16, 0.12);
  --ed-hairline-dark: rgba(255, 255, 255, 0.14);
  --ed-input-border-light: rgba(17, 18, 16, 0.2);
  --ed-input-border-dark: rgba(255, 255, 255, 0.18);
  --ed-accent-light: #09563a;
  --ed-accent-dark: #2bc48c;
  --ed-cta-bg: #2bc48c;
  --ed-cta-hover: #4cd3a0;
  --ed-cta-ink: #081a12;
  --ed-err-light: #b3261e;
  --ed-err-dark: #ff897d;
  --ed-err-bg-light: rgba(179, 38, 30, 0.06);
  --ed-err-bg-dark: rgba(255, 137, 125, 0.09);
  --ed-valid-light: #09563a;
  --ed-valid-dark: #2bc48c;
  --ed-rail-bg-light: rgba(17, 18, 16, 0.055);
  --ed-rail-bg-dark: rgba(255, 255, 255, 0.055);
  --ed-pill-bg-light: #ffffff;
  --ed-pill-bg-dark: rgba(255, 255, 255, 0.12);
  --ed-pill-border-light: rgba(17, 18, 16, 0.12);
  --ed-pill-border-dark: rgba(255, 255, 255, 0.2);

  /* Fallback defaults (light) */
  --demo-bg: var(--ed-bg-light);
  --demo-surface: var(--ed-surface-light);
  --demo-input-bg: var(--ed-input-light);
  --demo-text: var(--ed-text-light);
  --demo-muted: var(--ed-muted-light);
  --demo-hairline: var(--ed-hairline-light);
  --demo-input-border: var(--ed-input-border-light);
  --brand-accent: var(--ed-accent-light);
  --demo-err: var(--ed-err-light);
  --demo-err-bg: var(--ed-err-bg-light);
  --demo-valid: var(--ed-valid-light);
  --demo-rail-bg: var(--ed-rail-bg-light);
  --demo-pill-bg: var(--ed-pill-bg-light);
  --demo-pill-border: var(--ed-pill-border-light);
  --demo-shadow: 0 24px 56px rgba(17, 18, 16, 0.06);
  --demo-bar-bg: rgba(250, 247, 242, 0.88);
  --demo-scroll-thumb: #7b7972;
  --demo-scroll-track: #efebe3;

  @media (prefers-color-scheme: dark) {
    --demo-bg: var(--ed-bg-dark);
    --demo-surface: var(--ed-surface-dark);
    --demo-input-bg: var(--ed-input-dark);
    --demo-text: var(--ed-text-dark);
    --demo-muted: var(--ed-muted-dark);
    --demo-hairline: var(--ed-hairline-dark);
    --demo-input-border: var(--ed-input-border-dark);
    --brand-accent: var(--ed-accent-dark);
    --demo-err: var(--ed-err-dark);
    --demo-err-bg: var(--ed-err-bg-dark);
    --demo-valid: var(--ed-valid-dark);
    --demo-rail-bg: var(--ed-rail-bg-dark);
    --demo-pill-bg: var(--ed-pill-bg-dark);
    --demo-pill-border: var(--ed-pill-border-dark);
    --demo-shadow: 0 28px 64px rgba(0, 0, 0, 0.46);
    --demo-bar-bg: rgba(9, 10, 9, 0.88);
    --demo-scroll-thumb: #58635c;
    --demo-scroll-track: #101310;
  }

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    --demo-bg: var(--ed-bg-dark);
    --demo-surface: var(--ed-surface-dark);
    --demo-input-bg: var(--ed-input-dark);
    --demo-text: var(--ed-text-dark);
    --demo-muted: var(--ed-muted-dark);
    --demo-hairline: var(--ed-hairline-dark);
    --demo-input-border: var(--ed-input-border-dark);
    --brand-accent: var(--ed-accent-dark);
    --demo-err: var(--ed-err-dark);
    --demo-err-bg: var(--ed-err-bg-dark);
    --demo-valid: var(--ed-valid-dark);
    --demo-rail-bg: var(--ed-rail-bg-dark);
    --demo-pill-bg: var(--ed-pill-bg-dark);
    --demo-pill-border: var(--ed-pill-border-dark);
    --demo-shadow: 0 28px 64px rgba(0, 0, 0, 0.46);
    --demo-bar-bg: rgba(9, 10, 9, 0.88);
    --demo-scroll-thumb: #58635c;
    --demo-scroll-track: #101310;
  }

  &:has(> head > meta[name="color-scheme"][content="light"]) {
    --demo-bg: var(--ed-bg-light);
    --demo-surface: var(--ed-surface-light);
    --demo-input-bg: var(--ed-input-light);
    --demo-text: var(--ed-text-light);
    --demo-muted: var(--ed-muted-light);
    --demo-hairline: var(--ed-hairline-light);
    --demo-input-border: var(--ed-input-border-light);
    --brand-accent: var(--ed-accent-light);
    --demo-err: var(--ed-err-light);
    --demo-err-bg: var(--ed-err-bg-light);
    --demo-valid: var(--ed-valid-light);
    --demo-rail-bg: var(--ed-rail-bg-light);
    --demo-pill-bg: var(--ed-pill-bg-light);
    --demo-pill-border: var(--ed-pill-border-light);
    --demo-shadow: 0 24px 56px rgba(17, 18, 16, 0.06);
    --demo-bar-bg: rgba(250, 247, 242, 0.88);
    --demo-scroll-thumb: #7b7972;
    --demo-scroll-track: #efebe3;
  }

  @supports (color: light-dark(white, black)) {
    --demo-bg: light-dark(var(--ed-bg-light), var(--ed-bg-dark));
    --demo-surface: light-dark(var(--ed-surface-light), var(--ed-surface-dark));
    --demo-input-bg: light-dark(var(--ed-input-light), var(--ed-input-dark));
    --demo-text: light-dark(var(--ed-text-light), var(--ed-text-dark));
    --demo-muted: light-dark(var(--ed-muted-light), var(--ed-muted-dark));
    --demo-hairline: light-dark(var(--ed-hairline-light), var(--ed-hairline-dark));
    --demo-input-border: light-dark(var(--ed-input-border-light), var(--ed-input-border-dark));
    --brand-accent: light-dark(var(--ed-accent-light), var(--ed-accent-dark));
    --demo-err: light-dark(var(--ed-err-light), var(--ed-err-dark));
    --demo-err-bg: light-dark(var(--ed-err-bg-light), var(--ed-err-bg-dark));
    --demo-valid: light-dark(var(--ed-valid-light), var(--ed-valid-dark));
    --demo-rail-bg: light-dark(var(--ed-rail-bg-light), var(--ed-rail-bg-dark));
    --demo-pill-bg: light-dark(var(--ed-pill-bg-light), var(--ed-pill-bg-dark));
    --demo-pill-border: light-dark(var(--ed-pill-border-light), var(--ed-pill-border-dark));
    --demo-bar-bg: light-dark(rgba(250, 247, 242, 0.9), rgba(9, 10, 9, 0.9));
    --demo-scroll-thumb: light-dark(#7b7972, #58635c);
    --demo-scroll-track: light-dark(#efebe3, #101310);
  }

  accent-color: var(--brand-accent);
  scrollbar-width: thin;
  scrollbar-color: var(--demo-scroll-thumb) var(--demo-scroll-track);
}

@supports not (scrollbar-color: auto) {
  .demo-root {
    scrollbar-width: auto;
  }
  .demo-root::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  .demo-root::-webkit-scrollbar-thumb {
    background: var(--demo-scroll-thumb);
    border-radius: 3px;
  }
  .demo-root::-webkit-scrollbar-track {
    background: var(--demo-scroll-track);
  }
}

/* Non-color branching for in-HTML media & theme button state (dark-mode-toggle) */
.demo-root:has(> head > meta[name="color-scheme"][content="dark"]) .only-light-scheme {
  display: none !important;
}
.demo-root:has(> head > meta[name="color-scheme"][content="light"]) .only-dark-scheme {
  display: none !important;
}
@media (prefers-color-scheme: dark) {
  .demo-root:has(> head > meta[name="color-scheme"][content="light dark"]) .only-light-scheme {
    display: none !important;
  }
}
@media (prefers-color-scheme: light) {
  .demo-root:has(> head > meta[name="color-scheme"][content="light dark"]) .only-dark-scheme {
    display: none !important;
  }
}

/* Base Page Layout for demo.html */
.demo-body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--demo-bg);
  color: var(--demo-text);
  font: 400 1rem/1.55 Poppins, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  accent-color: var(--brand-accent);
  overflow-x: clip;
}

.demo-body *,
.demo-body *::before,
.demo-body *::after {
  box-sizing: border-box;
}

/* Subtle top PressReader editorial spectrum hairline */
.demo-spectrum-line {
  height: 2px;
  width: 100%;
  background: linear-gradient(
    90deg,
    #15d694 0%,
    #2bc48c 24%,
    #09563a 44%,
    #7442ae 72%,
    #ec90d8 86%,
    #f5823d 100%
  );
  flex: none;
}

.demo-wrap {
  width: 100%;
  max-width: 1320px;
  margin-inline: auto;
  padding-inline: clamp(1.15rem, 3.6vw, 3.5rem);
}

/* Header on demo.html */
.demo-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--demo-bar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--demo-hairline);
}

.demo-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
  padding-block: 0.65rem;
}

.demo-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.demo-brand img {
  width: clamp(112px, 12vw, 136px);
  height: auto;
  display: block;
  flex: none;
}

.demo-brand i {
  border-left: 1px solid var(--demo-hairline);
  padding-left: 0.85rem;
  font: italic 1.08rem/1.1 Georgia, serif;
  color: var(--demo-muted);
  white-space: nowrap;
}

.demo-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem clamp(0.65rem, 1.8vw, 1.45rem);
  font-size: 0.84rem;
}

.demo-nav a:not(.demo-phone-pill) {
  color: var(--demo-text);
  text-decoration: none;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  opacity: 0.84;
  transition: opacity 160ms ease, color 160ms ease;
}

.demo-nav a:not(.demo-phone-pill):hover,
.demo-nav a[aria-current="page"] {
  opacity: 1;
  color: var(--brand-accent);
  text-decoration: underline;
  text-underline-offset: 0.35em;
}

/* Discrete Sun / Moon Surface Switcher */
.scheme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-height: 36px;
  padding: 0.34rem 0.72rem;
  border-radius: 8px;
  border: 1px solid var(--demo-hairline);
  background: transparent;
  color: var(--demo-text);
  font: 500 0.8rem/1 Poppins, sans-serif;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.scheme-toggle:hover {
  background: var(--demo-rail-bg);
  border-color: var(--brand-accent);
}

.scheme-toggle svg {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--brand-accent);
}

.demo-phone-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-height: 36px;
  padding: 0.38rem 0.82rem;
  border-radius: 8px;
  background: var(--ed-cta-bg);
  color: var(--ed-cta-ink);
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 180ms ease, transform 180ms ease;
}

.demo-phone-pill:hover {
  background: var(--ed-cta-hover);
}

/* Accessible Visually Hidden Utility (modern-web-guidance canonical recipe) */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Main 2-Column Demo Canvas */
.demo-main {
  flex: 1;
  padding-block: clamp(1.8rem, 4vw, 3.8rem) clamp(2.5rem, 5vw, 4.5rem);
}

.demo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.98fr);
  gap: clamp(2rem, 4.4vw, 4.4rem);
  align-items: start;
}

/* RULE-PILL-001: Segmented Rail + Sliding Crystal Pill with Spring Bounce */
.seg-rail {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 2px;
  border-radius: 8px;
  background: var(--demo-rail-bg);
  border: 1px solid var(--demo-hairline);
  margin-bottom: 1.5rem;
  max-width: 520px;
  isolation: isolate;
}

.seg-glider {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  border-radius: 6px;
  background: var(--demo-pill-bg);
  border: 0.75px solid var(--demo-pill-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 2px 6px rgba(0, 0, 0, 0.14);
  z-index: 0;
  pointer-events: none;
  transform: translate3d(0%, 0, 0);
  will-change: transform;
}

.seg-rail[data-segment="corporate"] .seg-glider {
  transform: translate3d(100%, 0, 0);
}

/* RULE-PILL-001 Physical Spring Bounce: 180ms overshoot -> 250ms rebound -> 320ms settle */
@keyframes pillSpringRight {
  0% {
    transform: translate3d(0%, 0, 0);
  }
  56.25% {
    transform: translate3d(calc(100% + 3px), 0, 0);
  }
  78.125% {
    transform: translate3d(calc(100% - 2px), 0, 0);
  }
  100% {
    transform: translate3d(100%, 0, 0);
  }
}

@keyframes pillSpringLeft {
  0% {
    transform: translate3d(100%, 0, 0);
  }
  56.25% {
    transform: translate3d(-3px, 0, 0);
  }
  78.125% {
    transform: translate3d(2px, 0, 0);
  }
  100% {
    transform: translate3d(0%, 0, 0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .seg-rail.bounce-right .seg-glider {
    animation: pillSpringRight 320ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
  .seg-rail.bounce-left .seg-glider {
    animation: pillSpringLeft 320ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
}

.seg-btn {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--demo-muted);
  /* Fixed font-weight 500 -> Zero Layout Shift */
  font: 500 0.82rem/1.25 Poppins, sans-serif;
  padding: 0.56rem 0.65rem;
  min-height: 38px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: color 180ms ease;
}

.seg-btn[aria-selected="true"] {
  color: var(--demo-text);
}

.seg-btn:focus-visible,
.scheme-toggle:focus-visible,
.demo-body a:focus-visible,
.demo-submit:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

/* Left Column Editorial Pitch (Open, Zero Cajitis) */
.demo-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--brand-accent);
  margin: 0 0 0.65rem;
}

.demo-eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ed-cta-bg);
  flex: none;
}

.demo-pitch h1 {
  font: 400 clamp(2.35rem, 4.3vw, 3.85rem)/1.02 Georgia, serif;
  letter-spacing: -0.03em;
  margin: 0 0 0.55rem;
  color: var(--demo-text);
}

.demo-pitch h1 em {
  font-style: italic;
}

.demo-lead {
  font-size: clamp(0.96rem, 1.15vw, 1.06rem);
  line-height: 1.6;
  color: var(--demo-muted);
  margin: 0 0 1.55rem;
  max-width: 50ch;
}

/* Open Editorial Feature List (1px hairlines, zero icon boxes) */
.demo-points {
  list-style: none;
  margin: 0 0 1.85rem;
  padding: 0;
  border-top: 1px solid var(--demo-hairline);
}

.demo-points li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
  padding: 0.88rem 0;
  border-bottom: 1px solid var(--demo-hairline);
  font-size: 0.9rem;
  line-height: 1.52;
  color: var(--demo-muted);
}

.demo-points li svg {
  width: 20px;
  height: 20px;
  color: var(--brand-accent);
  margin-top: 0.14rem;
  flex: none;
}

.demo-points li strong {
  color: var(--demo-text);
  font-weight: 600;
}

.demo-points li em {
  font-style: italic;
  color: var(--demo-text);
}

/* Open Partner Strip (Zero boxes, crisp dual-scheme logos) */
.demo-partners {
  padding-block: 0.25rem 1.45rem;
  border-bottom: 1px solid var(--demo-hairline);
  margin-bottom: 1.35rem;
}

.demo-partners-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--demo-muted);
  margin: 0 0 0.85rem;
}

.demo-partners-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: center;
}

.demo-partners-row img {
  width: 100%;
  max-width: 96px;
  height: 36px;
  object-fit: contain;
  opacity: 0.86;
  transition: opacity 180ms ease;
}

.demo-partners-row img:hover {
  opacity: 1;
}

/* Direct Contact Signature (Open, 48x48 portrait with 1px hairline) */
.demo-advisor-mini {
  display: flex;
  align-items: center;
  gap: 0.95rem;
}

.demo-advisor-mini img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--demo-hairline);
  flex: none;
}

.demo-advisor-meta {
  min-width: 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.demo-advisor-meta strong {
  display: block;
  font-weight: 600;
  color: var(--demo-text);
}

.demo-advisor-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
  margin-top: 0.15rem;
}

.demo-advisor-links a {
  color: var(--brand-accent);
  text-decoration: underline;
  text-underline-offset: 0.22em;
  font-weight: 500;
}

.demo-advisor-note {
  display: block;
  font-size: 0.76rem;
  color: var(--demo-muted);
  margin-top: 0.18rem;
}

/* Right Column: Single Architectural Form Surface */
.demo-surface {
  background: var(--demo-surface);
  border: 1px solid var(--demo-hairline);
  border-radius: 12px;
  padding: clamp(1.35rem, 2.8vw, 2.2rem);
  box-shadow: var(--demo-shadow);
}

.demo-surface-head {
  margin-bottom: 1.25rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid var(--demo-hairline);
}

.demo-surface-head h2 {
  font: 400 clamp(1.55rem, 2.2vw, 1.95rem)/1.1 Georgia, serif;
  letter-spacing: -0.025em;
  margin: 0 0 0.28rem;
  color: var(--demo-text);
}

.demo-surface-head p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--demo-muted);
}

/* Form Grid & Controls */
.demo-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.92rem 0.88rem;
}

.demo-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.demo-field.full-span {
  grid-column: 1 / -1;
}

.demo-field label {
  font-size: 0.81rem;
  font-weight: 500;
  color: var(--demo-text);
  margin-bottom: 0.32rem;
  line-height: 1.3;
}

.demo-field .opt-tag {
  font-weight: 400;
  color: var(--demo-muted);
  font-size: 0.75rem;
}

/* Hint placed ABOVE input (validate-input-after-interaction) */
.field-hint {
  display: block;
  font-size: 0.74rem;
  color: var(--demo-muted);
  margin: -0.12rem 0 0.32rem;
}

.demo-field input:not([type="checkbox"]),
.demo-field select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0.62rem 0.82rem;
  border-radius: 8px;
  border: 1px solid var(--demo-input-border);
  background-color: var(--demo-input-bg);
  color: var(--demo-text);
  font: 400 0.94rem/1.35 Poppins, sans-serif;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.demo-field input::placeholder {
  color: var(--demo-muted);
  opacity: 0.68;
}

/* Custom clean Cupertino chevron on <select> (Zero Windows 98 arrow) */
.demo-field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.35rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.demo-field input:not([type="checkbox"]):focus,
.demo-field select:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(43, 196, 140, 0.2);
}

/* Validation ONLY after interaction (validate-input-after-interaction + select-menu-interaction) */
.demo-field :is(input:not([type="checkbox"]), select):is(:user-valid, .user-valid-fallback) {
  border-color: var(--demo-valid);
}

.demo-field :is(input:not([type="checkbox"]), select):is(:user-invalid, .user-invalid-fallback) {
  border-color: var(--demo-err);
  background-color: var(--demo-err-bg);
}

.error-msg {
  display: none;
  align-items: flex-start;
  gap: 0.42rem;
  color: var(--demo-err);
  font-size: 0.77rem;
  line-height: 1.38;
  margin-top: 0.34rem;
}

.err-icon {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.25px solid currentColor;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  flex: none;
  margin-top: 0.08rem;
}

.demo-field :is(:user-invalid, .user-invalid-fallback) ~ .error-msg,
.demo-field:has(:is(:user-invalid, .user-invalid-fallback)) > .error-msg {
  display: flex;
}

/* Honeypot off-flow */
.hp-trap {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Consent Checkbox (brand-consistent-forms + @supports not fallback) */
.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.78rem !important;
  font-weight: 400 !important;
  line-height: 1.48 !important;
  color: var(--demo-muted) !important;
  cursor: pointer;
  margin-bottom: 0 !important;
}

.consent-label input[type="checkbox"] {
  display: inline-block;
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0.16rem 0 0;
  padding: 0;
  flex: none;
  accent-color: var(--brand-accent);
  cursor: pointer;
}

.consent-label a {
  color: var(--brand-accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

@supports not (accent-color: #2bc48c) {
  .consent-label {
    position: relative;
    padding-left: 1.85rem;
  }
  .consent-label input[type="checkbox"].cb-brand {
    position: absolute !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: nowrap !important;
  }
  .consent-label input[type="checkbox"].cb-brand + span::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.18rem;
    width: 1.15rem;
    height: 1.15rem;
    border: 1.5px solid var(--demo-input-border);
    background: var(--demo-input-bg);
    border-radius: 4px;
    box-sizing: border-box;
  }
  .consent-label input[type="checkbox"].cb-brand:focus-visible + span::before {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
  }
  .consent-label input[type="checkbox"].cb-brand:checked + span::before {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
  }
  .consent-label input[type="checkbox"].cb-brand:checked + span::after {
    content: "✓";
    position: absolute;
    left: 0.24rem;
    top: 0.14rem;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.82rem;
  }
}

/* Primary Submit CTA */
.demo-submit {
  width: 100%;
  min-height: 48px;
  padding: 0.78rem 1.25rem;
  border-radius: 8px;
  border: 1px solid var(--ed-cta-bg);
  background: var(--ed-cta-bg);
  color: var(--ed-cta-ink);
  font: 600 0.95rem/1.25 Poppins, sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.demo-submit:hover:not(:disabled) {
  background: var(--ed-cta-hover);
  border-color: var(--ed-cta-hover);
}

.demo-submit:disabled {
  opacity: 0.72;
  cursor: progress;
}

.demo-form-alert {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: var(--demo-err);
  min-height: 0;
}

.demo-form-alert:empty {
  display: none;
}

/* Confirmation Panel (macosModalSpringEntrance) */
@keyframes demoConfirmSpring {
  0% {
    opacity: 0;
    transform: scale(0.965) translateY(8px);
  }
  68% {
    opacity: 1;
    transform: scale(1.005) translateY(-1px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.demo-confirmation {
  padding: 0.5rem 0;
  animation: demoConfirmSpring 300ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.demo-confirm-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-accent);
  margin-bottom: 0.75rem;
}

.demo-confirmation h3 {
  font: 400 clamp(1.55rem, 2.3vw, 2rem)/1.12 Georgia, serif;
  margin: 0 0 0.55rem;
  color: var(--demo-text);
}

.demo-confirmation p {
  font-size: 0.9rem;
  line-height: 1.58;
  color: var(--demo-muted);
  margin: 0 0 1.1rem;
}

.demo-confirm-summary {
  border-top: 1px solid var(--demo-hairline);
  border-bottom: 1px solid var(--demo-hairline);
  padding: 0.85rem 0;
  margin-bottom: 1.15rem;
  display: grid;
  gap: 0.4rem;
  font-size: 0.84rem;
}

.demo-confirm-summary div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.demo-confirm-summary span {
  color: var(--demo-muted);
}

.demo-confirm-summary strong {
  color: var(--demo-text);
  font-weight: 500;
  text-align: right;
}

.demo-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.demo-reset-link {
  appearance: none;
  background: transparent;
  border: 1px solid var(--demo-hairline);
  color: var(--demo-text);
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font: 500 0.82rem/1.2 Poppins, sans-serif;
  cursor: pointer;
}

/* Footer on demo.html */
.demo-footer {
  border-top: 1px solid var(--demo-hairline);
  padding-block: 1.2rem;
  font-size: 0.82rem;
  color: var(--demo-muted);
}

.demo-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1.5rem;
}

.demo-footer a {
  color: var(--brand-accent);
  text-decoration: underline;
  text-underline-offset: 0.24em;
}

/* ==========================================================================
   HOME (#demo) UPGRADED SECTION IN dist/index.html
   Harmonized with Ivory surface (#f1ebe2 / #faf7f2) without touching other sections
   ========================================================================== */
#demo.demo-home-section {
  --demo-bg: #f1ebe2;
  --demo-surface: #ffffff;
  --demo-input-bg: #faf8f4;
  --demo-text: #111210;
  --demo-muted: #55534c;
  --demo-hairline: rgba(17, 18, 16, 0.12);
  --demo-input-border: rgba(17, 18, 16, 0.2);
  --brand-accent: #09563a;
  --demo-err: #b3261e;
  --demo-err-bg: rgba(179, 38, 30, 0.06);
  --demo-valid: #09563a;
  --demo-rail-bg: rgba(17, 18, 16, 0.06);
  --demo-pill-bg: #ffffff;
  --demo-pill-border: rgba(17, 18, 16, 0.12);
  --demo-shadow: 0 20px 48px rgba(17, 18, 16, 0.06);
  --ed-cta-bg: #2bc48c;
  --ed-cta-hover: #4cd3a0;
  --ed-cta-ink: #081a12;
  accent-color: #09563a;
  color-scheme: light;
}

.demo-home-shell {
  border-top: 1px solid var(--demo-hairline);
  padding-top: clamp(1.5rem, 3.5vw, 2.8rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(1.75rem, 4vw, 3.8rem);
  align-items: start;
}

.demo-home-pitch h2 {
  font: 400 clamp(2.1rem, 3.8vw, 3.35rem)/1.02 Georgia, serif;
  letter-spacing: -0.03em;
  color: var(--demo-text);
  margin: 0 0 0.55rem;
}

.demo-home-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--brand-accent);
  text-decoration: underline;
  text-underline-offset: 0.26em;
}

.demo-home-link:hover {
  opacity: 0.82;
}

/* Responsive Breakpoints (Zero Horizontal Overflow at 390x844 and 320px+) */
@media (max-width: 980px) {
  .demo-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
  .demo-nav {
    width: 100%;
  }
  .demo-grid,
  .demo-home-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
  }
  .seg-rail {
    max-width: 100%;
  }
}

@media (max-width: 680px) {
  .demo-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .demo-partners-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem 1rem;
  }
  .demo-brand i {
    font-size: 0.95rem;
    padding-left: 0.6rem;
  }
}

@media (max-width: 520px) {
  .seg-btn {
    padding: 0.48rem 0.38rem;
    font-size: 0.78rem;
    line-height: 1.2;
  }
  .seg-btn .seg-dot {
    display: none;
  }
  .seg-btn .seg-sub {
    display: block;
    font-size: 0.68rem;
    font-weight: 400;
    opacity: 0.82;
    margin-top: 0.1rem;
  }
  .demo-confirm-summary div {
    flex-direction: column;
    gap: 0.12rem;
  }
  .demo-confirm-summary strong {
    text-align: left;
  }
}
