/* debate.ai -- restrained text-forum palette, system fonts only, no external assets */

:root {
  /* Minimalist system sans stack -- distinct from the previous one, still
     zero external font requests. */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", sans-serif;

  /* Alien theme: black background, alien-green text/accents everywhere. */
  --bg: #000000;
  --bg-alt: #06110a;
  --border: #1f5c33;
  --text: #39e639;
  --text-muted: #2f8f4a;

  /* Brand accent: alien green, used for links, buttons, headings and
     section accents across every page (replaces the old red palette). */
  --brand-red: #39ff5f;
  --brand-red-dark: #22b347;
  --link: var(--brand-red);
  --link-visited: #1f8a3d;
  --focus: var(--brand-red);

  --science: #39ff5f;
  --philosophy: #7CFC9E;

  --fund-orange: #2ecc59;
  --fund-orange-dark: #1f9e42;

  /* Small set of premium-polish tokens: consistent radius/shadow/motion,
     used sparingly rather than layered everywhere. */
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px -8px rgba(0, 255, 100, 0.16);
  --transition: 150ms ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image: linear-gradient(rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.82)), url("bg-aliens.webp");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  /* Never let a phone scroll sideways -- long unbroken debate text or a
     wide table is the usual cause; overflow-wrap below is the real fix,
     this is just a hard backstop. */
  overflow-x: hidden;
  width: 100%;
}

/* Long AI-generated paragraphs, book text, and table cells should wrap
   instead of forcing horizontal scroll on a phone-width viewport. */
.post-body, .book-text, p, li, td {
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.meta-table {
  max-width: 100%;
}

a {
  color: var(--link);
  text-decoration: underline;
}
a:visited { color: var(--link-visited); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
a:focus, button:focus, input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  position: sticky;
  top: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(2px);
  z-index: 20;
}
.site-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.site-header .brand {
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--brand-red);
}
.site-nav {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.85rem;
}
.site-nav a {
  text-decoration: none;
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.1rem 0;
}
.site-nav a:hover, .site-nav a:focus { text-decoration: underline; }
.site-nav a.current { font-weight: 700; color: var(--brand-red); border-bottom: 2px solid var(--brand-red); }
.site-nav a.fund-me-link {
  font-weight: 700;
  color: var(--fund-orange);
  background: var(--bg);
  border: 1px solid var(--fund-orange);
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.site-nav a.fund-me-link:hover, .site-nav a.fund-me-link:focus {
  background: var(--fund-orange);
  border-color: var(--fund-orange);
  color: #000;
  text-decoration: none;
}

/* Mobile hamburger toggle -- hidden entirely on wider screens, where the
   nav is always shown inline as before. */
.nav-toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle-bar {
  width: 16px;
  height: 2px;
  background: var(--text);
  transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle.open .nav-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.open .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle.open .nav-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.btn.fund-me-btn {
  background: var(--bg);
  border-color: var(--fund-orange);
  color: var(--fund-orange);
  font-weight: 700;
}
.btn.fund-me-btn:hover, .btn.fund-me-btn:focus { background: var(--fund-orange); border-color: var(--fund-orange); color: #000; opacity: 1; }
.btn.fund-me-btn[aria-disabled="true"] {
  background: #0a0a0a;
  border-color: #2a3a2f;
  color: #4d6e57;
  cursor: not-allowed;
}
.setup-note {
  color: var(--fund-orange-dark);
  font-size: 0.75rem;
  margin-top: 0.35rem;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}

h1 { font-size: 1.2rem; margin: 0 0 0.2rem; color: var(--brand-red); font-weight: 700; }
h2 { font-size: 0.92rem; margin: 1.35rem 0 0.4rem; color: var(--brand-red); font-weight: 700; letter-spacing: 0.01em; }
h3 { font-size: 0.85rem; margin: 0.9rem 0 0.35rem; color: var(--brand-red); font-weight: 700; }

.tagline { color: var(--text-muted); margin: 0 0 1rem; font-size: 0.85rem; }

.field-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
input[type="text"], textarea, select {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  width: 100%;
  transition: border-color var(--transition);
}
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--brand-red); }
textarea { resize: vertical; min-height: 4.5rem; }

button, .btn {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 0.42rem 0.8rem;
  border: 1px solid var(--brand-red);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--brand-red);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition), transform 100ms ease;
}
button:hover, .btn:hover { background: var(--brand-red); border-color: var(--brand-red); color: #000; }
button:active, .btn:active { transform: scale(0.97); }
button.secondary, .btn.secondary {
  background: var(--bg);
  color: var(--brand-red);
  border-color: var(--border);
}
button.secondary:hover, .btn.secondary:hover { background: var(--bg-alt); border-color: var(--brand-red); }

.example-list { color: var(--text-muted); font-size: 0.8rem; margin: 0.4rem 0 0.9rem; }
.example-list button.link-like {
  background: none; border: none; color: var(--link); text-decoration: underline;
  padding: 0; font-size: 0.8rem; cursor: pointer;
}

.debate-list-item {
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition);
}
.debate-list-item:hover, .debate-list-item:focus-within { background: var(--bg-alt); }
.debate-list-item .num { color: var(--text-muted); font-family: var(--font-mono); margin-right: 0.4rem; }
.debate-list-item .q { font-weight: 600; text-decoration: none; color: var(--text); font-size: 0.88rem; }
.debate-list-item .q:hover { text-decoration: underline; }
.debate-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}
.status-live { color: var(--brand-red); font-weight: 700; }
.status-closed { color: var(--text-muted); font-weight: 700; }

