/* ---- Find an anime (search.js): a full-screen sheet on phones, a centred panel on wider screens ---- */

html.fa-open { overflow: hidden; }

.fa-sheet { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; color: var(--ink); background: transparent; overflow: hidden; }
.fa-sheet[open] { display: flex; }
.fa-sheet::backdrop { background: rgba(8, 8, 8, .74); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fa-dim .3s ease-out; }
@keyframes fa-dim { from { opacity: 0; } }

.fa-inner { position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; overflow: hidden; color: var(--ink); background-color: var(--paper); background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(18, 18, 18, .045) 28px); }

/* ---- Head: seal, title, close ---- */
.fa-head { flex: none; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: calc(14px + env(safe-area-inset-top)) 14px 6px 18px; }
.fa-seal { display: grid; place-items: center; width: 40px; height: 40px; color: var(--paper); background: var(--red); font: 400 23px/1 "Yu Mincho", "MS Mincho", serif; box-shadow: 3px 3px 0 rgba(18, 18, 18, .85); transform: rotate(-4deg); }
.fa-head-copy small { display: block; color: var(--red); font: 800 10px/1.2 Arial, sans-serif; letter-spacing: .18em; text-transform: uppercase; }
.fa-head-copy h2 { margin: 2px 0 0; font: italic 400 24px/1.05 Georgia, serif; letter-spacing: -.02em; }
.fa-close { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid #b0aa98; border-radius: 50%; color: var(--ink); background: transparent; font: 400 26px/1 Georgia, serif; cursor: pointer; transition: border-color .15s, color .15s; }
.fa-close:hover { border-color: var(--red); color: var(--red); }

/* ---- The field: one big line on ruled paper, a red rule under it ---- */
.fa-form { position: relative; flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; margin: 6px 18px 0; border-bottom: 2px solid var(--ink); }
.fa-input { width: 100%; min-width: 0; min-height: 56px; padding: 6px 0 8px; border: 0; border-radius: 0; color: var(--ink); background: transparent; font: italic 400 28px/1.2 Georgia, serif; letter-spacing: -.02em; outline: none; -webkit-appearance: none; appearance: none; }
.fa-input::placeholder { color: #9b9586; opacity: 1; }
.fa-input::-webkit-search-cancel-button, .fa-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.fa-clear { align-self: center; min-width: 44px; min-height: 44px; padding: 0 6px; border: 0; color: #6f6b62; background: transparent; font: 800 10px/1 Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; cursor: pointer; }
.fa-clear:hover { color: var(--red); }
.fa-rule { position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--red); transform-origin: 0 50%; transform: scaleX(0); transition: transform .45s cubic-bezier(.2, .8, .2, 1); pointer-events: none; }
.fa-form:focus-within .fa-rule { transform: scaleX(1); }

.fa-status { flex: none; min-height: 34px; margin: 0; padding: 10px 18px 6px; color: #6f6b62; font: 800 10px/1.4 Arial, sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.fa-status.is-trouble { color: #b8352b; letter-spacing: .04em; text-transform: none; font: italic 14px/1.4 Georgia, serif; }

/* ---- Results ---- */
.fa-body { position: relative; flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 18px calc(24px + env(safe-area-inset-bottom)); }
.fa-body.is-loading .fa-list { opacity: .5; transition: opacity .2s; }
.fa-list { margin: 0; padding: 0; list-style: none; }
.fa-item { border-bottom: 1px solid #d3cdbb; }
.fa-row { position: relative; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 14px; width: 100%; min-height: 64px; margin: 0; padding: 10px 4px; border: 0; color: var(--ink); background: transparent; font: inherit; text-align: left; cursor: pointer; transition: background-color .15s; }
.fa-row:hover { background: rgba(18, 18, 18, .04); }
.fa-row:hover .fa-name { color: var(--red); }
.fa-cover { display: block; width: 48px; height: 68px; overflow: hidden; background: #cbc3ae; box-shadow: 3px 3px 0 rgba(18, 18, 18, .22); }
.fa-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.fa-cover i { display: grid; place-items: center; height: 100%; color: rgba(18, 18, 18, .38); font: normal 400 22px/1 "Yu Mincho", "MS Mincho", serif; }
.fa-item[data-shelf="pass"] .fa-cover img { filter: grayscale(.7) brightness(.9); }
.fa-copy { min-width: 0; display: grid; gap: 2px; }
.fa-name { display: -webkit-box; overflow: hidden; font: 400 18px/1.2 Georgia, serif; letter-spacing: -.01em; overflow-wrap: anywhere; -webkit-line-clamp: 2; -webkit-box-orient: vertical; transition: color .15s; }
.fa-alt { overflow: hidden; color: #5f5b53; font: italic 14px/1.35 Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.fa-meta { margin-top: 2px; color: #77736a; font: 800 10px/1.35 Arial, sans-serif; letter-spacing: .12em; text-transform: uppercase; }
/* What was typed, marked like a pencil underline. */
.fa-row mark { color: inherit; background: linear-gradient(transparent 64%, rgba(239, 75, 63, .3) 0); }

/* The shelf a title is already on: a small hanko, tilted like the notebook's. */
.fa-shelf { display: grid; justify-items: center; gap: 2px; min-width: 52px; padding: 5px 6px 4px; border: 2px solid currentColor; border-radius: 6px; color: var(--ink); background: rgba(242, 238, 223, .9); transform: rotate(-6deg); pointer-events: none; }
.fa-shelf i { font: normal 400 18px/1 "Yu Mincho", "MS Mincho", serif; }
.fa-shelf span { font: 800 8px/1 Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; }
.fa-shelf[data-shelf="watch"] { color: var(--red); }
.fa-shelf[data-shelf="watched"] { color: var(--blue); }
.fa-shelf[data-shelf="pass"] { color: #6f6b62; }

/* ---- Welcome and nothing-found ---- */
.fa-intro, .fa-none { display: grid; justify-items: center; gap: 10px; padding: 34px 8px 18px; text-align: center; }
.fa-mark { display: grid; place-items: center; width: 68px; height: 68px; border: 1.5px solid var(--ink); border-radius: 50%; color: var(--red); font: 400 32px/1 "Yu Mincho", "MS Mincho", serif; }
.fa-intro p, .fa-none p { max-width: 34ch; margin: 0; color: #4f4b44; font: italic 16px/1.55 Georgia, serif; }
.fa-intro .fa-intro-lead { color: var(--ink); font: 400 22px/1.25 Georgia, serif; }
.fa-none { padding-bottom: 6px; }
.fa-none b { color: var(--ink); font-style: normal; }

/* ---- Asking AniList: a ruled line under the catalogue, the main action when the catalogue had nothing ---- */
.fa-more { margin: 14px 0 0; }
.fa-anilist { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 14px; border: 1px solid var(--ink); color: var(--ink); background: rgba(255, 255, 255, .16); font: inherit; text-align: left; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s; }
.fa-anilist:hover { border-color: var(--red); }
.fa-anilist:hover .fa-anilist-arrow { color: var(--red); transform: translateX(3px); }
.fa-anilist:disabled { opacity: .5; cursor: not-allowed; }
.fa-anilist[aria-disabled="true"] { cursor: wait; }
.fa-anilist-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1.5px solid var(--blue); border-radius: 50%; color: var(--blue); font: 400 17px/1 "Yu Mincho", "MS Mincho", serif; }
.fa-anilist-copy { min-width: 0; display: grid; gap: 2px; }
.fa-anilist-label { overflow-wrap: anywhere; font: 400 17px/1.25 Georgia, serif; }
.fa-anilist-note { color: #6f6b62; font: 700 10px/1.3 Arial, sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.fa-anilist-arrow { font: 400 22px/1 Georgia, serif; transition: transform .2s, color .15s; }
.fa-more.is-first .fa-anilist { color: var(--paper); background: var(--ink); }
.fa-more.is-first .fa-anilist:hover { border-color: var(--red); background: var(--red); }
.fa-more.is-first .fa-anilist-mark { border-color: var(--paper); color: var(--paper); }
.fa-more.is-first .fa-anilist-note { color: #c9c3b3; }
.fa-more.is-first .fa-anilist:hover .fa-anilist-arrow { color: var(--paper); }
/* While AniList is asked, the arrow breathes. */
.fa-anilist.is-busy .fa-anilist-arrow { animation: fa-breathe 1.1s ease-in-out infinite; }
@keyframes fa-breathe { 50% { opacity: .25; } }
.fa-more-note { margin: 10px 2px 0; color: #4f4b44; font: italic 15px/1.5 Georgia, serif; }
.fa-more-note.is-trouble { padding-left: 12px; border-left: 3px solid var(--red); color: #8f2b23; }

.fa-from { margin-top: 22px; }
.fa-from-title { position: relative; display: flex; align-items: center; gap: 10px; margin: 0 0 4px; color: var(--blue); font: 800 10px/1.2 Arial, sans-serif; letter-spacing: .18em; text-transform: uppercase; }
.fa-from-title span { font: normal 400 15px/1 "Yu Mincho", "MS Mincho", serif; letter-spacing: 0; }
.fa-from-title i { flex: 1; height: 1px; background: var(--blue); opacity: .6; transform-origin: 0 50%; }

.fa-close:focus-visible, .fa-clear:focus-visible, .fa-anilist:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.fa-row:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.fa-more.is-first .fa-anilist:focus-visible { outline-offset: 3px; }

/* ---- Wider screens: a paper panel in the middle, anchored near the top so it does not jump as results arrive ---- */
@media (min-width: 761px) {
    .fa-sheet[open] { justify-content: center; align-items: flex-start; }
    .fa-inner { width: min(680px, calc(100% - 48px)); height: auto; max-height: min(820px, calc(100% - 13vh)); margin-top: 8vh; border-top: 3px solid var(--red); box-shadow: 14px 14px 0 #050505; }
    .fa-head { padding: 18px 16px 4px 26px; }
    .fa-form { margin: 8px 26px 0; }
    .fa-input { font-size: 32px; }
    .fa-status { padding-left: 26px; padding-right: 26px; }
    .fa-body { padding: 0 26px 26px; }
    .fa-row { grid-template-columns: 52px minmax(0, 1fr) auto; gap: 16px; padding: 10px 8px; }
    .fa-cover { width: 52px; height: 74px; }
    .fa-name { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
    .fa-sheet::backdrop { animation: none; }
    .fa-rule, .fa-anilist-arrow, .fa-body.is-loading .fa-list, .fa-row, .fa-name { transition: none; }
    .fa-anilist.is-busy .fa-anilist-arrow { animation: none; }
    .fa-anilist:hover .fa-anilist-arrow { transform: none; }
}

/* ---- Notebook → Shelf: the hand-off when the shelf has few or no matches (notebook.js) ---- */
.nb-find-all { margin: 16px 0 0; color: #b8b4a9; font: italic 15px/1.5 Georgia, serif; }
.nb-find-all button { min-height: 44px; padding: 0 4px; border: 0; color: var(--paper); background: transparent; font: 15px/1.3 Georgia, serif; text-align: left; text-decoration: underline; text-decoration-color: rgba(239, 75, 63, .8); text-decoration-thickness: 1px; text-underline-offset: 5px; cursor: pointer; }
.nb-find-all button:hover { color: #ff7a6f; }
.nb-find-all button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
/* In the empty shelf card the hand-off is the way forward, so it reads as paper on the night page. */
.nb-empty .primary[data-find-anime] { color: var(--ink); background: var(--paper); }
.nb-empty .primary[data-find-anime]:hover { color: var(--paper); background: var(--red); }
.nb-empty .primary[data-find-anime]:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.nb-empty .nb-ghost[data-find-anime], .nb-empty [data-find-anime] ~ .nb-ghost { justify-self: center; }
