/* ── Reset + variables ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:        #1a5276;
  --primary-dark:   #154360;
  --primary-light:  #d6eaf8;
  --primary-subtle: #eaf4fb;
  --font:           Inter, system-ui, -apple-system, sans-serif;
  --mono:           'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --bg:             #f8f9fa;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --border-subtle:  #f1f5f9;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --text-light:     #94a3b8;
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      16px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:         0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.08);
  --nav-h:          56px;
  --transition:     150ms ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -.01em;
  text-decoration: none;
  flex-shrink: 0;
}
.navbar-brand:hover { text-decoration: none; opacity: .9; }
.navbar-brand svg { opacity: .9; }

.navbar-right {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex: 1;
  justify-content: flex-end;
}

/* ── Search ──────────────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  max-width: 320px;
  width: 100%;
}
.search-icon {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,.6);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: .45rem .75rem .45rem 2.1rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: .875rem;
  font-family: var(--font);
  outline: none;
  transition: background var(--transition), border-color var(--transition);
}
.search-input::placeholder { color: rgba(255,255,255,.55); }
.search-input:focus {
  background: rgba(255,255,255,.25);
  border-color: rgba(255,255,255,.5);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition),
              opacity var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-secondary {
  background: #fff;
  color: var(--primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--primary-subtle); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--border-subtle); color: var(--text); }

.btn-sm { padding: .35rem .7rem; font-size: .8125rem; gap: .25rem; }

/* ── Tags ────────────────────────────────────────────────────────────────── */
.tag-chip {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary-dark);
  line-height: 1.6;
}
.tag-preview { background: #fef9c3; color: #854d0e; }

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  min-height: calc(100vh - var(--nav-h));
}

/* ── Gallery page ────────────────────────────────────────────────────────── */
.gallery-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.gallery-hero {
  text-align: center;
  margin-bottom: 2rem;
}
.gallery-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text);
  margin-bottom: .5rem;
}
.gallery-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* ── Tag filter pills ────────────────────────────────────────────────────── */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.tag-pill {
  padding: .3rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.tag-pill:hover { border-color: var(--primary); color: var(--primary); }
.tag-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.notebook-count {
  text-align: center;
  font-size: .875rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

/* ── Notebook grid ───────────────────────────────────────────────────────── */
.notebook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.notebook-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .875rem;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  position: relative;
}
.notebook-card:hover {
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
  transform: translateY(-2px);
}
.notebook-card.hidden { display: none; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}
.card-icon {
  color: var(--primary);
  opacity: .8;
  flex-shrink: 0;
}
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  justify-content: flex-end;
}

.card-body { flex: 1; }
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: .35rem;
}
.card-description {
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding-top: .25rem;
  border-top: 1px solid var(--border-subtle);
}
.btn-launch { flex: 1; justify-content: center; }

/* ── Empty / no-results ──────────────────────────────────────────────────── */
.empty-state,
.no-results {
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.empty-state svg,
.no-results svg { color: var(--text-light); }
.empty-state code { background: var(--border-subtle); padding: .1em .4em; border-radius: 4px; font-size: .875em; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .navbar { padding: 0 1rem; }
  .gallery-page { padding: 1.5rem 1rem 3rem; }
  .notebook-grid { grid-template-columns: 1fr; }
  .search-wrap { max-width: 100%; }
}
