:root {
  --bg: #191919;
  --panel: #2c2c2c;
  --panel2: #424242;
  --yellow: #F1E800;
  --text: #ffffff;
  --muted: #b9b9b9;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Cambria, Georgia, "Times New Roman", serif;
  font-size: 15px;
}

.app {
  --gap: 18px;
  --corner: 6px;
  --side: 280px;
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "dtitle doctitle"
    "cats pages";
  gap: var(--gap);
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 28px 0;
}

.box {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px;
}

.top {
  grid-area: top;
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  column-gap: var(--gap);
  align-items: end;
}

.logo img {
  display: block;
  width: 220px;
  height: auto;
  /* obrazok ma dole priehladny okraj */
  margin-bottom: -21px;
}

.client {
  background: var(--yellow);
  color: #111;
  border-radius: 8px;
  padding: 12px 18px;
}

.client h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.client p {
  margin: 4px 0 0;
  font-size: 14px;
}

.client .sep {
  margin: 0 8px;
  opacity: .55;
}

.side-title {
  grid-area: dtitle;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--yellow);
}

.side-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.side-name {
  text-box: trim-both cap alphabetic;
}

.side-count {
  --size: 24px;
  display: grid;
  place-items: center;
  min-width: var(--size);
  height: var(--size);
  padding: 0 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--yellow) 15%, transparent);
  font-size: 13px;
  font-variant-numeric: lining-nums;
  line-height: 1;
  letter-spacing: 0;
}

.side-count.drawn {
  background-size: 100% 100%;
  color: transparent;
}

.side {
  grid-area: cats;
  position: sticky;
  top: 12px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
  padding-bottom: var(--gap);
}

.cat-box {
  position: relative;
}

/* kategoria vybraneho dokumentu je napojena na dokument */
.bridge {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(100% - var(--radius));
  width: calc(var(--radius) + var(--gap));
  background: var(--panel);
  view-transition-class: bridge;
}

.bridge-top,
.bridge-bottom {
  position: absolute;
  right: 0;
  width: var(--corner);
  height: var(--corner);
}

.bridge-top {
  bottom: 100%;
  background: radial-gradient(circle at 0 0, transparent calc(var(--corner) - .5px), var(--panel) var(--corner));
  view-transition-class: bridge-corner bridge-top;
}

.bridge-bottom {
  top: 100%;
  background: radial-gradient(circle at 0 100%, transparent calc(var(--corner) - .5px), var(--panel) var(--corner));
  view-transition-class: bridge-corner bridge-bottom;
}

.cat {
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text);
  overflow-wrap: anywhere;
}

.doc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--panel2);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.doc:last-child {
  margin-bottom: 0;
}

.doc:hover {
  background: #4d4d4d;
  color: var(--text);
}

.doc.active {
  background: var(--yellow);
  color: #111;
  font-weight: 700;
}

.doc::after {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  margin-right: 3px;
  border-top: 2px solid;
  border-right: 2px solid;
  opacity: 0;
  transform: translateX(-4px) rotate(45deg);
}

.doc:hover::after,
.doc.active::after {
  opacity: 1;
  transform: rotate(45deg);
}

