/* Guides: the /blog/ index and its articles (api/_lib/seo.js renders both).
   Loaded only by those pages, on top of styles.css, seo.css and storefront.css,
   so no other page pays for it. Tokens only: every color has a dark value. */

/* Widths match the reference blog: a 1152px index grid and a 976px article
   column, each plus the page gutters. */
.guides-page {
  --guide-wide: 1152px;
  --guide-reading: 976px;
}

/* ---------- Index ---------- */

/* The articles open the page, with no page head above them. */
.guides-page .guides {
  max-width: calc(var(--guide-wide) + 2 * var(--gutter));
  padding-top: clamp(16px, 2vw, 28px);
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  /* Card text is ragged on the right, so the visible gutter is the column gap
     plus each card's line slack; a wider gap keeps that slack small next to it. */
  gap: clamp(40px, 5vw, 64px) clamp(28px, 3vw, 40px);
}

.guide-card {
  position: relative;
  display: grid;
  align-content: start;
}

.guide-card > * { align-self: start; }

/* The photographs are melted to the page color at their edges. Each one sits
   in a box of its own 4:5 shape, so the fade below lands exactly on the photo's
   edges whatever the surrounding frame's shape: in dark mode the floor glow is
   a few levels off the page color, and a seam there would show as a box. */
.guide-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  margin-bottom: 18px;
  background: var(--paper);
}

.guide-card__media picture {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.guide-card__media picture,
.guide__figure picture {
  display: block;
  height: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--paper);
}

.guide-card__media picture::after,
.guide__figure picture::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, var(--paper), transparent 12%, transparent 88%, var(--paper)),
    linear-gradient(to bottom, var(--paper), transparent 5%, transparent 95%, var(--paper));
}

/* The vial spans about 14–82% of its photograph's height; 1.2x from just
   above center fills the box and still clears the cap and the shadow. */
.guide-card__media img,
.guide__figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.2);
  transform-origin: 50% 46%;
}

.guide-card__media img { transition: transform .6s var(--ease); }

@media (hover: hover) { .guide-card:hover .guide-card__media img { transform: scale(1.235); } }

.guide-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

/* Lines fill to the card edge (no balancing or "pretty" shortening, which
   WebKit applies hard), so a two-line title never reads as a narrow stack and
   the gutters between cards look even. The renderer binds the last two words
   so no word is stranded. */
.guide-card__title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 1rem + .45vw, 1.375rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -.02em;
}

.guide-card__title a {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: text-decoration-color .2s;
}

/* The title link covers the whole card, so the card is one tap target. */
.guide-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--radius);
}

.guide-card:hover .guide-card__title a { text-decoration-color: var(--line-2); }

.guide-card__title a:focus-visible { outline: none; }

.guide-card__title a:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
}

.guide-card__dek {
  margin: 0;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1.55;
}