.debate-header-box {
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-red);
  border-radius: var(--radius);
  padding: 0.8rem 0.9rem;
  margin-bottom: 1.1rem;
}
.debate-header-box .thread-id { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.72rem; }

.conclusion-box {
  border: 2px solid var(--brand-red);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 1.35rem;
  background: var(--bg-alt);
}
.conclusion-box h2 { margin-top: 0; }
.outcome-tag {
  display: inline-block;
  font-weight: 700;
  color: var(--brand-red);
  border: 1px solid var(--brand-red);
  border-radius: var(--radius-sm);
  padding: 0.08rem 0.45rem;
  font-size: 0.72rem;
  margin-bottom: 0.5rem;
}

/* Debate messages: the visual centerpiece on mobile. A thin agent-colored
   left border makes SCIENCE vs PHILOSOPHY instantly scannable while
   scrolling, without adding icons/avatars or extra colors. */
.post {
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  padding: 0.75rem 0 0.75rem 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  animation: fadeInUp 0.25s ease both;
}
.post-science { border-left-color: var(--science); }
.post-philosophy { border-left-color: var(--philosophy); }
.post-head { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }
.post-num { margin-right: 0.5rem; }
.agent-tag { font-weight: 700; }
.agent-tag.science { color: var(--science); }
.agent-tag.philosophy { color: var(--philosophy); }
.post-body { margin-top: 0.3rem; white-space: pre-wrap; font-size: 0.85rem; }
.post-sources { margin-top: 0.3rem; font-size: 0.72rem; color: var(--text-muted); }

.status-line {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 0.65rem;
  margin-top: 0.4rem;
}

.corpus-cat { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.65rem 0.9rem; margin-bottom: 0.9rem; }
.corpus-cat h2 { margin-top: 0; }
.book-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.25rem 0; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.book-row:last-child { border-bottom: none; }
.book-row .author { color: var(--text-muted); font-size: 0.75rem; }

.book-text {
  font-family: var(--font-mono);
  white-space: pre-wrap;
  font-size: 0.78rem;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  background: var(--bg-alt);
  max-height: 70vh;
  overflow-y: auto;
}

.meta-table { border-collapse: collapse; font-size: 0.8rem; margin: 0.65rem 0; }
.meta-table td { padding: 0.12rem 0.65rem 0.12rem 0; vertical-align: top; }
.meta-table td.k { color: var(--text-muted); white-space: nowrap; }

/* The Five Foundational Questions -- and any future numbered thread list.
   Large, quiet numerals in the brand color; small, restrained question text. */
.foundational-list { margin-top: 0.75rem; }
.foundational-item {
  display: block;
  padding: 1rem 0.4rem;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: background-color var(--transition);
  animation: fadeInUp 0.25s ease both;
}
.foundational-item:hover, .foundational-item:focus { background: var(--bg-alt); }
.foundational-item:first-child { padding-top: 0.4rem; }
.foundational-num {
  display: block;
  font-family: var(--font-mono);
  color: var(--brand-red);
  font-weight: 700;
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
}
.foundational-q {
  font-size: 0.92rem;
  line-height: 1.45;
}
.foundational-item:hover .foundational-q, .foundational-item:focus .foundational-q { text-decoration: underline; }
.foundational-item .debate-meta { margin-top: 0.35rem; }

