/* bekr.uz. Dyes: nil (indigo), ipak (raw silk), anor (pomegranate), zar (saffron), feruza (turquoise), tut (mulberry).
   The cloth is one canvas fixed behind the page; each .panel is a length of it, and says which dye its ground is.
   Until the cloth is woven, and wherever it cannot be, each panel is plain colour with its name in plain type. */
@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("/fonts/unbounded-latin.woff2") format("woff2");
}
*, *::before, *::after { box-sizing: border-box; }
html { background: #1c2566; }
body { margin: 0; }
[hidden] { display: none !important; }

.loom {
  --ipak: #f3ead4;
  --zar: #eba51d;
  --foot: clamp(4.5rem, 13svh, 7.5rem);
  position: relative;
  color: var(--ipak);
  font-family: "Unbounded", system-ui, sans-serif;
}

.cloth {
  position: fixed;
  inset: 0 auto auto 0;
  width: 100%;
  height: 100lvh;
  display: block;
  touch-action: pan-y;
  cursor: grab;
  opacity: 0;
}
.cloth:active { cursor: grabbing; }
.woven .cloth { opacity: 1; }

.panel {
  --ground: #1c2566;
  --deep: #141a4b;
  --letter: var(--ipak);
  position: relative;
  height: clamp(24rem, 66svh, 42rem);
  background: var(--ground);
  pointer-events: none;
}
.panel.hero { height: 100svh; }
.panel[data-dye="anor"] { --ground: #b8243a; --deep: #7c1627; }
.panel[data-dye="feruza"] { --ground: #177f78; --deep: #0e524e; }
.panel[data-dye="zar"] { --ground: #e39f1c; --deep: #8f5c0d; --letter: #1c2566; }
.panel[data-dye="tut"] { --ground: #3b1d52; --deep: #261236; }
.woven .panel { background: none; }

.name {
  position: absolute;
  inset: 0 0 var(--foot) 0;
  margin: 0;
  padding: 0 6vw;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--letter);
  font-weight: 900;
  font-size: clamp(2.6rem, 9vw, 9rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
}
.hero .name { font-size: clamp(3.5rem, 19vw, 17rem); }
.woven:not(.typed) .name {
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  inset: auto;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
}

.foot {
  position: absolute;
  inset: auto 0 0 0;
  height: var(--foot);
  padding: 0.7rem clamp(1.1rem, 4vw, 3.5rem) 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  background: var(--deep);
  font-size: clamp(0.95rem, 0.6rem + 0.9vw, 1.35rem);
  font-weight: 500;
  line-height: 1.2;
}
.woven .foot { background: none; }
.foot > * { margin: 0; pointer-events: auto; }

.title { grid-column: 1; justify-self: start; }
.about {
  grid-column: 1 / 3;
  justify-self: start;
  max-width: 34em;
  font-size: 0.82em;
  font-weight: 400;
  line-height: 1.35;
}
.link {
  grid-column: 3;
  justify-self: end;
  color: inherit;
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-color: var(--zar);
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.3em;
}
.link:hover { text-decoration-color: var(--ipak); }

/* The first screen has no title: the link stands at the left of its foot, and the hint at the right. */
.hero .link { grid-column: 1; justify-self: start; }
.hero .hint { grid-column: 2 / 4; justify-self: end; }

.hint {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 1.1em;
  font-size: 0.72em;
  font-weight: 400;
  color: rgb(243 234 212 / 0.8);
  transition: color 0.6s;
}
.hint.done { color: rgb(243 234 212 / 0.45); }
.by-touch { display: none; }
@media (hover: none) {            /* a finger scrolls the cloth; only a mouse can take hold of a thread */
  .by-mouse { display: none; }
  .by-touch { display: inline; }
}
.sound {
  font: inherit;
  color: var(--ipak);
  background: none;
  border: 1px solid rgb(243 234 212 / 0.45);
  border-radius: 999px;
  padding: 0.35em 0.9em;
  cursor: pointer;
}
.sound:hover { border-color: var(--ipak); }
.sound[aria-pressed="true"] { background: var(--ipak); color: #141a4b; border-color: var(--ipak); }

/* The version with the names in type: the letters stay on the cloth, each with a ring of the next dye, and move with the threads. */
[data-names="type"] .name { text-wrap: balance; -webkit-text-stroke: 0.11em var(--ring, #c4283c); paint-order: stroke fill; }
[data-names="type"] .panel[data-dye="anor"] { --ring: #1c2566; }
[data-names="type"] .panel[data-dye="zar"] { --ring: #f3ead4; }
[data-names="type"] .panel[data-dye="tut"] { --ring: #eba51d; }
[data-names="type"] .panel:not(.hero) .name { padding-top: 5.5rem; font-size: clamp(2.6rem, 12vw, 8.4rem); }
.word { display: inline-block; white-space: nowrap; }
.ch { display: inline-block; will-change: transform; }

.link:focus-visible,
.sound:focus-visible {
  outline: 2px solid var(--zar);
  outline-offset: 4px;
  border-radius: 3px;
}

@media (max-width: 640px) {
  .foot { grid-template-columns: 1fr auto; row-gap: 0.35rem; align-content: center; }
  .link { grid-column: 2; }
  .hero .link { grid-column: 1 / -1; }
  .hint, .hero .hint { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; justify-content: space-between; }
  .panel:not(.hero) { --foot: 8.25rem; }
  .panel:not(.hero) .foot { grid-template-columns: 1fr; row-gap: 0.6rem; }
  .panel:not(.hero) .about, .panel:not(.hero) .link { grid-column: 1; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) {
  .hint { transition: none; }
}

/* The version where each length of cloth plays an instrument (data-plays): its name stands at the top of the length,
   and the sound button stays in the corner of the window, because the sound is the point of every length. */
.plays {
  visibility: hidden;                /* still measured before the cloth is woven: the pattern leaves it room */
  position: absolute;
  inset: 0 auto auto 0;
  margin: 0;
  padding: 0.95rem clamp(1.1rem, 4vw, 3.5rem) 0.5rem;
  max-width: 68vw;
  color: var(--letter);
  font-size: clamp(0.72rem, 0.5rem + 0.55vw, 0.95rem);
  font-weight: 400;
  line-height: 1.3;
}
.woven .plays { visibility: visible; }
.panel[data-plays]:not(.hero) { height: clamp(27rem, 80svh, 50rem); }   /* room for the instrument above the name, and more thread to play */
.sound.aloft {
  position: fixed;
  inset: 0.7rem clamp(1.1rem, 4vw, 3.5rem) auto auto;
  z-index: 2;
  background: #141a4b;
  font-size: clamp(0.72rem, 0.5rem + 0.55vw, 0.95rem);
  font-weight: 400;
}
.sound.aloft[aria-pressed="true"] { background: var(--ipak); }   /* pressed, its words turn dark: the ground under them has to turn light */
.sound:focus-visible { border-radius: 999px; }                  /* the ring keeps the button's own shape */
