/* =============================================
   guides.css — the Guides section (/guides/, /ru/guides/)
   Builds on shared.css tokens. A page sets --accent on <body>
   to its app's colour: StitchHub #B55A72, Needleply #C96E5A,
   the indexes the hub's #EB6260.
   ============================================= */

body.guide-page {
  --accent: #EB6260;
  --column: 720px;
  padding-top: 61px;
}

/* the RU articles' App Store button (the English ones show the badge) */
.guide-download {
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.2s;
}

.guide-download:hover {
  opacity: 0.88;
}

.guide-download:active {
  transform: scale(0.97);
}

/* ── ARTICLE ── */
.guide {
  max-width: calc(var(--column) + 2 * var(--px));
  margin: 0 auto;
  padding: 48px var(--px) 24px;
}

.guide-eyebrow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.guide-eyebrow img {
  width: 24px;
  height: 24px;
  border-radius: 22%;
  box-shadow: 0 1px 4px rgba(42, 37, 35, 0.12);
}

.guide h1 {
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.035em;
  margin-bottom: 18px;
}

.guide-lead {
  font-size: 1.15rem;
  line-height: 1.65;
  color: var(--ink-muted);
  margin-bottom: 28px;
}

.guide h2 {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 48px 0 14px;
}

.guide h3 {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 26px 0 8px;
}

.guide p,
.guide li {
  font-size: 1.02rem;
  line-height: 1.75;
}

.guide p + p {
  margin-top: 14px;
}

.guide strong {
  font-weight: 800;
}

.guide a:not(.guide-download):not(.guide-badge) {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: opacity 0.2s;
}

.guide a:not(.guide-download):not(.guide-badge):hover {
  opacity: 0.75;
}

.guide ul {
  margin: 12px 0 0 1.2em;
}

.guide ul li + li {
  margin-top: 6px;
}

/* one phone screenshot on one side and text about it on the other, as tall as the picture; the
   details follow below at full width (.shot-right puts the picture on the right). On a phone the
   text drops under the picture. */
.guide-shot {
  display: flex;
  align-items: center;
  gap: 36px;
  margin: 32px 0;
}

.guide-shot.shot-right {
  flex-direction: row-reverse;
}

.guide-shot > .guide-screen-single {
  flex: 0 0 250px;
  max-width: 250px;
  margin: 0;
}

.guide-shot-text {
  flex: 1 1 auto;
  min-width: 0;
}

.guide-shot-text > :first-child {
  margin-top: 0;
}

@media (max-width: 620px) {
  .guide-shot,
  .guide-shot.shot-right {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
  }

  .guide-shot > .guide-screen-single {
    flex-basis: auto;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
  }
}

/* a paragraph right after a list or the steps keeps the gap paragraphs have between them */
.guide ul + p,
.guide ol + p {
  margin-top: 16px;
}

/* numbered steps */
.guide-steps {
  list-style: none;
  counter-reset: step;
  margin: 18px 0 0;
}

.guide-steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 48px;
  margin-top: 18px;
}

.guide-steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  line-height: 32px;
  text-align: center;
}

/* the plans line and other asides */
.guide-note {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  padding: 16px 20px;
  margin: 8px 0 8px;
}

.guide-note p {
  font-size: 0.97rem;
}

/* picture types */
.guide-types {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.guide-types div {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 14px 16px;
}

.guide-types strong {
  display: block;
  margin-bottom: 2px;
}

.guide-types span {
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--ink-muted);
}

/* ── FIGURES ── */
.guide-figure {
  margin: 28px 0;
}

.guide-figure video,
.guide-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: var(--bg-alt);
  box-shadow: var(--shadow);
}

.guide-figure figcaption {
  margin-top: 10px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-muted);
}

.guide-credit {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.guide .guide-credit a {
  color: var(--ink-faint);
  font-weight: 600;
}

/* two before-and-after loops side by side */
.guide-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 28px 0;
}

.guide-pair .guide-figure {
  margin: 0;
}

/* phone screenshots */
.guide-screens {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 28px 0;
}

.guide-screens.two {
  grid-template-columns: repeat(2, minmax(0, 220px));
  justify-content: center;
}

.guide-screens .guide-figure {
  margin: 0;
}

.guide-screens img {
  border-radius: 22px;
  border: 1px solid var(--border);
}

