/* Marginalia — Reading-Circle Book Spine Trolley */

:root {
  --teal: #2f6f73;
  --teal-deep: #24555a;
  --marigold: #d9822b;
  --brick: #a8503c;
  --ink: #2b2620;
  --ink-soft: #6b6156;
  --parchment: #f6efdf;
  --plate: #f3e6cf;
  --plate-deep: #ead9ba;
  --line: #d9c7a4;
  --shadow: 0 10px 22px rgba(43, 38, 32, 0.14);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at 85% -10%, rgba(217, 130, 43, 0.10), transparent 45%),
    var(--parchment);
  color: var(--ink);
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

button { font-family: inherit; color: inherit; }

/* ---------- Masthead ---------- */
.masthead {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: var(--teal);
  color: #f6efdf;
  border-bottom: 4px solid var(--marigold);
}
.masthead-words h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.4px;
  line-height: 1.1;
}
.masthead-words p {
  margin: 3px 0 0;
  font-size: 12px;
  font-style: italic;
  opacity: 0.85;
}
.bookmark-mark { display: inline-flex; }

/* ---------- Layout ---------- */
#views { padding: 16px 16px calc(108px + env(safe-area-inset-bottom)); }
.view[hidden] { display: none; }

.kicker {
  margin: 22px 2px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--teal-deep);
}
.panel-title {
  margin: 4px 2px 14px;
  font-size: 21px;
  line-height: 1.2;
}

/* ---------- Shelf: cart rail counter ---------- */
.cart-rail {
  display: flex;
  align-items: stretch;
  background: var(--ink);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.rail-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px 10px;
  color: var(--parchment);
}
.rail-open { background: var(--teal); }
.rail-finished { background: #3a3a34; }
.rail-count { font-size: 26px; font-weight: 700; line-height: 1; }
.rail-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.92;
}
.rail-divider { width: 3px; background: var(--marigold); }

/* ---------- Shelf: teal add strip ---------- */
.add-strip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 14px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--teal);
  color: var(--parchment);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.add-strip:active { background: var(--teal-deep); }
.add-strip-spine {
  width: 14px;
  align-self: stretch;
  border-radius: 4px;
  background: repeating-linear-gradient(
    180deg,
    var(--marigold) 0 7px,
    transparent 7px 13px
  );
  border-right: 2px solid rgba(246, 239, 223, 0.35);
}
.add-strip-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.add-strip-text strong { font-size: 17px; }
.add-strip-text small { font-size: 12px; opacity: 0.85; font-style: italic; }
.add-strip-tail {
  font-size: 26px;
  line-height: 1;
  color: var(--marigold);
  font-weight: 700;
}

/* ---------- Featured book-spine card ---------- */
.spine-card {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 18px 16px 18px 0;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.spine-card .spine-band {
  width: 22px;
  border-radius: 6px 0 0 6px;
  flex: none;
}
.spine-card .spine-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.spine-card .spine-flag {
  position: absolute;
  top: -8px;
  right: 14px;
  background: var(--marigold);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 3px;
}
.spine-title { font-size: 20px; line-height: 1.25; }
.spine-author { font-size: 13px; font-style: italic; color: var(--ink-soft); }
.spine-note {
  font-size: 13px;
  color: var(--ink-soft);
  border-top: 1px dashed var(--line);
  padding-top: 7px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.spine-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.status-open { color: var(--teal); }
.status-finished { color: var(--brick); }

/* ---------- Dots: filled / hollow, never checks ---------- */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}
.dot-hollow { border: 2px solid currentColor; background: transparent; }
.dot-filled { background: currentColor; }

/* ---------- Picks: grouped spine stack ---------- */
.group { margin-bottom: 22px; }
.group-heading {
  margin: 0 2px 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--teal);
}
.group-heading-finished { color: var(--brick); }

.spine-stack { display: flex; flex-direction: column; gap: 10px; }

.spine-row {
  display: flex;
  align-items: stretch;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(43, 38, 32, 0.08);
}
.spine-row .spine-band { width: 12px; flex: none; }
.spine-row-main { flex: 1; min-width: 0; padding: 10px 4px 10px 12px; cursor: pointer; }
.spine-row-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spine-row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.spine-row-author {
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spine-row-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.spine-row-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 8px 10px 8px 4px;
  border-left: 1px dashed var(--line);
}
.spine-btn {
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--teal);
  text-align: right;
}
.spine-btn:active { background: var(--plate-deep); }
.spine-btn.warn { color: var(--brick); }
.spine-btn.flip { color: var(--marigold); }

