/* =========================================================
   Snow's New England Cookbook - site stylesheet
   Plain CSS only. Shared by every page on the site.
   ========================================================= */

/* ---------- Colors (light) ---------- */
:root {
  --bg: #f8deb7;          /* warm tan page (the original site color) */
  --surface: #fff7ea;     /* recipe boxes */
  --text: #2e1e12;        /* dark brown text */
  --muted: #5c4433;       /* softer brown text */
  --accent: #8c2b1f;      /* cranberry red */
  --rule: #dfbb87;        /* thin lines and borders */
  --nav-bg: #8a4a24;      /* top menu bar (warm medium brown) */
  --nav-text: #fff8ec;
  --nav-hover: #6f3a1b;
  --focus: #c2410c;       /* keyboard focus ring */
  --shadow: 0 1px 2px rgb(74 44 23 / 0.08), 0 4px 12px rgb(74 44 23 / 0.08);

  --font-body: "EB Garamond", Garamond, Georgia, "Times New Roman", serif;
  --font-head: "EB Garamond", Garamond, Georgia, "Times New Roman", serif;
}

/* ---------- Colors (dark), for people who set their device to dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1611;
    --surface: #2a2019;
    --text: #f3e8d8;
    --muted: #d3bfa6;
    --accent: #f2a78d;
    --rule: #4a3a2d;
    --nav-bg: #120d09;
    --nav-text: #f3e8d8;
    --nav-hover: #3a2a1e;
    --focus: #fdba74;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 12px rgb(0 0 0 / 0.3);
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.25rem;        /* 20px (Garamond runs small) at default browser size; grows with the reader's own settings */
  line-height: 1.6;
}

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

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

/* Clear, high-visibility keyboard focus on everything */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Text that is read aloud by screen readers but not shown */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Skip link (first thing a keyboard user reaches) ---------- */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -10rem;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  border: 3px solid var(--focus);
  border-radius: 0.5rem;
}
.skip-link:focus { top: 1rem; }

/* ---------- Header ---------- */
.site-header {
  text-align: center;
  padding: 1.75rem clamp(1.25rem, 4vw, 3rem) 1.25rem;
}

.site-title {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 400;            /* regular weight: elegant, like an old printed title page */
  font-size: clamp(1.85rem, 1.25rem + 2.4vw, 3rem);
  line-height: 1.15;
  letter-spacing: 0.03em;
}

.site-title a {
  color: var(--text);
  text-decoration: none;
}
.site-title a:hover { color: var(--accent); }


/* Thin double rule between title and tagline, in the style of early American printing */
.site-tagline::before {
  content: "";
  display: block;
  width: 9rem;
  margin: 0.7rem auto 0.6rem;
  border-top: 3px double var(--muted);
}

.site-tagline {
  margin: 0;
  color: var(--muted);
  font-style: italic;
  font-size: 1.15rem;
}

/* ---------- Top menu: one line ---------- */
.topnav {
  position: relative;          /* the Recipes dropdown opens below the whole bar */
  z-index: 10;
  background: var(--nav-bg);
  color: var(--nav-text);
}

.topnav-list {
  list-style: none;
  margin: 0 auto;
  padding: 0 0.25rem;
  max-width: 72rem;
  display: flex;
  flex-wrap: wrap;             /* only wraps if someone zooms text very large, so nothing is cut off */
  justify-content: center;
}

.topnav-list > li { flex: 0 1 auto; }

.topnav-list > li > a,
.topnav summary {
  display: flex;
  align-items: center;
  gap: 0.35em;
  min-height: 3rem;            /* large, easy-to-tap targets */
  padding: 0.5rem 0.55rem;
  color: var(--nav-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
  white-space: nowrap;
  cursor: pointer;
}

.topnav-list > li > a:hover,
.topnav summary:hover {
  background: var(--nav-hover);
}

.topnav-list > li > a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
}

.topnav :focus-visible {
  outline-color: var(--nav-text);
  outline-offset: -4px;
}

/* On narrow screens, the longer menu words are hidden from view
   but still read in full by screen readers */
.wide-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Smallest phones: tighten the menu so it stays on one line */
@media (max-width: 22.5em) {
  .topnav-list { padding: 0; }
  .topnav-list > li > a,
  .topnav summary { padding: 0.5rem 0.4rem; font-size: 1rem; }
}

