/* ============================================================
   datadex.app — shared site styles
   Dark mode only.
   ============================================================ */

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; }
img, svg { display: block; max-width: 100%; }

/* Custom properties — dark mode only */
:root {
  /* Color */
  --bg: hsl(220 18% 8%);
  --bg-elev: hsl(220 18% 11%);
  --bg-code: hsl(220 22% 14%);
  --fg: hsl(220 15% 91%);
  --fg-muted: hsl(220 10% 65%);
  --fg-subtle: hsl(220 10% 50%);
  --border: hsl(220 15% 20%);
  --border-strong: hsl(220 15% 28%);
  --accent: hsl(220 90% 73%);
  --accent-faded: hsla(220, 90%, 73%, 0.55);
  --accent-fg: hsl(220 30% 10%);
  --selection-bg: hsla(220, 90%, 73%, 0.22);

  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Layout */
  --content-max: 740px;
  --gutter: clamp(20px, 4vw, 40px);
  --radius: 8px;
}

/* Base */
body {
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  background-color: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background-color: var(--selection-bg); }

/* Header (sub-pages) */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px var(--gutter);
  border-bottom: 1px solid var(--border);
}

.site-mark {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--fg);
  flex-shrink: 0;
}
.site-mark img {
  height: 32px;
  width: auto;
  transition: opacity .15s ease;
}
.site-mark:hover img { opacity: 0.85; }

.site-nav {
  display: flex;
  gap: 22px;
  font-size: 0.94rem;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--fg-muted);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.site-nav a:hover { color: var(--fg); }
.site-nav a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* Narrow viewports — stack the nav below the logo so long labels fit on one row */
@media (max-width: 560px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .site-nav {
    width: 100%;
    gap: 14px;
    font-size: 0.82rem;
    flex-wrap: nowrap;
    justify-content: space-between;
  }
  .site-nav a { white-space: nowrap; }
}

/* Home page — centered logo, no header bar */
.home .site-logo {
  display: block;
  width: max-content;
  margin: clamp(40px, 8vw, 80px) auto 28px;
}
.home .site-logo img {
  height: clamp(96px, 14vw, 140px);
  width: auto;
}

/* Layout */
main {
  padding: clamp(28px, 5vw, 56px) var(--gutter) 96px;
}

article {
  max-width: var(--content-max);
  margin-inline: auto;
}

/* Typography */
h1, h2, h3, h4 {
  font-weight: 650;
  letter-spacing: -0.018em;
  line-height: 1.25;
  margin: 0 0 0.6em;
  color: var(--fg);
}

h1 {
  font-size: clamp(1.65rem, 2.4vw + 1rem, 2.05rem);
  margin-bottom: 1em;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

h2 {
  font-size: 1.35rem;
  margin-top: 2.2em;
  text-wrap: balance;
}

h3 {
  font-size: 1.08rem;
  margin-top: 2em;
  font-feature-settings: "tnum" 1;
  text-wrap: balance;
}

h4 {
  font-size: 1rem;
  margin-top: 1.6em;
  text-wrap: balance;
}

h1 + p, h2 + p, h3 + p, h4 + p { margin-top: 0; }

p, ul, ol {
  margin: 0 0 1.1em;
}

ul, ol { padding-left: 1.3em; }
ul ul, ol ol, ul ol, ol ul { margin: 0.4em 0 0.6em; }
li { margin-bottom: 0.5em; }
li:last-child { margin-bottom: 0; }
li p { margin: 0.4em 0; }

strong { font-weight: 650; color: var(--fg); }
em { font-style: italic; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--accent-faded);
  transition: text-decoration-color .15s ease, color .15s ease;
}
a:hover { text-decoration-color: var(--accent); }

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background-color: var(--bg-code);
  color: var(--fg);
  padding: 0.12em 0.42em;
  border-radius: 4px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

article a { overflow-wrap: anywhere; }

hr {
  border: 0;
  height: 1px;
  background-color: var(--border);
  margin: 2.4em 0;
}

/* Meta lines (timeline header block) */
.meta { color: var(--fg-muted); margin-bottom: 0.4em; }
.meta + .meta { margin-bottom: 1.1em; }
.meta strong { color: var(--fg); }
.meta code {
  background-color: var(--bg-code);
  color: var(--fg);
}

/* Tables */
.table-wrap {
  margin: 0 0 1.4em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  background-color: var(--bg-elev);
}

.creative-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}
.creative-table th,
.creative-table td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.creative-table tbody tr:last-child td { border-bottom: 0; }
.creative-table thead th {
  font-weight: 650;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  background-color: var(--bg-code);
}
.creative-table th:first-child,
.creative-table td:first-child {
  width: 1%;
  white-space: nowrap;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.creative-table td:nth-child(2) { white-space: nowrap; }
.creative-table td code {
  background-color: transparent;
  padding: 0;
  font-size: 0.82em;
  color: var(--fg-muted);
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* Narrow screens — let app-name column wrap */
@media (max-width: 640px) {
  .creative-table { font-size: 0.88rem; }
  .creative-table td:nth-child(2) { white-space: normal; }
  .creative-table th, .creative-table td { padding: 10px 12px; }
  .creative-table td code { font-size: 0.78em; }
}

/* Screenshot gallery (home page "Future of dataDex" section) */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin: 28px 0 8px;
}
.gallery-item {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.gallery-thumb {
  display: block;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 20px;
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform .25s ease, box-shadow .25s ease;
  width: 100%;
}
.gallery-thumb:hover,
.gallery-thumb:focus-visible {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  outline: none;
}
.gallery-thumb:focus-visible { box-shadow: 0 0 0 2px var(--accent), 0 12px 30px rgba(0, 0, 0, 0.55); }
.gallery-thumb img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
}
.gallery-item figcaption {
  font-size: 0.82rem;
  color: var(--fg-muted);
  text-align: center;
  line-height: 1.35;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 40px);
  z-index: 1000;
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 24px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}
.lightbox-close:hover,
.lightbox-close:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  outline: none;
}

/* Footer (home page) */
.site-footer {
  border-top: 1px solid var(--border);
  margin: 0 auto;
  max-width: var(--content-max);
  padding: 32px var(--gutter) 56px;
  color: var(--fg-muted);
  font-size: 0.86rem;
  text-align: center;
}
.footer-links {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.footer-links a {
  color: var(--fg-muted);
  text-decoration-color: transparent;
}
.footer-links a:hover {
  color: var(--fg);
  text-decoration-color: var(--accent);
}
.disclaimer {
  margin: 0;
  line-height: 1.55;
  color: var(--fg-subtle);
}

/* Focus states for accessibility */
a:focus-visible,
.site-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Print */
@media print {
  :root {
    --bg: #fff;
    --bg-elev: #fff;
    --bg-code: #f3f4f6;
    --fg: #111;
    --fg-muted: #555;
    --border: #ccc;
    --accent: #111;
    --accent-faded: #555;
  }
  .site-header { border-bottom: 1px solid #ccc; }
  .site-nav { display: none; }
  .site-footer { border-top: 1px solid #ccc; }
  body { background: #fff; color: #111; }
  a { color: #111; }
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.78em;
    color: #555;
    word-break: break-all;
  }
  main { padding: 24px; }
  hr { background: #ccc; }
  .table-wrap { border-color: #ccc; }
  .creative-table thead th { background-color: #f3f4f6; }
}
