/* ═══════════════════════════════════════════════════════════════════
   public-shell.css
   Shared "terminal shell" design system for AlphaProxy's public,
   pre-authentication surfaces: landing (/login), /about, /changelog.

   Brand palette (BRAND_COLORS.md):
     seamless-white      #fafafa   primary text (dark) / background (light)
     seamless-dark-grey  #1a1a1b   primary dark surface
     seamless-black      #0a0a0b   deepest dark / page background
     seamless-red-accent #ff1a4f   primary action
     seamless-green      #00b050   success / live state

   Terminal additions (new, for console clarity):
     term-mint   #2ee27a   "live" green legible on pure black (dark mode only;
                           light mode falls back to brand green #00b050)
     term-amber  #ffb454   flags / warnings / pending states
   ═══════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; }

:root {
  /* brand */
  --brand-white: #fafafa;
  --brand-dark-grey: #1a1a1b;
  --brand-black: #0a0a0b;
  --brand-red: #ff1a4f;
  --brand-green: #00b050;
  --term-mint: #2ee27a;
  --term-amber: #ffb454;

  /* dark surfaces (default) */
  --bg: var(--brand-black);
  --bg-raised: #101012;
  --bg-panel: #131316;
  --line: #24242a;
  --line-soft: #1b1b20;
  --text: var(--brand-white);
  --text-dim: rgba(250, 250, 250, 0.64);
  --text-faint: rgba(250, 250, 250, 0.4);
  --accent: var(--brand-red);
  --accent-hover: #ff3d6b;
  --accent-dim: rgba(255, 26, 79, 0.32);
  --live: var(--term-mint);
  --live-dim: rgba(46, 226, 122, 0.16);
  --amber: var(--term-amber);
  --grid-line: rgba(250, 250, 250, 0.028);
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.45);

  /* legacy tokens still read by /css/chat-header.css */
  --color-background: var(--bg);
  --color-panel: var(--bg-panel);
  --color-text: var(--text);
  --color-chat-background: var(--bg);
  --color-background-hover: rgba(250, 250, 250, 0.08);
  --color-text-light: #1a1a1b;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --maxw: 1080px;
}

.light-mode {
  --bg: var(--brand-white);
  --bg-raised: #f1f1f2;
  --bg-panel: #ffffff;
  --line: #d9d9dd;
  --line-soft: #e7e7ea;
  --text: var(--brand-dark-grey);
  --text-dim: rgba(26, 26, 27, 0.66);
  --text-faint: rgba(26, 26, 27, 0.42);
  --accent: var(--brand-red);
  --accent-hover: #e6163f;
  --accent-dim: rgba(255, 26, 79, 0.24);
  --live: var(--brand-green);
  --live-dim: rgba(0, 176, 80, 0.14);
  --amber: #a86500;
  --grid-line: rgba(26, 26, 27, 0.045);
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.1);
  --color-background-hover: rgba(26, 26, 27, 0.06);
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* faint console grid behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 42px 42px;
}

::selection { background: var(--accent); color: #ffffff; }
a { color: inherit; }
button { font-family: inherit; }
img { display: block; }

.tl-page { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 100vh; }
.tl-wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ─── Keyframes ───────────────────────────────────────────────── */
@keyframes tl-blink { 50% { opacity: 0; } }
@keyframes tl-pulse {
  0%   { box-shadow: 0 0 0 0 var(--live-dim), 0 0 0 0 var(--live-dim); }
  70%  { box-shadow: 0 0 0 7px transparent, 0 0 6px 1px var(--live-dim); }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; }
}
@keyframes tl-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.tl-caret {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  background: var(--accent);
  vertical-align: -0.16em;
  margin-left: 0.18em;
  animation: tl-blink 1.1s steps(1) infinite;
}
.tl-caret--live { background: var(--live); }

/* ─── Header ──────────────────────────────────────────────────── */
.tl-header {
  position: sticky;
  top: 0;
  z-index: 80;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.tl-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 24px;
}
.tl-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.tl-brand-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tl-brand-icon img { width: 100%; height: 100%; object-fit: contain; }
.tl-brand-word { display: inline-flex; align-items: baseline; line-height: 1; }
.tl-brand-word .dot { color: var(--accent); }
.tl-brand-word .tl-caret { margin-left: 5px; }

