/* ============================================================
   AMOS Protocol – styles.css
   Visual tone: "The Wire" – precise, technical, authoritative
   Companion to projectamos.org ("The Letter")
   ============================================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@600;700&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* --- Custom Properties --- */
:root {
  --bg:             #110F0C;
  --bg-raised:      #1A1714;
  --bg-code:        #0D0B09;
  --text:           #C9C1B6;
  --text-secondary: #8F8880;
  --text-bright:    #EDE8E0;
  --burgundy:       #D04545;
  --burgundy-dim:   #8B2525;
  --gold:           #C9A044;
  --gold-dim:       #958544;
  --border:         #2A2621;
  --border-accent:  #5C1A1A;

  --font-display:   'Cormorant Garamond', 'Georgia', serif;
  --font-body:      'DM Sans', 'Helvetica Neue', sans-serif;
  --font-mono:      'IBM Plex Mono', monospace;

  --measure:        72ch;
  --space-xs:       0.5rem;
  --space-sm:       1rem;
  --space-md:       2rem;
  --space-lg:       4rem;
  --space-xl:       6rem;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 17px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(201, 192, 180, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
}

::selection {
  background: rgba(208, 69, 69, 0.3);
  color: var(--text-bright);
}

/* --- Typography --- */
h2 {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-md);
  line-height: 1.3;
}

h3 {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

p {
  margin-bottom: 1em;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--burgundy);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--gold);
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-code);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* --- Skip link --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-sm);
  background: var(--burgundy);
  color: #fff;
  padding: var(--space-xs) var(--space-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  text-decoration: none;
  z-index: 1000;
  border-radius: 0 0 4px 4px;
}

.skip-link:focus {
  top: 0;
  color: #fff;
}

/* --- Screen-reader only --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Layout --- */
.page-wrap {
  max-width: calc(var(--measure) + 4rem);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.section {
  padding: var(--space-xl) 0;
}

.section-rule {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 0;
  max-width: 100%;
}

/* --- Navigation --- */
.site-nav {
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: var(--space-sm) 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-nav a:hover {
  color: var(--text-bright);
}

.nav-home {
  color: var(--text) !important;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.nav-links {
  display: flex;
  gap: var(--space-sm);
  list-style: none;
  flex-wrap: wrap;
}

.nav-sep {
  color: var(--border);
}

/* --- Hero --- */
.hero {
  padding: var(--space-xl) 0 var(--space-lg);
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-bright);
  margin-bottom: 0.3rem;
  line-height: 1.1;
}

.hero-subtitle {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  line-height: 1.6;
}

.hero-badges {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.25em 0.65em;
  border-radius: 3px;
}

.badge-version {
  color: var(--burgundy);
  border: 1px solid var(--border-accent);
  background: rgba(208, 69, 69, 0.07);
}

.badge-status {
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  background: rgba(201, 160, 68, 0.07);
}

.hero-desc {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
  max-width: 56ch;
  margin-bottom: var(--space-md);
}

.hero-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.55em 1.3em;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--burgundy);
  color: #fff;
}

.btn-primary:hover {
  background: #B83A3A;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--text-secondary);
  color: var(--text-bright);
}

/* --- Parameters Grid --- */
.params-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.param {
  background: var(--bg-raised);
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
}

.param-label {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.35rem;
}

.param-value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.2;
  color: #E04E4E;
  margin-bottom: 0.25rem;
}

.param-note {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.param-wide {
  grid-column: span 2;
}

.param-wide .param-value {
  font-size: 1.1rem;
  font-weight: 500;
}

.param-full {
  grid-column: 1 / -1;
}

.param-full .param-value {
  font-size: 1rem;
  font-weight: 500;
}

/* --- Primitives Table --- */
.primitives-list {
  list-style: none;
}

.primitives-list li {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  padding: 0.55em 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.primitives-list li:last-child {
  border-bottom: none;
}

.prim-label {
  font-weight: 600;
  color: var(--text-bright);
  min-width: 11ch;
  flex-shrink: 0;
}

.prim-value {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--text);
}

.prim-ref {
  color: var(--text-secondary);
  font-size: 0.78rem;
}

/* --- Architecture Flow --- */
.flow {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: var(--space-md);
}

.flow-node {
  flex: 1;
  padding: var(--space-sm);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.flow-node h3 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--burgundy);
  margin-bottom: 0.5rem;
}

.flow-node p {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.flow-arrow {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  color: var(--gold-dim);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.transport-modes {
  margin-top: var(--space-sm);
}

.transport-modes h3 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: var(--space-sm);
}

.mode-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mode-list li {
  font-size: 0.86rem;
  line-height: 1.5;
  padding-left: var(--space-sm);
  border-left: 2px solid var(--border);
  color: var(--text-secondary);
}

.mode-list li strong {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-bright);
  font-weight: 500;
}

/* --- Threat Model --- */
.threat-classes {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.threat-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.65rem var(--space-sm);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
}

.threat-row:last-child {
  border-bottom: none;
}

.class-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.2em 0.5em;
  border-radius: 2px;
  min-width: 5.5ch;
  text-align: center;
  flex-shrink: 0;
}

.threat-row.protected .class-badge {
  color: var(--gold);
  background: rgba(201, 160, 68, 0.1);
  border: 1px solid rgba(201, 160, 68, 0.2);
}

.threat-row.outside .class-badge {
  color: var(--text-secondary);
  background: rgba(133, 126, 117, 0.08);
  border: 1px solid var(--border);
}

.class-desc {
  flex: 1;
  color: var(--text);
}

.class-status {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  text-transform: uppercase;
}

