/* FiftyTwoMondays help site: one shared stylesheet.
   Spacing only ever uses the --s* steps (4, 8, 16, 24, 40, 64). */

:root {
  /* Brand palette (matches the planner) */
  --ink: #1F2A2E;
  --muted: #6B7774;
  --deep: #2F4F46;
  --mid: #6E8F84;
  --soft: #E4EDE8;
  --faint: #F5F8F6;
  --line: #DCE4E0;
  --frame: #AFC3BA;
  --terra: #C8553D;
  --gold-soft: #FBEFD5;
  --cream: #FFF8E7;
  --cream-line: #EADFC4;
  --white: #FFFFFF;

  /* Text shades derived from the palette so small text passes WCAG AA.
     --muted is only 4.65:1 on white and drops below 4.5:1 on tinted fills,
     --mid is 3.5:1, and --terra is 4.35:1, so those three are kept for
     large type, fills and decoration. Contrast on white / faint / cream:
     --muted-strong 5.7 / 5.4 / 5.4, --mid-ink 5.5 / 5.1 / 5.2. */
  --muted-strong: #5C6966;
  --mid-ink: #4F7064;

  /* Spacing scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 16px;
  --s4: 24px;
  --s5: 40px;
  --s6: 64px;

  --font-head: "Lora", Georgia, "Times New Roman", serif;
  --font-body: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --wrap: 1200px;
  --gutter: var(--s3);
  --measure: 42rem;
  --tap: 44px;
  --radius: 4px;
  --radius-btn: 6px;
  --h2-size: clamp(1.5rem, 1.1rem + 1.6vw, 2rem);
}

@media (min-width: 40rem) {
  :root { --gutter: var(--s4); }
}

/* Base */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink);
  background: var(--white);
  overflow-wrap: break-word;
}

@media (min-width: 48rem) {
  body { font-size: 1.0625rem; }
}

img { max-width: 100%; height: auto; }

a {
  color: var(--deep);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

@media (hover: hover) {
  a:hover {
    color: var(--mid-ink);
    text-decoration-thickness: 2px;
  }
}

:focus-visible {
  outline: 3px solid var(--deep);
  outline-offset: 2px;
}

strong { font-weight: 600; }

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--s3);
  top: -100px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--s3);
  background: var(--deep);
  color: var(--white);
  border-radius: var(--radius-btn);
  font-weight: 600;
}

.skip-link:focus {
  top: var(--s2);
  outline-color: var(--white);
  outline-offset: -4px;
}

/* Type */

.kicker {
  margin: 0 0 var(--s2);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--mid-ink);
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--deep);
}

h1,
h2 { text-wrap: balance; }

p,
li { text-wrap: pretty; }

h1 {
  margin: 0 0 var(--s3);
  font-size: clamp(2rem, 1.3rem + 3vw, 2.75rem);
  line-height: 1.15;
}

h2 {
  margin: 0;
  font-size: var(--h2-size);
  line-height: 1.2;
}

.lead {
  margin: 0 0 var(--s4);
  font-size: 1.125rem;
  line-height: 1.6;
}

p { margin: 0 0 var(--s3); }

/* Site header and footer */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: var(--s3);
  min-height: 64px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--deep);
  text-decoration: none;
}

@media (hover: hover) {
  .wordmark:hover {
    color: var(--deep);
    text-decoration: none;
  }
}

.header-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--s3);
  border: 1px solid var(--frame);
  border-radius: var(--radius-btn);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

@media (hover: hover) {
  .header-link:hover {
    background: var(--soft);
    color: var(--deep);
    text-decoration: none;
  }
}

.site-footer {
  margin-top: var(--s6);
  padding-block: var(--s5);
  border-top: 1px solid var(--line);
  background: var(--faint);
  color: var(--muted-strong);
  font-size: 0.9375rem;
}

.site-footer p { margin: 0; }
.site-footer p + p { margin-top: var(--s1); }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 var(--s4);
  border: 1px solid var(--deep);
  border-radius: var(--radius-btn);
  background: var(--deep);
  color: var(--white);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
}

