/* ── Container ───────────────────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 1.5rem;
}

.container--narrow { max-width: 680px; }
.container--wide   { max-width: 1440px; }

/* ── Site header ─────────────────────────────────────────────────────────── */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  height: 64px;
}

.site-logo {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.03em;
}
.site-logo:hover { color: var(--color-primary-dark); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  flex-wrap: wrap;
}

.site-nav a {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.site-nav a:hover {
  color: var(--color-text);
  background: var(--color-bg);
}
.site-nav a.active {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  min-height: calc(100vh - 64px - 72px);
  padding-block: 3rem;
}

/* ── Site footer ─────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-block: 1.25rem;
}

.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-footer p, .site-footer a {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  padding-block: 5rem 4rem;
  text-align: center;
}

.hero__title {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--color-text);
  line-height: 1.1;
  margin-bottom: 1rem;
}

.hero__title span { color: var(--color-primary); }

.hero__subtitle {
  font-size: 1.1875rem;
  color: var(--color-text-muted);
  max-width: 520px;
  margin-inline: auto;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.hero__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 2rem; }

.page-header__title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 0.375rem;
}

.page-header__subtitle {
  color: var(--color-text-muted);
}

/* ── Section ─────────────────────────────────────────────────────────────── */
.section { margin-bottom: 4rem; }

.section__header { margin-bottom: 1.5rem; }

.section__title {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.section__subtitle { color: var(--color-text-muted); }

/* ── Browse layout ───────────────────────────────────────────────────────── */
.browse-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  align-items: start;
}

/* ── File grid ───────────────────────────────────────────────────────────── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 1.125rem;
}

/* ── Utility: stack / cluster ────────────────────────────────────────────── */
.stack    { display: flex; flex-direction: column; }
.stack-sm { gap: 0.5rem; }
.stack-md { gap: 1rem; }
.stack-lg { gap: 2rem; }

.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

/* ── Nav toggle (hamburger, mobile only) ─────────────────────────────────── */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text);
  flex-shrink: 0;
  margin-left: auto;
}
.nav-toggle:hover { background: var(--color-bg); }

/* ── Filters toggle (browse page, mobile only) ───────────────────────────── */
.filters-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  margin-bottom: 0.875rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text);
  text-align: left;
}
.filters-toggle:hover { background: var(--color-bg); }

/* ── Tablet ──────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .browse-layout {
    grid-template-columns: 200px 1fr;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Show hamburger, hide nothing else until toggled */
  .nav-toggle { display: flex; }

  /* Header: shorter, relative-positioned for dropdown */
  .site-header__inner {
    height: 56px;
    gap: 0;
    position: relative;
  }

  /* Mobile nav: hidden by default, drops below header when open */
  .site-header .site-nav {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.875rem 1rem 1rem;
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.08);
    z-index: 99;
  }

  .site-header .site-nav--open { display: flex; }

  .site-header .site-nav a,
  .site-header .site-nav button {
    padding: 0.625rem 0.75rem;
    width: 100%;
    border-radius: var(--radius-md);
    text-align: left;
    justify-content: flex-start;
    font-size: 0.9375rem;
  }

  /* Footer nav: stays horizontal on mobile */
  .site-footer .site-nav {
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  /* Browse: stack sidebar + show filter toggle */
  .browse-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .filters-toggle { display: flex; }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  /* Hero */
  .hero { padding-block: 2.5rem 2rem; }

  /* Spacing */
  .main-content { padding-block: 1.5rem; }

  /* Footer: stack links below copyright */
  .site-footer__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.625rem;
  }
}

/* ── Small mobile ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .container { padding-inline: 1rem; }

  .main-content { padding-block: 1.25rem; }

  .hero__title { letter-spacing: -0.03em; }

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