/* Marginalia — Library Card-Catalog Drawer theme */

:root {
  --walnut: #5b3a29;
  --walnut-deep: #3e2517;
  --walnut-light: #7a5238;
  --cream: #f4ecd9;
  --cream-edge: #e8d8b7;
  --ink: #2f2318;
  --ink-soft: #6d5b48;
  --accent: #c94b4b;
  --queued: #b98a2e;
  --reading: #c94b4b;
  --discussed: #3f7d5c;
  --blueprint: #2e5c8a;
  --shadow: 0 6px 16px rgba(38, 22, 10, 0.35);
  --radius-card: 6px 14px 6px 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: var(--walnut-deep);
  min-height: 100dvh;
}

.wood {
  min-height: 100dvh;
  background:
    repeating-linear-gradient(90deg,
      rgba(0,0,0,0.10) 0 2px, transparent 2px 34px),
    repeating-linear-gradient(90deg,
      rgba(255,255,255,0.03) 0 1px, transparent 1px 11px),
    linear-gradient(180deg, #6b452f 0%, var(--walnut) 45%, #4a2e1e 100%);
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* ---------- Masthead ---------- */

.masthead {
  padding: calc(14px + env(safe-area-inset-top)) 18px 12px;
}

.label-holder {
  display: inline-block;
  background: linear-gradient(160deg, #d9b96a, #a87d2e 60%, #8a651f);
  padding: 5px;
  border-radius: 4px;
  box-shadow: var(--shadow), inset 0 1px 2px rgba(255,255,255,0.5);
}

.label-plate {
  display: block;
  background: var(--cream);
  border-radius: 2px;
  padding: 6px 18px;
  font-size: 1.25rem;
  font-weight: bold;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--walnut);
  border: 1px solid #c9b183;
}

.masthead-sub {
  margin-top: 8px;
  color: var(--cream-edge);
  font-size: 0.78rem;
  font-style: italic;
  letter-spacing: 0.06em;
  opacity: 0.85;
}

main { flex: 1; padding: 4px 16px 20px; }

.tab-panel { animation: rise 0.22s ease-out; }

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

/* ---------- Drawer pulls (Shelf) ---------- */

.drawer-header {
  background: linear-gradient(180deg, #4a2e1e, #351f12);
  border-radius: 10px;
  padding: 18px 12px 16px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.45), var(--shadow);
  margin-top: 4px;
}

.pull-group {
  display: flex;
  justify-content: space-evenly;
  gap: 10px;
}

.drawer-pull {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 132px;
}

.pull-knob {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, #f0d894 0%, #cfa64e 38%, #96702a 72%, #6e501c 100%);
  box-shadow:
    inset 0 -4px 8px rgba(60,40,5,0.55),
    inset 0 3px 5px rgba(255,245,210,0.55),
    0 4px 8px rgba(0,0,0,0.5);
  position: relative;
}

.pull-knob::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px solid rgba(70, 48, 8, 0.4);
}

.pull-count {
  margin: -49px 0 0;
  height: 49px;
  display: flex;
  align-items: center;
  pointer-events: none;
  font-size: 1.9rem;
  font-weight: bold;
  color: #4a3510;
  text-shadow: 0 1px 0 rgba(255,240,200,0.6), 0 -1px 1px rgba(60,40,5,0.5);
  line-height: 1;
}

.pull-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cream-edge);
}

/* ---------- Bookmark CTA ---------- */

.bookmark-cta {
  margin: 18px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 180px;
  padding: 18px 16px 14px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  background: linear-gradient(180deg, var(--accent), #a83a3a);
  color: #fff7ec;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  box-shadow: var(--shadow);
  transition: transform 0.12s;
}

.bookmark-cta:active { transform: translateY(2px); }

.cta-notch {
  width: 26px; height: 5px;
  border-radius: 3px;
  background: rgba(255,247,236,0.55);
  margin-bottom: 8px;
}

.cta-text {
  font-size: 1.05rem;
  font-weight: bold;
  letter-spacing: 0.06em;
}

.cta-sub {
  font-size: 0.72rem;
  font-style: italic;
  opacity: 0.85;
  margin-top: 3px;
}

/* ---------- Cream index cards ---------- */

.rail-heading {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--cream-edge);
  margin: 24px 2px 10px;
}

