/* Fixwise styles.
   All colours are custom properties, so light and dark themes share one set of rules.
   Palette: calm slate and teal for easy reading, amber for brand accents and warnings.
   Variable names are kept from the earlier palette: --accent-cyan is the teal,
   --accent-yellow is the amber. Rename them later if you prefer. */

:root {
  --bg: #0f172a;
  /* Header and footer bars: close to the body colour, with a very subtle green gradient (no blue).
     The gradient runs left to right so the brand row and category row join without a seam. */
  --chrome: linear-gradient(90deg, #0f3b3a 0%, #0f3b3a 78%, #14554a 100%);
  --footer-bg: #0f1b2b; /* solid footer colour (no gradient) */
  --surface: #1e293b;
  --help-bg: #15292c; /* "If it did not work" box: muted blue-green, so it stands apart from the steps */
  --help-border: #3b7a78;
  --help-title: #99f6e4;
  --border: #334155;
  --accent-cyan: #5eead4;
  --accent-yellow: #fbbf24;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --pixel-bg: #0b1220;
  --warn-bg: #34202a; /* safety box: muted wine, softer against the slate page; light text stays easy to read */
  --warn-border: #fca5a5;
  --warn-title: #ffffff;
  --warn-text: #ffffff;
  --focus: #5eead4;
  --title: #f1f5f9;
  --sitemap-guide: #7dd3fc;
  --link: #7dd3fc; /* links inside text: sky blue, clearly different from the teal/mint of the help box */
  --page-max: 1100px;
  --pad: 16px; /* side padding of the page; 24px from tablet width up (see below) */
  /* Side padding that lines header and footer content up with the page column. */
  --gutter: max(var(--pad), calc((100% - var(--page-max)) / 2 + var(--pad)));
  --brand-h: 68px;
  --nav-h: 52px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f7fa;
  --chrome: #c9dfd2; /* soft green bar, darker than the body */
  --footer-bg: #c9dfd2;
  --surface: #ffffff;
  --help-bg: #e8f5f0; /* "If it did not work" box: pale teal tint */
  --help-border: #0f766e;
  --help-title: #9a4f00;
  --border: #aebccb;
  --accent-cyan: #0f6b6b;
  --accent-yellow: #9a4f00;
  --text: #1f2937;
  --text-muted: #4b5563;
  --pixel-bg: #eef2f6;
  --warn-bg: #fdecec; /* safety box: pale red */
  --warn-border: #b91c1c;
  --warn-title: #8f1111;
  --warn-text: #3b0a0a;
  --focus: #0f6b6b;
  --title: #9a4f00;
  --sitemap-guide: #0b5f8a;
  --link: #0b5cad; /* links inside text: standard-looking blue, AA contrast on the page and cards */
  color-scheme: light;
}

/* ---------- Base ---------- */

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

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  /* Always reserve the scrollbar's width, so short pages (Terms, Licence) line up with long ones. */
  scrollbar-gutter: stable;
}

@supports not (scrollbar-gutter: stable) {
  html {
    overflow-y: scroll;
  }
}

body {
  margin: 0;
  /* Leaves room for the fixed header (brand row + category row). */
  padding-top: calc(var(--brand-h) + var(--nav-h));
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  /* Short pages: main grows to fill the screen, so the footer sits at the bottom. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--accent-cyan);
}

/* Tablets and larger: more room at the sides. The header, footer and page content all follow. */
@media (min-width: 768px) {
  :root {
    --pad: 24px;
  }
}

/* Links inside paragraphs and lists (breadcrumbs, video link, About/Privacy text) use the blue
   link colour and stay underlined, so they do not rely on colour alone. Cards, chips, buttons
   and the menu keep their own colours. */
main p a,
main li a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Mouse-over colour for text links: the amber used for headings (AA contrast in both modes). */
main p a:hover,
main li a:hover {
  color: var(--accent-yellow);
}

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

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  padding: 8px 12px;
  background: var(--accent-yellow);
  color: #000;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
}

/* ---------- Header ----------
   On phones (under 768px) the whole header (brand row and category row) slides up out of view
   on scroll down and back on scroll up. From 768px up, the brand row stays fixed and only the
   category row slides, as set in the media query near the end of this file. Only transform
   changes, so it stays smooth. */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  transition: transform 0.25s ease;
}

.site-header.nav-hidden {
  transform: translateY(calc(-1 * (var(--brand-h) + var(--nav-h))));
}