.tl-nav { display: flex; align-items: center; gap: 22px; font-size: 13px; color: var(--text-dim); }
.tl-nav a {
  position: relative;
  text-decoration: none;
  transition: color 0.15s ease;
}
.tl-nav a::before { content: "./"; color: var(--text-faint); margin-right: 1px; }
.tl-nav a:hover, .tl-nav a.is-active, .tl-nav a[aria-current="page"] { color: var(--text); }
.tl-nav a.is-active::before, .tl-nav a[aria-current="page"]::before { color: var(--live); }

.tl-actions { display: flex; align-items: center; gap: 10px; }

/* ─── Buttons ─────────────────────────────────────────────────── */
.tl-btn {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  padding: 9px 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  line-height: 1.2;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}
.tl-btn:hover { color: var(--text); border-color: color-mix(in srgb, var(--text) 40%, transparent); }
.tl-btn:active { transform: translateY(1px); }
.tl-btn:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }
.tl-btn--solid { background: var(--accent); border-color: var(--accent); color: #ffffff; font-weight: 600; }
.tl-btn--solid:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #ffffff; }
.tl-btn--live { border-color: color-mix(in srgb, var(--live) 55%, transparent); color: var(--live); }
.tl-btn--live:hover { background: var(--live-dim); border-color: var(--live); color: var(--live); }
.tl-btn--lg { padding: 13px 22px; font-size: 14px; }
.tl-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* system-coloured solid button: light on dark, dark on light */
.tl-btn--system { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.tl-btn--system:hover { background: color-mix(in srgb, var(--text) 88%, var(--bg)); border-color: color-mix(in srgb, var(--text) 88%, var(--bg)); color: var(--bg); }

/* header actions: same 28px height / 6px radius as the app header tabs */
.tl-actions .tl-btn {
  height: var(--ap-header-icon-button-size, 28px);
  padding: 0 12px;
  font-size: 12px;
  border-radius: var(--ap-header-icon-button-radius, 6px);
}

/* ─── Theme toggle — identical to the authenticated app header toggle ── */
.tl-page {
  --ap-header-icon-button-size: 28px;
  --ap-header-icon-button-radius: 6px;
  --ap-header-icon-glyph-size: 16px;
  --ap-header-icon-color-dark: #a1a1a1;
  --ap-header-icon-color-dark-hover: rgba(250, 250, 250, 0.9);
  --ap-header-icon-hover-bg-dark: rgba(250, 250, 250, 0.1);
  --ap-header-icon-color-light: #333333;
  --ap-header-icon-color-light-hover: #333333;
  --ap-header-icon-hover-bg-light: rgba(0, 0, 0, 0.06);
}
.ap-theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ap-header-icon-button-size);
  height: var(--ap-header-icon-button-size);
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--ap-header-icon-button-radius);
  background: transparent;
  color: var(--ap-header-icon-color-dark);
  cursor: pointer;
  flex-shrink: 0;
  box-sizing: border-box;
  font-size: 1rem;
  line-height: 1;
  transition: background-color 0.15s, color 0.15s, transform 0.15s;
}
.ap-theme-toggle:hover { background-color: var(--ap-header-icon-hover-bg-dark); color: var(--ap-header-icon-color-dark-hover); }
.ap-theme-toggle:active { transform: scale(0.95); }
.light-mode .ap-theme-toggle { color: var(--ap-header-icon-color-light); }
.light-mode .ap-theme-toggle:hover { background-color: var(--ap-header-icon-hover-bg-light); color: var(--ap-header-icon-color-light-hover); }
.ap-theme-toggle .ap-theme-toggle__icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  font-size: var(--ap-header-icon-glyph-size); /* specificity beats google-icons.css 24px default */
  line-height: 1;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.ap-theme-toggle__icon--sun { opacity: 1; transform: scale(1) rotate(0deg); }
.ap-theme-toggle__icon--moon { opacity: 0; transform: scale(0.7) rotate(-24deg); }
.ap-theme-toggle.is-dark .ap-theme-toggle__icon--sun { opacity: 0; transform: scale(0.7) rotate(24deg); }
.ap-theme-toggle.is-dark .ap-theme-toggle__icon--moon { opacity: 1; transform: scale(1) rotate(0deg); }

