/* ==========================================================================
   Library landing page
   Layered on top of shared/core.css, which supplies every token, the icon
   button, the brand mark and the author controls.

   The page is built to stay calm as the catalogue grows. Search and filters
   sit above the fold, subjects collapse, and a card carries only what helps
   someone decide whether to start: level, length, size, and their own
   progress. Author-facing counts are deliberately absent.
   ========================================================================== */

:root {
  /* Level chips. Kept out of the semantic family on purpose: an advanced
     guide is not a warning, and a beginner guide is not a success message. */
  --lvl-1:      #15803D;
  --lvl-1-soft: #F0FAF3;
  --lvl-1-line: #C3E8D0;
  --lvl-2:      #1D4ED8;
  --lvl-2-soft: #F1F5FE;
  --lvl-2-line: #CFDDF8;
  --lvl-3:      #6D28D9;
  --lvl-3-soft: #F6F2FE;
  --lvl-3-line: #DDD1F7;

  --hub-w: 68rem;
}

[data-theme="dark"] {
  --lvl-1:      #6EDB98;
  --lvl-1-soft: #101F16;
  --lvl-1-line: #1F4430;
  --lvl-2:      #82AFF7;
  --lvl-2-soft: #131A28;
  --lvl-2-line: #26364F;
  --lvl-3:      #BFA1F5;
  --lvl-3-soft: #1A1428;
  --lvl-3-line: #362A50;
}

body.hub {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.hub-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.hub-header-inner {
  max-width: var(--hub-w);
  margin: 0 auto;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: var(--text);
}
.hub-brand:hover { color: var(--accent); }

.hub-brand-text {
  font-size: 1rem;
  font-weight: 660;
  letter-spacing: -0.015em;
}

.hub-header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* --------------------------------------------------------------------------
   Main
   -------------------------------------------------------------------------- */

.hub-main {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--hub-w);
  margin: 0 auto;
  padding: 3.5rem 2rem 5rem;
}

.hub-intro { margin-bottom: 2.25rem; }

.hub-intro h1 {
  font-size: 2.75rem;
  letter-spacing: -0.028em;
  margin-bottom: 1rem;
}

.hub-tagline {
  font-size: 1.1875rem;
  line-height: 1.6;
  color: var(--text-2);
  max-width: 40rem;
  margin: 0;
}

/* --------------------------------------------------------------------------
   Continue Learning
   Only rendered when there is something to resume, so it never occupies
   space telling a first-time visitor that they have done nothing.
   -------------------------------------------------------------------------- */

.hub-resume { margin-bottom: 2.25rem; }

.hub-resume-head {
  font-size: var(--t-label);
  font-weight: 670;
  letter-spacing: var(--label-track);
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.75rem;
}

.resume-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.resume-list li { margin: 0; display: flex; }

.resume-card {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  width: 100%;
  padding: 0.9375rem 1.0625rem 1rem;
  border: 1px solid var(--accent-line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--accent-soft);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.16s var(--ease), transform 0.16s var(--ease);
}
.resume-card:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.resume-theme {
  font-size: 0.6875rem;
  font-weight: 660;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.resume-title {
  font-size: 1rem;
  font-weight: 640;
  letter-spacing: -0.012em;
  color: var(--text);
}

.resume-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.125rem;
}

.resume-pct {
  flex-shrink: 0;
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  font-weight: 650;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.resume-go {
  display: flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
}
.resume-go svg { flex: 0 0 13px; }
.resume-card:hover .resume-go svg { transform: translateX(2px); }
.resume-go svg { transition: transform 0.16s var(--ease); }

/* --------------------------------------------------------------------------
   Find a guide
   -------------------------------------------------------------------------- */

.hub-find { margin-bottom: 2rem; }

.find-field {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0 0.875rem;
  height: 52px;
  border: 1px solid var(--control-line);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.find-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.find-icon {
  flex: 0 0 16px;
  display: flex;
  color: var(--text-3);
}

.find-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  height: 100%;
}
.find-input::placeholder { color: var(--text-3); }
.find-input::-webkit-search-cancel-button { display: none; }

.find-clear {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-2);
  cursor: pointer;
}
.find-clear:hover { background: var(--border-strong); color: var(--text); }

.find-kbd { flex: 0 0 auto; }

/* Filters */

.find-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin-top: 0.875rem;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}

.filter-legend {
  font-size: 0.6875rem;
  font-weight: 670;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.chip-set {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 0.6875rem;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 560;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease),
              color 0.14s var(--ease);
}
.chip:hover { border-color: var(--control-line); color: var(--text); }
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.find-count {
  margin: 0.875rem 0 0;
  font-size: 0.875rem;
  color: var(--text-3);
  min-height: 1.25rem;
}