.threat-row.protected .class-status {
  color: var(--gold);
}

.threat-row.outside .class-status {
  color: var(--text-secondary);
}

.threat-note {
  margin-top: var(--space-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Documents --- */
.doc-list {
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.doc-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 0.75rem var(--space-sm);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s ease;
}

.doc-link:last-child {
  border-bottom: none;
}

.doc-link:hover {
  background: #1F1C18;
}

.doc-info {
  display: flex;
  flex-direction: column;
}

.doc-title {
  font-weight: 600;
  color: var(--text-bright);
  font-size: 0.9rem;
}

.doc-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

.doc-arrow {
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: color 0.15s ease, transform 0.15s ease;
}

.doc-link:hover .doc-arrow {
  color: var(--burgundy);
  transform: translateX(2px);
}

/* --- Footer --- */
.site-footer {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  padding: var(--space-lg) 0 var(--space-md);
  border-top: 1px solid var(--border);
  margin-top: var(--space-xl);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  list-style: none;
  margin-bottom: var(--space-sm);
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.03em;
}

.footer-links a:hover {
  color: var(--burgundy);
}

.footer-note {
  margin-top: var(--space-sm);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* --- Spec Page (rendered markdown) --- */
.spec-container {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space-lg) 0 var(--space-xl);
  line-height: 1.75;
}

.spec-loading {
  text-align: center;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: var(--space-xl) 0;
}

.spec-error {
  text-align: center;
  color: var(--text-secondary);
  padding: var(--space-xl) 0;
}

.spec-source-note {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.spec-source-note a {
  color: var(--text-secondary);
}

.spec-source-note a:hover {
  color: var(--gold);
}

.spec-container h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-bright);
  margin: var(--space-xl) 0 var(--space-sm);
  line-height: 1.2;
}

.spec-container h1:first-child {
  margin-top: 0;
}

.spec-container h2 {
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--burgundy);
  margin: var(--space-lg) 0 var(--space-sm);
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.spec-container h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-bright);
  margin: var(--space-md) 0 var(--space-xs);
}

.spec-container h4 {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--gold);
  margin: var(--space-md) 0 var(--space-xs);
  line-height: 1.3;
}

.spec-container p {
  margin-bottom: 1em;
}

.spec-container ul,
.spec-container ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.spec-container li {
  margin-bottom: 0.4em;
  line-height: 1.7;
}

.spec-container li ul,
.spec-container li ol {
  margin-top: 0.3em;
  margin-bottom: 0.3em;
}

.spec-container table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-md) 0;
  font-size: 0.84rem;
  display: block;
  overflow-x: auto;
}

.spec-container thead th {
  background: var(--bg-raised);
  color: var(--text-bright);
  font-weight: 600;
  text-align: left;
  padding: 0.55em 0.75em;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.spec-container tbody td {
  padding: 0.5em 0.75em;
  border: 1px solid var(--border);
  vertical-align: top;
}

.spec-container tbody tr:nth-child(even) {
  background: rgba(26, 23, 20, 0.5);
}

.spec-container pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: var(--space-sm);
  overflow-x: auto;
  margin: var(--space-sm) 0 var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
}

.spec-container pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.spec-container blockquote {
  border-left: 2px solid var(--burgundy-dim);
  padding-left: var(--space-sm);
  margin: var(--space-sm) 0 var(--space-md);
  color: var(--text-secondary);
  font-style: italic;
}

.spec-container blockquote p:last-child {
  margin-bottom: 0;
}

.spec-container hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: var(--space-lg) 0;
}

.spec-container strong {
  color: var(--text-bright);
  font-weight: 600;
}

/* Back-to-top button */
.back-to-top {
  position: fixed;
  bottom: var(--space-md);
  right: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.45em 0.8em;
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, color 0.15s ease, border-color 0.15s ease;
  z-index: 100;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  color: var(--text-bright);
  border-color: var(--text-secondary);
}

/* Active nav indicator */
.nav-active {
  color: var(--text-bright) !important;
}

/* --- Scroll Reveals --- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  .hero {
    padding: var(--space-lg) 0 var(--space-md);
  }

  .params-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .param-wide {
    grid-column: span 2;
  }

  .param-full {
    grid-column: 1 / -1;
  }

  .flow {
    flex-direction: column;
    gap: 0;
  }

  .flow-arrow {
    transform: rotate(90deg);
    padding: 0.4rem 0;
    justify-content: center;
  }

  .threat-row {
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  .class-status {
    width: 100%;
    text-align: right;
  }

  .site-nav {
    flex-direction: column;
    gap: var(--space-xs);
    text-align: center;
  }

  :root {
    --space-xl: 4rem;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

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

  .param-wide,
  .param-full {
    grid-column: 1;
  }

  .hero-actions {
    flex-direction: column;
  }

  .btn {
    justify-content: center;
  }

  .nav-links {
    flex-direction: column;
    gap: var(--space-xs);
    align-items: center;
  }

  .primitives-list li {
    flex-direction: column;
    gap: 0.15rem;
  }

  .prim-label {
    min-width: unset;
  }
}

/* --- Print --- */
@media print {
  .reveal {
    opacity: 1;
    transform: none;
  }
  .site-nav, .site-footer {
    display: none;
  }
  body {
    background: white;
    color: #1A1A1A;
    background-image: none;
  }
  .param-value, .flow-node h3 {
    color: #8B2525;
  }
  h2 {
    color: #8B7D3C;
  }
  .param, .flow-node, .threat-row, .doc-link {
    background: #F5F0E8;
  }
  a {
    color: #8B2525;
  }
}
