/* The tutorial at /how-to-play (D136). One column at every width, like the
   archive. Tokens come from style.css, loaded first. */
.tutorial {
  --tutorial-col: 560px;
  overflow-x: clip;
}

.tutorial [hidden] {
  display: none !important;
}

.tutorial .site-header {
  margin-bottom: 0;
}

.tutorial .site-header-inner {
  max-width: var(--tutorial-col);
}

.tutorial-page {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  gap: var(--space-7);
  width: 100%;
  max-width: var(--tutorial-col);
  margin: 0 auto;
  padding-bottom: var(--space-7);
}

.tutorial .site-footer {
  width: 100%;
  max-width: var(--tutorial-col);
  margin-inline: auto;
}

.tutorial-page p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.tutorial-page h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tutorial-page h3 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 700;
}

.tutorial-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.tutorial-section ol,
.tutorial-section ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* --- The hero, with the popup's own animated diagram. --- */
.tutorial-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-2);
  text-align: center;
}

.tutorial-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 2.75rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.tutorial-lede {
  max-width: 36ch;
  font-size: 1.05rem;
  text-wrap: balance;
}

.tutorial-diagram {
  width: 100%;
  max-width: 320px;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.tutorial-diagram .howto-diagram {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
}

/* --- The rules: numbered like a chain's own links. --- */
.tutorial-rules {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  counter-reset: rule;
}

.tutorial-rules li {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-left: 52px;
  counter-increment: rule;
}

.tutorial-rules li::before {
  content: counter(rule);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid transparent;
  border-radius: 50%;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--link-from), var(--link-to)) border-box;
  color: var(--text);
  font-weight: 800;
}

/* The line that joins one rule's badge to the next. */
.tutorial-rules li:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 40px;
  bottom: calc(-1 * var(--space-4) + 4px);
  left: 17px;
  width: 2px;
  background: linear-gradient(var(--link-from), var(--link-to));
  opacity: 0.5;
}

/* --- Scoring. --- */
.tutorial-scores {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.tutorial-scores li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* An odd last card spans the row, so the grid ends square. */
.tutorial-scores li:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.tutorial-scores b {
  font-size: var(--text-xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.tutorial-scores .is-blue {
  color: var(--accent-bright);
}

.tutorial-scores .is-gold {
  color: var(--accent-2);
}

.tutorial-scores .is-red {
  color: var(--danger);
}

.tutorial-callout {
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--accent-2);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: rgb(var(--accent-2-rgb) / 0.08);
}

.tutorial-callout strong {
  color: var(--accent-2);
}

/* --- Challenges: four chips. --- */
.tutorial-challenges {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.tutorial-challenges li {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.tutorial-challenges h3 {
  color: var(--accent-2);
}

.tutorial-challenges p {
  font-size: var(--text-sm);
  line-height: 1.45;
}

/* --- Reels (D156): the three rewards, one to a row, styled as the chips. */
.tutorial-reels {
  display: grid;
  gap: var(--space-2);
}

.tutorial-reels li {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.tutorial-reels h3 {
  color: var(--accent-2);
}

.tutorial-reels p {
  font-size: var(--text-sm);
  line-height: 1.45;
}

/* --- Tips: cards edged blue into gold, as where the logo's strokes cross. */
.tutorial-tips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: var(--space-3);
}

.tutorial-tip {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
  align-content: start;
  padding: var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(
        120% 80% at 0% 0%,
        rgb(var(--accent-bright-rgb) / 0.12),
        transparent 70%
      )
      padding-box,
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--link-from), var(--link-to)) border-box;
}

.tutorial-tip svg {
  grid-row: span 2;
  width: 32px;
  height: 32px;
  color: var(--accent-2);
}

.tutorial-tip p {
  font-size: var(--text-sm);
  line-height: 1.5;
}

@media (prefers-reduced-motion: no-preference) {
  .tutorial-tip svg {
    transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.4);
  }

  .tutorial-tip:hover svg {
    transform: rotate(-8deg) scale(1.12);
  }
}

/* --- FAQ. --- */
.tutorial-faq {
  border-bottom: 1px solid var(--border);
}

.tutorial-faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 52px;
  cursor: pointer;
  list-style: none;
}

.tutorial-faq summary::-webkit-details-marker {
  display: none;
}

.tutorial-faq summary::after {
  content: '+';
  color: var(--accent-bright);
  font-size: var(--text-lg);
  font-weight: 700;
}

.tutorial-faq[open] summary::after {
  content: '−';
}

.tutorial-faq p {
  padding-bottom: var(--space-4);
}

/* --- The end. --- */
.tutorial-end {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}

.tutorial-end .btn {
  min-width: 220px;
  text-decoration: none;
}

.tutorial-archive {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent-bright);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
}

/* --- The changelog (D152): the tutorial's frame, one card a version. --- */
.changelog-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.changelog-version {
  padding: 2px var(--space-3);
  border: 1px solid var(--accent-2);
  border-radius: var(--radius-pill);
  color: var(--accent-2);
  font-weight: 700;
}

.tutorial-section .changelog-changes {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-left: 1.35rem;
  list-style: disc;
  color: var(--muted);
  line-height: 1.55;
}

.changelog-changes li::marker {
  color: var(--accent-2);
}

.changelog-more {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.changelog-more a,
.changelog-discord a {
  color: var(--accent-bright);
  font-weight: 600;
}
