/* Coleção de livros — página de Projetos (imersiva) e camada de continuidade dos cases.
   Escopo: html[data-alan-books] (coleção ativa), body.alan-project-books-page (página),
   .alan-books-veil e html[data-alan-books-hold] (chegada ao case). */

/* ---------- Continuity veil (case page): last frame of the scene, under the site header. ---------- */
.alan-books-veil{position:fixed;left:0;top:0;z-index:3;overflow:hidden;pointer-events:none;background:var(--alan-ui-paper,#fff);contain:strict}
.alan-books-veil img{display:block;width:100%;height:100%;max-width:none;object-fit:fill;user-select:none}
/* While the veil covers the hero, the hero's own entrance stays at rest (no second animation). */
html[data-alan-books-hold] .alan-project-opening,html[data-alan-books-hold] .alan-project-opening *{opacity:1!important;visibility:visible!important;transition:none!important;animation:none!important}
@media (prefers-reduced-motion:reduce){.alan-books-veil{display:none!important}}

/* ---------- The page: no edge blur, no "Portfólio" eyebrow. ---------- */
body.alan-project-books-page .alan-project-catalog__heading>p{display:none}

/* ---------- Collection mode: one fixed, immersive viewport. ---------- */
html[data-alan-books],html[data-alan-books] body{overflow:hidden!important;overscroll-behavior:none}
html[data-alan-books]{scrollbar-gutter:auto!important}
html[data-alan-books] .alan-footer{display:none}
html[data-alan-books] .alan-project-catalog{position:fixed;inset:0;z-index:0;width:auto;max-width:none;margin:0;padding:0;background:radial-gradient(130% 95% at 50% 40%,#fff 0%,#fbfbfc 42%,#f2f2f4 100%)}
html[data-alan-books] .alan-project-catalog__grid{display:none}
html[data-alan-books] .alan-project-catalog__heading{position:absolute;width:1px;height:1px;margin:0;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}

/* Quiet loading line, only when the scene takes longer than a moment. */
html[data-alan-books="pending"] .alan-project-catalog::after{content:"";position:absolute;left:50%;top:50%;width:56px;height:1px;margin-left:-28px;background:linear-gradient(90deg,transparent,rgba(29,29,31,.45),transparent);background-size:200% 100%;opacity:0;animation:alan-books-wait 1.4s ease-in-out .7s infinite}
@keyframes alan-books-wait{0%{opacity:0;background-position:120% 0}30%{opacity:1}100%{opacity:0;background-position:-120% 0}}

/* Stage. */
.alan-books{position:absolute;inset:0;overflow:hidden;color:var(--alan-ui-ink,#1d1d1f);font-family:var(--alan-ui-font-sans,-apple-system,BlinkMacSystemFont,"Helvetica Neue",Helvetica,Arial,sans-serif);-webkit-tap-highlight-color:transparent}
.alan-books[hidden]{display:none}
.alan-books__viewport{position:absolute;inset:0;outline:none;touch-action:none;cursor:grab;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.alan-books__viewport[data-dragging]{cursor:grabbing}
.alan-books__viewport[data-hover]{cursor:pointer}
.alan-books__viewport:focus-visible{outline:1.5px solid rgba(29,29,31,.32);outline-offset:-14px;border-radius:20px}
.alan-books__canvas{position:absolute;inset:0;display:block;width:100%;height:100%;opacity:0;transition:opacity 1.5s cubic-bezier(.25,.1,.25,1) .12s}
.alan-books:not([data-state="loading"]) .alan-books__canvas{opacity:1}
.alan-books:is([data-state="opening"],[data-state="handoff"],[data-state="returning"]) .alan-books__canvas{transition:none}

/* Bottom bar: caption centred, arrows right; the view switch sits bottom-left (outside the stage). */
.alan-books__bar{--bar-bottom:max(28px,calc(env(safe-area-inset-bottom) + 18px));position:absolute;z-index:2;left:var(--alan-ui-gutter,clamp(1.25rem,4.5vw,4.5rem));right:var(--alan-ui-gutter,clamp(1.25rem,4.5vw,4.5rem));bottom:var(--bar-bottom);display:grid;grid-template-columns:1fr minmax(0,auto) 1fr;grid-template-areas:". caption arrows";align-items:center;gap:1.5rem;pointer-events:none;transition:opacity .45s cubic-bezier(.4,0,.2,1)}
.alan-books:not([data-state="browsing"]) .alan-books__bar{opacity:0;transition-duration:.25s}
.alan-books:not([data-state="browsing"]) .alan-books__bar *{pointer-events:none!important}
.alan-books__caption{grid-area:caption;min-width:0;text-align:center;pointer-events:auto}
.alan-books__meta{display:block;margin:0 0 .45rem;color:var(--alan-ui-muted,#6e6e73);font-size:.6875rem;font-weight:500;letter-spacing:.16em;font-variant-numeric:tabular-nums}
.alan-books__title{display:inline-block;max-width:100%;color:inherit;font-size:clamp(1.25rem,1.7vw,1.625rem);font-weight:500;line-height:1.15;letter-spacing:-.03em;text-decoration:none;text-wrap:balance;overflow-wrap:anywhere}
.alan-books__title:hover{text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:.2em}
.alan-books__arrows{grid-area:arrows;justify-self:end;display:flex;gap:10px;pointer-events:auto}
.alan-books__arrow{appearance:none;display:grid;place-items:center;width:44px;height:44px;margin:0;padding:0;border:1px solid var(--alan-ui-line,rgba(29,29,31,.13));border-radius:50%;background:rgba(255,255,255,.72);color:inherit;font:400 1rem/1 inherit;cursor:pointer;transition:border-color .25s,background .25s,opacity .25s}
.alan-books__arrow:hover{border-color:rgba(29,29,31,.42);background:#fff}
.alan-books__arrow:disabled{opacity:.28;cursor:default}
.alan-books__arrow svg{width:16px;height:16px}
.alan-books__title:focus-visible,.alan-books__arrow:focus-visible,.alan-books-view button:focus-visible{outline:2px solid currentColor;outline-offset:4px;border-radius:8px}
.alan-books__arrow:focus-visible{border-radius:50%}
.alan-books__hint{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}

/* List view: the books regrouped in the stage; each title is a real link under its book. */
.alan-books__labels{position:absolute;inset:0;z-index:1;margin:0;padding:0;list-style:none;pointer-events:none}
.alan-books__labels li{margin:0;padding:0}
.alan-books__label{position:absolute;left:0;top:0;max-width:22ch;padding:4px 8px;color:var(--alan-ui-muted,#6e6e73);font-size:.8125rem;font-weight:500;line-height:1.2;letter-spacing:-.01em;text-align:center;text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;opacity:0;visibility:hidden;pointer-events:auto;will-change:transform,opacity;transition:color .25s}
.alan-books__label:hover,.alan-books__label.is-focus{color:var(--alan-ui-ink,#1d1d1f)}
.alan-books__label:focus-visible{outline:2px solid currentColor;outline-offset:2px;border-radius:6px;color:var(--alan-ui-ink,#1d1d1f)}
.alan-books[data-view="collection"] .alan-books__labels{display:none}
.alan-books:not([data-state="browsing"]) .alan-books__labels{pointer-events:none}
@media (max-width:640px){.alan-books__label{font-size:.75rem;max-width:16ch}}

/* First entrance: caption, arrows and switch arrive after the books have landed. */
.alan-books[data-intro][data-state="browsing"] .alan-books__bar{transition:opacity .9s cubic-bezier(.25,.1,.25,1) 1.45s}
.alan-project-catalog[data-alan-books-intro][data-alan-books-state="browsing"] .alan-books-view{transition:opacity .9s cubic-bezier(.25,.1,.25,1) 1.45s}

/* Reading marks: a hairline under the caption, a short red line under list titles. */
.alan-books__reading{display:block;width:56px;height:2px;margin:.6rem auto 0;border-radius:2px;background:rgba(29,29,31,.12);overflow:hidden}
.alan-books__reading[hidden]{display:none}
.alan-books__reading>span{display:block;width:calc(var(--p,0) * 100%);height:100%;background:#a3242b;border-radius:inherit}
.alan-books__label.is-read::after{content:"";display:block;width:calc(6px + var(--p,0) * 22px);height:2px;margin:5px auto 0;border-radius:2px;background:#a3242b}
/* Read to the end: the line is complete and quieter. */
.alan-books__reading.is-done>span,.alan-books__label.is-done::after{opacity:.55}

/* View switch: bottom-left, far from the menu, in both views. */
.alan-books-view{position:fixed;z-index:4;left:var(--alan-ui-gutter,clamp(1.25rem,4.5vw,4.5rem));bottom:max(30px,calc(env(safe-area-inset-bottom) + 20px));display:inline-flex;gap:2px;padding:3px;border:1px solid var(--alan-ui-line,rgba(29,29,31,.13));border-radius:999px;background:rgba(255,255,255,.86);font-family:var(--alan-ui-font-sans,-apple-system,BlinkMacSystemFont,"Helvetica Neue",Helvetica,Arial,sans-serif);transition:opacity .45s cubic-bezier(.4,0,.2,1)}
.alan-books-view button{appearance:none;min-height:34px;margin:0;padding:0 .95rem;border:0;border-radius:999px;background:transparent;color:var(--alan-ui-muted,#6e6e73);font:500 .75rem/1 inherit;letter-spacing:.01em;cursor:pointer;transition:background .25s,color .25s}
.alan-books-view button[aria-pressed="true"]{background:var(--alan-ui-ink,#1d1d1f);color:#fff}
/* Reset: a quiet control beside the switch, shown only while a reading is remembered. */
.alan-books-view .alan-books-reset{position:absolute;left:calc(100% + 10px);top:50%;display:inline-flex;align-items:center;gap:.4rem;min-height:34px;padding:0 .6rem;transform:translateY(-50%);color:var(--alan-ui-muted,#6e6e73);font-size:.6875rem;font-weight:500;letter-spacing:.01em;white-space:nowrap;transition:color .25s}
.alan-books-view .alan-books-reset[hidden]{display:none}
.alan-books-view .alan-books-reset svg{flex:none;width:14px;height:14px}
.alan-books-view .alan-books-reset:hover,.alan-books-view .alan-books-reset:focus-visible{color:var(--alan-ui-ink,#1d1d1f)}
/* List view: keep the footer clear of the floating switch. */
html:not([data-alan-books]) body.alan-project-books-page .alan-footer{padding-bottom:calc(84px + env(safe-area-inset-bottom))}
html[data-alan-books="pending"] .alan-books-view,.alan-project-catalog:is([data-alan-books-state="loading"],[data-alan-books-state="opening"],[data-alan-books-state="handoff"],[data-alan-books-state="returning"]) .alan-books-view{opacity:0;pointer-events:none}

@media (max-width:640px){
 .alan-books__bar{grid-template-columns:1fr auto;grid-template-areas:"caption caption" ". arrows";row-gap:22px;gap:22px 12px}
 .alan-books__title{font-size:1.3rem}
 .alan-books__arrow{width:42px;height:42px}
 .alan-books-view{bottom:max(28px,calc(env(safe-area-inset-bottom) + 18px))}
 .alan-books-view button{min-height:36px;padding:0 .85rem}
 /* Phones: the icon alone (the label stays in the accessible name), clear of the arrows. */
 .alan-books-view .alan-books-reset{left:calc(100% + 4px);width:36px;min-height:36px;padding:0;justify-content:center}
 .alan-books-view .alan-books-reset span{display:none}
}
@media (max-height:520px) and (orientation:landscape){
 .alan-books__meta{display:none}
 .alan-books__bar{--bar-bottom:14px}
}
@media (prefers-reduced-motion:reduce){
 .alan-books__canvas,.alan-books__bar,.alan-books__arrow,.alan-books-view,.alan-books-view button,.alan-books-view .alan-books-reset,.alan-books[data-intro] .alan-books__bar,.alan-project-catalog[data-alan-books-intro] .alan-books-view{transition:none!important}
 html[data-alan-books="pending"] .alan-project-catalog::after{animation:none}
}

/* Hop between cases (previous/next): the collection is only the passage between two books.
   Its interface stays out of sight; only the two books involved are on stage (scene.solo). */
html[data-alan-books-hop] :is(.alan-books__bar,.alan-books__labels,.alan-books-view,.alan-books-reset,.alan-books__caption,.alan-books__hint,.alan-books__arrows,.alan-books__meta,.alan-books__reading){opacity:0!important;visibility:hidden!important;transition:none!important;animation:none!important}
