/*
 * Zazvoň 89: layout and components.
 * Values come from tokens.css; component order follows the page.
 */

/* ---------- Base ---------- */

:root {
  box-sizing: border-box;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

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

html {
  /* Anchor jumps (#transparent) land below the sticky top bar. */
  scroll-padding-top: calc(var(--safe-top) + 100px);
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
  -webkit-font-smoothing: antialiased;
}

/* Keeps the notch area covered when the page scrolls under it. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  z-index: 46;
  height: var(--safe-top);
  background: var(--color-bg);
}

/* Film grain over the whole page. It flickers for under 5 seconds after
   loading and then stays still (WCAG 2.2.2). */
body::after {
  content: "";
  position: fixed;
  inset: -50%;
  z-index: 50;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("../img/grain.svg");
  animation: grain .6s steps(4) 8;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-1%, 3%); }
}

@keyframes bump {
  0% { color: var(--color-blue); transform: scale(1.06); }
  100% { color: inherit; transform: none; }
}

button {
  font: inherit;
  text-transform: uppercase;
  cursor: pointer;
}

button:active {
  transform: translateY(2px);
}

button:focus-visible,
a:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

/* Hidden on screen, still available to scripts and assistive technology. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.page {
  position: relative;
  z-index: 1;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: var(--safe-top);
  z-index: 45;
  padding-bottom: 6px;
  background: var(--color-bg);
  box-shadow: 0 0 0 100vmax var(--color-bg);
  clip-path: inset(0 -100vmax -14px -100vmax);
}

.topbar.is-stuck {
  box-shadow: 0 0 0 100vmax var(--color-bg), 0 8px 14px -10px var(--color-shadow);
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 18px 0 12px;
  border-bottom: var(--border) solid var(--color-ink);
  font-family: var(--font-display);
  letter-spacing: .01em;
}

.site-header__date {
  margin: 0;
  font-size: clamp(28px, 7vw, 44px);
  line-height: .9;
}

.site-header__aside {
  display: flex;
  align-items: flex-end;
  gap: clamp(8px, 1.5vw, 14px);
}

.site-header__ribbon {
  display: block;
  width: auto;
  height: clamp(30px, 4.4vw, 40px);
  margin-bottom: -1px;
}

.site-header__years {
  margin: 0;
  font-size: clamp(15px, 3.6vw, 19px);
  line-height: 1.1;
  text-align: right;
}

.site-header,
.site-header__date,
.site-header__years,
.site-header__ribbon {
  transition: padding .25s ease, font-size .25s ease, height .25s ease;
}

.topbar.is-stuck .site-header {
  padding: 8px 0 6px;
}

.topbar.is-stuck .site-header__date {
  font-size: clamp(20px, 4.5vw, 28px);
}

.topbar.is-stuck .site-header__years {
  font-size: 13px;
}

.topbar.is-stuck .site-header__ribbon {
  height: 24px;
}

.tricolour {
  display: flex;
  height: 8px;
  margin-top: 6px;
}

.topbar.is-stuck .tricolour {
  height: 5px;
}

.tricolour__stripe {
  flex: 1;
}

.tricolour__stripe--white {
  background: var(--color-bg);
  outline: 1px solid var(--color-line);
}

.tricolour__stripe--blue {
  background: var(--color-blue);
}

.tricolour__stripe--red {
  background: var(--color-red);
}

/* Compact counter shown in the bar once it sticks. */
.topbar-count {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  max-width: 0;
  margin: 0 4px 0 0;
  overflow: hidden;
  line-height: 1;
  opacity: 0;
  transition: opacity .25s ease, max-width .3s ease;
}

.topbar.is-stuck .topbar-count:not(.is-off) {
  max-width: 170px;
  opacity: 1;
}

.topbar-count__value {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: .01em;
  transform-origin: right bottom;
}

.topbar-count__label {
  margin-top: 2px;
  color: var(--color-mute);
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .05em;
  white-space: nowrap;
}

/* ---------- Hero ---------- */

.hero__stage-wrap {
  position: relative;
}

.counter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 6px;
  margin: 0;
  padding: 12px 0 0;
  text-align: right;
}

.counter__total {
  display: inline-block;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(30px, 8vw, 44px);
  font-variant-numeric: tabular-nums;
  line-height: .9;
  transform-origin: right bottom;
}

.counter__label {
  margin: 0;
  color: var(--color-mute);
  font-size: 13px;
  letter-spacing: .04em;
}

.is-bumped {
  animation: bump .9s ease-out;
}

