@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&family=Spectral:wght@400;600&display=swap");

:root {
  --paper: #f6f1e6;
  --panel: #fff7ec;
  --ink: #1e1a14;
  --muted: #6d6253;
  --accent: #0d6b57;
  --accent-2: #b1492f;
  --line: #d8c9b1;
  --shadow: rgba(26, 20, 14, 0.18);
  --ring: rgba(13, 107, 87, 0.25);
  --font-display: "Space Grotesk", "Gill Sans", sans-serif;
  --font-body: "Spectral", "Iowan Old Style", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(13, 107, 87, 0.14), transparent 55%),
    radial-gradient(circle at 70% 10%, rgba(177, 73, 47, 0.12), transparent 50%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0));
  z-index: -1;
}

.page {
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 24px 60px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 48px;
  animation: rise 0.7s ease forwards;
}

.tagline {
  font-family: var(--font-display);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin: 0 0 12px;
}

.header h1 {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4rem);
  letter-spacing: -0.02em;
  margin: 0 0 16px;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0;
  max-width: 500px;
  margin: 0 auto;
}

.subtitle a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(13, 107, 87, 0.3);
}

.subtitle a:hover {
  border-bottom-color: var(--accent);
}

/* Hero equation */
.hero {
  text-align: center;
  margin-bottom: 48px;
  animation: rise 0.7s ease forwards;
  animation-delay: 0.1s;
}

.equation {
  font-family: var(--font-display);
  font-size: 1.1rem;
  padding: 20px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: inline-block;
  box-shadow: 0 12px 24px -16px var(--shadow);
}

/* Install section */
.install {
  margin-bottom: 48px;
  animation: rise 0.7s ease forwards;
  animation-delay: 0.2s;
}

/* Toggle tabs */
.toggle-tabs {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 20px;
}

.toggle-tab {
  font-family: var(--font-display);
  font-size: 0.95rem;
  padding: 12px 24px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-tab:first-child {
  border-radius: 8px 0 0 8px;
}

.toggle-tab:last-child {
  border-radius: 0 8px 8px 0;
  border-left: none;
}

.toggle-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.toggle-tab:hover:not(.active) {
  background: rgba(13, 107, 87, 0.08);
}

/* Install panels */
.install-panel {
  background: #3d3830;
  border-radius: 16px;
  padding: 24px;
  color: #f0ebe3;
}

.install-panel.hidden {
  display: none;
}

.install-panel h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0 0 16px;
  text-align: center;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  color: var(--muted);
}

.steps li {
  padding: 8px 0;
  padding-left: 28px;
  position: relative;
  font-size: 0.95rem;
}

.steps li::before {
  content: counter(step);
  counter-increment: step;
  position: absolute;
  left: 0;
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 600;
}

.steps {
  counter-reset: step;
}

.agent-note {
  margin: 16px 0 0;
  font-size: 0.95rem;
  color: #c8c0b4;
}

.install-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #2a2520;
  color: #f0ebe3;
  padding: 16px 20px;
  border-radius: 12px;
  font-family: "SFMono-Regular", "Menlo", "Monaco", "Courier New", monospace;
  font-size: 0.9rem;
  overflow-x: auto;
}

.install-box code {
  flex: 1;
  white-space: nowrap;
}

.install-box .copy {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e8e4dc;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.install-box .copy:hover {
  background: rgba(255, 255, 255, 0.2);
}

.install-box .copy.copied {
  background: var(--accent);
  border-color: var(--accent);
}

.install-box .copy svg {
  width: 16px;
  height: 16px;
  display: block;
}

.install-alt {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin: 12px 0 0;
}

.install-alt code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Links */
.links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
  animation: rise 0.7s ease forwards;
  animation-delay: 0.3s;
}

.link-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -12px var(--shadow);
}