.hub-nomatch {
  padding: 2rem 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--text-2);
  text-align: center;
  font-size: 0.9375rem;
}

.linkish {
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Subject groups
   -------------------------------------------------------------------------- */

.hub-theme { margin-bottom: 1.75rem; }

.group-toggle {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  width: 100%;
  padding: 0 0 0.75rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  color: var(--text);
}
.group-toggle:hover .group-name { color: var(--accent); }

.group-toggle svg {
  flex: 0 0 14px;
  align-self: center;
  color: var(--text-3);
  transition: transform 0.16s var(--ease);
}
.group-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

.group-name {
  flex: 0 0 auto;
  font-size: 1.1875rem;
  font-weight: 650;
  letter-spacing: -0.018em;
  transition: color 0.16s var(--ease);
}

.group-blurb {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-count {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 0.4rem;
  border-radius: 99px;
  background: var(--surface-3);
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  font-weight: 650;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.group-body { padding-top: 1rem; }

/* --------------------------------------------------------------------------
   Guide cards
   -------------------------------------------------------------------------- */

.hub-guides {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0.875rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.hub-guides li { margin: 0; display: flex; }

.guide-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  padding: 1.125rem 1.25rem 1.1875rem;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease),
              transform 0.16s var(--ease);
}

a.guide-card:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}
a.guide-card:hover .guide-title { color: var(--accent); }

.guide-card[data-status="planned"],
.guide-card[data-status="drafting"] {
  background: var(--surface-2);
  border-style: dashed;
  cursor: default;
}

.guide-head {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
}

.guide-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.0625rem;
  font-weight: 640;
  letter-spacing: -0.012em;
  transition: color 0.16s var(--ease);
}

.level-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 0.5rem;
  border-radius: 99px;
  border: 1px solid var(--lvl-1-line);
  background: var(--lvl-1-soft);
  color: var(--lvl-1);
  font-size: 0.6563rem;
  font-weight: 660;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}
.level-chip[data-level="intermediate"] {
  border-color: var(--lvl-2-line);
  background: var(--lvl-2-soft);
  color: var(--lvl-2);
}
.level-chip[data-level="advanced"] {
  border-color: var(--lvl-3-line);
  background: var(--lvl-3-soft);
  color: var(--lvl-3);
}

.guide-blurb {
  font-size: 0.9063rem;
  line-height: 1.55;
  color: var(--text-2);
  flex: 1 1 auto;
}
.guide-card[data-status="planned"] .guide-blurb { color: var(--text-3); }

.guide-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.875rem;
  margin-top: 0.125rem;
}

.meta-bit {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: 0.75rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.meta-bit svg { flex: 0 0 13px; }

.guide-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 0.55rem;
  border-radius: 99px;
  font-size: 0.6563rem;
  font-weight: 660;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.guide-card[data-status="drafting"] .guide-badge {
  border-color: var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn);
}

/* Progress on a started guide */
.guide-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  margin-top: 0.125rem;
}
.guide-progress-track {
  flex: 1 1 auto;
  height: 4px;
  min-width: 0;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.guide-progress-fill {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
}
.guide-progress-pct {
  flex-shrink: 0;
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  font-weight: 650;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.guide-empty {
  padding: 1.25rem 1.375rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  color: var(--text-3);
  font-size: 0.9375rem;
  background: var(--surface-2);
  margin: 0;
}

/* Search hit highlighting */
.hub-main mark {
  padding: 0 1px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 640;
}

/* --------------------------------------------------------------------------
   About and footer
   -------------------------------------------------------------------------- */

.hub-about {
  margin-top: 4rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}
.hub-about h2 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}

.hub-about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.75rem 2rem;
}
.hub-about-item h3 {
  font-size: var(--t-label);
  font-weight: 670;
  letter-spacing: var(--label-track);
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.hub-about-item p {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-2);
  margin: 0;
}

.hub-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.hub-footer p {
  max-width: var(--hub-w);
  margin: 0 auto;
  padding: 1.25rem 2rem;
  font-size: 0.875rem;
  color: var(--text-3);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .group-blurb { display: none; }
}

@media (max-width: 760px) {
  .hub-header-inner { padding: 0.625rem 1.25rem; }
  .hub-main { padding: 2.25rem 1.25rem 3.5rem; }
  .hub-footer p { padding: 1rem 1.25rem; }
  .hub-intro h1 { font-size: 2rem; }
  .hub-tagline { font-size: 1.0625rem; }
  .hub-guides { grid-template-columns: 1fr; }
  .resume-list { grid-template-columns: 1fr; }
  .find-filters { gap: 0.625rem 1.25rem; }
  .find-field { height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .resume-card,
  .guide-card,
  .group-toggle svg,
  .resume-go svg { transition: none; }
  a.guide-card:hover,
  .resume-card:hover { transform: none; }
}