.guide-screen-single {
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.guide-screen-single img {
  border-radius: 22px;
  border: 1px solid var(--border);
}

/* the closing call to action */
.guide-cta {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 52px 0 8px;
  padding: 22px 24px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.guide-cta > img {
  width: 64px;
  height: 64px;
  border-radius: 22%;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(42, 37, 35, 0.12);
}

.guide-cta-text {
  flex: 1;
  min-width: 0;
}

.guide-cta-text strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
}

.guide-cta-text span {
  font-size: 0.95rem;
  color: var(--ink-muted);
}

.guide-badge {
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.guide-badge img {
  display: block;
  width: 150px;
  height: auto;
}

.guide-badge:hover {
  opacity: 0.85;
}

.guide-fine {
  margin-top: 36px;
  font-size: 0.85rem !important;
  color: var(--ink-faint);
}

/* ── INDEX ── */
.guides-hero {
  max-width: calc(var(--column) + 2 * var(--px));
  margin: 0 auto;
  padding: 48px var(--px) 8px;
  text-align: center;
}

.guides-hero h1 {
  font-size: clamp(2.1rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  margin-bottom: 12px;
}

.guides-hero p {
  font-size: 1.05rem;
  color: var(--ink-muted);
  line-height: 1.7;
}

/* the cards fill the width: three in a row on a wide screen, then two, then one */
.guides-list {
  max-width: calc(1360px + 2 * var(--px));
  margin: 0 auto;
  padding: 40px var(--px) 56px;
  /* columns of cards, each card as tall as its own content and the next one right under it, so
     short cards (no picture) leave no gaps. Where a column ends is set by hand, so the first cards
     of the columns belong to different apps: .col-end-2 ends the first of two columns, .col-end-3
     ends a column of three. */
  columns: 1;
  column-gap: 24px;
}

.guides-list > .guide-card {
  break-inside: avoid;
  margin-bottom: 24px;
}

@media (min-width: 761px) {
  .guides-list {
    columns: 2;
  }

  .guides-list > .col-end-2 {
    -webkit-column-break-after: always;
    break-after: column;
  }
}

@media (min-width: 1180px) {
  .guides-list {
    columns: 3;
  }

  .guides-list > .col-end-2 {
    -webkit-column-break-after: auto;
    break-after: auto;
  }

  .guides-list > .col-end-3 {
    -webkit-column-break-after: always;
    break-after: column;
  }
}

/* with scripts on, guides.js puts the cards into these columns instead of CSS multi-column */
.guides-list.has-cols {
  columns: auto;
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.guides-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.guides-col > .guide-card {
  margin-bottom: 0;
}

.guide-card:focus-visible {
  outline-offset: 4px;
}

.guide-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
  /* the lift on hover moves `top`, not `transform`: a transformed card inside the columns makes
     Safari and Chrome stop painting it and its neighbours */
  position: relative;
  top: 0;
  transition: top 0.25s ease, box-shadow 0.25s ease;
}

.guide-card:hover {
  top: -3px;
  box-shadow: 0 22px 44px rgba(42, 37, 35, 0.09);
}

.guide-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1200 / 630;
  height: auto;
  object-fit: cover;
  background: var(--bg-alt);
}

.guide-card-body {
  padding: 18px 22px 22px;
}

.guide-card-app {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

/* how long the article takes to read, at the right of the app pills (tools/site_nav.py) */
.guide-card-time {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-faint);
  white-space: nowrap;
}

.guide-card-app img {
  width: 18px;
  height: 18px;
  aspect-ratio: 1;
  border-radius: 22%;
}

.guide-card h2 {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin-bottom: 6px;
}

.guide-card p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink-muted);
}

