/* Book trailer (docs/design-system.md): one card, one action per state, the
   four type tokens. The 9:16 frame keeps its size in every state, so nothing
   jumps while a trailer is planned, filmed, played or replaced. */
.book-trailer { container-type: inline-size; box-sizing: border-box; width: 100%; margin: 16px 0; padding: 20px; border: 1px solid #6b4f4d; border-radius: 16px; background: linear-gradient(135deg, #2a1f20, #171717 70%); color: var(--text-primary); }
.book-trailer [hidden] { display: none !important; }
.book-trailer .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.book-trailer-layout { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 28px; align-items: center; }
.book-trailer-preview { width: 100%; aspect-ratio: 9 / 16; min-width: 0; border-radius: 12px; background: #171314; }
.book-trailer-body { min-width: 0; }

.book-trailer-frame { position: relative; width: 100%; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; background: #0e0e0f; isolation: isolate; box-shadow: 0 18px 40px rgba(0, 0, 0, .35); }
.book-trailer-backdrop { position: absolute; inset: -12%; width: 124%; height: 124%; object-fit: cover; filter: blur(22px) brightness(.42) saturate(1.15); transition: opacity .3s; }
.book-trailer-cover { position: absolute; left: 50%; top: 50%; width: 74%; max-height: 82%; object-fit: contain; border-radius: 3px; box-shadow: 0 14px 32px rgba(0, 0, 0, .55); transform: translate(-50%, -50%); transition: opacity .35s, transform 2.4s ease-out, filter .35s; }
.book-trailer-backdrop:not([src]), .book-trailer-cover:not([src]) { visibility: hidden; }
.book-trailer-frame[data-state="ended"] .book-trailer-cover { transform: translate(-50%, -50%) scale(1.045); }
.book-trailer-frame[data-state="working"] .book-trailer-cover { opacity: .38; filter: saturate(.7); }
.book-trailer-frame::after { content: ''; position: absolute; inset: auto 0 0; z-index: 1; height: 30%; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); pointer-events: none; }
.book-trailer video { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; object-fit: cover; background: #000; opacity: 0; pointer-events: none; transition: opacity .25s; }
.book-trailer-frame[data-state="playing"] video, .book-trailer-frame[data-state="paused"] video { opacity: 1; pointer-events: auto; }
.book-trailer-hook { position: absolute; inset: 0 0 auto; z-index: 3; margin: 0; padding: 16% 9% 24%; background: linear-gradient(rgba(0, 0, 0, .78), transparent); color: #fffaf1; text-align: center; font: var(--type-body); font-weight: 600; overflow-wrap: break-word; pointer-events: none; opacity: 0; transition: opacity .3s; }
.book-trailer-hook.is-visible { opacity: 1; }
.book-trailer-meter { position: absolute; left: 12%; right: 12%; bottom: 8%; z-index: 3; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .18); overflow: hidden; }
.book-trailer-meter span { display: block; width: 100%; height: 100%; border-radius: inherit; background: var(--accent-rose, #e5b19d); transform: scaleX(0); transform-origin: left; transition: transform .9s ease; }
/* The universal video cue: a large ringed play button and a length badge. */
.book-trailer-play { position: absolute; left: 50%; top: 50%; z-index: 4; display: grid; place-items: center; width: 76px; height: 76px; padding: 0; border: 2px solid rgba(255, 255, 255, .9); border-radius: 50%; color: #fff; background: rgba(10, 10, 10, .5); box-shadow: 0 8px 28px rgba(0, 0, 0, .5); transform: translate(-50%, -50%); cursor: pointer; transition: transform .15s, background .15s; }
.book-trailer-play:hover { background: rgba(10, 10, 10, .72); transform: translate(-50%, -50%) scale(1.06); }
.book-trailer-play.is-waiting { opacity: .55; cursor: default; }
.book-trailer-play.is-waiting:hover { background: rgba(10, 10, 10, .5); transform: translate(-50%, -50%); }
.book-trailer-play svg { width: 34px; height: 34px; margin-left: 5px; fill: currentColor; }
.book-trailer-length { position: absolute; right: 8px; bottom: 8px; z-index: 3; padding: 2px 7px; border-radius: 6px; color: #fff; background: rgba(0, 0, 0, .7); font: var(--type-small); }
.book-trailer-play.is-loading svg { opacity: 0; }
.book-trailer-play.is-loading::after { content: ''; position: absolute; width: 22px; height: 22px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: book-trailer-spin 1s linear infinite; }

.book-trailer-title { margin: 0; font: var(--type-title); color: var(--text-primary); }
.book-trailer-lede, .book-trailer-status { margin: 6px 0 0; font: var(--type-body); color: var(--text-secondary); }
.book-trailer-status { color: var(--text-primary); }
.book-trailer-field { margin-top: 14px; }
.book-trailer-field label { display: block; margin-bottom: 6px; font: var(--type-small); color: var(--text-secondary); }
.book-trailer-optional { opacity: .75; }
.book-trailer textarea { display: block; box-sizing: border-box; width: 100%; min-width: 0; margin: 0; padding: 12px; resize: vertical; border: 1px solid var(--border-strong, #343438); border-radius: 10px; font: var(--type-body); font-size: 16px; color: var(--text-primary); background: rgba(0, 0, 0, .25); }
.book-trailer-editor { position: relative; height: 224px; overflow: hidden; border: 1px solid var(--border-strong, #343438); border-radius: 10px; background: rgba(0, 0, 0, .18); }
.book-trailer-editor:focus-within { border-color: var(--accent-rose, #e5b19d); box-shadow: 0 0 0 2px rgba(229,177,157,.12); }
.book-trailer .book-trailer-post-preview, .book-trailer [data-trailer-caption-input] { box-sizing: border-box; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 14px; border: 0; border-radius: 0; font: var(--type-body); font-size: 16px; line-height: 1.6; letter-spacing: normal; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; overflow-y: auto; scrollbar-width: thin; tab-size: 4; }
.book-trailer-post-preview { color: var(--text-primary); pointer-events: none; scrollbar-color: transparent transparent; }
.book-trailer-tag { color: var(--accent-rose, #e5b19d); }
.book-trailer [data-trailer-caption-input] { resize: none; color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--text-primary); background: transparent; }
.book-trailer [data-trailer-caption-input]:focus-visible { outline: none; }
.book-trailer [data-trailer-caption-input]::selection { background: rgba(229,177,157,.28); }
.book-trailer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 16px; }
.book-trailer .btn { max-width: 100%; min-height: 44px; white-space: normal; }
.book-trailer .text-action-link { min-height: 44px; padding: 0; border: 0; background: none; font: var(--type-small); cursor: pointer; }
.book-trailer-fine, .book-trailer-error { margin: 10px 0 0; font: var(--type-small); color: var(--text-secondary); overflow-wrap: anywhere; }
.book-trailer-error { color: var(--danger, #ff7b72); }

.book-trailer-more { position: relative; margin-left: auto; }
.book-trailer-more > summary { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--text-secondary); list-style: none; cursor: pointer; }
.book-trailer-more > summary::-webkit-details-marker { display: none; }
.book-trailer-more > summary:hover, .book-trailer-more[open] > summary { color: var(--text-primary); background: rgba(255, 255, 255, .07); }
.book-trailer-more > summary svg { width: 20px; height: 20px; fill: currentColor; }
.book-trailer-menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: 6; min-width: 210px; padding: 6px; border: 1px solid var(--border-strong, #343438); border-radius: 12px; background: #1d1b1b; box-shadow: 0 14px 34px rgba(0, 0, 0, .5); }
.book-trailer-menu button { display: block; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: var(--text-primary); font: var(--type-small); text-align: left; cursor: pointer; }
.book-trailer-menu button:hover { background: rgba(255, 255, 255, .07); }
.book-trailer-menu [data-trailer-delete] { color: var(--danger, #ff7b72); }
.book-trailer button:focus-visible, .book-trailer a:focus-visible, .book-trailer summary:focus-visible, .book-trailer textarea:focus-visible { outline: 2px solid var(--accent-rose, #e5b19d); outline-offset: 3px; }

@container (max-width: 480px) {
  .book-trailer-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .book-trailer-preview { justify-self: center; width: min(100%, 220px); }
  .book-trailer-body { text-align: left; }
}
@media (max-width: 600px) {
  .book-trailer { padding: 16px; }
  .book-trailer .btn { flex: 1 1 auto; }
}
@keyframes book-trailer-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .book-trailer-play.is-loading::after { animation: none; }
  .book-trailer-cover, .book-trailer-meter span { transition: none; }
}

/* "Share this book" for accounts without trailers. */
.book-share-simple textarea { box-sizing: border-box; margin: 0 0 .5rem; }
.book-share-simple .text-action-link { border: 0; background: transparent; min-height: 44px; cursor: pointer; font: var(--type-small); }

/* Native modal keeps keyboard focus and the shared modal-focus backdrop. */
.book-trailer-player { box-sizing: border-box; width: min(920px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 24px); padding: 16px 24px; margin: auto; border: 1px solid rgba(229,177,157,.24); border-radius: 20px; color: var(--text-primary); background: #111011; box-shadow: 0 24px 100px #0009; overflow: auto; }
.book-trailer-player-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.book-trailer-player-head h4 { margin: 0; font: var(--type-body); overflow-wrap: anywhere; }
.book-trailer-close { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: 10px; border: 0; border-radius: 50%; color: var(--text-primary); background: #ffffff0c; cursor: pointer; }
.book-trailer-close:hover { background: #ffffff18; }
.book-trailer-close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.book-trailer-stage { display: grid; place-items: center; }
.book-trailer-player .book-trailer-frame { width: min(100%, 440px, calc((100dvh - 184px) * .5625)); }
.book-trailer-player-foot { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0 20px; margin-top: 12px; }
.book-trailer-player-foot p { margin: 0; max-width: 40ch; font: var(--type-small); color: var(--text-secondary); }
.book-trailer-player-foot p:empty { display: none; }
@media (max-width: 600px) {
  .book-trailer-player { width: calc(100vw - 16px); padding: 12px; border-radius: 14px; }
  .book-trailer-editor { height: 200px; }
}
@media (forced-colors: active) {
  .book-trailer-post-preview { display: none; }
  .book-trailer [data-trailer-caption-input] { color: CanvasText; -webkit-text-fill-color: CanvasText; }
}
