/* Territorial Demos — PORTAL.md § 8. Typography and palette taken from territorial.dev (components/home/home-client.tsx). */
:root {
  --bg: #0b0c0e;          /* territorial.dev page */
  --bg-deep: #08090a;     /* territorial.dev "work" band */
  --surface: #0e0f12;     /* territorial.dev panels */
  --surface-2: #1a1b1f;
  --line: rgba(255, 255, 255, 0.05);
  --line-strong: rgba(255, 255, 255, 0.12);
  --fg: #ffffff;
  --fg-soft: #d4d4d8;     /* zinc-300: leads */
  --muted: #a1a1aa;       /* zinc-400: body copy */
  --faint: #71717a;       /* zinc-500: meta */
  --accent: #34d399;      /* emerald-400: labels, highlights */
  --accent-strong: #10b981;
  --radius: 20px;
  --gutter: clamp(16px, 4vw, 32px);
  --max: 1200px;
  --read: 680px;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Inconsolata", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; min-height: 100dvh; display: flex; flex-direction: column; }
img, video { display: block; max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.read { max-width: var(--read); margin-left: auto; margin-right: auto; }
.eyebrow { font: 400 14px/1.4 var(--mono); letter-spacing: 0.25em; text-transform: uppercase; color: var(--accent); }
.eyebrow.quiet { color: var(--muted); }
/* territorial.dev's highlighted headline line */
.hl { background: linear-gradient(to right, #6ee7b7, #34d399, #99f6e4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.client { font-size: 14px; color: var(--accent); }
h1, h2, h3 { text-rendering: optimizeLegibility; text-wrap: balance; }
.subtitle, .page-head p, .gate p, .closing p, figcaption { text-wrap: balance; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 28px; border-radius: 999px; border: 1px solid transparent; font: 500 15px/1 var(--sans); text-decoration: none; cursor: pointer; transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease; white-space: nowrap; }
.btn:hover { transform: scale(1.02); }
.btn:active { transform: scale(0.99); }
.btn-primary { background: #fff; color: #000; }
.btn-ghost { background: transparent; color: var(--fg); border-color: rgba(255, 255, 255, 0.2); }
.btn-ghost:hover { background: rgba(39, 39, 42, 0.5); }
.btn-quiet { background: transparent; color: #d4d4d8; padding: 0 14px; min-height: 36px; font-weight: 400; font-size: 14px; }
.btn-quiet:hover { color: #fff; transform: none; }
.btn .arrow { transition: transform 0.15s ease; }
.btn:hover .arrow { transform: translateX(2px); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* Nav */
.nav { position: sticky; top: 0; z-index: 20; background: rgba(11, 12, 14, 0.7); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.nav .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.brand-name { font: 700 18px/1 var(--mono); letter-spacing: 0.025em; }
.brand-sub { color: var(--faint); font-size: 14px; padding-left: 12px; border-left: 1px solid var(--line-strong); }
@media (max-width: 560px) { .brand-sub { display: none; } }
.nav-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.nav-right form { margin: 0; display: flex; }
.nav-who { color: var(--faint); font-size: 14px; margin-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.lang a { font: 500 12px/1 var(--mono); letter-spacing: 0.15em; padding: 6px 9px; border-radius: 999px; text-decoration: none; color: var(--muted); }
.lang a[aria-current="true"] { background: var(--surface-2); color: var(--fg); }
@media (max-width: 560px) { .nav-who { display: none; } }

/* Footer */
.foot { margin-top: auto; padding: 48px 0 40px; border-top: 1px solid var(--line); }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; align-items: center; color: var(--faint); font-size: 14px; }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--fg); }
.foot .mono { font: 700 16px var(--mono); letter-spacing: 0.025em; color: #fff; }

/* Gate: home, check inbox, messages */
.gate { flex: 1; display: grid; place-items: center; padding: 64px var(--gutter); position: relative; overflow: hidden; }
.gate::before { content: ""; position: absolute; top: -160px; left: 50%; width: 820px; height: 520px; transform: translateX(-50%); border-radius: 999px; background: rgba(16, 185, 129, 0.1); filter: blur(120px); pointer-events: none; }
.gate-inner { position: relative; width: 100%; max-width: 640px; text-align: center; }
.gate-inner form, .gate-inner .stack-form { max-width: 460px; margin-left: auto; margin-right: auto; }
.gate-inner > p { max-width: 520px; margin-left: auto; margin-right: auto; }
.gate .symbol { width: 88px; height: 88px; margin: 0 auto; }
.gate .wordmark { margin-top: 16px; font: 700 18px/1 var(--mono); letter-spacing: 0.025em; color: rgba(255, 255, 255, 0.85); }
.gate h1 { font-size: clamp(2.6rem, 7vw, 3.75rem); line-height: 1.02; font-weight: 600; letter-spacing: -0.035em; margin: 32px 0 20px; }
.gate p { color: var(--fg-soft); font-size: clamp(18px, 2vw, 20px); line-height: 1.625; margin: 0 auto 8px; }
.field { display: flex; gap: 8px; margin-top: 32px; padding: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; }
.field:focus-within { border-color: var(--accent-strong); }
.field input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--fg); font: 400 16px var(--sans); padding: 0 18px; outline: none; }
.field input::placeholder { color: #71717a; }
@media (max-width: 480px) { .field { flex-direction: column; border-radius: 22px; } .field input { min-height: 44px; } }
.stack-form { display: grid; gap: 12px; margin-top: 28px; text-align: left; }
.stack-form label { font-size: 14px; color: var(--muted); display: grid; gap: 6px; }
.stack-form input, .stack-form textarea { width: 100%; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); font: inherit; }
.stack-form input:focus, .stack-form textarea:focus { outline: none; border-color: var(--accent-strong); }
.notice { margin-top: 16px; font-size: 15px; }
.notice.error { color: #fca5a5; }
.cf-turnstile { margin-top: 16px; display: flex; justify-content: center; min-height: 65px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.divider { height: 1px; background: var(--line); margin: 40px 0 0; }

/* Catalog */
.page-head { padding: clamp(56px, 10vw, 112px) 0 clamp(32px, 5vw, 56px); text-align: center; }
.page-head h1 { font-size: clamp(2.6rem, 7vw, 4.5rem); line-height: 1.02; font-weight: 600; letter-spacing: -0.035em; margin: 20px 0 24px; }
.page-head p { font-size: clamp(18px, 2vw, 20px); line-height: 1.625; color: var(--fg-soft); margin: 0 auto; max-width: 36rem; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(20px, 3vw, 32px); padding-bottom: 96px; }
@media (max-width: 760px) { .cards { grid-template-columns: 1fr; } }
.card { display: block; text-decoration: none; border-radius: calc(var(--radius) + 4px); }
.card-media { aspect-ratio: 16 / 10; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1); }
.card:hover .card-media img { transform: scale(1.03); }
.card-media.blank { display: grid; place-items: center; background: radial-gradient(80% 80% at 30% 20%, rgba(16, 185, 129, 0.18), transparent 60%), var(--surface); }
.card-media.blank img { width: 64px; height: 64px; opacity: 0.6; }
.card-body { padding: 18px 4px 0; }
.card-body h2 { font-size: clamp(20px, 2.2vw, 24px); line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; margin: 10px 0 8px; }
.card-body p { color: var(--muted); font-size: 16px; line-height: 1.625; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-more { display: inline-flex; gap: 6px; margin-top: 16px; color: #fff; font-size: 14px; font-weight: 500; transition: color 0.2s ease; }
.card:hover .card-more { color: #6ee7b7; }
.empty { text-align: center; padding: 48px 0 120px; color: var(--muted); }

/* Story */
.hero { padding: clamp(56px, 9vw, 104px) 0 clamp(32px, 5vw, 48px); text-align: center; }
.hero .client { margin-bottom: 4px; }
.hero h1 { font-size: clamp(2.6rem, 7vw, 4.5rem); line-height: 1.02; font-weight: 600; letter-spacing: -0.035em; margin: 20px 0 24px; }
.hero .subtitle { font-size: clamp(18px, 2vw, 20px); line-height: 1.625; color: var(--fg-soft); max-width: 40rem; margin: 0 auto 36px; }
.hero-media { margin-top: clamp(32px, 5vw, 56px); }
.frame { border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.frame img, .frame video { width: 100%; height: auto; }
.lede { padding: clamp(56px, 9vw, 104px) 0 clamp(24px, 4vw, 40px); }
.lede-text { font-size: clamp(1.25rem, 2.4vw, 1.625rem); line-height: 1.5; font-weight: 500; letter-spacing: -0.012em; color: var(--fg); }
.lede-text p { margin: 0 0 0.7em; }
.section { padding: clamp(40px, 6vw, 72px) 0; }
.section h2 { margin: 0 0 20px; }
.section h2.eyebrow { margin-bottom: 20px; }
.prose { font-size: 18px; line-height: 1.625; color: var(--muted); }
.prose p { margin: 0 0 1.1em; }
.prose strong { color: #fff; font-weight: 500; }
.prose ul, .prose ol { padding-left: 1.2em; margin: 0 0 1.1em; }
.prose li { margin: 0 0 0.6em; }
.prose li::marker { color: var(--accent); }
.prose a { color: #fff; text-decoration: underline; text-decoration-color: rgba(255,255,255,.3); text-underline-offset: 3px; }
.prose a:hover { color: #6ee7b7; }
.prose code { font-family: var(--mono); font-size: 0.92em; background: var(--surface); padding: 1px 6px; border-radius: 6px; }
.figure { margin: clamp(24px, 4vw, 48px) auto; }
.figure figcaption { max-width: var(--read); margin: 16px auto 0; text-align: center; color: var(--faint); font-size: 14px; line-height: 1.625; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.chip { font: 400 12px/1 var(--sans); padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.1); color: var(--muted); }
.closing { position: relative; overflow: hidden; margin: clamp(48px, 8vw, 96px) 0; padding: clamp(56px, 9vw, 96px) var(--gutter); text-align: center; border-radius: calc(var(--radius) + 8px); background: var(--surface); border: 1px solid var(--line); }
.closing::before { content: ""; position: absolute; top: -160px; left: 50%; width: 820px; height: 520px; transform: translateX(-50%); border-radius: 999px; background: rgba(16, 185, 129, 0.1); filter: blur(120px); pointer-events: none; }
.closing > * { position: relative; }
.closing h2 { font-size: clamp(2.25rem, 5vw, 3.75rem); line-height: 1.05; letter-spacing: -0.03em; font-weight: 600; margin: 0 0 20px; }
.closing p { color: var(--muted); font-size: 18px; line-height: 1.625; margin: 0 auto 32px; max-width: 36rem; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; margin-top: 28px; }
.back:hover { color: var(--fg); }

/* Demo screen */
.demo-body { height: 100dvh; overflow: hidden; }
.bar { height: 48px; flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 12px; background: rgba(11, 12, 14, 0.92); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.bar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-left a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; }
.bar-left a:hover { color: var(--fg); }
.bar-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.bar-right { display: flex; justify-content: flex-end; }
.bar .btn { min-height: 32px; padding: 0 16px; font-size: 14px; }
.bar .btn:hover { transform: none; }
.switch { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px; max-width: 100%; overflow-x: auto; }
.switch a { padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; text-decoration: none; color: var(--muted); white-space: nowrap; }
.switch a[aria-current="page"] { background: var(--surface-2); color: var(--fg); }
@media (max-width: 640px) { .bar { grid-template-columns: auto 1fr auto; } .bar-left .crumb { display: none; } }
.stage { flex: 1; position: relative; background: var(--bg-deep); }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg-deep); }
.stage-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; transition: opacity 0.3s ease; }
.loading.done { opacity: 0; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent-strong); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tour */
.tour { flex: 1; overflow-y: auto; }
.tour-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100dvh - 48px); padding: 20px var(--gutter) 20px; gap: 14px; }
.tour-slide { display: none; width: 100%; max-width: 1280px; }
.tour-slide.on, .no-js .tour-slide { display: block; }
.no-js .tour-slide { margin-bottom: 32px; }
.tour-slide .frame { max-height: calc(100dvh - 250px); display: flex; justify-content: center; background: #000; }
.tour-slide img, .tour-slide video { width: auto; max-width: 100%; max-height: calc(100dvh - 250px); object-fit: contain; }
.tour-slide figcaption { text-align: center; color: var(--muted); font-size: 15px; line-height: 1.5; margin: 12px auto 0; max-width: 760px; }
.tour-controls { display: flex; align-items: center; gap: 16px; }
.no-js .tour-controls { display: none; }
.tour-count { font: 400 14px var(--mono); color: var(--accent); min-width: 64px; text-align: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; color: var(--fg); cursor: pointer; font-size: 18px; display: grid; place-items: center; }
.icon-btn:hover { border-color: rgba(255, 255, 255, 0.4); }

/* Reveal on scroll (only when JS runs) */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.8s cubic-bezier(0.2, 0.7, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1); }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .card-media img, .btn, .btn .arrow { transition: none; }
  .spinner { animation: none; }
}

/* Staff preview of unapproved cases */
.badge { display: inline-block; margin-bottom: 10px; font: 500 11px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.35); border-radius: 999px; padding: 5px 9px; }
.preview-note { margin: 20px auto 0; max-width: 720px; text-align: center; font-size: 14px; color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.06); border-radius: 12px; padding: 10px 14px; }
