/* ==========================================================================
   estimato — landing, site panel and footer.
   Source of truth: docs/design/planning-wall.md (§4 grid, §5 components,
   §6 motion, §7 copy); visual reference: mockup A «Стена».
   Loaded after styles.css, which owns tokens, base type, buttons and the
   screen skeleton. about.html links this file too (panel, article, footer;
   the .about-section and .card-value rules also dress the About modal).
   Animations are declared only inside `prefers-reduced-motion: no-preference`;
   the `reduce` block closes the file.

   1. Landing and About screens
   2. Site panel
   3. Hero
   4. Wall scene (five pinned cards, "≈ 5" note)
   5. How it works
   6. Footer
   7. Form screens (create, join, join by poll link)
   8. About page (about.html)
   9. Breakpoints
   10. Motion
   ========================================================================== */

/* 1. Landing and About screens: top-aligned flow instead of the centred form layout */
.landing-screen.active,
.about-screen.active {
  display: block;
  padding: 0;
}

/* 2. Site panel --------------------------------------------------------------- */
.site-header {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-5) var(--s-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3) var(--s-4);
  flex-wrap: wrap;
}

.site-header .logo-horizontal {
  display: block;
  height: 36px;
  width: auto;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s-3);
  border-radius: var(--r-control);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}

.site-nav a:hover {
  color: var(--cobalt);
  background: var(--tint);
}

/* 3. Hero -------------------------------------------------------------------- */
.hero {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-6) var(--s-6) var(--s-8);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-7);
  align-items: center;
}

.hero-copy {
  max-width: 560px;
}

.hero-lede {
  margin-top: var(--s-5);
  max-width: 46ch;
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-4) var(--s-6);
  margin-top: var(--s-6);
}

/* 4. Wall scene --------------------------------------------------------------- */
/* Final frame of the landing scene (§6): index cards pinned above five names,
   a yellow note with the round's average. Purely decorative (aria-hidden). */
.wall-scene {
  --card-w: clamp(48px, 7.2vw, 100px);
  --card-gap: clamp(8px, 1.6vw, 22px);
  --value-size: clamp(28px, 4.2vw, 60px);
  --note-w: 148px;
  --note-h: 136px;
  position: relative;
  padding: var(--s-4) 0 calc(var(--note-h) + var(--s-5));
}

.wall-seats {
  display: flex;
  justify-content: center;
  gap: var(--card-gap);
}

.wall-seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  transform: rotate(var(--rot, 0deg));
}

.wall-card {
  position: relative;
  width: var(--card-w);
  aspect-ratio: 5 / 7;
  perspective: 800px;
  transform-style: preserve-3d;
}

.wall-pin {
  position: absolute;
  left: 50%;
  top: -6px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: var(--r-pill);
  background: var(--cobalt);
  box-shadow: 0 2px 3px rgb(20 27 61 / 0.35);
  transform: translateZ(2px);
}

/* Two faces: the front shows the value, the back is the card's ruled back.
   Without motion the front is already up. */
.wall-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-card);
  background-color: var(--sheet);
  box-shadow: var(--lift-2);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.wall-front {
  /* index card (§5): red rule near the top, two faint ruling lines below */
  background-image:
    linear-gradient(var(--marker-red), var(--marker-red)),
    linear-gradient(var(--tint), var(--tint)),
    linear-gradient(var(--tint), var(--tint));
  background-size: 100% 2px, 100% 1px, 100% 1px;
  background-position: 0 16%, 0 84%, 0 91%;
  background-repeat: no-repeat;
  font-family: var(--font-numerals);
  font-weight: 800;
  font-size: var(--value-size);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--cobalt);
}

.wall-back {
  background-image: repeating-linear-gradient(var(--tint) 0 1px, transparent 1px 6px);
  transform: rotateY(180deg);
}

.wall-back::after {
  content: "";
  width: 44%;
  aspect-ratio: 1;
  background: var(--cobalt);
  opacity: 0.6;
  -webkit-mask: url("/static/brand/mark-v2.svg") center / contain no-repeat;
  mask: url("/static/brand/mark-v2.svg") center / contain no-repeat;
}

.wall-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink);
}

.wall-note {
  position: absolute;
  right: 4%;
  bottom: 0;
  width: var(--note-w);
  height: var(--note-h);
  padding: var(--s-4) 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: var(--r-note);
  background: var(--highlighter);
  color: var(--on-highlighter);
  box-shadow: var(--lift-2);
  transform: rotate(3deg);
}

.wall-note-value {
  font-family: var(--font-numerals);
  font-weight: 800;
  font-size: 64px;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.wall-note-caption {
  font-size: 0.875rem;
  font-weight: 600;
}

/* 5. How it works ------------------------------------------------------------- */
.how {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--s-6) var(--s-9);
  scroll-margin-top: var(--s-5);
}

.how h2 {
  font-size: var(--fs-5);
  margin-bottom: var(--s-6);
}

