/* Leitor do mangá CLOCK OUT. Independente do site.css: a pasta comic/
   pode ser copiada sozinha para o site atual (public/ do Vite). */

:root {
  --bg: #080807;
  --bg-2: #10100e;
  --bg-3: #1a1a17;
  --line: #2a2a26;
  --line-2: #3d3d38;
  --text: #dbdbdb;
  --text-2: #b4b4b0;
  --muted: #8a8a85;
  --mint: #8ae5c4;
  --emerald: #26c986;
  --white: #fff;
  --bar-h: 56px;
  --f-display: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --f-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 var(--f-body); -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 6px; }

/* ---------- barra ---------- */
.progress { position: fixed; z-index: 60; inset: 0 0 auto 0; height: 2px; background: transparent; }
.progress span { display: block; height: 100%; width: 0; background: var(--mint); transition: width .2s ease; }

.bar {
  position: fixed; z-index: 50; inset: 0 0 auto 0; height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  background: rgb(8 8 7 / .82); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: transform .25s ease;
}
.bar.is-hidden { transform: translateY(-100%); }
.bar__back {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px 0 6px;
  border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 14px;
}
.bar__back:hover { color: var(--white); background: var(--bg-3); }
.bar__title { margin: 0; font: 600 15px/1 var(--f-display); letter-spacing: .02em; color: var(--white); white-space: nowrap; }
.bar__title i { font-style: italic; font-weight: 900; color: var(--emerald); }
.bar__title small { font: 400 12px/1 var(--f-mono); color: var(--muted); margin-left: 6px; }
.bar__tools { justify-self: end; display: flex; align-items: center; gap: 8px; }
.bar__count { font: 400 12px/1 var(--f-mono); color: var(--muted); white-space: nowrap; min-width: 64px; text-align: right; }
.bar__count b { color: var(--white); font-weight: 500; }