@media (min-width: 54em) {
  .wide-only {
    position: static;
    width: auto; height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
  }
  .topnav-list > li > a,
  .topnav summary {
    padding: 0.5rem 1.1rem;
    font-size: 1.2rem;
  }
}

/* ---------- Recipes drop-down menu (HTML <details>, no scripts) ---------- */
.topnav summary {
  list-style: none;
}
.topnav summary::-webkit-details-marker { display: none; }

.topnav summary::after {        /* small arrow */
  content: "";
  border-left: 0.32em solid transparent;
  border-right: 0.32em solid transparent;
  border-top: 0.38em solid currentColor;
  transition: transform 0.15s ease;
}
.topnav details[open] > summary::after {
  transform: rotate(180deg);
}
.topnav details[open] > summary {
  background: var(--nav-hover);
}

.dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin: 0 auto;
  max-width: 60rem;
  padding: 0.5rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 0;
  border-radius: 0 0 0.75rem 0.75rem;
  box-shadow: 0 12px 28px rgb(0 0 0 / 0.18);
  display: grid;
  grid-template-columns: 1fr;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
}

@media (min-width: 30em) {
  .dropdown { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 46em) {
  .dropdown { grid-template-columns: repeat(3, 1fr); padding: 0.75rem 1rem; }
}

.dropdown a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.4rem;
  color: var(--text);
  text-decoration: none;
  font-size: 1.15rem;
}
.dropdown a:hover {
  background: var(--bg);
  color: var(--accent);
  text-decoration: underline;
}
.dropdown a:focus-visible {
  outline-color: var(--focus);
  outline-offset: -3px;
}

/* ---------- Main content ---------- */
main {
  max-width: 76rem;
  margin: 0 auto;
  padding: 1.75rem clamp(1.25rem, 4vw, 3rem) 3rem;
}

.welcome {
  max-width: 40rem;
  margin: 0 auto 2rem;
  text-align: center;
  font-size: 1.15rem;
}

.section-title {
  margin: 0 0 1.25rem;
  text-align: center;
  font-family: var(--font-head);
  font-weight: 400;
  font-size: 1.9rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
}


/* ---------- Category boxes ---------- */
.categories {
  /* Each box is at most 9rem (about 145px) wide, like a large button.
     --cols sets how many fit on a row; a partial last row is centered. */
  --cols: 3;
  --gap: 1rem;
  --box: 9rem;
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: calc(var(--cols) * var(--box) + (var(--cols) - 1) * var(--gap));
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
}

.categories > li {
  width: calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
  max-width: var(--box);
}

/* Very narrow, or text zoomed very large: 2 across so words still fit */
@media (max-width: 21em) { .categories { --cols: 2; } }
@media (min-width: 36em) { .categories { --cols: 4; --gap: 1.25rem; } }
@media (min-width: 56em) { .categories { --cols: 5; --gap: 1.5rem; } }
@media (min-width: 68em) { .categories { --cols: 6; --gap: 1.75rem; } }
@media (min-width: 80em) { .categories { --cols: 7; } }

.categories a {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.categories img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.categories img.photo-low { transform: scale(1.12); transform-origin: center 85%; }

.categories span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.4rem 0.6rem;
  text-align: center;
  font-weight: 500;
  font-size: 1.05rem;
  line-height: 1.25;
  overflow-wrap: break-word;   /* only breaks a word if it truly cannot fit */
  hyphens: manual;
}

@media (min-width: 36em) {
  .categories span { font-size: 1.15rem; padding: 0.65rem 0.5rem 0.75rem; }
}

.categories a:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgb(74 44 23 / 0.1), 0 10px 22px rgb(74 44 23 / 0.14);
}
.categories a:hover span {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.categories a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-color: var(--accent);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 1.5rem 1rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 1.05rem;
}
.site-footer p { margin: 0; }

/* =========================================================
   Page border: a printer's-rule frame around the whole page,
   like an 18th-century colonial title page.
   A heavy outer rule with a fine rule just inside it.
   ========================================================= */

body { padding: 0.35rem; }

.page {
  max-width: 82rem;
  margin: 0 auto;
  border: 2px solid var(--text);        /* heavy outer rule */
  outline: 1px solid var(--text);       /* fine inner rule */
  outline-offset: -6px;
  padding: 7px;                         /* keeps the menu bar inside the fine rule */
}

