/* ============================================
   Third Matter / Exopoiesis
   ============================================ */

/* --- Reset & Base --- */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg:       #0a0e17;
  --bg-card:  #111827;
  --bg-hover: #1a2332;
  --text:     #d4d4d8;
  --text-dim: #8891a0;
  --heading:  #f0f0f2;
  --accent:   #d4a04a;
  --accent2:  #b8863a;
  --border:   #1e293b;
  --pent:     #c9944a;
  --mack:     #6b8fa3;
  --max-w:    800px;
  --nav-h:    3.2rem;
}

/* --- Light theme --- */

[data-theme="light"] {
  --bg:       #f5f4f0;
  --bg-card:  #ffffff;
  --bg-hover: #edecea;
  --text:     #3d3d3d;
  --text-dim: #6b7280;
  --heading:  #1a1a1a;
  --accent:   #a07630;
  --accent2:  #8a6528;
  --border:   #ddd8d0;
  --pent:     #9a7030;
  --mack:     #4a7a90;
}

[data-theme="light"] .hero::before {
  background: radial-gradient(ellipse at 50% 60%, rgba(160,118,48,0.08) 0%, transparent 70%);
}

[data-theme="light"] #results {
  background: linear-gradient(180deg, var(--bg) 0%, rgba(245,244,240,0.5) 50%, var(--bg) 100%);
}

[data-theme="light"] .site-nav {
  background: rgba(245, 244, 240, 0.9);
}

[data-theme="light"] .is-home .site-nav {
  background: rgba(245, 244, 240, 0.7);
}

[data-theme="light"] .membrane-core {
  box-shadow: 0 0 20px rgba(160, 118, 48, 0.3);
}

[data-theme="light"] .diagram-acidic {
  background: rgba(200, 60, 60, 0.06);
  border-color: rgba(200, 60, 60, 0.2);
}

[data-theme="light"] .diagram-alkaline {
  background: rgba(60, 100, 200, 0.06);
  border-color: rgba(60, 100, 200, 0.2);
}

[data-theme="light"] .dialog-q {
  background: rgba(160, 118, 48, 0.06);
}

[data-theme="light"] .dialog-a {
  background: rgba(74, 122, 144, 0.04);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 1.05rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* CJK font fallback */
html[lang="zh"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", "Noto Sans SC",
    "Helvetica Neue", Arial, sans-serif;
}

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}


/* --- Typography --- */

h1, h2, h3 {
  color: var(--heading);
  font-weight: 600;
  line-height: 1.25;
}

h2 {
  font-size: 1.6rem;
  margin-bottom: 1.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--heading);
  text-decoration: underline;
}

strong {
  color: var(--heading);
}

.prose p {
  margin-bottom: 1rem;
}

.prose ul {
  margin: 1rem 0 1rem 1.2rem;
  list-style: none;
}

.prose ul li {
  position: relative;
  padding-left: 1rem;
  margin-bottom: 0.6rem;
}

.prose ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.prose ol {
  margin: 1rem 0 1rem 1.5rem;
}

.prose ol li {
  margin-bottom: 0.6rem;
}

.prose h2 {
  margin-top: 2.5rem;
}

.prose h3 {
  margin-top: 2rem;
  color: var(--heading);
}

.prose h4 {
  font-size: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--heading);
}

.prose code {
  background: var(--bg-card);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

.prose pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 1.2rem 0;
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: 1.2rem 0;
  color: var(--text-dim);
  font-style: italic;
}

.prose img {
  max-width: 100%;
  border-radius: 6px;
  margin: 1rem 0;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}


/* --- Site Navigation --- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0;
}

.is-home .site-nav {
  position: relative;
  background: rgba(10, 14, 23, 0.6);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.nav-brand:hover {
  color: var(--heading);
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.9rem;
}

.nav-links a {
  color: var(--text-dim);
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
  text-decoration: none;
}

.lang-switch {
  display: flex;
  gap: 0.6rem;
  margin-left: 0.8rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.lang-link {
  font-size: 0.8rem;
  color: var(--text-dim);
  opacity: 0.7;
}

.lang-link:hover {
  opacity: 1;
  color: var(--accent);
  text-decoration: none;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.4rem;
  transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}


/* --- Hero --- */

.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1.5rem;
  position: relative;
  overflow: hidden;
}

/* Subtle gradient overlay */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 60%, rgba(212,160,74,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero-project {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--accent);
  margin-bottom: 2rem;
  font-weight: 500;
}

.hero-title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 700;
  max-width: 700px;
  margin: 0 auto 1.5rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-dim);
  max-width: 500px;
  margin: 0 auto;
}

.hero-origin {
  display: inline-block;
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(212, 160, 74, 0.3);
  padding-bottom: 2px;
  transition: color 0.2s, border-color 0.2s;
  letter-spacing: 0.02em;
}

.hero-origin:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}


/* --- Membrane decoration --- */

.hero-decoration {
  margin-bottom: 3rem;
}

.membrane {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
  animation: membrane-breathe 6s ease-in-out infinite;
}