.guides__empty {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Article ---------- */

.guide__head > .container,
.guide__body,
.guide__more {
  max-width: calc(var(--guide-reading) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.guide__head .lede {
  font-size: clamp(1rem, .95rem + .2vw, 1.0625rem);
  color: var(--ink-2);
  text-wrap: balance;
}

/* The crumb stays small but gets a full-height tap area. */
.guide__head .seo-breadcrumb a {
  display: inline-block;
  padding-block: 14px;
  margin-block: -14px;
}

.guide__head .guide-meta { margin: 14px 0 0; }
.guide__head .guide-byline { margin-top: 6px; }

/* The photograph carries its own air above the cap, so the figure sits close
   to the head rule and reads evenly spaced between head and body. */
.guide__figure {
  margin: clamp(8px, 1.4vw, 16px) auto 0;
  padding-inline: var(--gutter);
}

.guide__figure picture {
  position: relative;
  height: clamp(300px, 22vw + 120px, 440px);
  margin-inline: auto;
}

.guide__body { padding-block: clamp(28px, 4vw, 48px) clamp(32px, 4vw, 48px); }

.guide__body > :first-child { margin-top: 0; }

.guide__body > :last-child { margin-bottom: 0; }

.guide__body p {
  margin: 0 0 1.1em;
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.8;
  text-wrap: pretty;
}

.guide__body h2 {
  margin: 2em 0 .55em;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1.05rem + .7vw, 1.625rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -.02em;
  text-wrap: balance;
}

/* The underline is what marks a link inside body text (its color alone is too
   close to the prose), so it stays visible at rest. */
.guide__body h3 {
  text-wrap: balance;
  margin: 1.6em 0 .4em;
  font-family: var(--font-display);
  font-size: clamp(1.0625rem, 1rem + .3vw, 1.25rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -.015em;
}

.guide__body h2 + h3 { margin-top: 1em; }

/* A list or table straight under a heading gets the same air a paragraph does. */
.guide__body :is(h2, h3) + :is(.guide__list, .guide__steps, .guide__table) { margin-top: 16px; }

/* Words held whole: a number range or product name never breaks at its dash. */
.guide-nb { white-space: nowrap; }

/* A heading reached from the contents lands clear of the sticky header. */
.guide__body h2,
.guide__body h3 { scroll-margin-top: calc(var(--header-h) + 24px); }

/* ---------- Table of contents ---------- */

/* A bordered box as wide as its longest entry, between the opening paragraphs
   and the first section. The native toggle folds it (the whole title row is
   the control); section numbers come from a counter, and the entries under a
   section align with its title and keep their own words. */
.guide-toc {
  width: fit-content;
  min-width: min(100%, 320px);
  max-width: 100%;
  margin: 8px 0 2.2em;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}

.guide-toc summary {
  display: block;
  list-style: none;
  cursor: pointer;
  border-radius: var(--radius);
}

.guide-toc summary::-webkit-details-marker { display: none; }

.guide-toc summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.guide-toc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 52px;
  padding: 8px 20px;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -.015em;
}

/* A chevron in a small square: up to fold the open list, down to unfold it. */
.guide-toc__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: color .2s, border-color .2s;
}

.guide-toc__icon::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: 3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-135deg);
  transition: transform .2s var(--ease), margin-top .2s var(--ease);
}

.guide-toc:not([open]) .guide-toc__icon::before { margin-top: -3px; transform: rotate(45deg); }

@media (hover: hover) { .guide-toc summary:hover .guide-toc__icon { color: var(--ink); border-color: var(--ink-3); } }

.guide-toc nav { padding: 0 20px 16px; }

.guide-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: guide-toc;
}

.guide-toc li { counter-increment: guide-toc; }

/* Number column (sized for "10.") + gap = the indent of the entries below. */
.guide-toc ol ol { padding-left: 32px; }

.guide__body .guide-toc a {
  display: flex;
  gap: 8px;
  padding-block: 3px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.5;
  text-decoration-color: transparent;
  text-wrap: balance;
}

/* Entries under a section: a step smaller and quieter, with a little air
   before the next section. */
.guide-toc ol ol { margin: 2px 0 6px; }

.guide__body .guide-toc ol ol a { color: var(--ink-3); font-size: 14px; }

/* Right-aligned in a fixed column, so the periods line up from 1. to 10. and
   a wrapped title hangs clear of its number. */
.guide-toc nav > ol > li > a::before {
  content: counter(guide-toc) ".";
  flex: none;
  width: 24px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.guide__body .guide-toc a:hover {
  color: var(--ink);
  text-decoration-color: var(--line-2);
}

/* Touch: every entry is a full-size tap target, its number still level with
   the first line. */
@media (pointer: coarse) {
  .guide__body .guide-toc a {
    min-height: 44px;
    padding-block: 11px;
  }
}

/* On a wide screen every column but the last hugs its content and the last
   takes the rest, so the gutters between columns are even whatever the
   content. Narrower, cells wrap; on a phone each row stacks (below). */
.guide__table {
  margin: 8px 0 1.4em;
  overflow-x: auto;
}

.guide__table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.guide__table th,
.guide__table td {
  padding: 12px 24px 12px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.guide__table :is(th, td):last-child { padding-right: 0; }

@media (min-width: 901px) {
  .guide__table :is(th, td):not(:last-child) {
    width: 1%;
    padding-right: 48px;
    white-space: nowrap;
  }
  /* Five or more columns: only the row label holds one line, the rest wrap. */
  .guide__table--wide :is(th, td):not(:first-child, :last-child) {
    width: auto;
    padding-right: 32px;
    white-space: normal;
  }
}

.guide__table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.guide__table td { color: var(--ink-2); }

.guide__table td:first-child { color: var(--ink); }

.guide__table thead th { border-bottom-color: var(--line-2); }

.guide__body a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--ink-3);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color .2s;
}

.guide__body a:hover { text-decoration-color: currentColor; }