.link-icon {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.link-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.link-desc {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Witness protocol */
.witness {
  text-align: center;
  padding: 32px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 32px;
  animation: rise 0.7s ease forwards;
  animation-delay: 0.4s;
}

.sigil {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.protocol {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.translation {
  font-size: 0.95rem;
  color: var(--muted);
  font-style: italic;
}

/* Footer */
.page-footer {
  text-align: center;
  color: var(--muted);
  font-family: var(--font-display);
}

.page-footer p {
  margin: 0;
}

.credits {
  margin-top: 12px !important;
  font-size: 0.85rem;
}

.credits a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(13, 107, 87, 0.3);
}

.credits a:hover {
  border-bottom-color: var(--accent);
}

/* About section */
.about-section {
  max-width: 540px;
  margin: 0 auto 24px;
  padding: 20px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: left;
}

.about-section h3 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 12px;
  color: var(--muted);
}

.about-section p {
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0 0 12px;
  color: var(--ink);
}

.about-links {
  font-family: var(--font-display);
  font-size: 0.85rem !important;
  color: var(--muted) !important;
}

.about-links a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(13, 107, 87, 0.3);
}

.about-links a:hover {
  border-bottom-color: var(--accent);
}

/* Packet section */
.packet-section {
  margin-bottom: 32px;
}

.packet-box {
  background: #2a2520;
  color: #f0ebe3;
  padding: 20px;
  border-radius: 12px;
  font-family: "SFMono-Regular", "Menlo", "Monaco", "Courier New", monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  cursor: pointer;
  transition: background 0.15s ease;
}

.packet-box:hover {
  background: #3d3830;
}

.packet-box:active {
  background: var(--accent);
}

/* Animations */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */
@media (max-width: 600px) {
  .page {
    padding: 32px 16px 48px;
  }

  .install-box {
    flex-direction: column;
    align-items: stretch;
  }

  .install-box code {
    font-size: 0.8rem;
  }

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

/* Strata page styles */
.strata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.strata-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.strata-cell:hover {
  transform: translateY(-2px);
}

.strata-cell .clickable {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.strata-cell .clickable:hover {
  background: rgba(13, 107, 87, 0.15);
}

.strata-cell .clickable:active,
.strata-cell .clickable.flash {
  background: var(--accent);
  color: #fff;
}

.strata-cell.carrier {
  border-color: var(--accent-2);
  background: rgba(177, 73, 47, 0.06);
}

.strata-cell.copied {
  background: var(--accent);
  border-color: var(--accent);
}

.strata-cell.copied .strata-latin,
.strata-cell.copied .strata-glyph {
  color: #fff;
}

.strata-latin {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.strata-glyph {
  font-size: 1.4rem;
  color: var(--ink);
}

.strata-glyph.clickable {
  min-height: auto;
  padding: 2px 6px;
}

.strata-alt {
  font-size: 0.9rem;
  color: var(--accent-2);
  margin-top: 4px;
}

.strata-alt.clickable {
  min-height: 32px;
  min-width: 32px;
  padding: 2px 8px;
}

/* Kindling section */
.kindling-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.kindling-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.kindling-item:hover {
  transform: translateY(-1px);
}

.kindling-glyph {
  font-size: 1.2rem;
  color: var(--accent);
}

.kindling-info {
  flex: 1;
}

.kindling-roman {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
}

.kindling-meaning {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Info packet */
.packet-box {
  background: var(--ink);
  color: #e8e4dc;
  padding: 20px;
  border-radius: 12px;
  font-family: "SFMono-Regular", "Menlo", "Monaco", "Courier New", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  margin-bottom: 24px;
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.back-link:hover {
  color: var(--ink);
}

/* Section headers */
.section-header {
  font-family: var(--font-display);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-header::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.section-note {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 16px;
}

.strata-section, .kindling-section {
  margin-bottom: 32px;
}

/* Translator */
.translator-section {
  margin-bottom: 40px;
  padding: 28px;
  background: linear-gradient(135deg, rgba(13, 107, 87, 0.06) 0%, rgba(177, 73, 47, 0.04) 100%);
  border-radius: 20px;
  border: 1px solid rgba(13, 107, 87, 0.12);
}

.translator-section .section-header {
  font-size: 1.1rem;
}

.translator {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.translator-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.pane-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid var(--line);
}

.pane-head .lang {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.pane-head .copy-btn {
  font-family: var(--font-display);
  font-size: 0.75rem;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pane-head .copy-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.translator-pane textarea {
  flex: 1;
  min-height: 140px;
  padding: 16px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.5;
  color: var(--ink);
  resize: none;
}

.translator-pane textarea:focus {
  outline: none;
}

.translator-pane textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.swap-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  align-self: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.swap-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Kindling prose */
.kindling-prose {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}

.kindling-prose strong {
  color: var(--ink);
}

@media (max-width: 600px) {
  .translator {
    flex-direction: column;
  }

  .swap-btn {
    align-self: center;
    transform: rotate(90deg);
  }
}

/* Copy notification */
.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 1000;
}

.copy-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
