/* Standard system fonts + high-contrast light/dark themes */

:root {
  --font-sans: "Segoe UI", Tahoma, Arial, Helvetica, sans-serif;
  --font-display: "Segoe UI", Tahoma, Arial, Helvetica, sans-serif;
  --font-mono: Consolas, "Courier New", monospace;

  --fs-body: 1.0625rem;
  --fs-small: 0.95rem;
  --fs-h1: clamp(2.25rem, 4vw, 3.35rem);
  --fs-h2: clamp(1.65rem, 3vw, 2.15rem);
  --fs-h3: 1.25rem;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  --ease: ease;
  --max: 1240px;

  /* Light - high contrast */
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --ink: #020617;
  --muted: #111827;
  --line: #64748b;
  --accent: #0b4bc2;
  --accent-2: #8a3a00;
  --ok: #047857;
  --chip: #e2e8f0;
  --hero-a: #dbeafe;
  --hero-b: #ffedd5;
  --code-bg: #e2e8f0;
  --nav: #020617;
  --caption-bg: #f1f5f9;
  --img-bg: #e5e7eb;
}

html[data-theme="dark"] {
  /* Dark - strong contrast, no washed text */
  --bg: #050816;
  --bg-elev: #111827;
  --ink: #ffffff;
  --muted: #eef4ff;
  --line: #7c8da8;
  --accent: #b7dcff;
  --accent-2: #ffd39b;
  --ok: #6ee7b7;
  --chip: #243149;
  --hero-a: #0b1328;
  --hero-b: #111c33;
  --code-bg: #0b1020;
  --nav: #f1f5f9;
  --caption-bg: #0b1220;
  --img-bg: #eef2f7;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.62);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  transition: background 0.25s ease, color 0.25s ease;
}

img { max-width: 100%; height: auto; display: block; }
a {
  color: var(--accent);
  text-underline-offset: 3px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
a:hover { color: var(--accent-2); }

.wrap { width: min(100% - 2rem, var(--max)); margin-inline: auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-elev);
  border-bottom: 3px solid var(--line);
}
.topbar .wrap {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
  white-space: nowrap;
}
.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  border: 3px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--ink);
  cursor: pointer;
}
.menu-toggle span {
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}
.nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.28rem;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.nav::-webkit-scrollbar { height: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.nav a {
  color: var(--nav);
  text-decoration: none;
  font-size: clamp(1rem, 1vw, 1.08rem);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  border-radius: 10px;
  padding: 0.54rem 0.46rem;
}
.nav a:hover {
  color: var(--ink);
  background: var(--chip);
}

html[data-theme="dark"] .nav a {
  color: #d7e7ff;
}

html[data-theme="dark"] .nav a:hover {
  color: #ffffff;
  background: #202a40;
}

.theme-btn,
.chip-btn {
  border: 2px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.52rem 0.78rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.theme-icon-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
}
.theme-icon {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
html[data-theme="dark"] .theme-icon-moon,
html[data-theme="light"] .theme-icon-sun { display: none; }
.theme-btn:hover,
.chip-btn:hover { border-color: var(--accent); }
.chip-btn.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
html[data-theme="dark"] .chip-btn.active {
  background: #2563eb;
  color: #ffffff;
}

.hero {
  padding: 3.4rem 0 2.4rem;
  background:
    linear-gradient(135deg, var(--hero-a), var(--hero-b));
  border-bottom: 2px solid var(--line);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr;
  gap: 1.6rem;
  align-items: center;
}
.kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.chip {
  background: var(--chip);
  border: 2px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font-size: var(--fs-small);
  font-weight: 800;
}

h1, .h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  line-height: 1.12;
  margin: 0 0 0.8rem;
  color: var(--ink);
  font-weight: 800;
}
h2, .h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  margin: 0 0 0.5rem;
  color: var(--ink);
}
h3, .h3 {
  font-size: var(--fs-h3);
  margin: 0 0 0.45rem;
  font-weight: 700;
  color: var(--ink);
}