.brand-row {
  position: relative;
  z-index: 2;
  height: var(--brand-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--gutter);
  background: var(--chrome);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 52px;
  height: 52px;
  flex: none;
}

/* Two logo files: dark-on-light and light-on-dark. Show the one that matches the theme. */
html[data-theme="light"] .logo-dark,
html:not([data-theme="light"]) .logo-light {
  display: none;
}

.brand-name {
  font-family: "Courier New", Courier, monospace;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-yellow);
}

.brand-tag {
  display: none;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--accent-yellow);
  font-size: 1.2rem;
  cursor: pointer;
}

/* Light / dark button icons: drawn SVG, centred by the button's flexbox. The button shows the mode
   it will switch to: a sun while the site is dark, a moon while it is light. */
.theme-icon {
  display: block;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Mouse-over for the colour-theme and search buttons (mouse devices only, so a tap on a phone does not
   leave the button stuck in the hover look): the button keeps its fill and only the border changes to the
   same accent colour as the other buttons. The sun turns a little and the magnifying glass grows, unless the visitor prefers
   reduced motion. */
@media (hover: hover) {
  #themeToggle:hover,
  #searchToggle:hover {
    border-color: var(--accent-cyan);
  }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  #themeToggle .theme-icon,
  #searchToggle svg {
    transition: transform 0.25s ease;
  }

  #themeToggle:hover .theme-icon-sun {
    transform: rotate(45deg);
  }

  #themeToggle:hover .theme-icon-moon {
    transform: rotate(-20deg);
  }

  #searchToggle:hover svg {
    transform: scale(1.2);
  }
}

/* The search button keeps the accent border (no fill) while the search is open. */
/* The search buttons keep the accent border while their search is open (and while pressed). The search
   field border is the same colour when open, so the button and the box match. */
#searchToggle[aria-expanded="true"],
#menuSearchToggle[aria-expanded="true"],
#menuSearchToggle:active {
  border-color: var(--accent-cyan);
}

.search-box.is-open input {
  border-color: var(--accent-cyan);
}

html[data-theme="light"] .theme-icon-sun,
html:not([data-theme="light"]) .theme-icon-moon {
  display: none;
}

.nav-row {
  position: absolute;
  z-index: 1;
  top: 100%;
  left: 0;
  right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--chrome);
  border-bottom: 2px solid var(--border);
}

.nav-row::-webkit-scrollbar {
  display: none;
}

.nav-chip {
  flex: none;
  padding: 8px 14px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  text-decoration: none;
  white-space: nowrap;
}

.nav-chip:hover,
.nav-chip:focus-visible {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.nav-chip[aria-current="page"] {
  border-color: var(--accent-yellow);
  color: var(--accent-yellow);
}

/* Category groups. Without JavaScript the group buttons are hidden and each group's links sit in the
   row as plain chips (display: contents lets them join the row). With JavaScript, from tablet width up,
   the rules in the 768px block below turn each group into a button with a dropdown. */
.nav-group,
.nav-group-panel {
  display: contents;
}

.nav-group-btn {
  display: none;
}

/* ---------- Layout ---------- */

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 24px var(--pad) 48px;
}

h1 {
  margin: 0.2em 0 0.4em;
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: var(--title);
}