/* Demo video (landing.js) left of the steps from 960px, above them below. aspect-ratio
   reserves the 16:9 box. The button covers the poster, pill bottom-left (the poster's
   centre has its own copy), focus ring inside the frame, which clips overflow. */
.how-grid {
  display: grid;
  gap: var(--s-6);
}

.demo-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--r-card);
  background: var(--sheet);
  box-shadow: var(--lift-1);
}

.demo-video {
  display: block;
  width: 100%;
  height: 100%; /* the height="720" attribute would otherwise letterbox the poster */
}

.demo-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: var(--s-4);
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--on-cobalt);
  font: inherit;
  cursor: pointer;
}

.demo-play:focus-visible {
  outline-offset: -3px;
}

.demo-play[hidden] {
  display: none;
}

.demo-play-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-4) 0 var(--s-3);
  border-radius: var(--r-pill);
  background: var(--cobalt);
  font-size: 0.9375rem;
  font-weight: 600;
  box-shadow: var(--lift-2);
  transition: box-shadow var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}

.demo-play:hover .demo-play-pill {
  box-shadow: inset 0 0 0 100vmax rgb(0 0 0 / 0.08), var(--lift-2);
}

.demo-play:active .demo-play-pill {
  transform: scale(0.98);
}

.demo-caption {
  margin-top: var(--s-3);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--muted);
}

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--s-6);
}

.steps li {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
}

.step-num {
  font-family: var(--font-numerals);
  font-weight: 800;
  font-size: 40px;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  color: var(--cobalt);
}

.step-title {
  display: block;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
}

.step-text {
  display: block;
  margin-top: var(--s-1);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--muted);
}

.how-polls {
  max-width: 66ch;
  margin-top: var(--s-7);
  padding-top: var(--s-5);
  border-top: 1px dashed var(--rule);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--muted);
}

/* 6. Footer ------------------------------------------------------------------- */
/* Static (not fixed): follows the active screen. Links are separated by space. */
.footer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-3) var(--s-6) var(--s-6);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  font-size: 0.875rem;
  color: var(--muted);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s-4);
}

.footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  text-decoration: none;
  text-underline-offset: 0.2em;
  transition: color var(--t-fast) var(--ease-out);
}

.footer a:hover {
  color: var(--cobalt);
  text-decoration: underline;
}

/* Hidden in the room: the room menu carries the same links through proxy buttons */
body[data-screen="pokerRoom"] .footer {
  display: none;
}

/* 7. Form screens --------------------------------------------------------------- */
/* One 440px index card on the wall: the head row (Back, theme toggle) sits
   above the card's red rule, then the heading and the fields (styles.css §7). */
.form-screen.active {
  padding: var(--s-6) var(--s-4);
}

.form-sheet {
  width: 100%;
  max-width: var(--form-max);
  padding: var(--s-4) var(--s-6) var(--s-6);
  border-radius: var(--r-sheet);
  background: var(--sheet);
  box-shadow: var(--lift-1);
}

.form-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  margin: 0 calc(-1 * var(--s-6)) var(--s-5);
  padding: 0 var(--s-5) var(--s-3);
  border-bottom: 2px solid var(--marker-red);
}

.form-head .theme-toggle {
  margin-left: auto;
}

.form-sheet h1 {
  font-size: var(--fs-4);
  margin-bottom: var(--s-5);
}

.form-sheet h1 + .form-lede {
  margin-top: calc(-1 * var(--s-3));
}

.form-lede {
  max-width: 40ch;
  margin-bottom: var(--s-5);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--muted);
}

.form-after {
  margin-top: var(--s-3);
}

/* Back: ghost button, icon inline with the text (also about.html) */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  min-height: 44px;
  padding: 0 var(--s-3) 0 var(--s-2);
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--cobalt);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out);
}

.back-btn:hover {
  background: var(--tint);
}

/* 8. About page (about.html) --------------------------------------------------- */
/* The article is one index card on the wall, like the form sheets: the head
   row (Back) sits above the card's red rule, then the heading, the lede and
   the sections. Text stays ≤ 66ch. */
.about-sheet {
  width: min(760px, 100% - 2 * var(--s-6));
  margin: 0 auto var(--s-8);
  padding: var(--s-4) var(--s-7) var(--s-7);
  border-radius: var(--r-sheet);
  background: var(--sheet);
  box-shadow: var(--lift-1);
}

.about-head {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 0 calc(-1 * var(--s-7)) var(--s-6);
  padding: 0 var(--s-6) var(--s-3);
  border-bottom: 2px solid var(--marker-red);
}

.about-sheet h1 {
  font-size: var(--fs-6);
  margin-bottom: var(--s-4);
}

.about-lede {
  max-width: 60ch;
  margin-bottom: var(--s-7);
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--muted);
}

/* Sections: shared with the About modal of index.html (h3 there, h2 here) */
.about-section {
  margin-bottom: var(--s-6);
}

.about-section h2 {
  margin-bottom: var(--s-3);
  font-size: var(--fs-3);
}