footer.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 1.75rem;
  padding: 0.9rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
footer.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 0.85rem; margin-bottom: 0.45rem; }
footer.site-footer nav a { color: var(--text-muted); }
.support-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }

/* Tiny, low-priority site-wide views counter. Hidden until a real count
   arrives (see site.js) so there is never a "0 views" flash. Intentionally
   quiet: smaller than the surrounding footer text, muted color, no border
   or background of its own. */
.views-line { margin: 0.4rem 0 0; }
.views-counter {
  display: none;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-muted);
  font-size: 0.68rem;
  opacity: 0.8;
}
.views-counter.is-ready { display: inline-flex; }
.views-counter svg { flex-shrink: 0; }

.search-box { margin-bottom: 0.9rem; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------------
   Mobile: nav collapses behind a hamburger toggle; touch targets grow;
   inputs use a 16px font so iOS Safari doesn't auto-zoom on focus.
   Everything above this point is unchanged desktop behavior.
   --------------------------------------------------------------------- */
@media (max-width: 700px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    flex-direction: column;
    gap: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    margin-top: 0;
    transition: max-height var(--transition), opacity var(--transition), margin-top var(--transition);
  }
  .site-nav.open {
    max-height: 480px;
    opacity: 1;
    pointer-events: auto;
    margin-top: 0.5rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
  }
  .site-nav a { padding: 0.5rem 0.1rem; font-size: 0.85rem; }
  .site-nav a.fund-me-link { display: inline-block; margin-top: 0.3rem; }

  button, .btn { min-height: 44px; padding: 0.5rem 0.9rem; }
  input[type="text"], textarea, select { min-height: 44px; font-size: 16px; }

  .support-buttons .btn { flex: 1 1 calc(50% - 0.5rem); text-align: center; }
}

@media (max-width: 480px) {
  main { padding: 0.85rem 0.7rem 2rem; }
  .site-header { padding: 0.55rem 0.85rem; }
  .book-text { max-height: 60vh; font-size: 0.74rem; }
  .post, .foundational-item { padding-left: 0.6rem; }
}

/* Respect reduced-motion preferences: no entrance animation, instant
   menu/transition state changes. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Share widget: floating share button + menu, on every page ---- */
#share-widget {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 500;
  font-family: inherit;
}

#share-toggle {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--brand-red);
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  transition: background var(--transition, 0.15s ease), color var(--transition, 0.15s ease);
}

#share-toggle:hover,
#share-toggle[aria-expanded="true"] {
  background: var(--brand-red);
  color: var(--bg);
}

#share-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.5rem);
  display: none;
  flex-direction: column;
  min-width: 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
}

#share-menu.open {
  display: flex;
}

#share-menu button {
  background: transparent;
  color: var(--text);
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
}

#share-menu button:last-child {
  border-bottom: none;
}

#share-menu button:hover {
  background: var(--bg-alt);
  color: var(--brand-red);
}

#share-toast {
  position: fixed;
  right: 1rem;
  bottom: 4.2rem;
  z-index: 501;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#share-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 480px) {
  #share-widget { right: 0.6rem; bottom: 0.6rem; }
  #share-toggle { padding: 0.55rem 0.9rem; font-size: 0.8rem; }
}

/* ---- Install App button: sits just above the Share button, same style ---- */
#install-app-btn {
  position: fixed;
  right: 1rem;
  bottom: 4.6rem;
  z-index: 500;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--brand-red);
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  transition: background var(--transition, 0.15s ease), color var(--transition, 0.15s ease);
}

#install-app-btn:hover {
  background: var(--brand-red);
  color: var(--bg);
}

@media (max-width: 480px) {
  #install-app-btn { right: 0.6rem; bottom: 3.4rem; padding: 0.55rem 0.9rem; font-size: 0.8rem; }
}

/* ---- Responsive YouTube embed (16:9), no fixed pixel height so it scales
   cleanly on phones down to desktop. ---- */
.video-embed-wrap {
  position: relative;
  width: 100%;
  max-width: 720px;
  aspect-ratio: 16 / 9;
  margin: 0.75rem 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-alt);
}
.video-embed-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
