/* ==========================================================================
   layout.css — app shell, hero, stat widgets, sections, footer
   ========================================================================== */

.app {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

.app__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0; /* long content shrinks instead of pushing the page sideways */
}

.main { flex: 1; display: flex; flex-direction: column; }

.main__inner {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-8) var(--gap) var(--space-12);
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

/* Staggered entrance: each top-level section slides up just after the last. */
.main__inner > * { animation: slide-up var(--t-slow) both; }
.main__inner > *:nth-child(2) { animation-delay: 0.05s; }
.main__inner > *:nth-child(3) { animation-delay: 0.1s; }
.main__inner > *:nth-child(4) { animation-delay: 0.15s; }

/* Drawer scrim (mobile).
   z-index sits above the header (60) so the whole page behind the drawer is
   blurred, but below the drawer itself (70) so the sidebar stays crisp. */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(9, 9, 11, 0.45);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  opacity: 0;
  transition: opacity var(--t);
}
.scrim.is-visible { opacity: 1; }

kbd {
  min-width: 20px;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   Stat widgets
   ========================================================================== */
/* `min(210px, 100%)` keeps the track from outgrowing a narrow container: a bare
   `minmax(210px, …)` would hold 210px open even at 320px wide and push the page
   sideways. Same reasoning on every auto-fill grid below. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: var(--space-4);
}

.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--t), border-color var(--t), box-shadow var(--t);
}
.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--stat-accent, var(--primary)), transparent);
  opacity: 0.5;
  transition: opacity var(--t);
}
.stat:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.stat:hover::before { opacity: 1; }

.stat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.stat__label {
  font-size: var(--text-sm);
  font-weight: 550;
  color: var(--text-muted);
}
.stat__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--stat-accent, var(--primary)) 12%, transparent);
  color: var(--stat-accent, var(--primary));
}
.stat__icon .icon { width: 17px; height: 17px; }

.stat__body { display: flex; align-items: baseline; gap: var(--space-3); }
.stat__value {
  font-size: var(--text-2xl);
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat__delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-sm);
  font-weight: 600;
}
.stat__delta--up { color: var(--success); }
.stat__delta--flat { color: var(--text-subtle); }
.stat__delta .icon { width: 13px; height: 13px; }

/* Sparkline drawn once on entry. */
.stat__spark { width: 100%; height: 26px; color: var(--stat-accent, var(--primary)); opacity: 0.65; }
.stat__spark path {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: draw 1.4s var(--ease) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ==========================================================================
   Sections
   ========================================================================== */
.section { display: flex; flex-direction: column; gap: var(--space-5); }

.section__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.section__subtitle {
  margin-top: 3px;
  font-size: var(--text-base);
  color: var(--text-muted);
}

.grid { display: grid; gap: var(--space-4); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(min(252px, 100%), 1fr)); }
.grid--tools { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }

/* ==========================================================================
   Page head (category / tool)
   ========================================================================== */
.page-head {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(560px 220px at 0% 0%, color-mix(in srgb, var(--accent, var(--primary)) 14%, transparent), transparent 70%),
    var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-sm);
}
.page-head__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 56px;
  height: 56px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--accent, var(--primary)) 14%, rgba(255, 255, 255, 0.03));
  color: var(--accent, var(--primary));
}
.page-head__icon .icon { width: 26px; height: 26px; }
.page-head__title { display: flex; align-items: center; gap: var(--space-3); }
.page-head__text {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: var(--text-base);
}
.page-head__aside { margin-left: auto; flex: none; }

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-6) var(--gap);
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: var(--text-sm);
}
.footer__brand { display: flex; align-items: center; gap: 8px; }
.footer__brand .icon { width: 15px; height: 15px; color: var(--primary); }
.footer__brand a { color: var(--text-secondary); font-weight: 550; transition: color var(--t); }
.footer__brand a:hover { color: var(--text); }
.footer__links { display: flex; gap: var(--space-5); }
.footer__links a { transition: color var(--t); }
.footer__links a:hover { color: var(--text); }

/* ==========================================================================
   404
   ========================================================================== */
.notfound {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  text-align: center;
}
.notfound__icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--gradient-soft);
  color: var(--primary);
}
.notfound__icon .icon { width: 30px; height: 30px; }
.notfound__text { max-width: 44ch; color: var(--text-muted); margin-bottom: var(--space-4); }

/* ==========================================================================
   Document / content pages (Privacy, Terms, Changelog, API)
   ========================================================================== */
/* `width: 100%` matters: .doc is a flex item with auto side margins, so without
   it the box is shrink-to-fit and a wide <pre> would stretch it past the
   viewport instead of scrolling inside its own container. */
.doc { width: 100%; max-width: 760px; margin: 0 auto; color: var(--text-secondary); line-height: 1.7; }
.doc__meta { margin: calc(var(--space-5) * -1) 0 var(--space-6); color: var(--text-subtle); font-size: var(--text-sm); }
.doc h3 {
  margin: var(--space-6) 0 var(--space-3);
  font-size: var(--text-lg);
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.01em;
}
.doc h3:first-child { margin-top: 0; }
.doc p { margin: 0 0 var(--space-4); }
.doc ul { margin: 0 0 var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: 7px; list-style: disc; }
.doc li { padding-left: 3px; }
.doc a { color: var(--primary); }
.doc a:hover { text-decoration: underline; }
.doc strong { color: var(--text); font-weight: 600; }
.doc code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 6px;
}
.doc pre {
  margin: 0 0 var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
}
.doc pre code { background: none; padding: 0; font-size: inherit; }
.doc__updated {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: var(--text-sm);
}

/* Changelog entries */
.log { display: flex; flex-direction: column; gap: var(--space-5); }
.log__item { padding-left: var(--space-4); border-left: 2px solid var(--border); }
.log__head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.log__ver { font-weight: 650; color: var(--text); }
.log__date { color: var(--text-subtle); font-size: var(--text-sm); }