@media (hover: hover) {
  .btn:hover {
    background: var(--mid-ink);
    border-color: var(--mid-ink);
    color: var(--white);
    text-decoration: none;
  }
}

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

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-weight: 600;
}

/* Home */

.home-hero {
  padding-block: var(--s5) var(--s4);
}

@media (min-width: 48rem) {
  .home-hero { padding-block: var(--s6) var(--s5); }
}

.home-hero h1 { max-width: 18ch; }

.home-hero .lead {
  max-width: 36rem;
  margin-bottom: 0;
  text-wrap: balance;
}

.accent-rule {
  width: var(--s5);
  height: 3px;
  margin: 0 0 var(--s4);
  border: 0;
  background: var(--terra);
}

.cards {
  display: grid;
  gap: var(--s4);
  max-width: 52rem;
  margin: 0;
  padding: 0;
  list-style: none;
  grid-template-columns: minmax(0, 1fr);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--frame);
  background: var(--white);
}

.card-thumb {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-bottom: 1px solid var(--frame);
  background: var(--faint);
}

/* Cropped teaser: the top-left of the dashboard, enlarged so the big number reads. */
.card-thumb img {
  display: block;
  width: 150%;
  max-width: none;
  height: auto;
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  padding: var(--s4);
}

@media (min-width: 40rem) {
  .card { flex-direction: row; }

  .card-thumb {
    position: relative;
    flex: 0 0 min(40%, 20rem);
    aspect-ratio: auto;
    border-bottom: 0;
    border-right: 1px solid var(--frame);
  }

  /* Out of flow, so the text column (not the image) sets the card height. */
  .card-thumb img {
    position: absolute;
    top: 0;
    left: 0;
  }

  .card-body {
    min-height: 17.5rem;
    padding: var(--s5);
  }
}

.card-body .kicker { margin-bottom: var(--s2); }

.card-title {
  margin: 0 0 var(--s2);
  font-size: 1.375rem;
  line-height: 1.25;
}

.card-desc {
  margin: 0 0 var(--s4);
  color: var(--ink);
}

/* Whole card is the click target; the button text is the link. */
.card .btn { margin-top: auto; }

.card .btn::after {
  content: "";
  position: absolute;
  inset: 0;
}

@media (hover: hover) {
  .card:hover { border-color: var(--deep); }
}

.card:focus-within { outline: 3px solid var(--deep); outline-offset: 2px; }
.card .btn:focus-visible { outline: none; }

/* Guide page layout */

.guide-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--s4);
  padding-block: var(--s5) 0;
}

@media (min-width: 64rem) {
  .guide-layout {
    grid-template-columns: 15rem minmax(0, 1fr);
    column-gap: var(--s6);
    padding-top: var(--s6);
  }

  .guide-hero { grid-column: 2; grid-row: 1; }

  .toc {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: start;
    position: sticky;
    top: var(--s4);
  }

  .guide-body { grid-column: 2; grid-row: 2; }
}

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

.guide-hero .lead { max-width: var(--measure); }

/* Panels: deep green band, white spaced caps, thin frame border */

.panel {
  margin: 0 0 var(--s4);
  border: 1px solid var(--frame);
  background: var(--white);
}

.panel-head {
  position: relative;
  margin: 0;
  padding: var(--s2) var(--s3);
  background: var(--deep);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.3em;
  text-align: center;
  text-indent: 0.3em;
  text-transform: uppercase;
}

/* an h2 inside a .panel-head takes the band style, not the serif one */
.panel-head h2 {
  margin: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-indent: inherit;
  text-transform: inherit;
}

.panel-body { padding: var(--s3) var(--s3) var(--s2); }

@media (min-width: 40rem) {
  .panel-body { padding: var(--s4) var(--s4) var(--s3); }
}

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

/* Contents (On this page) */

.toc-box {
  border: 1px solid var(--frame);
  background: var(--white);
}

