/* ==========================================================================
   Rust Crates — full-bleed app layout: a left navigation rail spanning the
   full height of the page, and a content area filling the rest of the
   screen. No centered floating card, no boxed-in content — deliberately,
   per feedback that the earlier "glass card in the middle of the page"
   look read as an awkward floating block. Dark slate-to-indigo theme,
   matching the existing rust-crates.com "under construction" page.

   No backdrop-filter/blur anywhere in this stylesheet: it was the likely
   cause of the sluggish, broken feel reported on a real phone (blurring a
   moving gradient behind a glass panel is one of the more expensive
   things a mobile GPU can be asked to do every frame). Flat, solid or
   semi-opaque backgrounds only — same visual family, far cheaper to
   render.
   ========================================================================== */

:root {
  --bg-start: #0f172a;
  --bg-mid: #1e293b;
  --bg-end: #312e81;

  --panel-bg: rgba(15, 23, 42, 0.4);
  --card-border: rgba(148, 163, 184, 0.2);

  --text-heading: #f8fafc;
  --text-body: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #a5b4fc;

  --accent: #6366f1;
  --accent-light: #a5b4fc;
  --accent-alt: #818cf8;

  --radius-md: 12px;
  --radius-sm: 8px;

  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  --sidebar-width: 300px;
}

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

html {
  scroll-behavior: smooth;
}

html, body {
  overflow-x: hidden;
  width: 100%;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text-body);
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-mid) 50%, var(--bg-end) 100%);
  background-size: 200% 200%;
  animation: gradientShift 18s ease infinite;
  line-height: 1.6;
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Respect users who've asked their OS/browser for less motion. */
@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
  html { scroll-behavior: auto; }
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

/* --------------------------------------------------------------------
   App frame: sidebar (full page height) + content, edge to edge.
   -------------------------------------------------------------------- */

.app-frame {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 100vh;
  width: 100%;
}

@media (max-width: 767.98px) {
  .app-frame {
    flex-direction: column;
    min-height: 0;
  }
}

/* --------------------------------------------------------------------
   Sidebar — the "bandeau" — logo, crate list, and a footer link,
   spanning the full height of the page on desktop/tablet.
   -------------------------------------------------------------------- */

.sidebar {
  flex: 0 0 var(--sidebar-width);
  /* Flex items default to min-width: auto, which lets long unwrapped
     text (the nowrap crate taglines below) push this wider than its
     300px flex-basis. Overriding it back to 0 is what actually makes
     the fixed width stick — this was the bug behind the sidebar
     ballooning to ~525px on the previous build. */
  min-width: 0;
  max-width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-right: 1px solid var(--card-border);
  padding: 1.75rem 1.5rem;
}

@media (max-width: 767.98px) {
  .sidebar {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    border-right: none;
    border-bottom: 1px solid var(--card-border);
    padding: 1.25rem;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #0f172a;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.1rem;
  color: var(--text-heading);
  font-weight: 700;
}

.brand-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sidebar-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0.6rem 0.75rem;
}

.crate-nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

@media (max-width: 767.98px) {
  .crate-nav-list {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }
}

.crate-nav-item {
  display: block;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

@media (max-width: 767.98px) {
  .crate-nav-item {
    flex: 0 0 auto;
    min-width: 200px;
  }
}

.crate-nav-item:hover {
  background: rgba(148, 163, 184, 0.08);
}

.crate-nav-item.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(165, 180, 252, 0.35);
}

.crate-nav-item .name {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.15rem;
}

.crate-nav-item.active .name {
  color: var(--text-accent);
}

.crate-nav-item .tagline {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crate-nav-item .mini-featured {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-alt);
  margin-top: 0.3rem;
}

.sidebar-footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--card-border);
  font-size: 0.85rem;
}

.sidebar-footer a {
  color: var(--text-body);
  transition: color 0.15s ease;
}

