/* Matrix Mathematics — shared styles */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #0b1220;
  --ink-2: #101a2e;
  --panel: #141f36;
  --panel-2: #18253f;
  --grid-line: rgba(120, 150, 200, 0.07);
  --text: #d8e1f0;
  --text-dim: #8fa0bd;
  --amber: #e8a33d;
  --amber-soft: rgba(232, 163, 61, 0.12);
  --cyan: #5fd4d0;
  --cyan-soft: rgba(95, 212, 208, 0.10);
  --rose: #e96d8d;
  --border: rgba(143, 160, 189, 0.18);
  --radius: 10px;
  --maxw: 1080px;
}

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

html { scroll-behavior: smooth; }

body {
  background-color: var(--ink);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'IBM Plex Serif', Georgia, serif; line-height: 1.2; }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 600; margin: 3rem 0 1rem; }
h3 { font-size: 1.2rem; font-weight: 600; margin: 2rem 0 0.75rem; color: var(--amber); }

p { margin: 0 0 1.1rem; color: var(--text); }
p.lede { font-size: 1.2rem; color: var(--text-dim); max-width: 46ch; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { color: #fff; }
code { font-family: 'IBM Plex Mono', monospace; background: var(--panel); padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.9em; }

/* ----- nav ----- */
nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0.8rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand {
  font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 1rem;
  color: var(--amber); letter-spacing: 0.02em; white-space: nowrap;
}
.brand .bracket { color: var(--text-dim); font-weight: 400; }
.nav-links { display: flex; gap: 1.1rem; flex-wrap: wrap; margin-left: auto; }
.nav-links a {
  color: var(--text-dim); font-size: 0.92rem; font-weight: 500;
  padding: 0.25rem 0; border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--amber); border-bottom-color: var(--amber); }

/* ----- layout ----- */
main { max-width: var(--maxw); margin: 0 auto; padding: 3rem 1.25rem 5rem; }
.content { max-width: 760px; }

.eyebrow {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.78rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--cyan); margin-bottom: 0.9rem;
}

/* ----- hero ----- */
.hero { padding: 4rem 0 3rem; display: grid; grid-template-columns: 1.2fr 1fr; gap: 3rem; align-items: center; }
.hero h1 .accent { color: var(--amber); }
.hero-matrix { display: flex; justify-content: center; }

/* ----- cards ----- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.1rem; margin: 2rem 0; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.2rem; display: block; color: var(--text);
  transition: border-color 0.2s, transform 0.2s;
}
.card:hover { border-color: var(--amber); transform: translateY(-2px); text-decoration: none; }
.card .num { font-family: 'IBM Plex Mono', monospace; color: var(--amber); font-size: 0.8rem; margin-bottom: 0.5rem; }
.card h3 { margin: 0 0 0.4rem; color: #fff; font-size: 1.1rem; }
.card p { color: var(--text-dim); font-size: 0.92rem; margin: 0; }

/* ----- panels / math boxes ----- */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; margin: 1.5rem 0; overflow-x: auto;
}
.panel.amber { border-left: 3px solid var(--amber); }
.panel.cyan { border-left: 3px solid var(--cyan); }
.panel .label {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.75rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 0.8rem;
}
.math-display { overflow-x: auto; padding: 0.5rem 0; }
.katex { font-size: 1.08em; }
.katex-display { margin: 1rem 0; }

/* ----- two-col ----- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

/* ----- tables ----- */
table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--border); }
th { font-family: 'IBM Plex Mono', monospace; font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber); }
td { color: var(--text); }
td:first-child { color: #fff; font-weight: 500; }

/* ----- interactive widgets ----- */
.widget {
  background: var(--ink-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; margin: 2rem 0;
}
.widget h3 { margin-top: 0; }
.widget input[type="number"] {
  width: 58px; padding: 0.4rem; text-align: center;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; font-family: 'IBM Plex Mono', monospace; font-size: 0.95rem;
}
.widget input[type="number"]:focus { outline: 2px solid var(--amber); border-color: transparent; }
.matrix-input { display: inline-grid; grid-template-columns: repeat(2, auto); gap: 6px; padding: 8px 14px; position: relative; }
.matrix-input::before, .matrix-input::after, .matrix-bracketed::before, .matrix-bracketed::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 8px;
  border: 2px solid var(--text-dim);
}
.matrix-input::before, .matrix-bracketed::before { left: 0; border-right: none; border-radius: 4px 0 0 4px; }
.matrix-input::after, .matrix-bracketed::after { right: 0; border-left: none; border-radius: 0 4px 4px 0; }
.matrix-bracketed { display: inline-grid; gap: 6px 14px; padding: 10px 16px; position: relative; font-family: 'IBM Plex Mono', monospace; }
.matrix-bracketed span { text-align: center; min-width: 2ch; }
.widget-row { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; margin: 1rem 0; }
.op-sign { font-size: 1.6rem; color: var(--amber); font-family: 'IBM Plex Serif', serif; }
.btn {
  background: var(--amber); color: var(--ink); border: none; border-radius: 6px;
  padding: 0.55rem 1.2rem; font-family: 'IBM Plex Sans', sans-serif; font-weight: 600;
  font-size: 0.92rem; cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.result-steps { font-family: 'IBM Plex Mono', monospace; font-size: 0.88rem; color: var(--text-dim); margin-top: 1rem; line-height: 1.9; }
.result-steps .hl { color: var(--cyan); }

/* ----- AI page callouts ----- */
.stat-band { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 2rem 0; }
.stat {
  background: var(--amber-soft); border: 1px solid rgba(232,163,61,0.3); border-radius: var(--radius);
  padding: 1.2rem;
}
.stat .big { font-family: 'IBM Plex Serif', serif; font-size: 1.7rem; font-weight: 700; color: var(--amber); }
.stat .small { font-size: 0.85rem; color: var(--text-dim); margin-top: 0.2rem; }

/* ----- footer ----- */
footer { border-top: 1px solid var(--border); margin-top: 4rem; }
.footer-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 2rem 1.25rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  color: var(--text-dim); font-size: 0.88rem;
}

/* ----- page nav (prev/next) ----- */
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 4rem; flex-wrap: wrap; }
.pager a {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem 1.3rem; color: var(--text); font-size: 0.92rem;
}
.pager a:hover { border-color: var(--amber); text-decoration: none; }
.pager .dir { display: block; font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem; color: var(--text-dim); letter-spacing: 0.12em; text-transform: uppercase; }

/* ----- hero grid animation ----- */
#transform-canvas { border: 1px solid var(--border); border-radius: var(--radius); background: var(--ink-2); max-width: 100%; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding-top: 2rem; }
  .two-col { grid-template-columns: 1fr; }
  body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .card:hover { transition: none; transform: none; }
}