.toc-box > summary {
  position: relative;
  display: block;
  min-height: var(--tap);
  padding: var(--s3) var(--s5);
  background: var(--deep);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.3em;
  text-align: center;
  text-indent: 0.3em;
  text-transform: uppercase;
  list-style: none;
  cursor: pointer;
}

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

.toc-box > summary::after {
  content: "";
  position: absolute;
  right: var(--s3);
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--white);
  border-bottom: 2px solid var(--white);
  transform: translateY(-70%) rotate(45deg);
}

.toc-box[open] > summary::after { transform: translateY(-30%) rotate(-135deg); }

.toc-box > summary:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: -6px;
}

.toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-list li + li { border-top: 1px solid var(--line); }

.toc-list a {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  color: var(--deep);
  font-weight: 500;
  line-height: 1.35;
  text-decoration: none;
}

@media (hover: hover) {
  .toc-list a:hover {
    background: var(--faint);
    color: var(--mid-ink);
  }
}

.toc-list a:focus-visible { outline-offset: -3px; }

@media (min-width: 64rem) {
  .toc-list a { font-size: 0.9375rem; }

  /* Always open on wide screens (site.js keeps it open; this covers no-JS). */
  .toc-box > summary {
    padding-block: var(--s2);
    min-height: 0;
    cursor: default;
    pointer-events: none;
  }

  .toc-box > summary::after { display: none; }

  .toc-box::details-content {
    content-visibility: visible;
    display: block;
  }
}

/* Guide sections */

.guide-section {
  margin-top: var(--s5);
  padding-top: var(--s5);
  border-top: 1px solid var(--line);
  scroll-margin-top: var(--s4);
}

.guide-section:first-child { margin-top: 0; }

.guide-section > :not(figure) { max-width: var(--measure); }

.section-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s1);
  margin-bottom: var(--s3);
}

.guide-section h2[id],
.panel-head h2[id] { scroll-margin-top: var(--s4); }

.guide-section h3 { margin: 0; }

/* Copy-link button (added by site.js, next to each section heading) */

.copy-link {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  margin-block: calc((var(--h2-size) * 1.2 - var(--tap)) / 2);
  padding: 0;
  border: 0;
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--deep);
  cursor: pointer;
  opacity: 0;
}

.section-head:hover .copy-link,
.panel-head:hover .copy-link,
.copy-link:focus-visible,
.copy-link.is-copied { opacity: 1; }

@media (hover: hover) {
  .copy-link:hover { background: var(--soft); }
}

.copy-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.copy-link.is-copied::after {
  content: attr(data-tip);
  position: absolute;
  left: 100%;
  top: 50%;
  margin-left: var(--s1);
  padding: var(--s1) var(--s2);
  transform: translateY(-50%);
  background: var(--deep);
  color: var(--white);
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
}

.panel-head .copy-link {
  position: absolute;
  right: 0;
  top: 50%;
  margin: 0;
  transform: translateY(-50%);
  color: var(--white);
}

@media (hover: hover) {
  .panel-head .copy-link:hover { background: rgba(255, 255, 255, 0.16); }
}
.panel-head .copy-link:focus-visible { outline-color: var(--white); outline-offset: -4px; }
.panel-head .copy-link.is-copied::after {
  left: auto;
  right: 100%;
  margin: 0 var(--s1) 0 0;
  background: var(--white);
  color: var(--deep);
}

@media (hover: none) {
  .copy-link { display: none; }
}

/* Lists */

.guide-section ul,
.guide-section ol,
.panel-body ul,
.panel-body ol {
  margin: 0 0 var(--s3);
  padding: 0;
  list-style: none;
}

.guide-section ul > li,
.panel-body ul > li {
  position: relative;
  margin-bottom: var(--s2);
  padding-left: var(--s4);
}

.guide-section ul > li::before,
.panel-body ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 8px;
  height: 8px;
  background: var(--deep);
}

ol.steps { counter-reset: step; }