.guide__body a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.guide__steps,
.guide__list {
  margin: 8px 0 1.4em;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.guide__steps { counter-reset: guide-step; }

.guide__steps li,
.guide__list li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.6;
}

.guide__steps li { counter-increment: guide-step; }

/* The longhand: the text-wrap shorthand would also reset wrapping, which
   breaks the no-wrap table columns. */
:is(.guide__list, .guide__steps) .guide__text { text-wrap-style: pretty; }

.guide__steps li::before {
  content: counter(guide-step, decimal-leading-zero);
  padding-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* A checklist, not a procedure: a hairline mark instead of a number. */
.guide__list li::before {
  content: "";
  width: 12px;
  height: 1px;
  margin-top: .8em;
  background: var(--muted);
}

.guide__body .guide__note {
  margin: 2.4em 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

/* After a list or table the block's own bottom rule already closes the
   section; a second rule right under it would read as a double line. */
.guide__body :is(.guide__list, .guide__steps, .guide__table) + .guide__note {
  margin-top: 1.6em;
  padding-top: 0;
  border-top: 0;
}

.guide__more { padding-bottom: clamp(48px, 6vw, 80px); }

.guide__more h2 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 1rem + .4vw, 1.375rem);
  font-weight: 500;
  letter-spacing: -.015em;
}

.guide__more ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.guide__more a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 16px;
  min-height: 44px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.guide__more a::after {
  content: "→";
  grid-column: 2;
  grid-row: 1 / span 2;
  color: var(--muted);
  transition: transform .2s var(--ease), color .2s;
}

.guide__more .guide-meta { margin: 0 0 4px; }

.guide__more-title {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -.01em;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: text-decoration-color .2s;
}

.guide__more a:hover .guide__more-title { text-decoration-color: var(--line-2); }

@media (hover: hover) { .guide__more a:hover::after { color: var(--ink); transform: translateX(3px); } }

.guide__more a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

/* ---------- Breakpoints ---------- */

/* Tablets: one column of horizontal cards, which reads the same for any
   number of guides (a two-column grid strands an odd one). */
@media (min-width: 601px) and (max-width: 960px) {
  .guide-grid {
    grid-template-columns: minmax(0, 1fr);
    row-gap: clamp(28px, 4vw, 40px);
  }
  .guide-card {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    grid-template-rows: 1fr auto auto auto 1fr;
    column-gap: clamp(20px, 3.5vw, 36px);
  }
  .guide-card__media {
    grid-column: 1;
    grid-row: 1 / -1;
    margin-bottom: 0;
  }
  .guide-card > .guide-meta { grid-column: 2; grid-row: 2; }
  .guide-card__title { grid-column: 2; grid-row: 3; }
  .guide-card__dek { grid-column: 2; grid-row: 4; }
}

@media (max-width: 600px) {
  .guide-grid { grid-template-columns: minmax(0, 1fr); }
  .guide__body p,
  .guide__steps li,
  .guide__list li { font-size: 16px; }
  /* A narrower mark column leaves the text the width of the screen. */
  .guide__steps li,
  .guide__list li { grid-template-columns: 22px minmax(0, 1fr); }
  .guide__table table { font-size: 15px; font-variant-numeric: normal; }
  /* Stacked: one block per row, each value beside its column's name in a
     column sized to that table's longest name. The header row stays for
     screen readers only. */
  .guide__table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .guide__table :is(table, tbody, tr) { display: block; }
  .guide__table tbody { border-top: 1px solid var(--line-2); }
  .guide__table tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  .guide__table td {
    display: grid;
    grid-template-columns: var(--guide-label, 84px) minmax(0, 1fr);
    align-items: baseline;
    gap: 12px;
    padding: 4px 0;
    border: 0;
  }
  .guide__table--label-m { --guide-label: 124px; }
  .guide__table--label-l { --guide-label: 148px; }
  .guide__table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
  }
  /* The row's first value leads it, set a little stronger. */
  .guide__table td:first-child {
    color: var(--ink);
    font-weight: 500;
  }
}

@media (prefers-reduced-motion: reduce) {
  .guide-card__media img,
  .guide-card__title a,
  .guide__body a,
  .guide__more a::after,
  .guide__more-title,
  .guide-toc__icon,
  .guide-toc__icon::before { transition: none; }
  .guide-card:hover .guide-card__media img { transform: scale(1.2); }
  .guide__more a:hover::after { transform: none; }
}
