/*
 * Demo page chrome. Separate from captcha.css so integrators can ship the widget
 * stylesheet alone.
 */

:root {
  --page-bg: #f7f7f8;
  --page-outer: #f1f2f4;
  --surface: #ffffff;
  --text: #15171a;
  --muted: #7b8088;
  --line: rgba(0, 0, 0, .06);
  --demo-badge-bg: #fff4d6;
  --demo-badge-text: #7a5a09;
  --demo-badge-line: #f0dca6;
  --shadow: 0 16px 50px rgba(0, 0, 0, .10);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page-bg: #17191c;
    --page-outer: #0f1113;
    --surface: #17191c;
    --text: #e8eaed;
    --muted: #9aa0a8;
    --line: rgba(255, 255, 255, .08);
    --demo-badge-bg: #3a2f12;
    --demo-badge-text: #f0d38a;
    --demo-badge-line: #574411;
    --shadow: 0 16px 50px rgba(0, 0, 0, .45);
  }
}

:root[data-theme="dark"] {
  --page-bg: #17191c;
  --page-outer: #0f1113;
  --surface: #17191c;
  --text: #e8eaed;
  --muted: #9aa0a8;
  --line: rgba(255, 255, 255, .08);
  --demo-badge-bg: #3a2f12;
  --demo-badge-text: #f0d38a;
  --demo-badge-line: #574411;
  --shadow: 0 16px 50px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100dvh;
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; }

.page-shell {
  min-height: 100dvh;
  display: grid;
  place-items: start center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.phone-page {
  width: min(100%, 520px);
  min-height: 100dvh;
  background: var(--surface);
}

.app-header {
  position: relative;
  height: 52px;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 2px;
  padding: 0 6px 0 4px;
  border-bottom: 1px solid var(--line);
}

.header-title { text-align: center; font-size: 15px; font-weight: 600; }

.header-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.header-icon:hover { background: var(--line); }
.header-icon:focus-visible { outline: 2px solid var(--muted); outline-offset: -2px; }
.header-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.header-actions { display: flex; align-items: center; gap: 2px; }

.lang-switch { position: relative; }
.lang-switch > button { font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.lang-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 132px;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}
.lang-menu[hidden] { display: none; }
.lang-menu button {
  width: 100%;
  padding: 8px 10px;
  text-align: start;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
}
.lang-menu button:hover { background: var(--line); }
.lang-menu button[aria-current="true"] { font-weight: 600; }

.demo-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 14px 0;
  padding: 8px 11px;
  border: 1px solid var(--demo-badge-line);
  border-radius: 9px;
  background: var(--demo-badge-bg);
  color: var(--demo-badge-text);
  font-size: 12px;
  line-height: 1.45;
}
.demo-banner strong {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--demo-badge-text);
  color: var(--demo-badge-bg);
  font-size: 10px;
  letter-spacing: .06em;
}

.demo-footer {
  padding: 4px 16px 28px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.demo-footer a { color: inherit; }

@media (min-width: 521px) {
  .page-shell { padding: 24px; place-items: center; background: var(--page-outer); }
  .phone-page { min-height: auto; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
}

@media (max-height: 560px) and (orientation: landscape) {
  .page-shell { place-items: center; padding: max(6px, env(safe-area-inset-top)) 10px max(6px, env(safe-area-inset-bottom)); }
  .phone-page { width: min(94vw, 620px); min-height: auto; }
  .app-header { height: 42px; }
  .demo-banner { margin-top: 6px; padding: 5px 9px; font-size: 11px; }
  .demo-footer { padding-bottom: 10px; }
}