.guide-card-plain .guide-card-body {
  padding-top: 22px;
}

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  .guide-screens {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .guide-download {
    padding: 7px 12px;
    font-size: 13px;
  }

  .guide {
    padding-top: 32px;
  }

  .guide-pair,
  .guide-types {
    grid-template-columns: 1fr;
  }

  .guide-cta {
    flex-direction: column;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {

  .guide-card,
  .guide-card:hover {
    transition: none;
    top: 0;
  }
}

.guide-page footer {
  justify-content: center;
}

/* ── ARTICLE LAYOUT: every guide on the left, the article, its sections on the right ── */
/* the whole width of the screen: the guides list at the left edge, the sections at the right
   edge, the article between them, centred, at a width that still reads well */
.guide-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 240px;
  gap: 48px;
  padding: 0 var(--px);
}

.guide-layout .guide {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 44px 0 24px;
}

/* the menu stays fixed at the top, so a section's heading stops below it */
.guide h2[id] {
  scroll-margin-top: 90px;
}

.guide-aside,
.guide-toc {
  position: sticky;
  top: 85px;
  align-self: start;
  max-height: calc(100vh - 110px);
  margin-top: 44px;
  overflow: auto;
}

.guide-aside-head {
  margin: 0 0 10px 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.guide-aside-list,
.guide-toc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guide-aside-list a,
.guide-toc-list a {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink-muted);
  text-decoration: none;
  transition: background-color 0.15s, color 0.2s;
}

.guide-aside-list a:hover,
.guide-toc-list a:hover {
  background: var(--bg-alt);
  color: var(--ink);
}

/* the open guide: a wash of the site's colour, as in the menu's drop-downs */
.guide-aside-list a[aria-current] {
  background: color-mix(in srgb, var(--heart) 14%, transparent);
  color: var(--heart);
}

/* the section being read: its colour only */
.guide-toc-list a {
  font-weight: 600;
}

.guide-toc-list a.is-current {
  color: var(--heart);
}

/* a sub-section, indented under its section */
.guide-toc-list a.toc-sub {
  padding: 5px 12px 5px 26px;
  font-size: 13px;
  font-weight: 500;
}

/* no room for the sections: the article and the guides list */
@media (max-width: 1180px) {
  .guide-layout {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 40px;
  }

  .guide-toc {
    display: none;
  }
}

/* a phone or a narrow tablet: the guides become a row of pills above the article */
@media (max-width: 860px) {
  .guide-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .guide-aside {
    position: static;
    max-height: none;
    margin: 20px calc(-1 * var(--px)) 0;
    overflow: visible;
  }

  .guide-aside-head {
    display: none;
  }

  .guide-aside-list {
    flex-direction: row;
    gap: 8px;
    padding: 0 var(--px) 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .guide-aside-list::-webkit-scrollbar {
    display: none;
  }

  .guide-aside-list a {
    flex-shrink: 0;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--bg-alt);
    white-space: nowrap;
  }

  .guide-layout .guide {
    padding-top: 24px;
  }
}

/* ── dmc-thread-equivalents: the worked-examples table ── */
/* a white card like .guide-note; on a narrow phone it scrolls sideways inside itself */
.guide-table-wrap {
  margin: 22px 0 8px;
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
}

.guide .guide-table th,
.guide .guide-table td {
  padding: 10px 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: left;
  vertical-align: top;
  border-top: 1px solid var(--border);
}

.guide .guide-table thead th {
  border-top: none;
  border-bottom: 1px solid var(--border);
  background: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.guide-table tbody th {
  font-weight: 800;
}

.guide-table small {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink-muted);
}

/* the DMC colour as the catalog stores it */
.guide-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 7px;
  border-radius: 50%;
  border: 1px solid rgba(42, 37, 35, 0.18);
  vertical-align: -2px;
}

/* which of the app's two tabs a thread is in */
.guide-tag {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: 1px;
}

