/* ══════════════════════════════════════════════════════════════════
   v2-demo.css — Demo page
   Uses tokens and patterns from v2-base.css + v2-components.css so
   the page reads as the same family as the homepage (dark hero,
   white feature band, dark CTA, dark footer).
   ══════════════════════════════════════════════════════════════════ */

/* ════════════════════════════════════
   1. HERO (dark)
   ════════════════════════════════════ */
.demo-hero {
  background: var(--bg);
  padding: 72px 5% 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.demo-hero::before {
  content: '';
  position: absolute; top: -80px; left: 50%; transform: translateX(-50%);
  width: 900px; height: 500px;
  background: var(--v2-hero-gradient);
  filter: blur(20px);
  pointer-events: none; z-index: 0;
}
.demo-hero > * { position: relative; z-index: 1; }
.demo-hero .v2-section-label { margin: 0 auto 14px; }
.demo-hero h1 {
  font-size: clamp(34px, 5vw, 58px);
  font-weight: 700; letter-spacing: -0.028em; line-height: 1.05;
  color: var(--text);
  max-width: 820px; margin: 0 auto 16px;
  text-wrap: balance;
}
.demo-hero h1 em {
  font-style: normal;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.demo-hero p {
  font-size: 17px; line-height: 1.65;
  color: var(--muted);
  max-width: 640px; margin: 0 auto 28px;
}
.demo-hero-meta {
  display: inline-flex; flex-wrap: wrap; justify-content: center;
  gap: 22px; font-size: 13px; color: var(--muted);
}
.demo-hero-dot { display: inline-flex; align-items: center; gap: 8px; }
.demo-hero-dot .ico { width: 14px; height: 14px; color: var(--accent); }

/* ════════════════════════════════════
   2. TRY IT (dark) — form + preview
   ════════════════════════════════════ */
.demo-try {
  background: var(--bg);
  padding: 0 5% 96px;
}
.demo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}

/* ── Form card ── */
.demo-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 30px 28px;
}
.demo-card-head {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 22px;
}
.demo-card-head .ico-tile { flex-shrink: 0; margin-top: 2px; }
.demo-card-head h3 {
  font-size: 18px; font-weight: 700; color: var(--text);
  letter-spacing: -0.015em; margin-bottom: 4px;
}
.demo-note { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ── Form layout ── */
.demo-form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.demo-form-row { display: flex; flex-direction: column; gap: 6px; }
.demo-form-row.full { grid-column: 1 / -1; }
.demo-form-row label {
  font-size: 12px; font-weight: 500;
  color: var(--muted); letter-spacing: 0.01em;
}
.demo-input, .demo-select, .demo-textarea {
  width: 100%;
  height: 44px; padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px; font-family: inherit;
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
  appearance: none;
  -webkit-appearance: none;
  /* Tells the browser to render native UI (calendar/time/select-popup) in
     dark mode so the option list matches the form. */
  color-scheme: dark;
}
.demo-input::placeholder, .demo-textarea::placeholder { color: var(--muted-2); }
.demo-input:hover, .demo-select:hover, .demo-textarea:hover {
  border-color: var(--line-2, rgba(255,255,255,0.18));
}
.demo-input:focus, .demo-select:focus, .demo-textarea:focus {
  outline: none;
  border-color: rgba(245,158,11,0.55);
  background: #141418;
  box-shadow: 0 0 0 3px rgba(245,158,11,0.12);
}
.demo-select {
  cursor: pointer;
  padding-right: 40px;
  /* Use the `background` shorthand with explicit `no-repeat` so Safari
     can't drop the repeat setting and tile the chevron across the width.
     `right 14px center` positions the chevron 14px in from the right edge. */
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f59e0b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>")
    no-repeat right 14px center / 14px 14px,
    var(--bg);
}
.demo-select:focus {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fbbf24' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>")
    no-repeat right 14px center / 14px 14px,
    #141418;
}
/* Native <option> styling (Chrome/Firefox honour these; Safari shows its
   own system popup — the custom dropdown below replaces it entirely). */
.demo-select option {
  background: #141418;
  color: var(--text);
}
.demo-select option:checked,
.demo-select option:hover {
  background: rgba(245,158,11,0.15);
}

/* ════════════════════════════════════
   Custom select popup (.demo-select wrapper)
   A lightweight dropdown layered on top of the real <select>. The real
   <select> stays in the DOM for form submission + screen readers, but
   its clicks are captured by JS which shows this dark, themed list
   instead of the white system popup.
   ════════════════════════════════════ */
.select-wrap {
  position: relative;
}
.select-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 50;
  background: #141418;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 20px 40px -12px rgba(0,0,0,0.6);
  max-height: 260px;
  overflow-y: auto;
  display: none;
}
.select-wrap.open .select-popup { display: block; }
.select-option {
  display: block;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--dur);
}
.select-option:hover,
.select-option.active {
  background: rgba(245,158,11,0.12);
  color: var(--text);
}
.select-option.selected {
  background: rgba(245,158,11,0.18);
  color: var(--accent);
  font-weight: 500;
}
.select-wrap.open .demo-select {
  border-color: rgba(245,158,11,0.55);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fbbf24' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='18 15 12 9 6 15'/></svg>");
}
.demo-textarea {
  height: 90px; padding: 12px 14px; resize: vertical;
  line-height: 1.5;
}
/* Browser will tint calendar/time widgets against dark bg */
.demo-input::-webkit-calendar-picker-indicator { filter: invert(0.7) opacity(0.7); cursor: pointer; }