ol.steps > li {
  position: relative;
  margin-bottom: var(--s3);
  padding-left: calc(32px + var(--s3));
  counter-increment: step;
  min-height: 32px;
}

ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: calc((1.6em - 32px) / 2);
  width: 32px;
  height: 32px;
  background: var(--deep);
  color: var(--white);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 32px;
  text-align: center;
}

ol.steps > li:last-child { margin-bottom: 0; }
ol.steps { margin-bottom: var(--s3); }

/* Callouts: cream, the colour of "type here" cells in the planner */

.callout {
  margin: 0 0 var(--s4);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--cream-line);
  border-radius: var(--radius);
  background: var(--cream);
}

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

.callout--note {
  font-size: 0.9375rem;
  line-height: 1.55;
}

.guide-hero .callout--note { max-width: var(--measure); }

.callout .recap { margin-bottom: var(--s3); }
.callout .recap li:last-child { margin-bottom: 0; }

/* Figures */

.figure { margin: var(--s4) 0; }

.figure-frame {
  border: 1px solid var(--frame);
  background: var(--white);
}

.figure-frame > a,
.figure-scroll > a {
  display: block;
  line-height: 0;
  cursor: zoom-in;
}

.figure-frame a:focus-visible { outline-offset: -4px; }

.figure img {
  display: block;
  width: 100%;
  height: auto;
}

.figure figcaption {
  max-width: var(--measure);
  margin-top: var(--s2);
  color: var(--muted-strong);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.figure-hint {
  margin: var(--s2) 0 0;
  color: var(--muted-strong);
  font-size: 0.9375rem;
}

@media (min-width: 48rem) {
  .figure-hint { display: none; }
}

/* Wide spreadsheet screenshots scroll inside their frame on small screens
   instead of shrinking until the text is unreadable. */
@media (max-width: 47.99rem) {
  .figure--wide .figure-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .figure--wide .figure-scroll:focus-visible { outline-offset: 2px; }

  .figure--wide img {
    width: 960px;
    max-width: none;
  }
}

/* Troubleshooting */

.faq {
  border-top: 1px solid var(--line);
  margin-bottom: var(--s4);
}

.faq details { border-bottom: 1px solid var(--line); }

.faq summary {
  position: relative;
  display: block;
  min-height: var(--tap);
  padding: var(--s3) var(--s5) var(--s3) 0;
  color: var(--deep);
  font-weight: 600;
  line-height: 1.4;
  list-style: none;
  cursor: pointer;
}

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

.faq summary::after {
  content: "";
  position: absolute;
  right: var(--s2);
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--deep);
  border-bottom: 2px solid var(--deep);
  transform: translateY(-70%) rotate(45deg);
}

.faq details[open] > summary::after { transform: translateY(-30%) rotate(-135deg); }

@media (hover: hover) {
  .faq summary:hover { color: var(--mid-ink); }
}
.faq summary:focus-visible { outline-offset: -3px; }

.faq .answer { padding: 0 0 var(--s3); }
.faq .answer > :last-child { margin-bottom: 0; }

/* Back link */

.back-link { margin: var(--s4) 0 0; }

/* 404 */

.notfound {
  padding-block: var(--s6);
}

.notfound h1 { max-width: 18ch; }

.notfound .lead { max-width: 30rem; }

/* Print: hide chrome, keep the images, keep each step in one piece. */

@media print {
  .site-header,
  .site-footer,
  .toc,
  .copy-link,
  .skip-link,
  .figure-hint,
  .back-link { display: none !important; }

  body { font-size: 11pt; }

  .wrap { max-width: none; padding-inline: 0; }

  .guide-layout { display: block; padding-top: 0; }

  .guide-section > :not(figure) { max-width: none; }

  .figure--wide .figure-scroll { overflow: visible; }
  .figure--wide img { width: 100%; max-width: 100%; }

  .figure,
  ol.steps > li,
  .callout,
  .panel,
  .faq details { break-inside: avoid; }

  h2,
  h3 { break-after: avoid; }

  a { color: inherit; text-decoration: none; }

  details::details-content {
    content-visibility: visible;
    display: block;
  }
}