/* ─── Status bar + flag ticker ────────────────────────────────── */
.tl-statusbar {
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}
.tl-statusbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}
.tl-status { display: inline-flex; align-items: center; gap: 8px; text-transform: uppercase; }
.tl-status b { color: var(--text-dim); font-weight: 600; }
.tl-status .live { color: var(--live); }
.tl-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  flex-shrink: 0;
  animation: tl-pulse 1.8s ease-out infinite;
}
.tl-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border: 1px solid color-mix(in srgb, var(--live) 45%, transparent);
  border-radius: 3px;
  color: var(--live);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}
.tl-statusbar .spacer { flex: 1; }

.tl-ticker-wrap {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
}
.tl-ticker {
  display: flex;
  gap: 44px;
  white-space: nowrap;
  padding: 10px 0;
  width: max-content;
  animation: tl-scroll 36s linear infinite;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.tl-ticker span { display: inline-flex; align-items: center; gap: 10px; }
.tl-ticker span::before { content: "●"; color: var(--live); font-size: 7px; }
.tl-ticker span.flag-accent::before { color: var(--accent); }
.tl-ticker-wrap:hover .tl-ticker { animation-play-state: paused; }

/* ─── Sections ────────────────────────────────────────────────── */
.tl-section { padding: 64px 0; border-bottom: 1px solid var(--line); }
.tl-kicker {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tl-kicker::before { content: "›"; color: var(--text-faint); }
.tl-h2 {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 14px;
  max-width: 680px;
  color: var(--text);
}
.tl-lede { color: var(--text-dim); max-width: 620px; margin: 0 0 36px; font-size: 15px; line-height: 1.75; }
.tl-comment { color: var(--text-faint); }
.tl-comment::before { content: "# "; }

/* ─── Terminal panel primitives ───────────────────────────────── */
.tl-term {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-panel);
  font-size: 13px;
  overflow: hidden;
}
.tl-term-hd {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.tl-term-hd i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.tl-term-hd i:first-child { background: color-mix(in srgb, var(--accent) 65%, var(--line)); }
.tl-term-hd .title { margin-left: 8px; }
.tl-term-hd .right { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
.tl-term-body { padding: 18px 20px 20px; }
.tl-cmd { color: var(--text); margin-bottom: 14px; word-break: break-word; }
.tl-cmd .prompt { color: var(--live); margin-right: 8px; }
.tl-cmd .flag { color: var(--amber); }
.tl-cmd .str { color: var(--text-dim); }
.tl-out { border-left: 2px solid var(--line-soft); padding-left: 16px; color: var(--text-dim); }
.tl-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--line-soft);
}
.tl-row:last-of-type { border-bottom: none; }
.tl-row .k { color: var(--text-faint); }
.tl-row .v { color: var(--text); text-align: right; }
.tl-row .v.ok { color: var(--live); }
.tl-row .v.amber { color: var(--amber); }
.tl-row .v.accent { color: var(--accent); }
.tl-note { margin: 14px 0 0; color: var(--text-dim); font-size: 12.5px; line-height: 1.7; }
.ln-ok { color: var(--live); }
.ln-amber { color: var(--amber); }
.ln-accent { color: var(--accent); }
.ln-dim { color: var(--text-faint); }

/* ─── Footer ──────────────────────────────────────────────────── */
.tl-footer { padding: 34px 0 40px; color: var(--text-faint); font-size: 12px; }
.tl-foot-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; }
.tl-foot-links { display: flex; gap: 22px; flex-wrap: wrap; }
.tl-foot-links a { text-decoration: none; color: var(--text-faint); }
.tl-foot-links a:hover { color: var(--accent); }
.tl-foot-legal { margin-top: 12px; line-height: 1.7; }

/* ─── Motion / responsive ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .tl-caret, .tl-dot, .tl-ticker { animation: none; }
}
@media (max-width: 860px) {
  .tl-nav { display: none; }
}
@media (max-width: 600px) {
  .tl-topbar { padding: 12px 16px; gap: 10px; }
  .tl-actions { gap: 6px; }
  .tl-actions .tl-btn { padding: 0 10px; font-size: 12px; }
  .tl-brand-word .tl-caret { display: none; }
  .tl-wrap { padding: 0 16px; }
  .tl-statusbar-inner { padding: 8px 16px; gap: 14px; }
  .tl-section { padding: 46px 0; }
  .tl-brand { font-size: 15px; }
}
