/* ============================================================
   LIL-LIBRARY — STYLES
   ------------------------------------------------------------
   Theme tokens are all declared as CSS variables at the top —
   change the palette or type here and it updates everywhere.
============================================================= */

:root {
  /* -- palette: library ledger -------------------------------- */
  --ink:        #21261f;
  --paper:      #ede7d8;
  --paper-2:    #e2dac5;
  --card:       #f4efe1;
  --cloth:      #26433a;   /* bookcloth green */
  --cloth-dark: #1a2f28;
  --brass:      #a9782f;   /* brass / gilt accent */
  --stamp:      #7c2f2b;   /* oxblood stamp red */
  --line:       #c9bfa4;

  /* -- type ----------------------------------------------------- */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body:    "Source Serif 4", Georgia, serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

body.no-scroll { overflow: hidden; }

::selection { background: var(--brass); color: var(--paper); }

/* subtle paper texture via layered gradients */
body {
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.35), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(0,0,0,0.03), transparent 45%);
  background-attachment: fixed;
}

a { color: inherit; }

code {
  font-family: var(--font-mono);
  background: var(--paper-2);
  padding: 0.1em 0.4em;
  border-radius: var(--radius);
  font-size: 0.9em;
}

/* ============================================================
   HEADER
============================================================= */

.site-header {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 22px 32px;
  background: var(--cloth);
  color: var(--paper);
  border-bottom: 6px solid var(--brass);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--brass);
  object-fit: cover;
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  margin: 0;
  letter-spacing: 0.2px;
}

.tagline {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--paper-2);
  font-style: italic;
}

.search-wrap {
  position: relative;
  margin-left: auto;
  flex: 1 1 320px;
  max-width: 420px;
}

.search-input {
  width: 100%;
  padding: 11px 40px 11px 14px;
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.92rem;
}

.search-input:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.6;
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 24px rgba(0,0,0,0.18);
  max-height: 360px;
  overflow-y: auto;
  z-index: 50;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-body);
}

.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--paper-2); }

.sr-icon { font-size: 1.2rem; }
.sr-text { display: flex; flex-direction: column; }
.sr-title { font-weight: 600; }
.sr-sub {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--stamp);
}

.search-empty {
  padding: 14px;
  font-size: 0.9rem;
  color: #7a7460;
  font-style: italic;
}

.hidden { display: none !important; }

/* ============================================================
   LAYOUT
============================================================= */

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 90px);
}

/* ============================================================
   SIDEBAR — DRAWER TABS
============================================================= */

.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px 0;
  background: var(--paper-2);
}

.drawer-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  background: none;
  border: none;
  border-left: 4px solid transparent;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
}

.drawer-tab:hover { background: rgba(0,0,0,0.04); }

.drawer-tab.active {
  border-left-color: var(--brass);
  background: var(--card);
  font-weight: 600;
}

.drawer-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.drawer-label { flex: 1; }

.drawer-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #7a7460;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1px 7px;
}

/* ============================================================
   MAIN — CATALOG GRID
============================================================= */

.main { padding: 28px 32px 60px; }

.main-heading h2 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  margin: 0 0 4px;
}

.section-desc {
  margin: 0 0 22px;
  color: #5c5642;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card:hover, .card:focus {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(38,67,58,0.16);
  border-color: var(--brass);
  outline: none;
}

.card-stamp {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--stamp);
  border: 1px solid var(--stamp);
  border-radius: 10px;
  padding: 2px 8px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
}

.card-tagline {
  margin: 0;
  font-size: 0.88rem;
  color: #5c5642;
  flex: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1px 8px;
  color: #4a4636;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #7a7460;
}

.card-open { color: var(--cloth); font-weight: 600; }

.empty-state {
  margin-top: 40px;
  color: #7a7460;
  font-style: italic;
}

/* ============================================================
   DETAIL SUB-PANEL (per-project section)
============================================================= */

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 24, 16, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 20px;
  overflow-y: auto;
  z-index: 100;
}

.detail-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  max-width: 640px;
  width: 100%;
  padding: 34px 34px 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.detail-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}

.detail-stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--stamp);
  border: 1px solid var(--stamp);
  border-radius: 10px;
  padding: 2px 9px;
  margin-bottom: 12px;
}

#detailTitle {
  font-family: var(--font-display);
  font-size: 1.7rem;
  margin: 0 0 4px;
}

.detail-tagline {
  color: #5c5642;
  margin: 0 0 12px;
  font-style: italic;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.detail-desc {
  margin: 0 0 20px;
  line-height: 1.6;
}

.files-heading {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--cloth);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin: 0 0 10px;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.file-thumb {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.file-icon {
  width: 34px;
  text-align: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.file-name {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.file-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1px 7px;
  color: #4a4636;
}

.file-download {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--cloth);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.file-download:hover { color: var(--brass); }

.file-empty {
  color: #7a7460;
  font-style: italic;
  font-size: 0.9rem;
}

/* ============================================================
   FOOTER
============================================================= */

.site-footer {
  text-align: center;
  padding: 18px;
  font-size: 0.8rem;
  color: #7a7460;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
}

/* ============================================================
   RESPONSIVE
============================================================= */

@media (max-width: 780px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    display: flex;
    overflow-x: auto;
    padding: 10px;
    gap: 6px;
  }

  .drawer-tab {
    border-left: none;
    border-bottom: 4px solid transparent;
    white-space: nowrap;
    padding: 8px 14px;
  }

  .drawer-tab.active {
    border-bottom-color: var(--brass);
  }

  .main { padding: 20px; }
  .site-header { padding: 16px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
}