.membrane-layer {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.layer-outer {
  width: 120px;
  height: 120px;
  border-color: rgba(201, 148, 74, 0.3);
}

.layer-mid {
  width: 80px;
  height: 80px;
  border-color: rgba(201, 148, 74, 0.5);
}

.layer-inner {
  width: 48px;
  height: 48px;
  border-color: rgba(107, 143, 163, 0.6);
}

.membrane-core {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 20px rgba(212, 160, 74, 0.4);
}

@keyframes membrane-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}


/* --- Sections --- */

.section {
  padding: 5rem 0;
}

.section + .section {
  border-top: 1px solid var(--border);
}

#results {
  background: linear-gradient(180deg, var(--bg) 0%, rgba(17,24,39,0.5) 50%, var(--bg) 100%);
}


/* --- Card Grid --- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.3s, background 0.3s;
}

.card:hover {
  border-color: var(--accent2);
  background: var(--bg-hover);
}

.card-number {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.card-label {
  font-size: 0.95rem;
  color: var(--heading);
  font-weight: 500;
}

.card-detail {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}


/* --- Visions Two-Column --- */

.visions-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
}

.visions-column h2 {
  font-size: 1.2rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
}

.vision-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  transition: border-color 0.3s, background 0.3s;
  text-decoration: none;
  margin-bottom: 1rem;
}

.vision-card:hover {
  border-color: var(--accent2);
  background: var(--bg-hover);
  text-decoration: none;
}

.vision-card h3 {
  font-size: 1.1rem;
  color: var(--heading);
  margin-bottom: 0.6rem;
}

.vision-card:hover h3 {
  color: var(--accent);
}

.vision-card-quote {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.6;
  font-style: italic;
  margin-bottom: 0.8rem;
}

.vision-card-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

@media (max-width: 600px) {
  .visions-columns {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}


/* --- Novella Page --- */

.prose img.novella-cover {
  float: left;
  width: 50%;
  margin: 1.2rem 1.5rem 1.2rem 0;
  border-radius: 8px;
  border: 2px solid #2ec4b6;
  box-shadow: 0 0 0 1px #e8c547;
}

@media (max-width: 600px) {
  .novella-cover {
    float: none;
    width: 100%;
    margin: 0 0 1.5rem 0;
  }
}


/* --- Architecture Diagram --- */

.diagram {
  margin: 2.5rem 0;
  padding: 2rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}

.diagram-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  max-width: 600px;
  margin: 0 auto;
}

.diagram-chamber {
  flex: 1;
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.diagram-acidic {
  border-radius: 8px 0 0 8px;
  background: rgba(180, 60, 60, 0.1);
  border: 1px solid rgba(180, 60, 60, 0.25);
  border-right: none;
}

.diagram-alkaline {
  border-radius: 0 8px 8px 0;
  background: rgba(60, 100, 180, 0.1);
  border: 1px solid rgba(60, 100, 180, 0.25);
  border-left: none;
}

.diagram-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--heading);
}