.guide-tag.same {
  background: color-mix(in srgb, var(--accent) 16%, #fff);
  color: var(--ink);
}

.guide-tag.near {
  border: 1px solid color-mix(in srgb, var(--accent) 45%, #fff);
  color: var(--ink-muted);
}

.guide-table-none {
  color: var(--ink-muted);
}

@media (max-width: 520px) {
  .guide .guide-table th,
  .guide .guide-table td {
    padding: 8px 6px;
    font-size: 0.88rem;
  }

  .guide .guide-table th:first-child,
  .guide .guide-table td:first-child {
    padding-left: 10px;
  }

  .guide-swatch {
    display: block;
    margin: 0 0 4px;
  }
}


/* ── send-a-palette-from-needleply: the map of the three apps, and the review screens drawn ── */
/* both figures follow their own width, not the window's: the article column changes with the asides */
.pal-figure {
  container-type: inline-size;
}

/* the drawings sit centred, so their captions do too */
.pal-figure figcaption {
  text-align: center;
}

/* the map: Needleply above, a fork down to StitchHub and Needlentory, the chart's arrow between
   those two. The three columns are equal, so the fork's ends land on the icons' centres. */
.pal-map {
  --pal-icon: 60px;
  --pal-line: color-mix(in srgb, var(--accent) 50%, #fff);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    ". ply ."
    "fork fork fork"
    "sh link nt"
    "label label label";
  max-width: 560px;
  margin: 0 auto;
  padding: 26px 20px 24px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.pal-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  text-align: center;
}

.pal-map .pal-app img {
  width: var(--pal-icon);
  height: var(--pal-icon);
  border-radius: 22%;
  background: none;
  box-shadow: 0 2px 8px rgba(42, 37, 35, 0.12);
}

.pal-app strong {
  font-size: 0.95rem;
  line-height: 1.3;
}

.pal-ply {
  grid-area: ply;
  position: relative;
  padding-bottom: 18px;
}

/* the stem from Needleply down to the fork */
.pal-ply::after {
  content: "";
  position: absolute;
  left: calc(50% - 1px);
  bottom: 0;
  width: 2px;
  height: 18px;
  background: var(--pal-line);
}

.pal-fork {
  grid-area: fork;
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 calc(100% / 6 - 1px);
  padding: 12px 14px 20px;
  border: 2px solid var(--pal-line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
}

.pal-fork > span,
.pal-map .pal-link-label {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink-muted);
  text-wrap: balance;
}

.pal-fork > span {
  flex: 0 1 46%;
}

.pal-fork > span:last-child {
  text-align: right;
}

/* the arrowheads at the fork's two ends */
.pal-fork::before,
.pal-fork::after {
  content: "";
  position: absolute;
  bottom: -8px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--pal-line);
}

.pal-fork::before {
  left: -7px;
}

.pal-fork::after {
  right: -7px;
}

.pal-sh,
.pal-nt {
  padding-top: 12px;
}

.pal-sh {
  grid-area: sh;
}

.pal-nt {
  grid-area: nt;
}

/* the chart's arrow, at the icons' middle, from one icon's edge to the other's */
.pal-link {
  grid-area: link;
  align-self: start;
  position: relative;
  height: 2px;
  margin: calc(12px + var(--pal-icon) / 2 - 1px) calc(var(--pal-icon) / 2 + 10px - 50%) 0;
  background: var(--pal-line);
}

.pal-link::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -5px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid var(--pal-line);
}

.pal-map .pal-link-label {
  grid-area: link;
  align-self: start;
  margin: calc(12px + var(--pal-icon) / 2 + 10px) calc(var(--pal-icon) / 2 + 10px - 50%) 0;
  text-align: center;
}

/* the two apps' import rows, then the paragraph that follows them */
.pal-types + p {
  margin-top: 18px;
}

/* a paragraph after a list or the steps keeps a gap like the one between paragraphs */
.pal-list + p {
  margin-top: 16px;
}

/* the review screens: Palette Changes beside Color Changes, on a tray that marks them as drawn */
.pal-mock {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
  padding: 20px;
  background: var(--bg-alt);
  border-radius: 20px;
}

.pal-screen {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.pal-screen-title {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  font-weight: 800;
  text-align: center;
}

.guide .pal-rows {
  margin: 0;
  list-style: none;
}

.guide .pal-rows li,
.pal-color {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  font-size: 1rem;
  line-height: 1.3;
}

.guide .pal-rows li + li {
  margin-top: 0;
  border-top: 1px solid var(--border);
}

.pal-swatch {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(42, 37, 35, 0.12);
}

.pal-row-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.pal-row-text small {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* an updated colour opens its Before and After */
.pal-chevron {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-top: 2px solid var(--ink-faint);
  border-right: 2px solid var(--ink-faint);
  transform: rotate(45deg);
}

.pal-section {
  padding: 14px 16px 2px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* a narrow column: smaller icons, the chart's words under the row, the two screens one above the other */
@container (max-width: 480px) {
  .pal-map {
    --pal-icon: 52px;
    padding: 22px 12px 20px;
  }

  .pal-app strong {
    font-size: 0.85rem;
  }

  .pal-fork {
    gap: 10px;
    padding: 10px 10px 18px;
  }

  .pal-fork > span,
  .pal-map .pal-link-label {
    font-size: 0.8rem;
  }

  .pal-map .pal-link-label {
    grid-area: label;
    margin: 12px 0 0;
  }

  .pal-mock {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }
}