/* Status band colors: Teal, Marigold, Brick, Ink */
.band-open { background: var(--teal); }
.band-finished { background: var(--brick); }
.band-flip { background: var(--marigold); }
.band-neutral { background: #3a3a34; }

/* ---------- Forms ---------- */
.bookplate {
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 15px 18px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--teal-deep);
}
.field-label .req {
  font-style: italic;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--brick);
  margin-left: 4px;
}
.field input[type="text"],
.field input[type="search"],
.field textarea {
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom */
  color: var(--ink);
  background: #fdf8ec;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  width: 100%;
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}
.field-error {
  font-size: 12.5px;
  color: var(--brick);
  font-style: italic;
}
.field.has-error input { border-color: var(--brick); outline: 1px solid var(--brick); }

.segmented {
  display: flex;
  gap: 0;
  border: 1px solid var(--teal);
  border-radius: 9px;
  overflow: hidden;
}
.seg-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 6px;
  border: 0;
  background: #fdf8ec;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-soft);
}
.seg-btn + .seg-btn { border-left: 1px solid var(--teal); }
.seg-btn[aria-pressed="true"] { background: var(--teal); color: var(--parchment); }
.seg-btn[aria-pressed="true"] .dot-hollow { border-color: var(--parchment); }

.btn-primary {
  border: 0;
  border-radius: 10px;
  background: var(--marigold);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(217, 130, 43, 0.35);
}
.btn-primary:active { background: #bf6f1f; }
.btn-quiet {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  font-style: italic;
  padding: 8px;
  cursor: pointer;
  text-decoration: underline;
}

/* ---------- Find ---------- */
.find-head { margin-bottom: 14px; }
.search-plate {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fdf8ec;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 4px 12px;
  box-shadow: 0 3px 8px rgba(43, 38, 32, 0.07);
}
.search-plate:focus-within { outline: 2px solid var(--teal); outline-offset: 1px; }
.search-glyph {
  width: 12px;
  height: 12px;
  border: 2.5px solid var(--teal);
  border-radius: 50%;
  position: relative;
  flex: none;
}
.search-glyph::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2.5px;
  background: var(--teal);
  bottom: -4px;
  right: -4px;
  transform: rotate(45deg);
  border-radius: 2px;
}
.search-plate input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  padding: 10px 0;
  color: var(--ink);
}
.search-plate input:focus { outline: none; }

.find-count {
  margin: 0 2px 10px;
  font-size: 12.5px;
  font-style: italic;
  color: var(--ink-soft);
}

/* ---------- Empty states ---------- */
.empty {
  text-align: center;
  padding: 40px 24px;
  background: var(--plate);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-spine {
  display: block;
  width: 34px;
  height: 66px;
  margin: 0 auto 14px;
  border-radius: 6px;
  background: var(--teal);
  position: relative;
}
.empty-spine::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 16px;
  height: 5px;
  border-radius: 3px;
  background: var(--marigold);
}
.empty-spine-tilt { background: var(--plate-deep); }
.empty-spine-tilt::after { background: var(--line); }
.empty-title { margin: 0; font-size: 18px; font-weight: 700; }
.empty-hint { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-soft); font-style: italic; }

/* ---------- Bottom tab bar: leaning book spines ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 2px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--ink);
  border-top: 3px solid var(--marigold);
  z-index: 10;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 2px 5px;
  border: 0;
  background: transparent;
  color: #a89d8e;
  cursor: pointer;
  border-radius: 8px;
}
.tab-word {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}
.spine-icon {
  width: 26px;
  height: 34px;
  border-radius: 4px;
  background: #57503f;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 0 5px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.spine-icon i { display: block; height: 3px; border-radius: 2px; background: #7a715c; }
.spine-icon-b { width: 30px; }
.spine-icon-c { width: 22px; height: 36px; }
.spine-icon-d { width: 28px; transform-origin: bottom center; }

/* Active spine leans with a short soft shadow; others stay flat and matte */
.tab.is-active { color: var(--parchment); }
.tab.is-active .spine-icon {
  background: var(--teal);
  transform: rotate(-5deg) translateY(-3px);
  box-shadow: -4px 6px 10px rgba(0, 0, 0, 0.45);
}
.tab.is-active .spine-icon i { background: var(--marigold); }
.tab.is-active.tab[data-tab="find"] .spine-icon { transform: rotate(5deg) translateY(-3px); }

/* ---------- Misc ---------- */
@media (min-width: 560px) {
  #views, .masthead { max-width: 560px; margin: 0 auto; }
  .tabbar { max-width: 560px; margin: 0 auto; }
}
