@property --angle {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}

:root {
  --page: #08080a;
  --bg: #131316;
  --fg: #f3f3f7;
  --soft: #b9b9c4;
  --muted: #6e6e7a;
  /* Barvu aktivního webu nastavuje script.js. */
  --accent: var(--fg);
  --accent-ink: var(--bg);
  --ease: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --display: "Climate Crisis", "Arial Black", sans-serif;
  --frame-gap: 8px;
  --radius: 20px;
  --thumb-gap: 8px;
  --thumb-max: 112px;
  --cols: 3;
}

@media (min-width: 641px) {
  :root {
    --thumb-gap: 12px;
    --thumb-max: 150px;
    --cols: 5;
  }
}

@media (min-width: 768px) {
  :root {
    --radius: 24px;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  padding: var(--frame-gap);
  background: var(--page);
  color: var(--fg);
  font-family: "Space Grotesk", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Layout ---------- */

/* Box se zaoblenými rohy, ve kterém je celý obsah. */
.frame {
  position: relative;
  min-height: calc(100svh - 2 * var(--frame-gap));
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 5vh, 4rem);
  padding: 2rem 16px;
}

@media (min-width: 768px) {
  .stage {
    padding-inline: 32px;
  }
}

/* ---------- Úvodní animace ---------- */

/* Dokud se stránka načítá, obsah je schovaný (jen když běží JavaScript). */
.js .frame:not(.is-ready) .thumbs,
.js .frame:not(.is-ready) .bar {
  visibility: hidden;
}

.loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity 0.4s, transform 0.5s var(--ease);
}

html:not(.js) .loader,
.frame.is-loaded .loader {
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
}

.loader-track {
  width: min(200px, 50vw);
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

/* Gradient je natažený přes celou dráhu a odkrývá se zleva. */
.loader-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--bar-colors, #fff, #fff));
  clip-path: inset(0 calc((1 - var(--p, 0)) * 100%) 0 0);
}

.loader-num {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* Záblesk po okrajích. Prstenec je maskou vyříznutý z kuželového gradientu;
   rozmazává se rodič, aby blur zasahoval i dovnitř boxu. */
.glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

.glow.is-on {
  animation: glow-breath 2.8s var(--ease) forwards;
}

@keyframes glow-breath {
  0% {
    opacity: 0;
    --angle: 0deg;
  }
  25% {
    opacity: 1;
  }
  45% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    --angle: 160deg;
  }
}

.glow-layer {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.glow-soft {
  filter: blur(16px);
}

.glow-sharp {
  filter: blur(2px);
  opacity: 0.9;
}

.glow-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: var(--w);
  background: conic-gradient(from var(--angle), var(--glow-colors, #fff, #fff));
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
}

.glow-soft .glow-ring {
  --w: 18px;
}

.glow-sharp .glow-ring {
  --w: 3px;
}

/* ---------- Náhledy ---------- */

/* Max. 5 v řadě (na mobilu 3), poslední řada je vycentrovaná.
   Šířka je daná sloupcem, výšku si určí obrázek podle svého poměru stran. */
.thumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--thumb-gap);
  width: 100%;
  max-width: calc(var(--cols) * var(--thumb-max) + (var(--cols) - 1) * var(--thumb-gap));
}

.thumb {
  flex: none;
  display: block;
  width: calc((100% - (var(--cols) - 1) * var(--thumb-gap)) / var(--cols));
  border-radius: 8px;
  overflow: hidden;
  outline: none;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.45s var(--ease-out), box-shadow 0.3s;
}

.thumb img {
  display: block;
  width: 100%;
  height: auto;
}

.thumb.is-active {
  position: relative;
  z-index: 1;
  transform: scale(1.08);
  box-shadow: 0 0 0 2px var(--c);
}

.thumb:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c);
}

.thumb-placeholder {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 22px;
  color: rgba(255, 255, 255, 0.85);
}

/* ---------- Velký nápis ---------- */

.title {
  position: relative;
  width: 100%;
  height: var(--title-h, 30vh);
  overflow: hidden;
  font-family: var(--display);
  text-transform: uppercase;
  user-select: none;
}

.word {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  column-gap: 0.35em;
  line-height: 1.3;
  color: var(--fg);
}

/* Každé slovo ořezává svá písmena, takže na víc řádcích se nepřekrývají. */
.token {
  display: flex;
  overflow: hidden;
}

.char {
  display: inline-block;
  will-change: transform;
}

/* ---------- Tlačítko na mobilu ---------- */

.visit {
  display: none;
}

@media (hover: none) {
  .visit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 22px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 500;
    font-size: 16px;
    text-decoration: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.4s var(--ease), visibility 0s 0.4s, background-color 0.3s, color 0.3s;
  }

  .visit.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.3s, transform 0.4s var(--ease), background-color 0.3s, color 0.3s;
  }
}

/* ---------- Kurzor ---------- */

/* Pozici, velikost a protažení řídí script.js; barvy se prolínají přes CSS. */
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  pointer-events: none;
  transform: translate3d(-200px, -200px, 0);
}

.cursor-dot {
  position: absolute;
  width: 88px;
  height: 88px;
  margin: -44px 0 0 -44px;
  border-radius: 50%;
  background: var(--fg);
  transform: scale(0);
  transition: background-color 0.4s var(--ease);
}

.cursor[data-state="link"] .cursor-dot {
  background: rgba(243, 243, 247, 0.22);
}

.cursor[data-state="project"] .cursor-dot {
  background: var(--accent);
}

.cursor-arrow {
  position: absolute;
  margin: -11px 0 0 -11px;
  color: var(--accent-ink);
  opacity: var(--arrow, 0);
  transform: scale(calc(0.4 + var(--arrow, 0) * 0.6)) rotate(calc((1 - var(--arrow, 0)) * -90deg));
  transition: color 0.4s var(--ease);
}

/* Systémový kurzor schováme, jen když máme myš a vlastní kolečko běží. */
@media (hover: hover) and (pointer: fine) {
  .has-cursor,
  .has-cursor * {
    cursor: none !important;
  }
}

@media (hover: none) {
  .cursor {
    display: none;
  }
}

/* ---------- Spodní lišta ---------- */

/* Vpravo bez odsazení: čárka na konci loga lícuje s pravým okrajem boxu.
   Spodní odsazení = zaoblení rohu, aby čárku roh neořízl. */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 var(--radius) 16px;
}

@media (min-width: 768px) {
  .bar {
    padding-left: 32px;
  }
}

.contact {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.email {
  color: var(--soft);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s;
}

.email:hover {
  color: var(--fg);
}

.copy {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}

.copy:hover,
.copy.is-done {
  color: var(--fg);
}

.copy:focus-visible {
  color: var(--fg);
  outline: 2px solid var(--fg);
  outline-offset: 1px;
}

.copy .icon-check,
.copy.is-done .icon-copy {
  display: none;
}

.copy.is-done .icon-check {
  display: block;
}

.copied {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  font-size: 12px;
  color: var(--fg);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.copied.is-visible {
  opacity: 1;
  transform: none;
}

.logo {
  flex: none;
  display: block;
  height: 20px;
  width: auto;
}

@media (min-width: 768px) {
  .logo {
    height: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0s !important;
  }

  .glow.is-on {
    animation-duration: 1.2s;
  }
}
