/* Site additions for chardikalakids.com: the title-page PDF button and the slim top bar.
   Uses the book's own CSS variables. The book markup itself is never edited. */

html { scroll-padding-top: calc(52px + env(safe-area-inset-top, 0px)); }

/* ---------- Title-page button ----------
   site.js inserts it right after .cover .sub. Until then, the same height is held open under
   the subtitle, so the cover picture doesn't jump down when the button appears. */
.cover { --ck-pdf-h: calc(44px + .4rem + 1.2rem); }
.cover .sub::after { content: ""; display: block; height: calc(var(--ck-pdf-h) + 1.6rem); }
html.ck-ready .cover .sub::after { display: none; }

.ck-pdf {
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  min-height: var(--ck-pdf-h); margin: 0 auto 1.6rem; max-width: none;
}
.cover a.ck-pdf-btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: 44px; padding: 0 1.25rem;
  background: var(--cloth); color: var(--paper);
  border: 1px solid var(--gold); border-radius: 6px;
  font: 600 .95rem/1.2 var(--small); letter-spacing: .01em;
  text-decoration: none; cursor: pointer;
  transition: background-color .15s ease;
}
.cover a.ck-pdf-btn:hover { background: var(--indigo); color: var(--paper); }
.cover a.ck-pdf-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.ck-pdf-cap { font: 400 .8rem/1.2rem var(--small); color: var(--ink-soft); margin: 0; }

/* ---------- Slim top bar ----------
   Hidden while the cover is on screen; afterwards it hides on scroll down and returns on scroll up. */
.ck-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  box-sizing: border-box;
  height: calc(44px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; gap: .15rem;
  background: var(--cloth); border-bottom: 1px solid var(--gold);
  transform: translateY(-100%);
  transition: transform .2s ease;
}
.ck-bar.ck-show { transform: none; }
.ck-bar a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 44px;
  color: var(--paper); text-decoration: none; white-space: nowrap;
}
.ck-bar a:focus-visible { outline: 2px solid var(--gold); outline-offset: -3px; border-radius: 4px; }
.ck-bar .ck-bar-title {
  justify-content: flex-start; margin-right: auto; padding-right: .5rem;
  font: 400 17px/1 var(--display); letter-spacing: .01em;
  overflow: hidden; text-overflow: ellipsis;
}
.ck-bar .ck-bar-link { padding: 0 .65rem; font: 600 .85rem/1 var(--small); }
.ck-bar .ck-bar-link:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--gold); }
.ck-bar .ck-bar-pdf { padding-left: .3rem; }
.ck-bar .ck-bar-pdf span {
  display: inline-block; padding: .32rem .8rem;
  border: 1px solid var(--gold); border-radius: 999px;
  font: 600 .85rem/1 var(--small); letter-spacing: .03em;
  transition: background-color .15s ease;
}
.ck-bar .ck-bar-pdf:hover span { background: var(--indigo); }

@media (prefers-reduced-motion: reduce) {
  .ck-bar, .cover a.ck-pdf-btn, .ck-bar .ck-bar-pdf span { transition: none; }
}

@media print {
  .ck-bar, .ck-pdf { display: none !important; }
  .cover .sub::after { display: none !important; }
}
