/* The bookshelf (Your collections) and the add-a-text flow. Theme variables for chrome; the book spines and the wood are their own fixed colours so a shelf looks like a shelf in every theme. */

/* ---------- Shelf screen ---------- */
.shelf-content { max-width: 1100px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.shelf-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.shelf-bar input[type="search"] { flex: 1 1 240px; min-height: 44px; box-sizing: border-box; }
.shelf-bar .primary { min-height: 44px; }
.shelf-create { display: flex; flex-direction: column; gap: 8px; margin: 0 0 18px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.shelf-create[hidden] { display: none; }
.shelf-create input, .shelf-create textarea { width: 100%; min-height: 44px; box-sizing: border-box; font: inherit; color: var(--text); background: var(--control); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.shelf-create textarea { resize: vertical; }
.shelf-create-row { display: flex; gap: 8px; flex-wrap: wrap; }
.shelf-create button { min-height: 44px; }
.shelf-hint { margin: 18px 0 0; color: var(--muted); line-height: 1.55; max-width: 60ch; }
.shelf-results { display: flex; flex-direction: column; gap: 10px; }

/* A bookcase: flat, drawn from the theme's own text and background colours so it suits whichever theme the reader picked, rows of books standing on planks. No gradients, no shadows. */
.shelf { display: flex; flex-direction: column; padding: 12px 12px 0; background: color-mix(in srgb, var(--accent-2) 42%, var(--border)); border-radius: 6px; }
.shelf-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 18px 18px 0;
  min-height: 206px;
  flex-wrap: nowrap;
  background: color-mix(in srgb, var(--accent-2) 12%, var(--stage));
}
.shelf-row::after { content: ''; position: absolute; left: 0; right: 0; bottom: -16px; height: 16px; background: color-mix(in srgb, var(--accent-2) 34%, var(--border)); border-top: 3px solid color-mix(in srgb, white 28%, color-mix(in srgb, var(--accent-2) 34%, var(--border))); }
.shelf-row { margin-bottom: 16px; }

/* A book standing cover out: wears its collection's theme (data-theme) and font, so every colour is a theme variable. Flat: no gradient, no shadow. */
.cover {
  --cover: color-mix(in srgb, var(--accent-2) 22%, var(--card));
  position: relative;
  flex: 0 0 auto;
  width: 144px;
  height: 188px;
  padding: 20px 12px 12px 24px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  text-align: left;
  color: var(--text);
  background: var(--cover);
  border: 1px solid color-mix(in srgb, var(--accent-2) 55%, var(--border));
  border-left: 10px solid var(--accent-2);
  border-radius: 4px 10px 0 0;
  cursor: pointer;
  font-family: inherit;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.15s ease;
}
/* The cover never changes colour on hover or press: a book on the shelf only slides out a little. */
.cover:hover, .cover:active, .cover:focus-visible { color: var(--text); background: var(--cover); }
.cover:hover, .cover:focus-visible { transform: translateY(-8px); }
.cover:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.cover-band { position: absolute; left: 14px; right: 12px; top: 10px; height: 3px; background: var(--accent-2); }
.cover-title { font-size: 1.02rem; line-height: 1.2; font-weight: 700; overflow-wrap: normal; word-break: normal; hyphens: none; display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; align-self: stretch; text-align: left; }
.cover-author { align-self: stretch; text-align: right; margin-top: 10px; font-size: 0.78rem; line-height: 1.25; font-style: italic; color: var(--muted); overflow-wrap: break-word; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; }
.cover-meta { margin-top: auto; display: flex; flex-direction: column; font-size: 0.78rem; color: var(--muted); }
.cover-saves { color: var(--accent-2); font-weight: 600; }
.cover-meter { display: block; width: 100%; height: 4px; background: var(--control-hover, var(--control)); overflow: hidden; }
.cover-meter i { display: block; height: 100%; background: var(--accent-2); }
.cover-new { background: transparent; color: var(--text); border: 2px dashed color-mix(in srgb, var(--accent-2) 55%, var(--text)); align-items: center; justify-content: center; padding: 10px; }
.cover-new:hover, .cover-new:active, .cover-new:focus-visible { background: transparent; }
.cover-plus { font-size: 2.4rem; line-height: 1; color: var(--text); }

/* The book that opens and fills the screen when a collection is chosen (see bookshelf.js, which sets every transform). All flat: scaling across, never rotating. */
.book-zoom { position: fixed; inset: 0; z-index: 400; pointer-events: none; overflow: hidden; }
.bz-book { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.bz-page { position: absolute; inset: 0; box-sizing: border-box; background: var(--bg); border: 1px solid color-mix(in srgb, var(--accent-2) 55%, var(--border)); }
.bz-flip { right: 100%; left: auto; width: 100%; transform-origin: right center; transform: scaleX(0); }
.bz-cover { position: absolute; left: 0; top: 0; margin: 0; transform-origin: left center; pointer-events: none; transition: none; }

@media (max-width: 560px) {
  .shelf { padding: 8px 8px 0; }
  .shelf-row { gap: 12px; padding: 14px 12px 0; min-height: 186px; }
  .cover { width: 124px; height: 168px; padding: 18px 10px 10px 20px; }
}
@media (prefers-reduced-motion: reduce) { .cover { transition: none; } .cover:hover, .cover:focus-visible { transform: none; } }

/* ---------- Add a text ---------- */
body.add-open { overflow: hidden; }
.add-screen { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; overflow-y: auto; background: var(--bg); color: var(--text); padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
.add-screen[hidden] { display: none; }
.add-screen > * { width: 100%; max-width: 920px; margin-left: auto; margin-right: auto; box-sizing: border-box; }
.add-head { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px 14px; padding-bottom: 14px; }
.add-sub { grid-column: 1 / -1; }
.add-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.add-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.add-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 18px; min-height: 96px; text-align: left; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); font: inherit; cursor: pointer; }
.add-choice strong { font-size: 1.05rem; }
.add-choice span { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.add-choice.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.add-choice.primary span { color: inherit; opacity: 0.9; }
.add-choice:hover { border-color: var(--accent-2); }
.add-status:empty { display: none; }
.add-sources { padding-bottom: 8px; }
.add-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.add-fields input { width: 100%; min-height: 44px; box-sizing: border-box; }
.add-trim { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.add-trim-part { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.add-trim-part input[type="range"] { width: 100%; min-height: 32px; }
.add-preview { margin: 0; padding: 10px 12px; min-height: 4.2em; border-left: 3px solid var(--accent-2); background: var(--control); border-radius: 4px; color: var(--text); line-height: 1.5; font-size: 0.92rem; overflow-wrap: anywhere; }
.add-count { margin: 0; color: var(--muted); }
.add-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.add-actions button { min-height: 44px; }

/* ---------- On the collection page ---------- */
.coll-block > .primary { align-self: flex-start; min-height: 44px; }
.coll-move { min-height: 44px; max-width: 150px; }
.coll-editor { list-style: none; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }

/* ---------- The reader's collection bar: the collection page's tabs, under the reader ---------- */
.reader-coll { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 8px; margin: 16px auto 0; max-width: 920px; }
.reader-coll[hidden] { display: none; }
.rc-name { min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent-2) 55%, var(--border)); background: color-mix(in srgb, var(--accent-2) 14%, var(--card)); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.rc-tab { min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.rc-tab:hover { background: var(--control); color: var(--text); }
.rc-name:hover { background: color-mix(in srgb, var(--accent-2) 24%, var(--card)); }

/* ---------- Fields and buttons on these screens follow the theme (they used to fall back to the browser's white) ---------- */
.shelf-content input:not([type="range"]):not([type="checkbox"]):not([type="file"]),
.add-screen input:not([type="range"]):not([type="checkbox"]):not([type="file"]),
.coll-screen input:not([type="range"]):not([type="checkbox"]):not([type="file"]),
.shelf-content select, .add-screen select, .coll-screen select, .coll-screen textarea, .add-screen textarea {
  font: inherit;
  color: var(--text);
  background: var(--control);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 44px;
  box-sizing: border-box;
}
.shelf-content input::placeholder, .add-screen input::placeholder, .coll-screen input::placeholder, .coll-screen textarea::placeholder { color: var(--muted); opacity: 1; }
.shelf-content input[type="checkbox"], .add-screen input[type="checkbox"], .coll-screen input[type="checkbox"], input[type="range"] { accent-color: var(--accent-2); }
.shelf-content input:focus-visible, .add-screen input:focus-visible, .coll-screen input:focus-visible, .shelf-content select:focus-visible, .coll-screen select:focus-visible, .add-screen select:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.shelf-content button:not(.cover):not(.primary), .add-screen button:not(.cover):not(.primary):not(.add-choice), .coll-screen button:not(.primary):not(.coll-tab) {
  font: inherit;
  color: var(--text);
  background: var(--control);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 44px;
  padding: 8px 16px;
  cursor: pointer;
}
.shelf-content button:not(.cover):not(.primary):hover, .add-screen button:not(.cover):not(.primary):not(.add-choice):hover, .coll-screen button:not(.primary):not(.coll-tab):hover { background: var(--control-hover, var(--control)); }
.hl-cover { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.hl-cover input { width: 5em; min-height: 40px; font: inherit; color: var(--text); background: var(--control); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; box-sizing: border-box; }
.coll-screen { color-scheme: inherit; }
.coll-screen button.coll-danger { margin-left: auto; color: var(--accent); border-color: var(--accent); background: transparent; }

/* Depth for the bookcase (decision 29): the frame, back panel and plank are three tints of the theme colour, so they read as parts of a shelf; a short shadow falls from the top rail, and each book stands on a soft shadow. The cover colour itself never changes on hover. */
.shelf-row { background-image: linear-gradient(180deg, rgb(0 0 0 / 0.2), rgb(0 0 0 / 0) 26px); }
.cover { box-shadow: 6px 8px 14px -8px rgb(0 0 0 / 0.55); }
.cover-new { box-shadow: none; }

/* Quizlet-style search field: a filled, borderless, rounded box with a magnifier. */
.shelf-content .shelf-bar input[type="search"]:not([type="range"]):not([type="checkbox"]):not([type="file"]) { min-height: 52px; padding-left: 46px; border: 2px solid transparent; border-radius: 14px; background-color: var(--control); background-repeat: no-repeat; background-position: 16px center; background-size: 20px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
.shelf-content .shelf-bar input[type="search"]:not([type="range"]):not([type="checkbox"]):not([type="file"]):focus { border-color: var(--accent-2); background-color: var(--card); }

/* Labels and callouts (design audit) */
.add-preview { border: 1px solid color-mix(in srgb, var(--accent-2) 40%, var(--border)); border-radius: 12px; }

/* Add-a-text choices keep their card shape (the pill rule for primary buttons must not reach them): the suggested way in is the card with a 2px accent border and a faint tint, as the picked answer is in a quiz. */
.add-choice { border-width: 2px; box-shadow: var(--shadow-sm); }
button.primary.add-choice { padding: 18px; border-radius: var(--radius); border: 2px solid var(--accent-2); background: color-mix(in srgb, var(--accent-2) 10%, var(--card)); color: var(--text); font-weight: 400; }
button.primary.add-choice span { color: var(--muted); opacity: 1; }
button.primary.add-choice:hover { filter: none; box-shadow: var(--shadow-sm); }