.slogan {
  position: absolute;
  top: 0;
  left: var(--gutter);
  margin: 0;
  font-family: var(--font-marker);
  font-size: clamp(40px, 4.6vw, 64px);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: 0;
  /* A long word may break rather than be cut off with larger text spacing (WCAG 1.4.12). */
  overflow-wrap: break-word;
  pointer-events: none;
  transform: rotate(-4deg);
}

.slogan__line--1 {
  font-size: .72em;
}

.slogan__line--2 {
  color: var(--color-blue);
}

.slogan__line--3 {
  display: block;
  width: max-content;
  color: var(--color-red);
  font-size: .96em;
  transform: translate(.3em, .05em) rotate(2deg);
}

.keys-stage {
  position: relative;
  height: min(62vh, 600px);
  min-height: 380px;
  margin: 22px calc(-1 * var(--gutter)) 0;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

.keys-stage:focus-visible {
  outline: var(--focus-ring);
  outline-offset: -3px;
}

.keys-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Without (GPU) WebGL the stage shows a still render of the keys at rest
   (captured from the 3D scene); tapping still rings and counts. */
.keys-stage.is-static {
  background: url("../img/keys-static.webp") center 30% / auto 82% no-repeat;
}

.keys-stage__hint {
  position: absolute;
  top: 50%;
  right: clamp(16px, 6vw, 70px);
  max-width: 6.2em;
  margin: 0;
  color: var(--color-ink);
  font-family: var(--font-marker);
  font-size: clamp(22px, 3vw, 38px);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: .01em;
  text-align: left;
  pointer-events: none;
  transform: translateY(-50%) rotate(-3deg);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 16px 0 28px;
}

.button {
  min-height: 56px;
  padding: 14px 22px;
  border: var(--border) solid var(--color-ink);
  background: var(--color-ink);
  color: var(--color-on-ink);
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: .02em;
}

.button--primary {
  border-color: var(--color-blue);
  background: var(--color-blue);
}

.button--primary:hover {
  border-color: var(--color-blue-dark);
  background: var(--color-blue-dark);
}

/* ---------- Share ---------- */

.share {
  margin: 60px 0 44px;
}

.share__title {
  margin: 0 0 20px;
  font-family: var(--font-marker);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.3;
  transform: rotate(-2deg);
  transform-origin: left;
}

.share__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 16px;
  border: var(--border) solid var(--color-ink);
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: .03em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
}

.share__button:hover {
  background: var(--color-ink);
  color: var(--color-on-ink);
}

.share__button--facebook:hover {
  border-color: var(--color-blue);
  background: var(--color-blue);
}

.share__button--instagram:hover {
  border-color: var(--color-instagram);
  background: var(--gradient-instagram);
}

.share__message {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: var(--color-mute);
  font-size: 14px;
}

/* ---------- Story ---------- */

.story__paragraph {
  max-width: 34em;
  margin: 0 0 40px;
  font-family: var(--font-typewriter);
  font-size: 19px;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0;
  text-transform: none;
}

.story__paragraph + .story__paragraph {
  margin-top: -20px;
}

/* ---------- Banner ---------- */

.banner {
  max-width: 640px;
  margin: 48px 0 20px;
}

.banner__title {
  margin: 0 0 8px;
  font-family: var(--font-marker);
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 400;
  line-height: 1.25;
  transform: rotate(-2deg);
  transform-origin: left;
}

.banner__title-blue {
  color: var(--color-blue);
}

.banner__title-red {
  color: var(--color-red);
}

.banner__intro {
  margin: 0 0 18px;
  font-family: var(--font-typewriter);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
  text-transform: none;
}

.banner__label {
  display: block;
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: .04em;
}

.banner__input {
  width: 100%;
  padding: 14px;
  border: var(--border) solid var(--color-ink);
  border-radius: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font: 400 22px/1.2 var(--font-marker);
  text-transform: uppercase;
  -webkit-appearance: none;
  appearance: none;
}

.banner__input:focus {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.banner__input::placeholder {
  color: var(--color-placeholder);
}

.banner__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 18px;
}

.banner__chip,
.banner__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--border) solid var(--color-ink);
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: .03em;
}

.banner__chip {
  min-height: 40px;
  padding: 6px 12px;
  border-width: var(--border-thin);
  font-size: 14px;
}

.banner__chip:hover,
.banner__action:hover {
  background: var(--color-ink);
  color: var(--color-on-ink);
}

.banner__preview {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  margin: 0 0 14px;
}

.banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.banner__action {
  min-height: 48px;
  padding: 10px 18px;
  font-size: 17px;
}

.banner__action--instagram {
  background: var(--color-ink);
  color: var(--color-on-ink);
}

.banner__action--instagram:hover {
  border-color: var(--color-instagram);
  background: var(--gradient-instagram);
}

.banner__message {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--color-mute);
  font-size: 14px;
}

/* ---------- Brush strokes ---------- */

.brush {
  position: relative;
  width: 100vw;
  height: clamp(170px, 26vw, 330px);
  margin: 34px 0 0 calc(50% - 50vw);
  overflow: hidden;
  pointer-events: none;
}

.brush__stroke {
  position: absolute;
  width: max(120%, 560px);
  max-width: 1500px;
  height: auto;
}

.brush__stroke--red {
  top: 2%;
  left: -12%;
  transform: rotate(-5deg);
}

.brush__stroke--blue {
  top: 38%;
  right: -14%;
  transform: rotate(3.5deg) scaleX(-1);
}

/* ---------- Footer ---------- */

.site-footer {
  position: relative;
  z-index: 1;
  padding: 22px var(--gutter) 28px;
  color: var(--color-mute);
  font-size: 13px;
  letter-spacing: .06em;
  text-align: center;
}

.site-footer a {
  border-bottom: 1px solid currentColor;
  color: var(--color-ink);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--color-blue);
}

/* ---------- Responsive ---------- */

/* Desktop: slogan and counter overlay the keys (a short landscape screen below overrides this). */
@media (min-width: 1100px) {
  .slogan {
    top: 36px;
    z-index: 2;
  }

  .keys-stage {
    margin-top: 36px;
  }

  .counter {
    position: absolute;
    top: 22px;
    right: 0;
    z-index: 3;
    padding: 0;
  }

  .counter__total {
    font-size: clamp(44px, 4vw, 64px);
  }
}

/* Phones and tablets: counter, slogan and keys stacked, hint under the keys.
   The counter follows the heading in the markup (reading order) but is shown above it. */
@media (max-width: 1099px) {
  .hero__stage-wrap {
    display: flex;
    flex-direction: column;
  }

  .counter {
    order: -1;
  }

  .slogan {
    position: static;
    margin: 20px 0 -6px;
    font-size: clamp(40px, 12.4vw, 60px);
  }

  .slogan__line--3 {
    white-space: nowrap;
  }

  .keys-stage {
    height: min(58vh, 520px);
    height: min(calc(100svh - 280px - 3.3 * clamp(40px, 12.4vw, 60px)), 520px);
    min-height: 270px;
    margin-top: 0;
  }

  .keys-stage__hint {
    top: auto;
    right: 0;
    bottom: 4px;
    left: 0;
    max-width: none;
    font-size: clamp(16px, 3.4vw, 22px);
    text-align: center;
    transform: none;
  }
}

@media (max-width: 400px) {
  .topbar-count__value {
    font-size: 19px;
  }

  .topbar-count__label {
    font-size: 8px;
  }
}

@media (max-width: 359px) {
  .keys-stage__hint {
    right: 6px;
    font-size: 14px;
  }
}

/* Phones held sideways: everything overlays the keys. */
@media (orientation: landscape) and (max-height: 520px) {
  .hero__stage-wrap {
    display: block;
  }

  .site-header {
    padding: 10px 0 8px;
  }

  .site-header__date {
    font-size: 28px;
  }

  .keys-stage {
    height: calc(100vh - 90px);
    min-height: 240px;
    margin-top: 8px;
  }

  .slogan {
    position: absolute;
    top: 18px;
    left: var(--gutter);
    z-index: 2;
    margin: 0;
    font-size: clamp(26px, 4.4vw, 40px);
  }

  .keys-stage__hint {
    top: 50%;
    right: var(--gutter);
    bottom: auto;
    left: auto;
    max-width: 6.2em;
    font-size: 20px;
    text-align: left;
    transform: translateY(-50%) rotate(-3deg);
  }

  .counter {
    position: absolute;
    top: 6px;
    right: 0;
    z-index: 3;
    gap: 2px;
    padding: 0;
  }
}

@media (min-width: 1080px) {
  .page {
    max-width: var(--page-width-wide);
  }

  .story__paragraph {
    max-width: 40em;
  }
}

@media (min-width: 1100px) {
  .keys-stage {
    height: min(70vh, 680px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::after {
    animation: none;
  }

  .is-bumped {
    animation: none;
  }
}