/* Phones: give the boxes and menu as much of the narrow screen as possible */
@media (max-width: 39.99em) {
  .page main { padding-left: 0.6rem; padding-right: 0.6rem; }
  .page .categories { --gap: 0.75rem; }
  .page .categories span { font-size: 1rem; }
  .page .topnav-list > li > a,
  .page .topnav summary { padding: 0.5rem 0.4rem; font-size: 1rem; }
}
@media (max-width: 22.5em) {
  .page .topnav-list > li > a,
  .page .topnav summary { padding: 0.5rem 0.3rem; font-size: 0.95rem; }
}

@media (min-width: 40em) {
  body { padding: 1.5rem; }
  .page {
    border-width: 4px;
    outline-offset: -10px;
    padding: 13px;
  }
}

/* The footer rule would sit right against the border, so drop it */
.page .site-footer { border-top: 0; padding-bottom: 1.25rem; }

@media (forced-colors: active) {
  .page { border-color: CanvasText; outline-color: CanvasText; }
}
@media print {
  body { padding: 0; }
}


/* =========================================================
   Inner pages: category lists, holidays, tips, index, recipes
   ========================================================= */
.content {
  max-width: 44rem;
  margin: 0 auto;
}

.page-title {
  margin: 0 0 0.5rem;
  text-align: center;
  font-family: var(--font-head);
  font-weight: 400;
  font-size: clamp(1.8rem, 1.4rem + 1.5vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.intro {
  margin: 0 auto 1.5rem;
  max-width: 36rem;
  text-align: center;
  font-style: italic;
  color: var(--muted);
}

.content h2 {
  margin: 2rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: 0.02em;
}

.content p { margin: 0.75rem 0; }

/* Photos: never shown larger than the original, softly framed like a snapshot */
.content img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  margin: 1.5rem auto;
  padding: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 0.3rem;
  box-shadow: var(--shadow);
}

/* Ingredients and instructions */
.content ul,
.content ol {
  margin: 0.5rem 0 1rem;
  padding-left: 1.6rem;
}
.content li { margin: 0.35rem 0; padding-left: 0.2rem; }
.content ol li { margin: 0.6rem 0; }
.content li::marker { color: var(--muted); }

.content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
.content a:hover { text-decoration-thickness: 2px; }

/* "Ginny's Recipe" and similar credits */
.credit {
  margin-top: 2rem !important;
  text-align: right;
  font-style: italic;
  color: var(--muted);
}
.credit::before { content: "\2014\00a0"; }   /* em dash */

/* Lists of recipe links (category, holiday, tips pages) */
.link-list {
  list-style: none;
  padding-left: 0 !important;
}
.link-list li {
  margin: 0;
  padding: 0.3rem 0;
}
.link-list a {
  display: inline-block;
  padding: 0.15rem 0;
}
@media (min-width: 40em) {
  .link-list { columns: 2; column-gap: 2.5rem; }
  .link-list li { break-inside: avoid; }
}

/* The alphabetical index flows into columns on wider screens */
.content.index-page { max-width: 64rem; }
.index-columns { columns: 15rem; column-gap: 2.5rem; }
.index-columns h2 {
  break-after: avoid;
  margin-top: 1.25rem;
  font-size: 1.3rem;
}
.index-columns ul { break-before: avoid; }
.index-columns > h2:first-child { margin-top: 0; }
.index-columns li { break-inside: avoid; }
.index-columns .link-list { columns: auto; }

/* Printing a recipe: just the recipe */
@media print {
  .page { border: 0; outline: 0; padding: 0; }
  .site-header { padding: 0 0 0.5rem; }
  .site-tagline { display: none; }
  .content img { box-shadow: none; max-width: 60%; }
  .content a { color: #000; }
}

/* ---------- Respect "reduce motion" settings ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
  .categories a:hover { transform: none; }
}

/* ---------- Windows High Contrast and other forced-color modes ---------- */
@media (forced-colors: active) {
  .categories a,
  .dropdown { border: 1px solid CanvasText; }
  .topnav { border-bottom: 1px solid CanvasText; }
  :focus-visible { outline: 3px solid Highlight; }
  .site-tagline::before { border-color: CanvasText; }
}

/* ---------- Printing ---------- */
@media print {
  .skip-link, .topnav, .site-footer { display: none; }
  body { background: #fff; color: #000; }
  .categories a { box-shadow: none; border-color: #999; }
}