/* ── Actions ── */
.demo-actions {
  margin-top: 22px;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.demo-actions .btn-hero,
.demo-actions .btn-outline { gap: 8px; }
.demo-actions .ico { width: 16px; height: 16px; }
.demo-status {
  margin-top: 14px;
  font-size: 13px; color: var(--text-dim); min-height: 18px;
}
.demo-cooldown {
  font-size: 12px; color: var(--accent); min-height: 16px;
}

/* ── Preview column (browser chrome around iframe) ── */
.demo-preview-col {
  position: sticky; top: 110px;  /* nav + banner height-ish */
  display: flex; flex-direction: column; gap: 12px;
}
.demo-preview-col .browser {
  background: #0d0d10;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.6);
  position: relative;
}
.demo-preview-col .browser-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--line);
}
.demo-preview-col .browser-bar .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  flex-shrink: 0;
}
.demo-preview-col .browser-bar .dot-r { background: rgba(255,95,86,0.55); }
.demo-preview-col .browser-bar .dot-y { background: rgba(255,189,46,0.55); }
.demo-preview-col .browser-bar .dot-g { background: rgba(39,201,63,0.55); }
.demo-preview-col .browser-url {
  flex: 1;
  font-size: 11.5px; color: var(--muted);
  background: rgba(0,0,0,0.3);
  padding: 6px 12px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.demo-preview-col .preview-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--accent);
  background: rgba(245,158,11,0.15);
  border: 1px solid rgba(245,158,11,0.3);
  padding: 4px 8px; border-radius: 6px;
  flex-shrink: 0;
}
.demo-preview-col .browser-pdf {
  position: relative;
  background: #fff;
  /* A4 aspect (595 × 842 pt). Width is 100 % of the browser-chrome wrapper;
     height follows the ratio so the iframe below fills it fully without
     clipping. No max-height — clamping height while aspect-ratio is set
     would shrink width too and leave a gap next to the chrome. */
  aspect-ratio: 595 / 842;
  width: 100%;
  overflow: hidden;
}
/* SVG mock of the invoice — always rendered, sits underneath the iframe.
   Real browsers paint the iframe's PDF on top. If the PDF renderer is
   unavailable (headless screenshots / very old browsers), the SVG is still
   visible so the preview is never empty. */
/* SVG mock sits in the background. In real browsers the iframe's PDF
   viewer paints its own white page + content on top, fully covering the
   mock — users see the real PDF. The mock is a graceful fallback. */
.demo-preview-col .browser-pdf .pdf-mock {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  display: block;
  background: #fff;
  z-index: 0;
}
.demo-preview-col .browser-pdf iframe {
  position: relative;
  display: block;
  width: 100%; height: 100%; border: 0;
  background: transparent;
  z-index: 1;
}
/* When JS confirms the real PDF is ready (or the generate handler swaps
   in a fresh blob), we don't need the mock anymore — hide it so the page
   is leaner. */
.demo-preview-col .browser-pdf.pdf-ready .pdf-mock {
  display: none;
}
.demo-preview-caption {
  font-size: 12.5px; color: var(--muted);
  text-align: center; line-height: 1.55;
}
.demo-preview-caption strong { color: var(--text); font-weight: 600; }

/* ════════════════════════════════════
   3. FEATURES (light)
   ════════════════════════════════════ */
.demo-features {
  background: var(--bg-light);
  color: var(--text-light);
  padding: var(--v2-section-padding);
}
.demo-features .v2-section-label { color: var(--accent); }
.demo-features .v2-section-title { color: var(--text-light); }
.demo-features .v2-section-desc  { color: var(--muted-light); }
.demo-features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 22px;
  max-width: 1000px;
  margin: 48px auto 0;
}
.demo-feature-card {
  background: #fff;
  border: 1px solid #e8e8ec;
  border-radius: var(--radius-lg);
  padding: 28px 26px;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur);
}
.demo-feature-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px -12px rgba(0,0,0,0.12);
}
.demo-feature-card .ico-tile-light {
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(245,158,11,0.1);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.demo-feature-card .ico-tile-light .ico { width: 20px; height: 20px; }
.demo-feature-card h3 {
  font-size: 16px; font-weight: 700;
  color: var(--text-light);
  letter-spacing: -0.015em; margin-bottom: 6px;
}
.demo-feature-card p {
  font-size: 13.5px;
  color: var(--muted-light);
  line-height: 1.6;
}

/* ════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════ */
@media (max-width: 1060px) {
  .demo-preview-col { position: static; }
}
@media (max-width: 900px) {
  .demo-grid { grid-template-columns: 1fr; }
  .demo-features-grid { grid-template-columns: 1fr; max-width: 480px; }
  .demo-hero { padding: 56px 5% 44px; }
  /* iframe height removed — aspect-ratio on .browser-pdf handles sizing */
}
@media (max-width: 560px) {
  .demo-form-grid { grid-template-columns: 1fr; }
  .demo-form-row.full { grid-column: 1; }
  .demo-card { padding: 26px 22px 24px; }
  .demo-hero-meta { gap: 14px; }
}
