/* ==========================================================================
   crates.aptlantis.net — Rust Material Theme
   Palette from RustPageStyleColors.png
   ========================================================================== */

/* ===== TOKENS ===== */
:root {
  --app-bg:              #0c0303;
  --app-surface:         #181008;
  --app-surface-2:       #2d1a0a;
  --app-border:          rgba(221, 100, 10, 0.15);
  --app-text:            #e8d0b8;
  --app-muted:           rgba(232, 208, 184, 0.65);
  --app-accent:          #dd640a;
  --app-accent-2:        #a93403;
  --app-accent-3:        #4d1403;
  --app-danger:          #ff6b6b;
  /* Derived */
  --app-surface-elev:    color-mix(in oklab, var(--app-surface) 92%, black 8%);
  --app-hl:              rgba(221, 100, 10, 0.08);
  --app-hl-active:       rgba(221, 100, 10, 0.16);
}

/* ===== RESET / BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

html {
  background-color: var(--app-bg);
}

body {
  background:
    radial-gradient(1200px 500px at 25% 0%,  rgba(221, 100, 10, 0.18), transparent 55%),
    radial-gradient(900px  500px at 80% 20%, rgba(169, 52,  3, 0.12), transparent 50%),
    var(--app-bg);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--app-text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
}

a {
  text-decoration: none;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

button {
  cursor: pointer;
}

/* ===== UTILITIES ===== */
.hidden     { display: none !important; }
.mono       { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.muted      { color: var(--app-muted); }
.text-muted { color: var(--app-muted); }
.text-rust  { color: var(--app-accent); }

/* ===== PILL ===== */
.pill {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--app-border);
  color: var(--app-muted);
}

/* ===== PANEL (base card) ===== */
.panel {
  background: color-mix(in oklab, var(--app-surface) 92%, black 8%);
  border: 1px solid var(--app-border);
  border-radius: 14px;
}

.panel-header {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--app-border);
  border-radius: 14px 14px 0 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  background: color-mix(in oklab, var(--app-surface-2) 75%, transparent);
}

.panel-body {
  padding: 1rem;
}

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--app-border);
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(45, 26, 10, 0.75), rgba(24, 16, 8, 0.75));
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand img {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(221, 100, 10, 0.45);
}

.brand span {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand strong {
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
}

.brand small {
  color: var(--app-accent);
  font-size: 0.68rem;
}

.top-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
}

.top-nav ul a {
  color: var(--app-muted);
  font-size: 0.78rem;
  transition: color 0.15s;
}

.top-nav ul a:hover {
  color: #fff;
}

.top-nav a[aria-current='page'] {
  color: var(--app-accent) !important;
}

/* ===== MAIN CONTAINER ===== */
.site-main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}

/* ===== PAGE HERO ===== */
.page-hero {
  padding: 2rem 0 1.25rem;
  border-bottom: 1px solid var(--app-border);
  margin-bottom: 1.5rem;
}

.page-hero h1 {
  margin: 0 0 0.4rem;
  font-size: 1.85rem;
  font-weight: 700;
  color: #fff;
}

.page-hero p {
  color: var(--app-muted);
  margin: 0;
  font-size: 0.9rem;
}

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.stat-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  text-align: center;
  transition: border-color 0.15s;
}

.stat-card:hover {
  border-color: var(--app-accent-2);
}

.stat-card .stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--app-accent);
  display: block;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--app-muted);
  margin-top: 0.35rem;
  display: block;
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-yanked {
  background: var(--app-accent-2);
  color: #fff;
}

.badge-stable {
  background: #1a3d1a;
  color: #7dff7d;
}

.badge-latest {
  background: var(--app-accent-3);
  color: var(--app-accent);
}

/* ===== TAG CHIPS ===== */
.tag, .chips span {
  display: inline-block;
  border-radius: 999px;
  color: var(--app-accent);
  background: var(--app-accent-3);
  padding: 0.16rem 0.48rem;
  font-size: 0.66rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

/* ===== CRATES GRID ===== */
.crates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.crate-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.crate-card:hover {
  border-color: var(--app-accent-2);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(221, 100, 10, 0.1);
}

.crate-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--app-accent);
}

.crate-card .crate-meta {
  font-size: 0.8rem;
  color: var(--app-muted);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.crate-card p {
  color: var(--app-muted);
  font-size: 0.8rem;
  margin: 0.25rem 0 0;
  line-height: 1.5;
}

/* ===== CRATE DETAIL HEADER ===== */
.crate-header {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.crate-header h1 {
  margin: 0 0 0.5rem;
  color: var(--app-accent);
  font-size: 1.6rem;
}

.crate-header .external-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.crate-header .external-links a {
  font-size: 0.83rem;
  color: var(--app-muted);
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  transition: border-color 0.15s, color 0.15s;
}

.crate-header .external-links a:hover {
  border-color: var(--app-accent);
  color: var(--app-accent);
}

/* ===== TABS ===== */
.tab-list {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--app-border);
  margin-bottom: 1.25rem;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 1.2rem;
  color: var(--app-muted);
  cursor: pointer;
  font-size: 0.875rem;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  color: var(--app-accent);
  border-bottom-color: var(--app-accent);
}

/* ===== EXPLORE LAYOUT ===== */
.explore-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.filter-sidebar {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 1.25rem;
  position: sticky;
  top: 64px;
}

.filter-sidebar h3 {
  margin: 0 0 1rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-muted);
  font-weight: 600;
}