.seg { display: flex; padding: 3px; border-radius: 9px; background: var(--bg-2); border: 1px solid var(--line); }
.seg button {
  border: 0; background: none; cursor: pointer; height: 28px; padding: 0 10px; border-radius: 6px;
  font: 500 12px/1 var(--f-mono); color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--bg-3); color: var(--white); }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { color: var(--white); border-color: var(--line-2); }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
  font: 600 14px/1 var(--f-body);
}
.btn--mint { background: var(--mint); color: var(--bg); }
.btn--mint:hover { background: #a9f0d6; }
.btn--ghost { border-color: var(--line-2); color: var(--text); background: none; }
.btn--ghost:hover { border-color: var(--mint); color: var(--mint); }

/* ---------- páginas: modo rolagem ---------- */
.reader { padding-top: calc(var(--bar-h) + env(safe-area-inset-top)); }
.pages {
  list-style: none; margin: 0 auto; padding: 16px 0 0;
  width: min(780px, 100%); display: grid; gap: 10px;
}
.pages li { position: relative; scroll-margin-top: calc(var(--bar-h) + env(safe-area-inset-top) + 8px); }
.pages li > img {
  width: 100%; background: var(--bg-2);
  box-shadow: 0 20px 50px -30px rgb(0 0 0 / .9);
}
.tap { display: none; }

.end { min-height: 85svh; display: grid; place-items: center; padding: 48px 20px 80px; text-align: center; }
.end__box img { width: 150px; margin: 0 auto 18px; filter: drop-shadow(0 0 16px rgb(38 201 134 / .4)); }
.end__kicker { margin: 0 0 6px; font: 500 12px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.end__line { margin: 0 0 28px; font: italic 900 clamp(34px, 7vw, 56px)/1 var(--f-display); letter-spacing: -.03em; color: var(--white); }
.end__cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.end__home { display: inline-block; margin-top: 26px; color: var(--muted); font-size: 13px; text-underline-offset: 3px; }
.end__home:hover { color: var(--mint); }

/* ---------- páginas: modo página ---------- */
.mode-pages .reader {
  position: fixed; inset: 0; padding: calc(var(--bar-h) + env(safe-area-inset-top) + 12px) 12px 12px;
}
.mode-pages { overflow: hidden; overscroll-behavior: none; }
.mode-pages .pages { position: relative; width: 100%; height: 100%; padding: 0; display: block; }
/* Todas as páginas ocupam o mesmo lugar; só aparece a atual. Durante a virada aparecem duas:
   a da frente (a que vira) e a de baixo (a que fica à mostra). */
.mode-pages .pages li { position: absolute; inset: 0; display: none; }
.mode-pages .pages li.is-current,
.mode-pages .pages li.is-front,
.mode-pages .pages li.is-under { display: flex; align-items: center; justify-content: center; }
.mode-pages .pages li.is-under { z-index: 1; }
.mode-pages .pages li.is-front { z-index: 2; }
.mode-pages .pages li > img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.mode-pages .end { min-height: 0; }

/* ---------- a página virando (modo página) ----------
   O reader.js move tudo: a dobra é uma reta, a parte virada da página aparece espelhada do outro lado dela (o verso). */
.turn { display: none; }
.mode-pages .pages li.turn.is-on { display: block; z-index: 3; pointer-events: none; }
.turn__castbox { position: absolute; overflow: hidden; }
.turn__cast, .turn__bend { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
/* a sombra que o verso faz na página de baixo, colada na dobra */
.turn__cast { background: linear-gradient(to right, rgb(0 0 0 / .46), rgb(0 0 0 / .16) 38%, rgb(0 0 0 / 0)); }
.turn__lift { position: absolute; inset: 0; filter: drop-shadow(0 0 14px rgb(0 0 0 / .55)); }
.turn__sheet { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
.turn__paper { position: absolute; background: #ebe5d7; }
/* o desenho da página visto pelo verso, como em papel fino */
.turn__ghost { position: absolute; max-width: none; opacity: .17; filter: grayscale(.5); }
/* a curva do papel perto da dobra: escuro na dobra, um brilho, e de novo um pouco de sombra na ponta */
.turn__bend {
  background: linear-gradient(to right,
    rgb(0 0 0 / .30), rgb(0 0 0 / .07) 9%, rgb(255 255 255 / .34) 22%, rgb(255 255 255 / 0) 48%, rgb(0 0 0 / .10));
}

.mode-pages .tap {
  display: flex; align-items: center; position: fixed; z-index: 10; top: var(--bar-h); bottom: 0; width: 34%;
  border: 0; background: none; cursor: pointer; padding: 0 18px; color: var(--white);
}
.tap--prev { left: 0; justify-content: flex-start; }
.tap--next { right: 0; justify-content: flex-end; }
.tap span {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: rgb(8 8 7 / .7); border: 1px solid var(--line-2); font-size: 26px; line-height: 1;
  opacity: 0; transition: opacity .2s ease;
}
.tap:hover span, .tap:focus-visible span { opacity: 1; }
.tap[disabled] { cursor: default; }
.tap[disabled] span { opacity: 0 !important; }

/* ---------- grade de páginas ---------- */
.grid {
  width: min(920px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); padding: 0;
  border: 1px solid var(--line-2); border-radius: 16px; background: var(--bg); color: var(--text);
}
.grid::backdrop { background: rgb(0 0 0 / .7); backdrop-filter: blur(4px); }
.grid__head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 12px 12px 18px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.grid__head p { margin: 0; font: 500 12px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.grid__list { list-style: none; margin: 0; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.grid__list a { display: block; text-decoration: none; color: var(--muted); font: 400 11px/1 var(--f-mono); text-align: center; }
.grid__list img { border-radius: 6px; border: 1px solid var(--line); margin-bottom: 6px; aspect-ratio: 240 / 424; object-fit: cover; width: 100%; }
.grid__list a:hover img { border-color: var(--line-2); }
.grid__list a[aria-current="page"] { color: var(--mint); }
.grid__list a[aria-current="page"] img { border-color: var(--mint); }

/* ---------- aviso ---------- */
.toast {
  position: fixed; z-index: 70; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 10px; background: var(--mint); color: var(--bg); font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- celular ---------- */
@media (max-width: 640px) {
  :root { --bar-h: 52px; }
  .bar { grid-template-columns: auto 1fr auto; gap: 6px; }
  .bar__back { padding: 0 4px; }
  .bar__back span, .bar__title small, [data-full] { display: none; }
  .bar__title { justify-self: start; font-size: 14px; }
  .bar__tools { gap: 6px; }
  .bar__count { min-width: 0; }
  .seg button { padding: 0 7px; }
  .pages { padding-top: 0; gap: 6px; }
  .mode-pages .reader { padding: calc(var(--bar-h) + env(safe-area-inset-top)) 0 0; }
}
@media (max-width: 340px) {
  .bar__count { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