.recent-strip {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  position: relative;
  background:
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(120, 90, 40, 0.10) 22px 23px),
    linear-gradient(180deg, #faf3e2, var(--cream));
  border-radius: var(--radius-card);
  padding: 14px 14px 12px 46px;
  box-shadow: var(--shadow);
  border-left: 6px solid var(--queued);
  min-height: 62px;
}

.card[data-status="Reading"] { border-left-color: var(--reading); }
.card[data-status="Discussed"] { border-left-color: var(--discussed); }
.card[data-status="Queued"] { border-left-color: var(--queued); }

.card .hole {
  position: absolute;
  left: 15px;
  top: 12px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--walnut-deep);
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.7), 0 1px 0 rgba(255,255,255,0.6);
}

.card .tape {
  position: absolute;
  left: 12px;
  top: 32px;
  width: 19px;
  height: 20px;
  border-radius: 2px;
  background: var(--queued);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}

.card[data-status="Reading"] .tape { background: var(--reading); }
.card[data-status="Discussed"] .tape { background: var(--discussed); }

.card .due-slip {
  position: absolute;
  top: 0; right: 0;
  width: 44px; height: 44px;
  background: linear-gradient(135deg, transparent 49%, rgba(46,92,138,0.16) 50%);
  border-top-right-radius: 14px;
}

.card-title {
  font-size: 1rem;
  font-weight: bold;
  color: var(--ink);
  line-height: 1.25;
}

.card-author {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-soft);
  margin-top: 1px;
}

.card-meta {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blueprint);
}

button.card { width: 100%; text-align: left; cursor: pointer; font-family: inherit; }
button.card:active { transform: scale(0.985); }

.card-row { position: relative; }

.card-actions {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 8px;
}

.icon-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 5px 10px;
  border-radius: 3px;
  background: var(--cream-edge);
  color: var(--walnut);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.icon-btn.danger { background: #e9c9c9; color: #8a2f2f; }
.icon-btn:active { transform: translateY(1px); }

/* ---------- Empty states ---------- */

.empty {
  margin-top: 6px;
  background: rgba(244, 236, 217, 0.12);
  border: 1px dashed rgba(232, 216, 183, 0.45);
  border-radius: 10px;
  padding: 26px 18px;
  text-align: center;
  color: var(--cream-edge);
}

.empty .empty-big {
  font-size: 1rem;
  font-style: italic;
  display: block;
  margin-bottom: 5px;
}

.empty .empty-small { font-size: 0.78rem; opacity: 0.8; }

/* ---------- Catalog ---------- */

.search-wrap { margin: 6px 0 16px; }

#catalog-search {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 11px 14px;
  border-radius: 20px;
  border: 1px solid rgba(232, 216, 183, 0.4);
  background: rgba(244, 236, 217, 0.14);
  color: var(--cream);
  outline: none;
}

#catalog-search::placeholder { color: rgba(232, 216, 183, 0.6); }
#catalog-search:focus { border-color: var(--cream-edge); background: rgba(244, 236, 217, 0.2); }

.catalog-group + .catalog-group { margin-top: 18px; }

.group-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--cream-edge);
  margin-bottom: 9px;
}

.group-heading .chip {
  width: 14px; height: 14px;
  border-radius: 3px;
  flex: none;
}

.group-heading .chip[data-s="Queued"] { background: var(--queued); }
.group-heading .chip[data-s="Reading"] { background: var(--reading); }
.group-heading .chip[data-s="Discussed"] { background: var(--discussed); }

.catalog-group .card + .card { margin-top: 10px; }