.sidebar-footer a:hover {
  color: var(--text-accent);
}

.sidebar-footer .copyright {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

@media (max-width: 767.98px) {
  .sidebar-footer {
    margin-top: 1.25rem;
    padding-top: 1rem;
  }
}

/* --------------------------------------------------------------------
   Content area — fills the rest of the screen, no boxed card.
   -------------------------------------------------------------------- */

main.viewer {
  flex: 1 1 auto;
  min-width: 0;
}

.crate-panel {
  display: none;
  padding: clamp(1.5rem, 4vw, 3.5rem);
  animation: panelIn 0.25s ease;
}

.crate-panel.active {
  display: block;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .crate-panel { animation: none; }
}

.crate-panel .eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  color: var(--text-accent);
}

.badge.featured {
  background: linear-gradient(90deg, var(--accent), var(--accent-alt));
  color: #f8fafc;
  border: none;
}

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

.crate-panel h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  color: var(--text-heading);
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.crate-panel .tagline {
  font-size: 1.05rem;
  color: var(--text-accent);
  margin-bottom: 1.4rem;
  max-width: 60ch;
}

.crate-panel .description {
  font-size: 0.98rem;
  color: var(--text-body);
  max-width: 68ch;
  margin-bottom: 1.75rem;
}

.crate-panel .divider {
  width: 48px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 3px;
  margin-bottom: 1.75rem;
}

/* --------------------------------------------------------------------
   Crate screenshot — clickable thumbnail that opens in the lightbox.
   -------------------------------------------------------------------- */

.crate-image-trigger {
  display: block;
  position: relative;
  max-width: 640px;
  width: 100%;
  margin: 0 0 1.75rem;
  padding: 0;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: none;
  cursor: zoom-in;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.crate-image-trigger:hover,
.crate-image-trigger:focus-visible {
  border-color: rgba(165, 180, 252, 0.5);
}

.crate-image-trigger img {
  display: block;
  width: 100%;
  height: auto;
}

.crate-image-hint {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-heading);
  background: rgba(15, 23, 42, 0.75);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.crate-image-trigger:hover .crate-image-hint,
.crate-image-trigger:focus-visible .crate-image-hint {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------------------------
   Lightbox — full-size view of a crate screenshot. Plain solid
   background (no backdrop-filter), same reasoning as the rest of this
   stylesheet: cheap to render, including on mobile.
   -------------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  /* Fully opaque, deliberately: at anything less, a few percent of the
     page behind bleeds through and — since that page can itself contain
     the very same screenshot, just scrolled to a different spot — reads
     as a faint ghost duplicate of the image sitting in the lightbox. */
  background: #080b16;
  animation: lightboxIn 0.15s ease;
}

.lightbox[hidden] {
  display: none;
}

@keyframes lightboxIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text-heading);
  cursor: pointer;
  transition: background 0.15s ease;
}

.lightbox-close:hover {
  background: rgba(148, 163, 184, 0.2);
}

.lightbox-close svg {
  width: 18px;
  height: 18px;
}

@media (prefers-reduced-motion: reduce) {
  .lightbox { animation: none; }
}

.highlights {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 2.1rem;
  max-width: 62ch;
}

.highlights li {
  position: relative;
  padding-left: 1.6rem;
  font-size: 0.92rem;
  color: var(--text-body);
}

.highlights li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--card-border);
  color: var(--text-heading);
  background: rgba(148, 163, 184, 0.08);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: rgba(148, 163, 184, 0.15);
  border-color: rgba(165, 180, 252, 0.4);
}

.btn.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-alt));
  border: none;
  color: #f8fafc;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------
   Responsive fine-tuning
   -------------------------------------------------------------------- */

@media (max-width: 520px) {
  .action-row {
    flex-direction: column;
  }

  .btn {
    justify-content: center;
  }

  .crate-panel h2 {
    font-size: 1.5rem;
  }
}