.section-title {
  margin: 2.2rem 0 0.6rem;
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.lead {
  max-width: 65ch;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.breadcrumb {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* The copy of the breadcrumb at the end of a guide: space above it, and links easy to tap. */
.breadcrumb--bottom {
  margin-top: 32px;
}

.breadcrumb--bottom a {
  display: inline-block;
  padding: 10px 2px;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Page number links under a category ---------- */

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
}

/* Smaller than the header chips, but still at least 32px square to tap. */
.pager {
  gap: 6px;
  margin-top: 24px;
}

/* Space between the pager above the cards and the first row of guides. */
.pager + .grid {
  margin-top: 24px;
}

.pager .nav-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  padding: 2px 8px;
  border-width: 1px;
  font-size: 0.85rem;
  text-align: center;
}

.pager-icon {
  display: block;
}

.pager-gap {
  color: var(--text);
  padding: 0 2px;
  font-size: 0.85rem;
}

.pager .is-disabled {
  opacity: 0.35;
}

/* ---------- Home and cards ---------- */

.search {
  width: 100%;
  max-width: 520px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.search:focus {
  border-color: var(--accent-cyan);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

/* The whole square is the link: the square reacts (border, lift, pointer), the text does not. */
.card-link {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.card-link:hover,
.card-link:focus-visible {
  border-color: var(--accent-cyan);
  transform: translateY(-3px);
}

.card-link:focus-visible {
  outline: 3px solid var(--accent-cyan);
  outline-offset: 2px;
}

.card-link:active {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .card-link {
    transition: none;
  }

  .card-link:hover,
  .card-link:focus-visible {
    transform: none;
  }
}

.card--soon {
  border-style: dashed;
  opacity: 0.8;
}

/* Dark mode: coming-soon cards at full opacity so their text stays readable. */
:root[data-theme="dark"] .card--soon {
  opacity: 1;
}

/* Category cards on the home page: the pixel icon sits to the left of the count and the name. */
.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-head > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.category-icon {
  flex: none;
}

/* Category page heading: the larger icon beside the title. */
.intro-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0.2em 0 0.4em;
}

.intro-head h1 {
  margin: 0;
}

.card-label {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-title {
  margin: 0;
  font-family: "Courier New", Courier, monospace;
  font-size: 1.1rem;
  color: var(--title);
}

.card-title a {
  color: inherit;
  text-decoration: none;
}

.card-title a:hover {
  text-decoration: underline;
}

.card-text {
  margin: 0;
  color: var(--text-muted);
}

/* ---------- Guide page ---------- */

.hero-figure,
.step-figure {
  margin: 20px 0;
  padding: 8px;
  border: 2px solid var(--border);
  background: #ffffff;
}

/* "Related guide" box under the safety warning. */
.see-also {
  margin: 0 0 20px;
  padding: 4px 18px 12px;
  border: 2px solid var(--border);
  background: var(--surface);
}

.see-also h2 {
  margin: 14px 0 8px;
  font-size: 1.1rem;
}

.see-also ul {
  margin: 0;
  padding-left: 20px;
}

.see-also li {
  margin-bottom: 6px;
}

/* Video link at the bottom of a guide. */
/* Time and difficulty line under the guide summary. */
.guide-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.guide-meta strong {
  color: var(--text);
}

/* "Print this guide" button, at the right end of the time and difficulty line.
   Hidden until JavaScript runs, because it needs JavaScript to open the print window. */
.print-btn {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-left: auto;
  padding: 6px 14px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

html.js .print-btn {
  display: inline-flex;
}

.print-btn:hover,
.print-btn:focus-visible {
  border-color: var(--accent-cyan);
}

.print-btn svg {
  flex: none;
  color: var(--accent-cyan);
}

/* "If it did not work" box after the steps. */
.troubleshoot {
  margin-top: 32px;
  padding: 4px 18px 12px;
  border: 2px solid var(--help-border);
  background: var(--help-bg);
}

.troubleshoot ul {
  margin: 0;
  padding-left: 20px;
}

.troubleshoot li {
  margin-bottom: 10px;
}

.troubleshoot strong {
  color: var(--help-title);
}

.video {
  margin-top: 32px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Heading row: the video icon sits directly to the right of "Watch a video". */
.video-title {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.video-icon {
  flex: none;
  color: var(--accent-cyan);
}

/* Same size as the body text (no smaller font). */
.video-note {
  color: var(--text-muted);
}

/* On wide screens the main diagram stays at its natural size instead of filling the column. */
.hero-figure {
  max-width: 640px;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tools li {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-height: 44px; /* text-only tools stay as tall as tools with an icon */
  padding: 4px 12px 4px 4px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
}

/* Small pixel icon at the start of each tool. */
.tool-icon {
  flex: none;
  width: 32px;
  height: 32px;
}

/* A tool with no icon (such as "None") keeps the same left padding as the others. */
.tools li > span:only-child {
  padding-left: 8px;
}

/* Recipe ingredients: a plain list in a card, two columns when there is room. */
.ingredients {
  display: grid;
  gap: 6px 24px;
  margin: 0;
  padding: 14px 18px 14px 36px;
  border: 2px solid var(--border);
  background: var(--surface);
}

@media (min-width: 768px) {
  .ingredients {
    grid-template-columns: 1fr 1fr;
  }
}

/* Photo credit under a recipe photo. The photo keeps its 3:2 shape at any width. */
.photo-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.photo-figure figcaption {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.warning {
  margin: 24px 0;
  padding: 16px 18px;
  border: 2px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-text);
}

.warning h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warn-title);
}

.warning ul {
  margin: 0;
  padding-left: 20px;
}

.steps {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  counter-increment: step;
  padding: 16px 18px 16px 68px;
  border: 2px solid var(--border);
  background: var(--surface);
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 16px;
  top: 16px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid var(--accent-yellow);
  color: var(--accent-yellow);
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
}

.steps p {
  margin: 0;
}

/* A step with a diagram: the text block is at least two lines tall, so a one-line step leaves the
   same space between the number box and the diagram as a two-line step does. */
.steps li:has(> .step-figure) > p {
  min-height: 3.2em;
}

/* Step diagrams use the full width of the step card, so their labels stay readable on phones. */
.steps .step-figure {
  max-width: 560px;
  margin: 14px 0 0 -50px;
}

/* ---------- Footer ---------- */

.site-footer {
  padding: 24px var(--gutter);
  background: var(--footer-bg);
  border-top: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

/* ---------- Header search panel ---------- */

.search-panel {
  position: absolute;
  z-index: 3;
  top: 100%;
  left: 0;
  right: 0;
  padding: 16px var(--gutter);
  background: var(--chrome);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.search-panel-inner {
  display: grid;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}

/* Right of the brand row, left to right: theme button, search button, and on phones the menu button.
   The search field is hidden to the left of the search button (.search-tool is its positioning
   parent) and slides out to the left when opened, over the theme button and the brand. */
.header-tools {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.search-tool {
  position: relative;
  display: flex;
  flex: none;
}

.search-box {
  position: absolute;
  z-index: 5;
  top: 0;
  right: calc(100% + 8px);
  width: 0;
  height: 44px;
  overflow: hidden;
  visibility: hidden;
  /* Closing: hide the field only after it has slid shut. */
  transition: width 0.3s ease, visibility 0s linear 0.3s;
}

.search-box.is-open {
  width: min(260px, 60vw);
  visibility: visible;
  /* Opening: become visible straight away, so the field can take focus on the tap
     and the phone keyboard opens. */
  transition: width 0.3s ease, visibility 0s;
}

.search-box input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.search-box input:focus {
  border-color: var(--accent-cyan);
}

.search-status {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.search-results {
  display: grid;
  gap: 8px;
  max-height: 50vh;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.search-results a {
  display: block;
  padding: 10px 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.search-results a:hover,
.search-results a:focus-visible {
  border-color: var(--accent-cyan);
}

.search-results small {
  color: var(--text-muted);
}

/* ---------- Footer links ---------- */

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin-bottom: 12px;
}

.footer-link {
  color: var(--text);
}

/* ---------- Static pages and contact form ---------- */

.updated {
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.sitemap {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

.sitemap ul {
  margin: 4px 0 8px;
  padding-left: 1.2rem;
}

/* Site map links use the amber accent, matching the guide titles. */
.sitemap a {
  color: var(--accent-yellow);
  font-weight: 400;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.sitemap a:hover {
  text-decoration: none;
}

/* Guide links in the site map get their own colour, so they differ from the category links above. */
.sitemap ul a {
  color: var(--sitemap-guide);
}

.form {
  display: grid;
  gap: 14px;
  max-width: 560px;
  margin-top: 20px;
}

.form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.form input,
.form select,
.form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

.form textarea {
  min-height: 140px;
  resize: vertical;
}

.form button {
  justify-self: start;
  padding: 10px 18px;
  border: 2px solid var(--accent-yellow);
  background: var(--surface);
  color: var(--accent-yellow);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.form button:hover {
  background: var(--accent-yellow);
  color: #000;
}

.form-note {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ---------- Ads (AdSense) ----------
   Ad panels use the surface colour in both themes, so they match the cards. */
.ad-slot {
  padding: 8px;
  border: 2px solid var(--border);
  background: var(--surface);
}

/* Visible "Advertisement" label above each ad. */
.ad-label {
  margin: 0 0 6px;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}

/* Grey box shown only in preview mode, in place of a real ad. */
.ad-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  background: var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

/* Menu icons: three bars. The top and bottom bars move to the middle and turn 45 degrees to make an X,
   the middle bar fades out. The header hamburger shows bars and becomes an X when the menu opens; the
   X inside the menu shows an X and becomes bars as the menu closes. Same 0.4s as the menu slide. */
.bars .bar {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.bars-x .bar-top { transform: translateY(6px) rotate(45deg); }
.bars-x .bar-mid { opacity: 0; }
.bars-x .bar-bot { transform: translateY(-6px) rotate(-45deg); }

/* Phone menu: a hamburger in the top bar opens a panel that slides in from the left.
   Only used on phones and only when JavaScript is on (theme.js adds the "js" class to <html>);
   otherwise phones keep the scrolling category row. Tablet and up never show it. */
.brand-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.menu-toggle,
.drawer,
.drawer-overlay {
  display: none;
}

/* "Phone" = narrow screens, plus phones turned sideways (wider than 768px but short, so tablets,
   which are taller, keep the category row). */
@media (max-width: 767.98px), (max-width: 1000px) and (max-height: 500px) {
  /* The category row is gone on phones, so only the top bar is left. With --nav-h at 0 it slides
     away on scroll down and back on scroll up, as before. */
  html.js {
    --nav-h: 0px;
  }

  html.js .nav-row {
    display: none;
  }

  html.js .menu-toggle {
    display: flex;
  }

  /* The search field slides out to the left over the hamburger and brand (they stay where they are
     underneath and show again when it closes). It stops at the left edge of the page column. */
  .search-box.is-open {
    width: calc(100vw - 2 * var(--gutter) - 104px);
  }

  html.js .drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 70;
    width: 100%;
    max-width: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg);
    border-right: 2px solid var(--border);
    /* Off screen to the left. visibility keeps its links out of the tab order until it is open. */
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.4s ease, visibility 0s linear 0.4s;
  }

  html.js.drawer-open .drawer {
    transform: none;
    visibility: visible;
    transition: transform 0.4s ease, visibility 0s;
  }

  html.js .drawer-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s linear 0.4s;
  }

  html.js.drawer-open .drawer-overlay {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease, visibility 0s;
  }

  html.drawer-open {
    overflow: hidden; /* the page behind the menu does not scroll */
  }

  /* Icon states. Open: the header hamburger becomes an X. Closing: the menu's X becomes bars again.
     main.js adds "drawer-closing" to <html> for the 0.4s the menu slides away. */
  html.js.drawer-open .menu-toggle .bar-top { transform: translateY(6px) rotate(45deg); }
  html.js.drawer-open .menu-toggle .bar-mid { opacity: 0; }
  html.js.drawer-open .menu-toggle .bar-bot { transform: translateY(-6px) rotate(-45deg); }

  html.js.drawer-closing #drawerClose .bar-top,
  html.js.drawer-closing #drawerClose .bar-bot { transform: none; }
  html.js.drawer-closing #drawerClose .bar-mid { opacity: 1; }

  .drawer-top {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--brand-h);
    padding: 0 var(--gutter);
    border-bottom: 2px solid var(--border);
  }

  .drawer-title {
    color: var(--accent-yellow);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  /* Menu search: the magnifier sits left of the X, and its field slides out to the left over the title,
     the same as the header search. */
  .drawer-top .drawer-title {
    flex: 1;
  }

  .drawer-tools {
    display: flex;
    align-items: center;
    flex: none;
    margin-right: 8px;
  }

  /* The menu's search field is positioned from the top bar, not the button: it starts at the page gutter
     and stops 8px left of the magnifier. 104px = the magnifier, the X and the gaps between them. */
  .drawer-top {
    position: relative;
  }

  .drawer-top .search-box {
    top: calc(50% - 22px);
    right: calc(var(--gutter) + 104px);
  }

  .drawer-top .search-box.is-open {
    width: calc(100% - 2 * var(--gutter) - 104px);
  }

  /* While a menu search is open, the category links make room for the results. */
  .drawer-results:not([hidden]) ~ .drawer-nav {
    display: none;
  }

  .drawer-results {
    padding: 8px var(--gutter) 16px;
  }

  .drawer-results .search-results {
    max-height: none; /* the whole menu scrolls, not the list */
    overflow: visible;
  }

  .drawer-nav {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
  }

  .drawer-link {
    display: flex;
    align-items: center;
    min-height: 54px;
    padding: 0 var(--gutter);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 1.05rem;
    letter-spacing: 0.05em;
    text-decoration: none;
    text-transform: uppercase;
  }

  .drawer-link:hover,
  .drawer-link:focus-visible {
    color: var(--accent-cyan);
  }

  .drawer-link[aria-current="page"] {
    color: var(--accent-yellow);
    font-weight: 700;
  }

  /* Groups in the phone menu: a <details> block whose title is a row with a + / minus sign, and
     whose links are indented below it. */
  .drawer-group-summary {
    position: relative; /* the + sign is drawn from two bars placed against the right edge */
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
  }

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

  /* The + / minus sign is two bars. The horizontal bar stays still; the upright bar turns a quarter
     turn to the left when the group opens, so it lies flat and the plus becomes a minus. */
  .drawer-group-summary::before,
  .drawer-group-summary::after {
    content: "";
    position: absolute;
    right: var(--gutter);
    top: 50%;
    width: 16px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
  }

  .drawer-group-summary::before {
    transform: translateY(-50%);
  }

  .drawer-group-summary::after {
    transform: translateY(-50%) rotate(90deg);
  }

  .drawer-group[open] > .drawer-group-summary::after {
    transform: translateY(-50%) rotate(0deg);
  }

  /* While a group slides shut, turn the bar back straight away (the open attribute is only
     removed when the slide ends). */
  .drawer-group.is-closing > .drawer-group-summary::after {
    transform: translateY(-50%) rotate(90deg);
  }

  @media (prefers-reduced-motion: no-preference) {
    .drawer-group-summary::after {
      transition: transform 0.25s ease;
    }
  }

  .drawer-sub {
    padding-left: calc(var(--gutter) + 18px);
    background: var(--surface);
    font-size: 0.98rem;
  }

}

@media (max-width: 359.98px) {
  /* Very narrow phones (320px): a smaller logo and name so the hamburger, brand and tools all fit. */
  html.js .menu-toggle {
    width: 40px;
    height: 40px;
  }

  html.js .brand-left {
    gap: 6px;
  }

  html.js .brand {
    gap: 6px;
  }

  html.js .brand img {
    width: 36px;
    height: 36px;
  }

  html.js .brand-name {
    font-size: 1rem;
    letter-spacing: 0.08em;
  }

  html.js .brand-row {
    gap: 6px;
  }

  html.js .header-tools {
    gap: 6px;
  }
}

@media (max-width: 429.98px) {
  /* "Drawnsteps" is a long name. On phones it shrinks with the screen so it never runs under the
     theme, search and menu buttons: the width needed is about 6.5 x the font size at this letter spacing. */
  .brand-name,
  html.js .brand-name {
    font-size: clamp(12px, calc((100vw - 262px) / 6.6), 22.4px);
    letter-spacing: 0.05em;
  }
}

@media (min-width: 768px) {
  /* Tablet and up: one row of chips. Chips that do not fit are moved by main.js into a "More"
     dropdown at the end of the row, so any number of categories works and the row stays one line.
     (Without JavaScript the row simply scrolls sideways.) */
  html.js .nav-row {
    overflow: visible; /* lets the dropdown hang below the row */
  }

  .nav-more {
    position: relative;
    flex: none;
  }

  .nav-more-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
  }

  .nav-more-btn.is-current {
    border-color: var(--accent-yellow);
    color: var(--accent-yellow);
  }

  .nav-more-btn[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }

  /* Group dropdowns: each group is a button; its categories hang below in a panel (shown by main.js
     adding .is-open). Reuses the look of the "More" panel. */
  html.js .nav-group {
    display: block;
    position: relative;
    flex: none;
  }

  html.js .nav-group-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
  }

  html.js .nav-group-btn.is-current {
    border-color: var(--accent-yellow);
    color: var(--accent-yellow);
  }

  html.js .nav-group-btn[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }

  html.js .nav-group-panel {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 10;
    gap: 8px;
    min-width: 220px;
    padding: 12px;
    background: var(--chrome);
    border: 2px solid var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  }

  html.js .nav-group-panel.is-open {
    display: grid;
  }

  html.js .nav-group-panel .nav-chip {
    white-space: normal;
  }

  .nav-more-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
    width: min(560px, calc(100vw - 2 * var(--gutter)));
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    padding: 12px;
    background: var(--chrome);
    border: 2px solid var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  }

  .nav-more-panel .nav-chip {
    white-space: normal;
  }

  .search-box.is-open {
    width: min(340px, 60vw);
  }

  /* From tablet width up, the logo bar stays fixed and only the category row slides away. */
  .site-header.nav-hidden {
    transform: none;
  }

  .nav-row {
    transition: transform 0.25s ease;
  }

  .site-header.nav-hidden .nav-row {
    transform: translateY(-100%);
  }

  .brand-tag {
    display: inline;
  }

  .brand img {
    width: 60px;
    height: 60px;
  }

  .brand-name {
    font-size: 1.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .site-header,
  .nav-row,
  .drawer,
  .drawer-overlay {
    transition: none;
  }

  /* The icons change shape at once, with no animation, for visitors who ask for less motion. */
  .bars .bar {
    transition: none;
  }
}

/* ---------- "Report a mistake" line at the end of a guide ---------- */

/* A thin divider above it, so it reads as the end-of-guide feedback line, not part of the video. */
.report-link {
  margin: 32px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

/* ---------- Printing a guide ----------
   Keeps what you need at the bench: title, safety box, tools, ingredients and steps with their diagrams.
   Hides the menu, search, footer, related guides and links to other pages. */
@media print {
  .skip-link,
  .site-header,
  .drawer,
  .drawer-overlay,
  .site-footer,
  .breadcrumb,
  .related,
  .report-link,
  .print-btn,
  .video,
  .pager {
    display: none !important;
  }

  html,
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12pt;
  }

  main,
  .guide {
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .warning {
    border: 2px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
    break-inside: avoid;
  }

  h1,
  h2 {
    break-after: avoid;
  }

  .steps li,
  .step-figure,
  .hero-figure,
  .troubleshoot {
    break-inside: avoid;
  }

  .steps .step-figure {
    max-width: 420px;
    margin: 8px 0 0 0;
    border: 1px solid #999999;
  }

  .hero-figure {
    max-width: 480px;
    border: 1px solid #999999;
  }

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

  /* Print the address after a link, so the page still makes sense on paper. */
  .guide a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }
}

/* ---------- Previous and Next guide ----------
   A teal-tinted box with a solid block arrow. The tint is mixed from the page's own teal and surface colours,
   so it stays soft in light mode and deep in dark mode. */

.guide-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 8px;
}

.guide-nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 15rem;
  padding: 12px 16px;
  border: 2px solid var(--accent-cyan);
  background: var(--surface);                                   /* fallback for old browsers */
  background: color-mix(in srgb, var(--accent-cyan) 14%, var(--surface));
  color: var(--text);
  text-decoration: none;
}

.guide-nav-next {
  justify-content: space-between;
  text-align: right;
}

/* The text fills the box and hugs the arrow, so "Next guide" and the title line up on the right. */
.guide-nav-next .guide-nav-text {
  flex: 1 1 auto;
  align-items: flex-end;
  text-align: right;
}

.guide-nav-link:hover,
.guide-nav-link:focus-visible {
  background: color-mix(in srgb, var(--accent-cyan) 26%, var(--surface));
}

.guide-nav-arrow {
  flex: none;
  color: var(--accent-cyan);
}

.guide-nav-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.guide-nav-label {
  color: var(--text);   /* full text colour: the muted grey is too faint on the tinted box in dark mode */
  opacity: 0.85;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.guide-nav-title {
  font-weight: 700;
}

/* Desktop and larger: bigger arrows (40px instead of 30px). */
@media (min-width: 1024px) {
  .guide-nav-arrow {
    width: 40px;
    height: 40px;
  }
}

/* Desktop and larger, with a mouse: when the pointer enters the box, the arrow bounces twice and finishes
   pushed a little way in its own direction (left for Previous, right for Next). It stays there while the
   pointer is over the box and slides back when the pointer leaves. Not used for visitors who ask for less motion. */
@keyframes arrow-bounce-left {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-8px); }
  50%  { transform: translateX(-2px); }
  75%  { transform: translateX(-8px); }
  100% { transform: translateX(-8px); }
}

@keyframes arrow-bounce-right {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(8px); }
  50%  { transform: translateX(2px); }
  75%  { transform: translateX(8px); }
  100% { transform: translateX(8px); }
}

@media (min-width: 1024px) and (hover: hover) and (prefers-reduced-motion: no-preference) {
  .guide-nav-arrow {
    transition: transform 0.25s ease;
  }

  /* The resting position on hover is the end of the bounce, so the arrow stays pushed out while hovered
     and the transition above slides it back smoothly when the pointer leaves. */
  .guide-nav-prev:hover .guide-nav-arrow {
    transform: translateX(-8px);
    animation: arrow-bounce-left 0.9s ease-in-out;
  }

  .guide-nav-next:hover .guide-nav-arrow {
    transform: translateX(8px);
    animation: arrow-bounce-right 0.9s ease-in-out;
  }
}

@media print {
  .guide-nav {
    display: none !important;
  }
}

/* ---------- Search filters (category and difficulty) ---------- */

.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0 0 12px;
}

.search-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 8rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.search-filters select {
  min-height: 44px;
  padding: 6px 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.search-filters select:focus-visible {
  outline: 3px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* ---------- Dim the page behind the search panel ---------- */

.search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;  /* below the header (50), so the header and search panel stay bright */
  background: rgba(2, 6, 23, 0.6);
}

.search-backdrop[hidden] {
  display: none;
}

/* ---------- Filters button (phones only) ----------
   On a phone the three drop-down lists are folded away until you tap Filters, so the results keep the room
   above the on-screen keyboard. On tablets and larger screens the lists are always shown. */

.search-filters-toggle {
  display: none;
  align-items: center;
  min-height: 44px;
  padding: 6px 14px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 767.98px) {
  .search-filters-toggle {
    display: inline-flex;
    justify-self: start;
  }

  .search-filters:not(.is-open) {
    display: none;
  }

  /* Filters button and the "51 guides found" line share one row, to save height above the keyboard. */
  .search-panel-inner {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px 12px;
  }

  .search-filters-toggle { order: 1; }
  .search-panel-inner .search-status { order: 2; margin: 0; }
  .search-filters { order: 3; grid-column: 1 / -1; margin-bottom: 4px; }
  .search-panel-inner .search-results { order: 4; grid-column: 1 / -1; }
}

/* ---------- Search panel height (tablet and larger) ----------
   The whole drop-down (filters, count and results) ends no lower than 3/4 of the way down the screen.
   The filters and count stay in view and the results list scrolls. */

@media (min-width: 768px) {
  .search-panel-inner {
    display: flex;
    flex-direction: column;
    /* The drop-down starts under the logo bar (--brand-h), so its bottom edge stays within 3/4 of the screen.
       34px = the panel's top and bottom padding (32px) and its bottom border (2px). */
    max-height: calc(75vh - var(--brand-h) - 34px);
    max-height: calc(75dvh - var(--brand-h) - 34px);
  }

  .search-panel-inner .search-filters,
  .search-panel-inner .search-status {
    flex: none;
  }

  .search-panel-inner .search-results {
    flex: 0 1 auto;
    min-height: 0;
    max-height: none;
  }
}

/* A step with two diagrams: a small gap between them. */
.step-figure + .step-figure {
  margin-top: 12px;
}

/* Typed commands (added v108): short code chips inside steps, warnings and help text. */
.steps code,
.troubleshoot code,
.warning code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  font-size: 0.92em;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  white-space: nowrap; /* a short command such as cd %userprofile% is never split over two lines */
}

/* Only on very narrow screens (under 360px) may a long command break, so the page never scrolls sideways. */
@media (max-width: 359px) {
  .steps code,
  .troubleshoot code,
  .warning code {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* Enlarge a picture (js/main.js, section 2b): diagrams and photos in a guide open in a full-screen viewer, fitted to the
   screen. Pinch or Ctrl + scroll zooms in further; Close resets the zoom. */
html.js .step-figure img,
html.js .hero-figure img {
  cursor: zoom-in;
}

html.js .step-figure img:focus-visible,
html.js .hero-figure img:focus-visible {
  outline: 3px solid var(--accent-yellow);
  outline-offset: 3px;
}

html.viewer-open {
  overflow: hidden; /* the page behind the viewer does not scroll */
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.88);
}

.image-viewer[hidden] {
  display: none;
}

.image-viewer-close {
  align-self: flex-end;
  min-width: 88px;
  min-height: 48px;
  margin: 8px;
  padding: 0 18px;
  border: 2px solid var(--accent-cyan);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.image-viewer-close:hover,
.image-viewer-close:focus-visible {
  border-color: var(--accent-yellow);
}

.image-viewer-hint {
  position: absolute;
  top: 20px;
  left: 14px;
  margin: 0;
  color: #ffffff;
  font-size: 0.9rem;
}

.image-viewer-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 8px 16px;
  overflow: hidden; /* nothing scrolls; the picture is moved by js/main.js when zoomed */
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* the viewer handles pinch and drag itself, so the page behind does not zoom */
}

.image-viewer-img {
  flex: none;
  display: block;
  max-width: none; /* width and height are set by fit() in js/main.js so the picture fills the screen */
  background: #ffffff;
  border-radius: 6px;
  transform-origin: 50% 50%;
  user-select: none;
  -webkit-user-drag: none;
  cursor: default;
}

@media print {
  .image-viewer {
    display: none;
  }
}