.catalog-list { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Form ---------- */

.form-heading {
  color: var(--cream);
  font-size: 1.3rem;
  margin: 10px 0 4px;
}

#card-form {
  margin-top: 14px;
  background: linear-gradient(180deg, #faf3e2, var(--cream));
  border-radius: 10px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
}

.field + .field { margin-top: 15px; }

.field label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--walnut-light);
  margin-bottom: 5px;
}

.field .optional { text-transform: none; letter-spacing: 0; opacity: 0.65; font-style: italic; }

.field input,
.field select,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fffdf6;
  border: 1px solid #d3c19a;
  border-radius: 5px;
  padding: 11px 12px;
  outline: none;
}

.field textarea { resize: vertical; min-height: 84px; line-height: 1.45; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blueprint);
  box-shadow: 0 0 0 3px rgba(46, 92, 138, 0.18);
}

.field.invalid input,
.field.invalid select { border-color: var(--accent); }

.field-error {
  margin-top: 5px;
  font-size: 0.78rem;
  color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: bold;
  padding: 13px 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  letter-spacing: 0.03em;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--walnut);
  color: var(--cream);
  box-shadow: var(--shadow);
}

.btn-ghost {
  background: transparent;
  color: var(--walnut-light);
  border: 1px solid #d3c19a;
}

.btn-danger {
  width: 100%;
  margin-top: 12px;
  background: transparent;
  color: #b8543f;
  border: 1px solid #c98d80;
  font-weight: normal;
  font-size: 0.85rem;
}

/* ---------- Notes tab ---------- */

.note-card {
  position: relative;
  background: linear-gradient(180deg, #faf3e2, var(--cream));
  border-radius: var(--radius-card);
  padding: 13px 14px 13px 40px;
  box-shadow: var(--shadow);
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.note-card + .note-card { margin-top: 10px; }

.note-card .ribbon {
  position: absolute;
  left: 13px; top: 13px;
  width: 12px; height: 26px;
  border-radius: 2px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
}

.note-card .ribbon.alt { background: var(--blueprint); }

.note-title { font-size: 0.95rem; font-weight: bold; color: var(--ink); }

.note-excerpt {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- About ---------- */

.about-block { margin-top: 28px; }

.about-card {
  background: rgba(244, 236, 217, 0.12);
  border: 1px solid rgba(232, 216, 183, 0.3);
  border-radius: 10px;
  padding: 16px;
  color: var(--cream-edge);
}

.about-name { font-weight: bold; font-size: 1rem; color: var(--cream); }

.about-line { font-size: 0.82rem; margin-top: 4px; line-height: 1.5; opacity: 0.85; }

.about-meta { font-size: 0.74rem; margin-top: 8px; opacity: 0.7; }

.reset-confirm {
  margin-top: 8px;
  font-size: 0.74rem;
  color: #f0b3a5;
}

/* ---------- Tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 6px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #35200f, var(--walnut-deep));
  box-shadow: 0 -4px 14px rgba(0,0,0,0.4);
  z-index: 10;
}

.tab {
  flex: 1;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 2px 10px;
  border-radius: 4px 4px 8px 8px;
  color: rgba(244, 236, 217, 0.55);
  background: rgba(244, 236, 217, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.tab-dot {
  width: 16px; height: 22px;
  border-radius: 2px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 70%, 0 100%);
  background: currentColor;
  opacity: 0.55;
}

.tab-shelf.active   { background: var(--queued); }
.tab-catalog.active { background: var(--blueprint); }
.tab-new.active     { background: var(--accent); }
.tab-notes.active   { background: var(--discussed); }

.tab.active {
  color: #fff8ea;
  transform: translateY(-7px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.5);
  font-weight: bold;
}

.tab.active .tab-dot { opacity: 1; background: #fff8ea; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--cream);
  color: var(--walnut);
  font-size: 0.85rem;
  padding: 10px 18px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  z-index: 20;
  white-space: nowrap;
}

/* Larger screens: keep drawer column centered */
@media (min-width: 560px) {
  main, .masthead { max-width: 520px; width: 100%; margin-left: auto; margin-right: auto; }
  .masthead { padding-left: 0; padding-right: 0; }
}
