/* Team Reading List: warm paper, ink, and bookcloth spines. */

:root {
  --paper: #F3EFE6;
  --paper-deep: #EAE4D7;
  --card: #FBF9F4;
  --ink: #1C1B18;
  --ink-2: #4A4740;
  --ink-3: #8A857A;
  --rule: #DDD6C7;
  --rule-soft: #E7E1D4;
  --green: #1F3D32;
  --green-2: #2C5446;
  --green-tint: #DCE6DF;
  --danger: #9A3A2E;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;

  --radius: 12px;
  --side-w: 360px;
  --shadow: 0 1px 0 rgba(28, 27, 24, .04), 0 8px 24px -12px rgba(28, 27, 24, .18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  gap: 64px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 56px 56px 80px;
}

.side {
  position: sticky;
  top: 56px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.brand h1 {
  margin: 0;
  font: 400 52px/1 var(--serif);
  font-variation-settings: "opsz" 72;
  letter-spacing: -.02em;
}

/* ---------- tally ---------- */

.tally {
  padding: 20px 0 0;
  border-top: 1px solid var(--rule);
}
.tally-row { display: flex; gap: 40px; }
.tally-cell { display: flex; flex-direction: column; }
.tally-num {
  font: 400 40px/1 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
  min-width: 1.2ch;
}
.tally-label { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.meter {
  margin-top: 18px;
  height: 4px;
  border-radius: 4px;
  background: var(--paper-deep);
  overflow: hidden;
}
.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: 4px;
  transition: width .5s cubic-bezier(.2, .7, .2, 1);
}

/* ---------- add form ---------- */

.add {
  background: var(--card);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.add-title {
  margin: 0 0 2px;
  font: 500 13px/1 var(--sans);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-size: 16px; /* keeps phones from zooming in */
}
.field input::placeholder { color: #B3AEA3; }
.field input:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(44, 84, 70, .16);
}
.form-error {
  margin: -4px 0 0;
  min-height: 0;
  font-size: 13px;
  color: var(--danger);
}
.form-error:empty { display: none; }
.add-actions { display: flex; gap: 10px; justify-content: flex-end; }
.add-actions .primary { flex: 1; }

.btn {
  height: 44px;
  padding: 0 18px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s, transform .1s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green); color: #F6F3EC; }
@media (hover: hover) { .btn.primary:hover { background: var(--green-2); } }
.btn.primary:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; border-color: var(--rule); color: var(--ink-2); }
.btn.wide { width: 100%; height: 52px; font-size: 16px; border-radius: 12px; }
.sheet-only { display: none; }

.shared-note {
  margin: 0;
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
}
.sync-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5E9C7E;
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(94, 156, 126, .18);
}
.sync-dot.off { background: #C08B3E; box-shadow: 0 0 0 3px rgba(192, 139, 62, .2); }

/* ---------- main ---------- */

.main { min-width: 0; padding-top: 4px; }
.main-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.view-title {
  margin: 0;
  font: 400 28px/1.1 var(--serif);
  letter-spacing: -.01em;
}

.tabs {
  display: inline-flex;
  padding: 3px;
  background: var(--paper-deep);
  border-radius: 10px;
  gap: 2px;
}
.tab {
  border: 0;
  background: transparent;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.tab[aria-selected="true"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(28, 27, 24, .1);
}
.tab-count {
  margin-left: 4px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

.group-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 30px 0 4px;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.group-label::after { content: ""; flex: 1; height: 1px; background: var(--rule-soft); }

.book {
  display: grid;
  grid-template-columns: 32px 12px minmax(0, 1fr) auto 36px;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 12px 8px 12px 6px;
  border-bottom: 1px solid var(--rule-soft);
  animation: rise .35s cubic-bezier(.2, .7, .2, 1) both;
}
.book:last-child { border-bottom: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

.toggle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid #B9B2A3;
  background: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  transition: background .15s, border-color .15s, transform .15s;
}
.toggle svg { opacity: 0; transition: opacity .15s; }
.toggle:hover { border-color: var(--green-2); }
.toggle:hover svg { opacity: .35; }
.book.is-read .toggle { background: var(--green); border-color: var(--green); color: #F6F3EC; }
.book.is-read .toggle svg { opacity: 1; }
.toggle:active { transform: scale(.92); }

.spine {
  width: 12px;
  height: 46px;
  border-radius: 2px 3px 3px 2px;
  background: var(--spine, #6B6B6B);
  box-shadow: inset -2px 0 0 rgba(0, 0, 0, .14), inset 1px 0 0 rgba(255, 255, 255, .12);
  position: relative;
}
.spine::before, .spine::after {
  content: "";
  position: absolute;
  left: 2px; right: 3px;
  height: 1px;
  background: rgba(255, 255, 255, .35);
}
.spine::before { top: 7px; }
.spine::after { bottom: 7px; }
.book.is-read .spine { opacity: .45; }

.book-text { min-width: 0; }
.book-title {
  margin: 0;
  font: 400 20px/1.25 var(--serif);
  letter-spacing: -.005em;
  overflow-wrap: anywhere;
}
.book-author {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.book.is-read .book-title { color: var(--ink-3); }
.book.is-read .book-author { color: var(--ink-3); }

.book-meta {
  font-size: 13px;
  color: var(--ink-3);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.read-pill {
  display: inline-block;
  margin-right: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--green-tint);
  color: var(--green);
  font-size: 12px;
  font-weight: 500;
}

.remove {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
}
.book:hover .remove, .remove:focus-visible { opacity: 1; }
.remove:hover { background: var(--paper-deep); color: var(--danger); }

.empty {
  padding: 72px 0;
  text-align: center;
  color: var(--ink-3);
}
.empty strong {
  display: block;
  font: 400 24px/1.3 var(--serif);
  color: var(--ink-2);
  margin-bottom: 6px;
}

.skeleton { padding-top: 24px; }
.skeleton i {
  display: block;
  height: 76px;
  border-bottom: 1px solid var(--rule-soft);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent) 0 0 / 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

:focus-visible { outline: 2px solid var(--green-2); outline-offset: 2px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: #F3EFE6;
  font-size: 14px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .45);
  animation: rise .25s ease both;
}
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-action {
  flex: none;
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
}

.thumb-bar, .scrim { display: none; }

/* ---------- wide desktop ---------- */

@media (min-width: 1500px) {
  :root { --side-w: 380px; }
  .shell { gap: 96px; }
}

/* ---------- tablet & phone ---------- */

@media (max-width: 960px) {
  .shell {
    display: block;
    padding: 28px 20px calc(110px + env(safe-area-inset-bottom));
  }
  .side { position: static; gap: 0; }
  .brand h1 { font-size: 42px; }
  .eyebrow { font-size: 11px; }

  .tally { border-top: 0; padding: 18px 0 0; }
  .tally-row { gap: 28px; }
  .tally-num { font-size: 30px; }
  .tally-label { margin-top: 4px; font-size: 12px; }
  .meter { margin-top: 14px; }

  .shared-note { margin-top: 16px; font-size: 12.5px; }

  .main { margin-top: 26px; }
  .main-head {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 -20px;
    padding: 12px 20px;
    background: rgba(243, 239, 230, .94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  .view-title { display: none; }
  .tabs { width: 100%; }
  .tab { flex: 1; height: 38px; padding: 0 8px; }

  .group-label { margin-top: 22px; }

  .book {
    grid-template-columns: 30px 10px minmax(0, 1fr) 36px;
    gap: 14px;
    min-height: 72px;
    padding: 12px 0;
  }
  .spine { width: 10px; height: 42px; }
  .book-title { font-size: 18px; }
  .book-author { font-size: 13.5px; }
  .book-meta { display: none; }
  .remove { opacity: .55; margin-right: -8px; }

  /* the add form becomes a bottom sheet */
  .add {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    border-radius: 18px 18px 0 0;
    border: 0;
    padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
    box-shadow: 0 -16px 40px -16px rgba(0, 0, 0, .3);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform .28s cubic-bezier(.2, .7, .2, 1), visibility 0s linear .28s;
  }
  .add::before {
    content: "";
    align-self: center;
    width: 40px; height: 4px;
    margin: -10px 0 4px;
    border-radius: 4px;
    background: var(--rule);
  }
  body.sheet-open .add {
    transform: none;
    visibility: visible;
    transition: transform .28s cubic-bezier(.2, .7, .2, 1);
  }
  .sheet-only { display: inline-flex; }

  .thumb-bar {
    display: block;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
    background: linear-gradient(rgba(243, 239, 230, 0), var(--paper) 30%);
  }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(28, 27, 24, .32);
  }
  .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
  body.sheet-open .toast { bottom: calc(300px + env(safe-area-inset-bottom)); }
}

@media (hover: none) {
  .remove { opacity: .55; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