.diagram-ph {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.diagram-membrane {
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.diagram-layer {
  padding: 1.2rem 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  font-size: 0.78rem;
  font-weight: 600;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  letter-spacing: 0.05em;
}

.diagram-pent {
  background: rgba(201, 148, 74, 0.15);
  border-top: 1px solid var(--pent);
  border-bottom: 1px solid var(--pent);
  color: var(--pent);
  min-width: 3.5rem;
}

.diagram-mack {
  background: rgba(107, 143, 163, 0.15);
  border-top: 1px solid var(--mack);
  border-bottom: 1px solid var(--mack);
  color: var(--mack);
  min-width: 3.5rem;
}

.diagram-spec {
  font-size: 0.68rem;
  font-weight: 400;
  opacity: 0.7;
}

.diagram-arrow {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.diagram-arrow sup,
.diagram-arrow sub {
  font-size: 0.7em;
}


/* --- Collaborate --- */

.collab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0 2rem;
}

.collab-item {
  padding: 1.2rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-card);
  border-radius: 0 6px 6px 0;
}

.collab-item p {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.cta {
  text-align: center;
  margin-top: 2rem;
}

.button {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.75rem 2rem;
  background: transparent;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 500;
  border-radius: 6px;
  transition: background 0.3s, color 0.3s;
  letter-spacing: 0.03em;
}

.button:hover {
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
}


/* --- Page (post / vision) --- */

.page {
  padding: 3rem 0 5rem;
}

.post-header,
.vision-header {
  margin-bottom: 2.5rem;
}

.post-header h1,
.vision-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  border-bottom: none;
  display: block;
  margin-bottom: 0.5rem;
}

.post-date {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.vision-subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}


/* --- Listings (blog, visions) --- */

.listing {
  padding: 3rem 0 5rem;
}

.listing h1 {
  font-size: 1.8rem;
  margin-bottom: 2.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.post-list,
.vision-list {
  list-style: none;
}

.post-list li,
.vision-list li {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.post-list li:first-child,
.vision-list li:first-child {
  border-top: 1px solid var(--border);
}

.post-list a,
.vision-list a {
  text-decoration: none;
  display: block;
}

.post-list a:hover,
.vision-list a:hover {
  text-decoration: none;
}

.post-list h2,
.vision-list h2 {
  font-size: 1.2rem;
  border-bottom: none;
  display: block;
  margin-bottom: 0.3rem;
  padding-bottom: 0;
  transition: color 0.2s;
}

.post-list a:hover h2,
.vision-list a:hover h2 {
  color: var(--accent);
}

.post-list time {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.post-list .excerpt {
  font-size: 0.92rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  line-height: 1.6;
}

.vision-list .subtitle {
  font-size: 0.92rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

.empty-state {
  color: var(--text-dim);
  font-style: italic;
  padding: 2rem 0;
}


/* --- Vision categories --- */

.vision-category {
  margin-bottom: 3rem;
}

.vision-category h2 {
  font-size: 1.3rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  padding-bottom: 0.4rem;
}


/* --- Dialog (Q&A) --- */

.dialog {
  margin: 2rem 0;
}

.dialog-turn {
  margin-bottom: 2rem;
}

.dialog-q,
.dialog-a {
  padding: 1.2rem 1.5rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

.dialog-q {
  background: rgba(212, 160, 74, 0.08);
  border-left: 3px solid var(--accent);
}

.dialog-q p,
.dialog-a p {
  margin-bottom: 0.8rem;
}

.dialog-q p:last-child,
.dialog-a p:last-child {
  margin-bottom: 0;
}

.dialog-a {
  background: rgba(107, 143, 163, 0.06);
  border-left: 3px solid var(--mack);
}

.dialog-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.6rem;
}

.dialog-q .dialog-label {
  color: var(--accent);
}

.dialog-a .dialog-label {
  color: var(--mack);
}

.dialog-a h3 {
  color: var(--heading);
  font-size: 1.05rem;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
}

.dialog-a h3:first-of-type {
  margin-top: 0.5rem;
}

.dialog-a ul {
  margin: 0.5rem 0 0.5rem 1.2rem;
  list-style: none;
}

.dialog-a ul li {
  position: relative;
  padding-left: 1rem;
  margin-bottom: 0.4rem;
}

.dialog-a ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 5px;
  height: 5px;
  background: var(--mack);
  border-radius: 50%;
}

.dialog-a em {
  color: var(--text-dim);
}

.dialog-a strong {
  color: var(--heading);
}

.dialog-separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}


/* --- Footer --- */

.footer {
  padding: 3rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.footer-muted {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.footer-note {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  font-style: italic;
}

.footer-copy {
  font-size: 0.78rem;
  color: var(--text-dim);
  opacity: 0.7;
}


/* --- Responsive --- */

@media (max-width: 600px) {

  .hero {
    min-height: 90vh;
    padding: 3rem 1rem;
  }

  .hero-title {
    font-size: 1.6rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .section {
    padding: 3.5rem 0;
  }

  h2 {
    font-size: 1.3rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .diagram-row {
    flex-direction: column;
    align-items: center;
  }

  .diagram-chamber {
    width: 100%;
    border-radius: 0;
  }

  .diagram-acidic {
    border-radius: 8px 8px 0 0;
    border: 1px solid rgba(180, 60, 60, 0.25);
    border-bottom: none;
  }

  .diagram-alkaline {
    border-radius: 0 0 8px 8px;
    border: 1px solid rgba(60, 100, 180, 0.25);
    border-top: none;
  }

  .diagram-membrane {
    flex-direction: column;
    width: 100%;
  }

  .diagram-layer {
    writing-mode: horizontal-tb;
    text-orientation: initial;
    padding: 0.8rem;
    min-width: auto;
  }

  .collab-grid {
    grid-template-columns: 1fr;
  }

  .footer-links {
    flex-direction: column;
    gap: 0.8rem;
  }

  /* Nav mobile */
  .nav-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .nav-links {
    gap: 1rem;
    font-size: 0.85rem;
  }

  .lang-switch {
    margin-left: 0.4rem;
    padding-left: 0.6rem;
    gap: 0.4rem;
  }
}

@media (min-width: 601px) and (max-width: 900px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* --- Print --- */

@media print {
  body {
    background: #fff;
    color: #111;
  }

  .hero {
    min-height: auto;
    padding: 2rem 0;
  }

  .membrane {
    display: none;
  }

  .site-nav,
  .theme-toggle {
    display: none;
  }

  .card {
    border: 1px solid #ccc;
    background: #f9f9f9;
  }

  h2 {
    border-bottom-color: #333;
  }
}

/* Light theme for membrane layers */
[data-theme="light"] .layer-outer {
  border-color: rgba(154, 112, 48, 0.35);
}

[data-theme="light"] .layer-mid {
  border-color: rgba(154, 112, 48, 0.55);
}

[data-theme="light"] .layer-inner {
  border-color: rgba(74, 122, 144, 0.6);
}