.lede,
.section-lead {
  color: var(--muted);
  margin: 0 0 1.15rem;
  max-width: 70ch;
  font-size: 1.05rem;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0.8rem 1.15rem;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  border: 2px solid transparent;
}
.btn-primary {
  background: #1d4ed8;
  color: #ffffff;
}
.btn-primary:hover { background: #1e40af; color: #ffffff; }
html[data-theme="dark"] .btn-primary {
  background: #3b82f6;
  color: #ffffff;
}
.btn-secondary {
  background: var(--bg-elev);
  border-color: var(--line);
  color: var(--ink);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.panel,
.card,
.shot {
  background: var(--bg-elev);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 1.2rem; }
.card { padding: 1.1rem; }
.card,
.panel,
.shot,
td,
th,
pre {
  min-width: 0;
  overflow-wrap: anywhere;
}
.card p { margin: 0; color: var(--muted); font-size: 1.05rem; }

html[data-theme="dark"] .panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .shot,
html[data-theme="dark"] .theme-btn,
html[data-theme="dark"] .chip-btn,
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .filters input[type="search"] {
  background: #111827;
}

html[data-theme="dark"] a {
  color: #9bd0ff;
}

html[data-theme="dark"] a:hover {
  color: #ffd19a;
}

html[data-theme="dark"] .theme-btn {
  color: #ffffff;
  border-color: #9ca9bd;
}
html[data-theme="dark"] .menu-toggle {
  background: #111827;
  color: #ffffff;
  border-color: #9ca9bd;
}

.stat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.8rem; }
.stat-list li {
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}
.stat-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.stat-list strong {
  display: block;
  font-size: 1.25rem;
  color: var(--ink);
}
.stat-list span {
  color: var(--muted);
  font-size: 1rem;
}

section { padding: 1.5rem 0 2.3rem; }
.grid-2, .grid-3, .kpi { display: grid; gap: 1rem; min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi .card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-family: var(--font-display);
  color: var(--ink);
}

.filters { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-bottom: 1rem; align-items: center; }
.filters input[type="search"] {
  min-width: min(100%, 240px);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

.shot { overflow: hidden; }
.shot { margin: 0; }
.shot figcaption {
  padding: 0.95rem 1rem 0.7rem;
  border-bottom: 3px solid var(--line);
  background: var(--caption-bg);
  color: var(--muted);
  font-size: 1.02rem;
}
.shot figcaption strong {
  display: block;
  color: var(--ink);
  margin-bottom: 0.25rem;
  font-size: 1.12rem;
}
.shot img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
  background: var(--img-bg);
}

.accordion details {
  background: var(--bg-elev);
  border: 3px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.7rem;
}
.accordion summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  list-style: none;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion details[open] summary {
  color: var(--accent);
  margin-bottom: 0.55rem;
}
.accordion p,
.accordion li {
  color: var(--muted);
  font-size: 1.05rem;
}

.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.9rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  border: 3px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
th, td {
  padding: 0.8rem 0.9rem;
  border-bottom: 2px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 1.05rem;
  color: var(--ink);
}
th {
  background: var(--chip);
  font-weight: 700;
}
tr:last-child td { border-bottom: 0; }

.note {
  border-left: 4px solid var(--accent-2);
  background: var(--chip);
  padding: 0.95rem 1rem;
  border-radius: 0 12px 12px 0;
  color: var(--ink);
  font-size: 1.05rem;
}

pre, code {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--ink);
}
pre {
  background: var(--code-bg);
  border: 3px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Reveal class kept for layout hooks — content always fully visible */
.reveal {
  opacity: 1;
  transform: none;
}

.footer {
  border-top: 2px solid var(--line);
  padding: 1.5rem 0 2.5rem;
  color: var(--muted);
  font-size: 1rem;
}

.nb-theme-toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-start;
  padding: 0.75rem 1rem;
  background: var(--bg-elev);
  border-bottom: 2px solid var(--line);
  color: var(--ink);
}
.nb-theme-toolbar > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.nb-theme-toolbar a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.55rem 0.9rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev) !important;
  color: var(--ink) !important;
  font-weight: 700;
  text-decoration: none;
  font-size: 1rem;
}
.nb-theme-toolbar a:hover {
  border-color: var(--accent);
  color: var(--accent) !important;
}

html[data-theme="dark"] .nb-theme-toolbar a {
  background: #151c2e !important;
  color: #ffffff !important;
  border-color: #71809a !important;
}

@media (max-width: 1100px) {
  .topbar .wrap {
    flex-direction: row;
    padding: 0.7rem 0;
  }
  .nav {
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
}

@media (max-width: 960px) {
  .hero-grid, .grid-3, .kpi { grid-template-columns: 1fr 1fr; }
  .hero-grid { align-items: start; }
}
@media (max-width: 720px) {
  .hero-grid, .grid-2, .grid-3, .kpi { grid-template-columns: 1fr; }
  .wrap { width: min(100% - 1.2rem, var(--max)); }
  .topbar .wrap {
    width: min(100% - 0.8rem, var(--max));
    min-height: 64px;
    gap: 0.6rem;
    flex-wrap: wrap;
  }
  .menu-toggle { display: inline-flex; margin-left: auto; }
  .brand {
    max-width: calc(100% - 56px);
    white-space: normal;
    line-height: 1.2;
    overflow: visible;
    text-overflow: clip;
  }
  .nav {
    display: none;
    flex: 1 0 100%;
    width: 100%;
    max-height: none;
    overflow: visible;
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.45rem 0 0.2rem;
  }
  .topbar.menu-open .nav { display: flex; }
  .nav a {
    flex: 1 1 calc(50% - 0.5rem);
    text-align: center;
    background: var(--chip);
    border: 2px solid var(--line);
    font-size: 0.96rem;
    padding: 0.72rem 0.55rem;
  }
  .theme-icon-btn {
    width: 44px;
    height: 44px;
    margin-left: auto;
  }
  #gallery .wrap,
  main.wrap {
    width: min(100% - 0.5rem, var(--max));
  }
  .shot figcaption {
    padding: 0.8rem 0.75rem 0.6rem;
  }
  .shot img {
    width: 100%;
    max-height: 680px;
  }
}

/* Uniform screenshot frames: every .shot image gets the same 16:10 frame
   (full card width). object-fit: scale-down = shrink large images to fit
   with nothing cropped, never upscale small ones (no blur). */
.shot img,
html[data-theme="dark"] .shot img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: none;
  aspect-ratio: 16 / 10;
  object-fit: scale-down;
  object-position: center;
  background: var(--img-bg);
}
