/* VIP Relay — "Broadcast Console" design system (docs/15 §7).
 *
 * Source stylesheet. Hand-authored, self-contained CSS (its own minimal reset below) — no CSS
 * framework, no build step. Edit this file, then sync it to ../static/css/app.css
 * (scripts/build_css.{ps1,sh} does a plain copy); the served copy ships in the image as a
 * committed asset.
 *
 * The look is OURS — bespoke, token-driven component classes, not framework defaults (P6).
 * Tokens are CSS custom properties so every value is overridable in one place. Fonts use a
 * strong system stack (self-hosted webfonts are a deferred polish option, Q-UI-3).
 */

@layer base {
  :root {
    /* Color — dark canvas, ONE saturated accent */
    --bg: #0a0b0d;
    --surface: #14161a;
    --surface-2: #1c1f25;
    --border: #2a2e37;
    --text: #f2f4f7;
    --muted: #9aa4b2;
    --accent: #3ddc84;
    --accent-press: #2fb870;
    --danger: #ff5c5c;
    --focus: #7aa2ff;

    /* Type — grotesk display, humanist body, mono metadata (system stack until U1) */
    --font-display: ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-body: ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

    /* Space (4px base) + radius */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --r-pill: 999px;

    color-scheme: dark;
  }

  /* Minimal reset (we ship no CSS framework, so we own the baseline). */
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    -webkit-text-size-adjust: 100%;
  }

  img,
  svg {
    display: block;
    max-width: 100%;
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }

  h1,
  h2,
  h3,
  p {
    margin: 0;
  }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    /* Subtle vignette so the near-black canvas reads as a console, not a void. */
    background-image: radial-gradient(120% 80% at 50% -10%, #11151c 0%, var(--bg) 60%);
    background-attachment: fixed;
    min-height: 100vh;
  }

  a {
    color: inherit;
  }

  :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 3px;
  }
}

