/* Folio: proposed product override (bookcloth indigo) + app styles.
   Brand tokens live here until Folio is registered in Foundry; then they move to
   tokens/products/folio.css and are vendored like Foundry's own files. */

:root[data-product="folio"] {
  --fd-border-focus: #a9b1e0;
  --fd-action-primary: #a9b1e0;
  --fd-action-primary-hover: #c0c6ea;
  --fd-action-primary-text: #191c19;
  --fd-accent: #a9b1e0;
  --fd-accent-soft: #23263a;
  --fd-nav-accent: #a9b1e0;
}
:root[data-product="folio"][data-theme="light"] {
  --fd-border-focus: #4a5490;
  --fd-action-primary: #4a5490;
  --fd-action-primary-hover: #3c4578;
  --fd-action-primary-text: #fffaf2;
  --fd-accent: #4a5490;
  --fd-accent-soft: #e9eaf4;
  --fd-nav-accent: #4a5490;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 10; padding: 10px 14px; border-radius: var(--fd-radius-control); background: var(--fd-surface-base); color: var(--fd-text-primary); }
.skip-link:focus { top: 12px; }
main:focus { outline: none; }
[hidden] { display: none !important; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.text-link { color: var(--fd-accent); text-decoration: underline; text-underline-offset: 3px; }

/* Brand row (Foundry "Brand row size"): 32px visible mark, 20px cap height.
   The mark symbol's viewBox is cropped to its artwork, so height = visible height.
   Live serif lettering: Iowan Old Style caps are ~0.69em, so 29px ≈ 20px caps. */
.brand { display: inline-flex; align-items: center; gap: var(--fd-logo-gap); color: var(--fd-text-primary); }
.brand-mark { display: block; width: 32px; height: 32px; color: var(--fd-accent); }
.brand-name { font: var(--fd-font-weight-medium) 29px/1 var(--fd-font-display); letter-spacing: -.02em; }

/* Header: brand left; product actions, theme toggle, Settings right */
.hdr { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: var(--fd-header-height); padding: 0 var(--fd-gutter-desktop); border-bottom: 1px solid var(--fd-border-default); background: var(--fd-surface-canvas); }
.hdr-actions { display: flex; align-items: center; gap: 4px; }
.ico-sun { display: none; }
:root[data-theme="dark"] .ico-sun { display: block; }
:root[data-theme="dark"] .ico-moon { display: none; }

.wrap { max-width: var(--fd-content-media); margin: 0 auto; padding: 36px var(--fd-gutter-desktop) 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-head .fd-title { margin: 0; }
.section-title { font: var(--fd-font-weight-medium) var(--fd-font-size-heading)/var(--fd-line-height-heading) var(--fd-font-display); letter-spacing: -.02em; margin: 0 0 16px; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.js [data-noscript-only] { display: none; }
.quiet { color: var(--fd-text-secondary); margin: 0; }

/* Header search and Add books */
.search { position: relative; display: flex; align-items: center; margin-right: 8px; }
.search .ico { position: absolute; left: 12px; color: var(--fd-text-tertiary); pointer-events: none; }
.search input { width: 280px; height: 40px; padding: 0 12px 0 38px; border: 1px solid var(--fd-border-default); border-radius: var(--fd-radius-control); background: var(--fd-surface-base); color: var(--fd-text-primary); font: var(--fd-font-size-body) var(--fd-font-interface); }
.search input::placeholder { color: var(--fd-text-tertiary); }
.search-mobile { display: none; }
.upload-form { display: flex; margin-right: 8px; }
.add { gap: 8px; }
.upload-form input:focus-visible + .add { outline: 2px solid var(--fd-border-focus); outline-offset: 3px; }

/* Notices and upload progress */
.notices { display: grid; gap: 8px; margin-bottom: 28px; }
.notice, .upload-status { padding: 12px 14px; border-radius: var(--fd-radius-control); background: var(--fd-surface-raised); border-inline-start: 3px solid var(--fd-accent); }
.notice p { margin: 0; }
.notice-error { border-inline-start-color: var(--fd-feedback-danger); }
.upload-status { margin-bottom: 28px; }
.drop-overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: color-mix(in srgb, var(--fd-surface-canvas) 88%, transparent); border: 2px dashed var(--fd-accent); }
.drop-overlay p { font: var(--fd-font-weight-medium) var(--fd-font-size-heading)/1.2 var(--fd-font-display); color: var(--fd-text-primary); }

/* Shelves */
.tabs { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--fd-border-default); margin-bottom: 32px; }
.tab { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; color: var(--fd-text-secondary); font-size: var(--fd-font-size-body); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--fd-text-primary); border-color: var(--fd-accent); font-weight: var(--fd-font-weight-medium); }
.tab b { font-weight: var(--fd-font-weight-regular); color: var(--fd-text-tertiary); margin-left: 6px; }
.sort { margin-left: auto; display: flex; align-items: center; gap: 4px; color: var(--fd-text-secondary); }
.sort select { min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--fd-text-secondary); font: var(--fd-font-size-meta) var(--fd-font-interface); cursor: pointer; }
.sort-go { min-height: 36px; border: 1px solid var(--fd-border-default); border-radius: var(--fd-radius-control); background: var(--fd-surface-base); color: var(--fd-text-primary); }