.filter-sidebar label {
  display: block;
  font-size: 0.8rem;
  color: var(--app-muted);
  margin-bottom: 0.3rem;
}

/* ===== FORM ELEMENTS ===== */
input[type='search'],
input[type='text'],
select,
textarea {
  width: 100%;
  color: var(--app-text);
  background: var(--app-surface-2);
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

input[type='search']:focus,
input[type='text']:focus,
select:focus,
textarea:focus {
  border-color: var(--app-accent);
}

input[type='checkbox'] {
  accent-color: var(--app-accent);
}

fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

/* ===== QUICK SEARCH RESULTS ===== */
#quick-results {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 10px;
  max-height: 360px;
  overflow-y: auto;
}

#quick-results .quick-result-item {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--app-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s;
}

#quick-results .quick-result-item:last-child {
  border-bottom: none;
}

#quick-results .quick-result-item:hover {
  background: var(--app-hl);
}

/* ===== TIMELINE ===== */
.timeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.timeline-month-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: border-color 0.15s;
}

.timeline-month-card:hover {
  border-color: var(--app-accent-2);
}

.timeline-month-card h3 {
  margin: 0 0 1rem;
  color: #fff;
  font-size: 0.95rem;
  text-transform: capitalize;
  font-weight: 600;
}

.timeline-month-card .timeline-stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--app-border);
  color: var(--app-muted);
}

.timeline-month-card .timeline-stat:last-child {
  border-bottom: none;
}

.timeline-month-card .timeline-stat .val {
  color: var(--app-accent);
  font-weight: 600;
}

/* ===== ARCHIVE ===== */
.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
}

.archive-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: border-color 0.15s;
}

.archive-card:hover {
  border-color: var(--app-accent-2);
}

.archive-card h3 {
  margin: 0 0 0.75rem;
  color: #fff;
  font-size: 0.95rem;
}

.archive-card .download-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-block;
  padding: 0.42rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--app-border);
  background: var(--app-surface-2);
  color: var(--app-muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  background: color-mix(in oklab, var(--app-surface-2) 80%, var(--app-accent) 20%);
  color: #fff;
  border-color: var(--app-accent-2);
}

.btn-primary {
  background: var(--app-accent);
  color: #fff;
  border-color: var(--app-accent);
}

.btn-primary:hover {
  background: var(--app-accent-2);
  border-color: var(--app-accent-2);
  color: #fff;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.5rem;
  align-items: center;
}

.pagination button {
  min-width: 2.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--app-border);
  background: var(--app-surface-2);
  color: var(--app-muted);
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
}

.pagination button:hover,
.pagination button.active {
  background: var(--app-accent);
  color: #fff;
  border-color: var(--app-accent);
}

/* ===== VERSION TABLE ===== */
.version-table {
  width: 100%;
  font-size: 0.88rem;
  border-collapse: collapse;
}

.version-table th {
  color: var(--app-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--app-border);
}

.version-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--app-border);
  color: var(--app-text);
}

.version-table tr:last-child td {
  border-bottom: none;
}

.version-table tr:hover td {
  background: var(--app-hl);
}

/* ===== MERMAID OUTPUT ===== */
#mermaid-output {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 1.5rem;
  min-height: 100px;
  overflow-x: auto;
}

#mermaid-output svg {
  max-width: 100%;
}

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--app-border);
  border-top-color: var(--app-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-left: 0.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== HR ===== */
hr {
  border: none;
  border-top: 1px solid var(--app-border);
  margin: 1.5rem 0;
}

/* ===== CODE ===== */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
  background: var(--app-surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  color: var(--app-accent);
}

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--app-border);
  margin-top: 1rem;
  padding: 1.25rem 1rem 0.75rem;
  background: color-mix(in oklab, var(--app-bg) 70%, black 30%);
}

.footer-grid {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.footer-grid strong {
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}

.footer-grid > div > p {
  color: var(--app-accent);
  font-size: 0.75rem;
  margin: 0.2rem 0 0;
}

.footer-grid nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  font-size: 0.75rem;
}

.footer-grid nav a {
  color: var(--app-muted);
  transition: color 0.15s;
}

.footer-grid nav a:hover {
  color: var(--app-accent);
}

.copyright {
  text-align: center;
  color: var(--app-muted);
  margin: 1rem 0 0;
  font-size: 0.78rem;
  padding: 0 1rem;
  opacity: 0.6;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .explore-layout {
    grid-template-columns: 1fr;
  }

  .filter-sidebar {
    position: static;
  }

  .top-nav ul {
    gap: 0.5rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .page-hero h1 {
    font-size: 1.45rem;
  }
}