.about-section p,
.about-section li {
  max-width: 66ch;
}

.about-section p + p,
.about-section p + ul,
.about-section p + ol {
  margin-top: var(--s-3);
}

.about-section ul,
.about-section ol {
  padding-left: 1.4em;
}

.about-section li {
  margin-bottom: var(--s-2);
}

.about-section li::marker {
  color: var(--cobalt);
}

.about-section ol li::marker {
  font-family: var(--font-numerals);
  font-weight: 800;
}

/* The deck in miniature: index cards (red rule on top) on the paper, 44px
   wide, 5:7. ? and ☕ are the special cards, in marker red (§5). */
.card-values {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin: var(--s-4) 0;
}

.card-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  aspect-ratio: 5 / 7;
  border-radius: var(--r-card);
  background-color: var(--paper);
  background-image: linear-gradient(var(--marker-red), var(--marker-red));
  background-size: 100% 2px;
  background-position: 0 16%;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px var(--rule);
  font-family: var(--font-numerals);
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--cobalt);
}

.card-value.is-special {
  color: var(--marker-red);
}

.card-explanation {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--muted);
}

.about-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4) var(--s-6);
  margin-top: var(--s-7);
  padding-top: var(--s-5);
  border-top: 1px dashed var(--rule);
}

.about-note {
  color: var(--muted);
}

/* 9. Breakpoints -------------------------------------------------------------- */
@media (min-width: 960px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: var(--s-8);
    padding-top: var(--s-7);
    padding-bottom: var(--s-9);
  }

  .how-grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: var(--s-8);
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: var(--s-4);
  }

  .site-header .logo-horizontal {
    height: 30px;
  }

  .hero {
    padding: var(--s-5) var(--s-4) var(--s-7);
    gap: var(--s-6);
  }

  .hero-lede {
    font-size: 1rem;
  }

  .hero-actions {
    margin-top: var(--s-5);
  }

  .wall-scene {
    --note-w: 112px;
    --note-h: 104px;
  }

  .wall-note {
    padding: var(--s-3) var(--s-4);
  }

  .wall-note-value {
    font-size: 44px;
  }

  .how {
    padding: 0 var(--s-4) var(--s-8);
  }

  .how h2 {
    font-size: var(--fs-4);
  }

  /* text-only pill: it clears the poster's own bottom line on phones */
  .demo-play .icon {
    display: none;
  }

  .footer {
    padding: var(--s-2) var(--s-4) var(--s-5);
  }

  .about-sheet {
    width: calc(100% - 2 * var(--s-4));
  }
}

@media (max-width: 640px) {
  .form-screen.active {
    justify-content: flex-start;
    padding: var(--s-3) var(--s-3) var(--s-6);
  }

  .form-sheet {
    padding: var(--s-2) var(--s-5) var(--s-5);
  }

  .form-head {
    margin: 0 calc(-1 * var(--s-5)) var(--s-5);
    padding: 0 var(--s-4) var(--s-2);
  }

  .about-sheet {
    margin-bottom: var(--s-6);
    padding: var(--s-2) var(--s-5) var(--s-6);
  }

  .about-head {
    margin: 0 calc(-1 * var(--s-5)) var(--s-5);
    padding: 0 var(--s-4) var(--s-2);
  }

  .about-sheet h1 {
    font-size: var(--fs-5);
  }

  .about-lede {
    margin-bottom: var(--s-6);
    font-size: 1rem;
  }

  .about-cta .btn {
    width: 100%;
  }
}

/* 10. Motion ------------------------------------------------------------------ */
/* One orchestrated scene, once (§6): cards pin to the wall 90 ms apart, flip
   over 60 ms apart, then the note lands. Everything is settled by 1.8 s. */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .wall-card {
    animation: wall-settle 500ms var(--ease-spring) calc(var(--i, 0) * 90ms) both;
  }

  .wall-front {
    animation: wall-flip-in var(--t-flip) var(--ease-out) calc(700ms + var(--i, 0) * 60ms) both;
  }

  .wall-back {
    animation: wall-flip-out var(--t-flip) var(--ease-out) calc(700ms + var(--i, 0) * 60ms) both;
  }

  .wall-note {
    animation: wall-land 420ms var(--ease-spring) 1300ms both;
  }

  @keyframes wall-settle {
    from {
      opacity: 0;
      transform: translateY(-28px) scale(1.04);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes wall-flip-in {
    from {
      transform: rotateY(-180deg);
    }

    to {
      transform: rotateY(0deg);
    }
  }

  @keyframes wall-flip-out {
    from {
      transform: rotateY(0deg);
    }

    to {
      transform: rotateY(180deg);
    }
  }

  @keyframes wall-land {
    from {
      opacity: 0;
      transform: translateY(-12px) rotate(9deg) scale(1.08);
    }

    to {
      opacity: 1;
      transform: rotate(3deg);
    }
  }
}

/* Reduced motion: no animations exist above, and every transition here takes
   its duration from --t-fast, which styles.css collapses to 0 ms. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