.doc:focus-visible,
.to-top:focus-visible,
.download:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.toolbar {
  grid-area: doctitle;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  column-gap: 18px;
  row-gap: 3px;
  padding: 14px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.doc-title {
  flex: 1 1 260px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.doc-cat {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.doc-name {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.doc-cat + .doc-name {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.3;
}

.doc-meta {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.doc-meta time {
  color: var(--text);
}

.doc-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 9px;
  border: 1px solid var(--yellow);
  border-radius: var(--radius);
  color: var(--yellow);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.download svg {
  width: 14px;
  height: 14px;
}

.download:hover {
  background: var(--yellow);
  color: #111;
}

.download[hidden] {
  display: none;
}

.pages {
  grid-area: pages;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-width: 0;
  min-height: 240px;
  margin-top: calc(-1 * var(--gap));
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 18px;
}

.page {
  position: relative;
  max-width: 100%;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .55);
}

.page canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pages.loading .page {
  opacity: .45;
}

.skeleton {
  width: 100%;
  aspect-ratio: 210 / 297;
  overflow: hidden;
  color: #ececec;
  background:
    linear-gradient(currentColor, currentColor) 50% 9% / 46% 22px no-repeat,
    repeating-linear-gradient(currentColor 0 10px, transparent 10px 28px) 50% 32% / 80% 50% no-repeat,
    #fff;
}

.skeleton + .status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* pravidla textovej vrstvy su z pdf.js, licencia Apache 2.0 */
.textLayer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.25;
  line-height: 1;
  text-align: initial;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 2;
}

.textLayer :is(span, br) {
  position: absolute;
  color: transparent;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

.textLayer span.markedContent {
  top: 0;
  height: 0;
}

.textLayer ::selection {
  background: blue;
}

.textLayer br::selection {
  background: transparent;
}

.textLayer[data-main-rotation="90"] {
  transform: rotate(90deg) translateY(-100%);
}

.textLayer[data-main-rotation="180"] {
  transform: rotate(180deg) translate(-100%, -100%);
}

.textLayer[data-main-rotation="270"] {
  transform: rotate(270deg) translateX(-100%);
}

.status {
  margin: auto;
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
}

.message {
  grid-column: 1 / -1;
  padding: 48px 16px;
  text-align: center;
}

.message b {
  display: block;
  margin-bottom: 6px;
  font-size: 18px;
}

.message span {
  color: var(--muted);
}

.print-note {
  grid-area: pages;
  display: none;
}

.progress {
  display: none;
}

.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--yellow);
  color: #111;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}

.to-top::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-top: 2px solid;
  border-left: 2px solid;
  transform: rotate(45deg);
}

.to-top.show {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.foot {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: #777;
}

@supports (animation-timeline: scroll()) {
  .progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
    display: block;
    width: 100%;
    height: 3px;
    background: var(--yellow);
    transform: scaleX(0);
    transform-origin: 0 50%;
    animation: progress linear both;
    animation-timeline: scroll(root);
  }
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  html {
    scroll-behavior: smooth;
  }

  .doc,
  .doc::after,
  .to-top,
  .download,
  .download svg {
    transition: background-color .2s, color .2s, opacity .2s, transform .2s, visibility .2s;
  }

  .download:hover svg {
    transform: translateY(2px);
  }

  .side {
    view-transition-name: side;
  }

  ::view-transition-old(*.bridge-top),
  ::view-transition-new(*.bridge-top) {
    transform-origin: 100% 100%;
  }

  ::view-transition-old(*.bridge-bottom),
  ::view-transition-new(*.bridge-bottom) {
    transform-origin: 100% 0;
  }

  ::view-transition-old(*.bridge-corner):only-child {
    animation: fold .12s ease-in both;
  }

  ::view-transition-old(*.bridge):only-child {
    animation: detach .2s ease-in .1s both;
  }

  ::view-transition-new(*.bridge):only-child {
    animation: attach .25s cubic-bezier(.2, .8, .2, 1) .1s both;
  }

  ::view-transition-new(*.bridge-corner):only-child {
    animation: spread .16s ease-out .33s both;
  }

  .page {
    transition: opacity .2s;
  }

  .page canvas.fade {
    animation: fade-in .3s ease-out;
  }

  .skeleton::after {
    content: "";
    display: block;
    height: 100%;
    background: linear-gradient(100deg, transparent 35%, rgba(255, 255, 255, .8) 50%, transparent 65%);
    animation: shimmer 1.4s ease-in-out infinite;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes attach {
  from {
    clip-path: inset(0 100% 0 0 round 0 var(--radius) var(--radius) 0);
  }

  85% {
    clip-path: inset(0 0 0 0 round 0 var(--radius) var(--radius) 0);
  }

  to {
    clip-path: inset(0 round 0);
  }
}

@keyframes detach {
  from {
    clip-path: inset(0 round 0);
  }

  15% {
    clip-path: inset(0 0 0 0 round 0 var(--radius) var(--radius) 0);
  }

  to {
    clip-path: inset(0 100% 0 0 round 0 var(--radius) var(--radius) 0);
  }
}

@keyframes spread {
  from {
    transform: scale(0);
  }
}

@keyframes fold {
  to {
    transform: scale(0);
  }
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(100%);
  }
}

@keyframes progress {
  to {
    transform: scaleX(1);
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "dtitle"
      "cats"
      "doctitle"
      "pages";
    --gap: 12px;
    padding: 14px 12px 0;
  }

  .top {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--gap);
  }

  .logo img {
    width: 200px;
  }

  .client h1 {
    font-size: 18px;
  }

  .client .sep {
    display: none;
  }

  .client .ico {
    display: block;
  }

  .side {
    position: static;
    padding-bottom: 0;
  }

  .bridge {
    display: none;
  }

  .doc-cat {
    font-size: 18px;
  }

  .doc-name {
    font-size: 20px;
  }

  .pages {
    gap: 10px;
    padding: 8px;
  }

  .to-top {
    right: 16px;
    bottom: 16px;
  }
}

@media print {
  .pages,
  .progress,
  .to-top,
  .download {
    display: none;
  }

  .print-note {
    display: block;
    padding: 24px 0;
    color: #000;
  }
}