/* Continue reading */
.continue { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 48px; }
.cr { display: flex; gap: 18px; padding: 18px; border: 1px solid var(--fd-border-default); border-radius: var(--fd-radius-card); background: var(--fd-surface-base); }
.cr .cover { width: 76px; flex: none; }
.cr-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cr h3 { margin: 0; font: var(--fd-font-weight-medium) 19px/1.2 var(--fd-font-display); letter-spacing: -.01em; }
.cr .by { color: var(--fd-text-secondary); font-size: var(--fd-font-size-meta); margin-top: 4px; }
.cr-progress { margin-top: auto; padding-top: 12px; }
.where { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fd-font-size-label); color: var(--fd-text-tertiary); }
.bar { display: block; width: 100%; height: 4px; margin: 8px 0 6px; border-radius: 4px; overflow: hidden; }
.bar-track { fill: var(--fd-surface-raised); }
.bar-fill { fill: var(--fd-accent); }

/* Cover grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 36px 28px; margin: 0; padding: 0; list-style: none; }
.book { display: block; }
.book .t { margin-top: 12px; font: var(--fd-font-weight-medium) 15px/1.25 var(--fd-font-display); overflow-wrap: anywhere; }
.book .a { color: var(--fd-text-secondary); font-size: 12.5px; margin-top: 3px; }
.book .pct { color: var(--fd-text-tertiary); font-size: var(--fd-font-size-label); margin-top: 4px; }
.book .pct.done { color: var(--fd-accent); }
@media (hover: hover) { .book:hover .t { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; } .cr:hover { border-color: var(--fd-text-tertiary); } }

/* Covers. Type scales with the cover (container units), so one design works at every size.
   cqi measures the content box (78% of the width after padding), hence the sizes. */
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 3px 5px 5px 3px; overflow: hidden; container-type: inline-size; background: var(--fd-surface-raised); }
.cover-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-image::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); pointer-events: none; }
.cover-type { display: flex; flex-direction: column; padding: 12% 11% 10%; background: var(--cloth); color: var(--ink); box-shadow: inset 6px 0 0 rgba(0,0,0,.14), inset 7px 0 0 rgba(255,255,255,.06); }
.cover-type::after { content: ""; position: absolute; inset: 7% 8%; border: 1px solid currentColor; opacity: .35; border-radius: 2px; pointer-events: none; }
.cover-type .ct { font: var(--fd-font-weight-medium) 12.6cqi/1.12 var(--fd-font-display); letter-spacing: -.01em; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.cover-type .rule { flex: none; width: 28%; height: 1px; background: currentColor; opacity: .55; margin: 10% 0; }
.cover-type .orn { font: italic var(--fd-font-weight-regular) 10cqi/1.15 var(--fd-font-display); opacity: .75; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cover-type .ca { margin-top: auto; padding-bottom: 2px; font: var(--fd-font-weight-regular) 7.8cqi/1.3 var(--fd-font-interface); letter-spacing: .14em; text-transform: uppercase; opacity: .85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Small covers (Continue reading): title only, legibly sized. */
.cr .cover-type { padding: 14px 11px; }
.cr .cover-type .ct { font-size: 10px; line-height: 1.15; -webkit-line-clamp: 5; }
.cr .cover-type .rule, .cr .cover-type .orn, .cr .cover-type .ca { display: none; }

/* Bookcloth palette (cloth, ink). Kept in step with folio/covers.py CLOTHS. */
.cloth-green { --cloth: #33463a; --ink: #efe6cf; }  .cloth-oxblood { --cloth: #6b2f2f; --ink: #f3e3c8; }
.cloth-navy { --cloth: #23314f; --ink: #e9dfc4; }   .cloth-ochre { --cloth: #b98a3e; --ink: #22201a; }
.cloth-slate { --cloth: #4d5660; --ink: #f0ebe0; }  .cloth-plum { --cloth: #4f3550; --ink: #efe2d6; }
.cloth-cream { --cloth: #e8dfc9; --ink: #2a2a26; }  .cloth-teal { --cloth: #2f5552; --ink: #f0e7d0; }
.cloth-rust { --cloth: #9a4b2c; --ink: #f8ecd8; }   .cloth-ink { --cloth: #1f2322; --ink: #d9c9a3; }
.cloth-sage { --cloth: #8a9a7b; --ink: #1f241c; }   .cloth-rose { --cloth: #c9a49a; --ink: #2b2220; }

/* Book page */
.detail-wrap { max-width: var(--fd-content-detail); margin: 0 auto; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--fd-text-secondary); font-size: var(--fd-font-size-body); margin-bottom: 16px; }
@media (hover: hover) { .back:hover { color: var(--fd-text-primary); } }
.detail { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 56px; }
.eyebrow { color: var(--fd-text-secondary); font-size: var(--fd-font-size-label); letter-spacing: .08em; text-transform: uppercase; margin: 0 0 10px; }
.detail h1 { font: var(--fd-font-weight-medium) var(--fd-title-feature)/var(--fd-line-height-feature) var(--fd-font-display); letter-spacing: -.035em; margin: 0; overflow-wrap: anywhere; }
.detail .subtitle { font: italic var(--fd-font-weight-regular) 20px/1.3 var(--fd-font-display); color: var(--fd-text-secondary); margin: 8px 0 0; }
.detail .author { font: italic var(--fd-font-weight-regular) 22px/1.3 var(--fd-font-display); color: var(--fd-text-secondary); margin: 8px 0 0; }
.detail .series { color: var(--fd-text-secondary); font-size: var(--fd-font-size-meta); margin: 8px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 32px; }
.fd-btn { gap: 8px; text-decoration: none; }
.blurb { font: var(--fd-font-weight-regular) 17px/1.6 var(--fd-font-display); max-width: 62ch; margin: 0 0 36px; }
.blurb p { margin: 0 0 .8em; }
.facts { display: flex; flex-wrap: wrap; row-gap: 12px; margin: 0 0 40px; }
.fact { padding: 2px 24px; border-left: 1px solid var(--fd-border-default); }
.fact:first-child { padding-left: 0; border-left: 0; }
.fact dt { color: var(--fd-text-secondary); font-size: var(--fd-font-size-label); }
.fact dd { margin: 0; font-weight: var(--fd-font-weight-medium); font-size: 15px; }
.dev-row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--fd-border-default); }
.dev-row:last-of-type { border-bottom: 0; }
.dev-ico { width: 36px; height: 36px; border-radius: var(--fd-radius-control); background: var(--fd-surface-raised); display: grid; place-items: center; color: var(--fd-text-secondary); flex: none; }
.dev-main { flex: 1; min-width: 0; }
.dev-main .bar { margin: 8px 0 0; max-width: 360px; }
.dev-meta { color: var(--fd-text-secondary); font-size: var(--fd-font-size-meta); }
.dev-pct { font: var(--fd-font-weight-medium) 20px/1 var(--fd-font-interface); font-variant-numeric: tabular-nums; }
.chip { display: inline-block; padding: 2px 8px; border-radius: var(--fd-radius-chip); background: var(--fd-accent-soft); color: var(--fd-accent); font-size: var(--fd-font-size-label); margin-left: 8px; vertical-align: 1px; }
.manage { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--fd-border-default); }

/* Forms (edit, delete) */
.form-page { max-width: 720px; margin: 0 auto; }
.lede { color: var(--fd-text-secondary); margin: 0 0 28px; max-width: 60ch; }
.edit-form { display: grid; gap: 22px; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend { font-size: var(--fd-font-size-body); padding: 0; }
.field > legend { margin-bottom: 6px; } /* a legend sits outside the grid gap */
.field .fd-segmented { justify-self: start; }
.field .fd-control { width: 100%; }
.field textarea { resize: vertical; line-height: 1.5; }
.field-hint { margin: 0; color: var(--fd-text-secondary); font-size: var(--fd-font-size-meta); }
.field-error { margin: 0; color: var(--fd-feedback-danger); font-size: var(--fd-font-size-meta); }
.form-error { margin: 0 0 20px; padding: 12px 14px; border-inline-start: 3px solid var(--fd-feedback-danger); border-radius: var(--fd-radius-control); background: var(--fd-surface-raised); }
.fd-control[aria-invalid="true"] { border-color: var(--fd-feedback-danger); }
.field-row { display: flex; gap: 16px; }
.field-row .grow { flex: 1; }
.field-row .narrow { width: 120px; flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; width: 44px; height: 44px; border-radius: var(--fd-radius-control); background: var(--cloth); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); cursor: pointer; margin: 0 !important; }
.swatch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.swatch:has(input:checked) { outline: 2px solid var(--fd-text-primary); outline-offset: 3px; }
.swatch:has(input:focus-visible) { outline: 2px solid var(--fd-border-focus); outline-offset: 3px; }

/* Empty and error states */
.empty { max-width: 560px; padding: 48px 0; color: var(--fd-text-secondary); }
.empty .section-title, .empty .fd-title { color: var(--fd-text-primary); }
.empty p { margin: 0 0 12px; }

/* Settings: the endorsement is centred on the page (components.css centres it in the column). */
.fd-settings .fd-title { margin-bottom: 0; }

@media (max-width: 1100px) { .continue { grid-template-columns: repeat(2, minmax(0, 1fr)); } .continue .cr:nth-child(n+3) { display: none; } }
@media (max-width: 820px) {
  .hdr .search, .add span { display: none; }
  .add { width: 44px; padding: 0; }
  .upload-form { margin-right: 0; }
  .search-mobile { display: flex; margin: 0 0 24px; }
  .search-mobile input { width: 100%; height: 44px; font-size: var(--fd-font-size-input); }
  .continue { grid-template-columns: 1fr; gap: 12px; margin-bottom: 36px; }
  .cr .cover { width: 64px; }
  .tabs { overflow-x: auto; scrollbar-width: none; margin-bottom: 24px; }
  .tab { padding: 0 8px; font-size: var(--fd-font-size-meta); }
  .tab b { margin-left: 4px; }
  .sort { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 18px; }
  .detail { grid-template-columns: 1fr; gap: 28px; }
  .detail-cover { width: min(220px, 60%); }
  .facts .fact { padding: 2px 16px; }
  .field-row { flex-direction: column; }
  .field-row .narrow { width: 100%; }
  .field .fd-control { font-size: var(--fd-font-size-input); }
}
@media (max-width: 820px) {
  .hdr { padding: 0 10px 0 var(--fd-gutter-mobile); }
  .brand-mark { width: 28px; height: 28px; }
  .brand-name { font-size: 25.5px; } /* ≈17.5px caps */
  .wrap { padding: 24px var(--fd-gutter-mobile) 48px; }
}
