/* ─── Tokens (aligned with the Tabula app's dark palette) ───────────────────
   Greys come from crates/ui-core/src/theme.rs (Palette::DARK); the green is
   sampled from the app icon. */
:root {
  --bg:          #1a1d24;  /* window_bg */
  --bg-elevated: #21252d;  /* panel_alt_bg */
  --surface:     #2b2f38;  /* panel_bg */
  --border:      #3d4350;  /* divider */
  --text:        #e6eaf2;
  --muted:       #8a93a5;
  --gridline:    #3a3f4a;

  --accent:      #2ec27e;
  --accent-deep: #17965d;  /* the icon green */
  --accent-text: #04231a;
  --accent-dim:  rgba(46, 194, 126, 0.14);
  --accent-glow: rgba(23, 150, 93, 0.30);

  --radius: 12px;
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: min(1080px, 100% - 48px);
  margin-inline: auto;
}

/* ─── Header ────────────────────────────────────────────────────────────── */
.site-header {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(26, 29, 36, 0.85);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.brand:hover { text-decoration: none; opacity: 0.9; }

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.backlink {
  font-size: 0.875rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  transition: border-color 0.2s, color 0.2s;
}

.backlink:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  text-decoration: none;
}

/* ─── Hero ──────────────────────────────────────────────────────────────── */
.hero {
  padding: 80px 0 64px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 70%;
  height: 120%;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: center;
  position: relative;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.lead {
  font-size: 1.125rem;
  color: var(--muted);
  max-width: 38ch;
  margin-bottom: 32px;
}

.hero-note {
  margin-top: 16px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.version-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

/* ─── Hero visual: a small live-looking sheet ───────────────────────────── */
.hero-visual {
  position: relative;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.sheet {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.2;
}

.sheet-formula {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.sheet-formula .fx {
  color: var(--muted);
  font-style: italic;
  flex: none;
}

.sheet-formula .formula {
  color: var(--accent);
  white-space: nowrap;
}

.sheet-grid {
  display: grid;
  grid-template-columns: 2.2rem repeat(3, 1fr);
  gap: 1px;
  background: var(--gridline);
  border: 1px solid var(--gridline);
  border-radius: 4px;
  overflow: hidden;
}

.sh,
.sc {
  padding: 7px 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sh {
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font-size: 0.75rem;
}

.sh--corner { background: var(--surface); }
.sh--on { color: var(--text); background: #343945; }

.sc {
  background: var(--bg);
  color: var(--text);
}

.sc.num { text-align: right; }

.sc--sel {
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 2px var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ─── Downloads ─────────────────────────────────────────────────────────── */
.downloads {
  padding: 0 0 80px;
}

.downloads h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.downloads .section-lead {
  color: var(--muted);
  margin-bottom: 28px;
}

.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.download-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color 0.2s, transform 0.2s;
}

.download-card:hover {
  border-color: rgba(46, 194, 126, 0.45);
  transform: translateY(-2px);
}

.download-card .platform {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.download-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.download-card p {
  font-size: 0.875rem;
  color: var(--muted);
  flex: 1;
}

.download-link-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0.7;
  word-break: break-all;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  font-size: 0.9375rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, opacity 0.2s;
}

.btn-download:hover {
  background: var(--accent-deep);
  color: #fff;
  text-decoration: none;
}

.btn-download.disabled {
  background: var(--surface);
  color: var(--muted);
  pointer-events: none;
  cursor: not-allowed;
}

/* ─── Install notes ─────────────────────────────────────────────────────── */
.install-notes {
  margin-top: 32px;
  padding: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.install-notes h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.install-notes ul {
  list-style: none;
  display: grid;
  gap: 10px;
}

.install-notes li {
  font-size: 0.875rem;
  color: var(--muted);
  padding-left: 16px;
  position: relative;
}

.install-notes li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-deep);
}

.install-notes strong { color: var(--text); font-weight: 600; }

.notes-foot {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ─── Features ──────────────────────────────────────────────────────────── */
.features {
  padding: 64px 0 80px;
  border-top: 1px solid var(--border);
}

.features h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  text-align: center;
  margin-bottom: 40px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.feature {
  padding: 24px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.feature h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.feature p {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ─── Footer ────────────────────────────────────────────────────────────── */
.site-footer {
  margin-top: auto;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--text);
  font-weight: 500;
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .hero { padding: 56px 0 48px; }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* --- Long-form prose: the release notes page ------------------------------
   Generated from RELEASE_NOTES.md by website/scripts/build.py, so these rules
   have to cover whatever that file uses — headings, lists, tables, code. */

.prose {
  max-width: 46rem;
}

.prose h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.75rem);
  margin: 0 0 2rem;
}

/* No rule of its own: RELEASE_NOTES.md already separates entries with `---`,
   which renders as an <hr>. Adding a border here drew both. */
.prose h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0.5rem 0 1rem;
}

.prose h2:first-of-type {
  margin-top: 0;
}

.prose h3 {
  font-size: 1.15rem;
  margin: 2rem 0 0.5rem;
  color: var(--text);
}

/* The global reset zeroes every margin, so prose has to reinstate its own or
   every paragraph runs into the next. */
.prose p {
  margin: 0 0 1rem;
}

.prose p,
.prose li {
  color: var(--muted);
  line-height: 1.7;
}

.prose ul {
  padding-left: 1.2rem;
  margin: 0.75rem 0;
}

.prose li {
  margin: 0.35rem 0;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.35em;
  color: var(--text);
}

.prose a {
  color: var(--accent);
}

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

/* A release-notes table (the reference forms, say) can outrun a phone; let it
   scroll inside its own box rather than widening the page. */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.prose th {
  color: var(--text);
  font-weight: 600;
}