@layer components {
  .container {
    width: 100%;
    max-width: 960px;
    margin-inline: auto;
    padding-inline: 24px;
  }

  .mono {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
  }

  .muted {
    color: var(--muted);
  }

  .accent {
    color: var(--accent);
  }

  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: absolute;
    left: 12px;
    top: -48px;
    z-index: 100;
    background: var(--surface-2);
    color: var(--text);
    padding: 10px 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    transition: top 120ms ease-out;
  }
  .skip-link:focus {
    top: 12px;
  }

  /* --- Header / nav --- */
  .site-header {
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
  }
  .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-weight: 600;
  }
  .brand-mark {
    display: inline-flex;
    color: var(--accent);
  }
  .brand-name {
    font-family: var(--font-display);
    letter-spacing: 0.01em;
  }
  .nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: color 120ms ease-out;
  }
  .nav-link:hover {
    color: var(--text);
  }

  /* --- Hero --- */
  .hero {
    padding-block: clamp(56px, 12vw, 128px) 64px;
    max-width: 720px;
  }
  .hero-eyebrow {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
  }
  .hero-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.25rem, 7vw, 3.75rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin: 0 0 20px;
  }
  .hero-sub {
    font-size: clamp(1rem, 2.4vw, 1.25rem);
    color: var(--muted);
    max-width: 56ch;
    margin: 0 0 28px;
  }
  .search-hint {
    margin-top: 12px;
    font-size: 0.875rem;
    max-width: 560px;
  }
  .search-hint .mono {
    color: var(--text);
  }

  .hero-proof {
    margin-top: 18px;
  }

  /* --- Platform toggle (segmented control) --- */
  .platform-toggle {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
  }
  .seg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: var(--r-pill);
    font-size: 0.9375rem;
    color: var(--muted);
    cursor: pointer;
    transition: background 120ms ease-out, color 120ms ease-out;
  }
  .seg input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
  }
  /* The checked radio drives the highlight (updates instantly on click — no JS). */
  .seg:has(input:checked) {
    background: var(--surface-2);
    color: var(--text);
  }
  .seg:has(input:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  /* --- Find page + results --- */
  .find {
    padding-block: clamp(40px, 8vw, 80px) 64px;
    max-width: 720px;
  }
  .find-title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    letter-spacing: -0.02em;
    margin-bottom: 24px;
  }
  .results {
    margin-top: 28px;
  }
  .results-prompt,
  .result-empty {
    padding: 24px;
    border: 1px dashed var(--border);
    border-radius: var(--r-lg);
  }
  .result-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    flex-wrap: wrap;
  }
  .avatar {
    width: 64px;
    height: 64px;
    border-radius: var(--r-md);
    object-fit: cover;
    background: var(--surface-2);
    flex: 0 0 auto;
  }
  .avatar-mono {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.75rem;
    color: var(--accent);
  }
  .result-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    flex: 1;
    min-width: 160px;
  }
  .result-name {
    font-family: var(--font-display);
    font-size: 1.375rem;
    margin: 2px 0 0;
  }
  .result-action {
    flex: 0 0 auto;
  }

  /* --- Creator page --- */
  .creator {
    padding-block: clamp(48px, 9vw, 96px) 64px;
    max-width: 640px;
  }
  .creator-head {
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
  }
  .creator-name {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 3rem);
    letter-spacing: -0.02em;
  }
  .creator-sub {
    margin-top: 16px;
    font-size: 1.0625rem;
    max-width: 52ch;
  }
  .wallet-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    flex-wrap: wrap;
  }
  .wallet-actions .btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
  }

  /* --- Pass preview (decorative wallet face on the install page) --- */
  .pass-preview {
    margin: 32px 0 0;
    max-width: 340px;
  }
  .pp-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px 20px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: linear-gradient(158deg, var(--surface-2), var(--surface));
    box-shadow: 0 18px 44px -26px rgba(0, 0, 0, 0.85);
  }
  .pp-top {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .pp-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    background: var(--accent);
    color: #04130a;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.125rem;
  }
  .pp-brand {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }
  .pp-chip {
    margin-left: auto;
    padding: 4px 10px;
    font-size: 0.6875rem;
  }
  .pp-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
  }
  .pp-label {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.6875rem;
  }
  .pp-name {
    font-family: var(--font-display);
    font-size: 1.375rem;
    letter-spacing: -0.01em;
  }
  .pp-status {
    font-size: 0.9375rem;
  }
  .pp-card .waveform {
    margin: 2px 0 0;
    height: 22px;
  }
  .pp-cap {
    margin-top: 12px;
    text-align: center;
  }

  /* --- Not found --- */
  .notfound {
    padding-block: clamp(64px, 12vw, 140px);
    max-width: 560px;
  }
  .notfound-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 3rem);
    margin-bottom: 12px;
  }
  .notfound .btn {
    margin-top: 24px;
  }

  /* --- Creator identity row + avatar sizes --- */
  .creator-id {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
  }
  .avatar-lg {
    width: 88px;
    height: 88px;
    font-size: 2.25rem;
    border-radius: var(--r-lg);
  }

  /* --- Share --- */
  .share {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
    flex-wrap: wrap;
  }

  /* --- Claim landing --- */
  .claim {
    padding-block: clamp(48px, 9vw, 96px) 64px;
    max-width: 640px;
  }
  .claim-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 3rem);
    letter-spacing: -0.02em;
  }
  .claim-sub {
    margin-top: 16px;
    font-size: 1.0625rem;
    max-width: 56ch;
  }
  .claim-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    flex-wrap: wrap;
  }
  .claim-points {
    margin-top: 32px;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    line-height: 1.5;
  }
  .claim-find {
    margin-top: 28px;
    margin-bottom: 14px;
    font-weight: 600;
  }
  .creator-claim {
    margin-top: 32px;
  }
  .creator-claim a {
    color: var(--accent);
  }

  /* --- Claim panel (creator-facing CTA on the public install page; unclaimed only) --- */
  .claim-panel {
    margin-top: 40px;
    padding: clamp(20px, 4vw, 28px);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
  }
  .claim-panel-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.6875rem;
  }
  .claim-panel-title {
    margin-top: 6px;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 2rem);
    letter-spacing: -0.02em;
  }
  .claim-panel-lead {
    margin-top: 12px;
    font-size: 1.0625rem;
    max-width: 52ch;
    line-height: 1.5;
  }
  .claim-panel-points {
    margin-top: 20px;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    line-height: 1.5;
  }
  .claim-panel-actions {
    margin-top: 24px;
  }
  .claim-panel .consent-note {
    margin-top: 16px;
  }

  /* --- Creator dashboard --- */
  .dash-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 28px;
  }
  .dash-stat {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px 20px;
    min-width: 160px;
  }
  .dash-stat-value {
    display: block;
    margin-top: 6px;
    font-size: 1.75rem;
    font-weight: 700;
  }
  .signout-form {
    margin-top: 32px;
  }
  .share-link {
    margin-top: 12px;
  }
  .share-link-url {
    display: inline-block;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--accent);
    word-break: break-all;
  }

  /* --- Channel switcher (multi-channel accounts, docs/16 §7) --- */
  .avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: var(--r-sm);
    font-size: 1.05rem;
  }
  .channel-list {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .channel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
  }
  .channel-active {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  }
  .channel-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }
  .channel-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
  }
  .channel-name {
    font-weight: 600;
    word-break: break-word;
  }
  .channel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
  }
  .channel-form {
    margin: 0;
  }
  .channel-current {
    color: var(--text-muted);
  }
  .channel-list-muted {
    opacity: 0.72;
  }
  .channel-add {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
  }
  .banner-error {
    border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
    background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  }

  /* --- Component gallery (internal) --- */
  .gallery {
    padding-block: 48px 96px;
  }
  .gallery-h {
    margin-top: 36px;
    margin-bottom: 4px;
    font-family: var(--font-display);
    font-size: 1.25rem;
  }
  .gallery-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 12px 0;
  }

  /* --- Chip --- */
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--muted);
    text-transform: uppercase;
  }
  .chip-live {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  }
  .chip-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent);
    animation: vr-pulse 1.8s ease-out infinite;
  }

  /* --- Buttons --- */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 12px 20px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 120ms ease-out, border-color 120ms ease-out, transform 120ms ease-out;
  }
  .btn:active {
    transform: translateY(1px);
  }
  .btn-primary {
    background: var(--accent);
    color: #04130a;
  }
  .btn-primary:hover {
    background: var(--accent-press);
  }
  .btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
  }
  .btn-secondary:hover {
    border-color: var(--muted);
  }
  .btn-ghost {
    background: transparent;
    color: var(--text);
  }
  .btn[disabled],
  .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  /* --- Search --- */
  .search {
    display: flex;
    gap: 10px;
    align-items: stretch;
    max-width: 560px;
  }
  .search-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    padding: 12px 16px;
    font-size: 1rem;
  }
  .search-input::placeholder {
    color: var(--muted);
  }
  .search-input:focus {
    border-color: var(--focus);
  }
  .search-input:disabled {
    opacity: 0.6;
  }

  /* --- Waveform divider (motif) --- */
  .waveform {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 36px;
    margin: 28px 0;
  }
  .waveform span {
    width: 4px;
    height: 12px;
    border-radius: var(--r-pill);
    background: color-mix(in srgb, var(--accent) 55%, var(--border));
    animation: vr-bars 1.6s ease-in-out infinite;
  }
  /* Static height pattern (kept in CSS so templates carry no inline style → strict CSP). */
  .waveform span:nth-child(1),
  .waveform span:nth-child(9),
  .waveform span:nth-child(13) {
    height: 6px;
  }
  .waveform span:nth-child(2),
  .waveform span:nth-child(8) {
    height: 10px;
  }
  .waveform span:nth-child(3),
  .waveform span:nth-child(7) {
    height: 16px;
  }
  .waveform span:nth-child(4),
  .waveform span:nth-child(6),
  .waveform span:nth-child(11) {
    height: 24px;
  }
  .waveform span:nth-child(5) {
    height: 32px;
  }
  .waveform span:nth-child(10),
  .waveform span:nth-child(12) {
    height: 20px;
  }
  .waveform span:nth-child(odd) {
    animation-delay: 0.2s;
  }
  .waveform span:nth-child(3n) {
    animation-delay: 0.4s;
  }

  /* --- Banner (claim success / notice, shown after the OAuth round-trip) --- */
  .banner {
    padding: 12px 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 0.95rem;
  }
  .banner-success {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  }
  .banner-success strong {
    color: var(--accent);
  }
  .banner-notice {
    background: var(--surface);
    color: var(--muted);
  }

  /* --- Consent-on-action micro-copy (action-wrap, beneath search / wallet CTAs) --- */
  .consent-note {
    margin-top: 10px;
    max-width: 56ch;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--muted);
  }
  .consent-note a {
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .consent-note a:hover {
    color: var(--text);
  }

  /* --- Legal pages (privacy / terms) --- */
  .legal {
    padding-block: clamp(40px, 8vw, 80px) 64px;
    max-width: 70ch;
  }
  .legal-title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    letter-spacing: -0.02em;
    margin-bottom: 8px;
  }
  .legal h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin: 32px 0 8px;
  }
  .legal h3 {
    font-size: 1.0625rem;
    margin: 20px 0 4px;
  }
  .legal p,
  .legal li {
    color: var(--muted);
  }
  .legal ul {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0;
  }
  .legal strong {
    color: var(--text);
  }
  .legal a {
    color: var(--accent);
  }
  .legal code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--text);
  }
  /* Plain-English summary / callout box (the "TL;DR" creators actually read). */
  .legal-lead {
    border-left: 3px solid var(--accent);
    background: var(--surface);
    border-radius: var(--r-md);
    padding: 16px 18px;
    margin: 20px 0 8px;
  }
  .legal-lead p {
    color: var(--text);
    margin: 0;
  }

  /* --- Footer --- */
  .footer-links {
    display: inline-flex;
    gap: 16px;
  }
  .site-footer {
    border-top: 1px solid var(--border);
    margin-top: 96px;
    padding-block: 28px;
  }
  .footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
  }

  .signal-dot {
    animation: vr-pulse 1.8s ease-out infinite;
  }
}

@keyframes vr-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent);
  }
  70% {
    box-shadow: 0 0 0 8px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@keyframes vr-bars {
  0%,
  100% {
    transform: scaleY(0.7);
  }
  50% {
    transform: scaleY(1.25);
  }
}

/* Honor reduced-motion: no pulse, no waveform animation (docs/15 §9). */
@media (prefers-reduced-motion: reduce) {
  .chip-dot,
  .signal-dot,
  .waveform span {
    animation: none !important;
  }
  * {
    scroll-behavior: auto !important;
  }
}
