/* ============================================
   The Blind Chef — Modern Accessible Styles
   ============================================ */

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

/* Light mode (default) */
:root {
  --bg-color: #ffffff;
  --text-color: #000000;
}

/* Dark mode (system preference) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #121212;
    --text-color: #f0f0f0;
  }
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
}

:root {
  --color-bg: #f8f6ef;
  --color-bg-top: #ebe4d5;
  --color-surface: #fffcf5;
  --color-surface-strong: #fff4d7;
  --color-text: #15120f;
  --color-text-muted: #4f4338;
  --color-border: #cebda0;
  --color-accent: #9f2f14;
  --color-accent-strong: #7a220f;
  --color-focus: #005fcc;
  --shadow-soft: 0 8px 24px rgba(64, 38, 11, 0.12);
  --radius-sm: 0.5rem;
  --radius-md: 0.85rem;
  --radius-lg: 1.15rem;
  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --max-width: 980px;
  --font-heading: "Fraunces", Georgia, serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(159, 47, 20, 0.14), transparent 55%),
    radial-gradient(900px 380px at 95% 2%, rgba(130, 103, 56, 0.18), transparent 45%),
    linear-gradient(180deg, var(--color-bg-top) 0%, var(--color-bg) 35%, var(--color-bg) 100%);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.75;
  font-size: clamp(1rem, 0.5vw + 0.95rem, 1.125rem);
  padding: var(--space-3);
}

.skip-link {
  position: absolute;
  top: -120%;
  left: var(--space-3);
  z-index: 1000;
  background: var(--color-focus);
  color: #ffffff;
  padding: var(--space-2) var(--space-3);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

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

header,
nav,
main,
footer,
.a11y-controls {
  width: min(100%, var(--max-width));
  margin-inline: auto;
}

body > header {
  padding-block: var(--space-4);
  margin-bottom: var(--space-3);
}

body > header h1 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: clamp(2.2rem, 4.2vw, 4rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--color-accent-strong);
}

body > header p {
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  font-size: clamp(1rem, 1.1vw, 1.2rem);
}

.site-nav {
  margin-bottom: var(--space-4);
}

.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.site-nav a {
  display: inline-block;
  text-decoration: none;
  color: var(--color-accent-strong);
  font-weight: 700;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  background: var(--color-surface-strong);
  border-color: var(--color-border);
}

.nav-toggle {
  display: none;
}

main {
  padding-bottom: var(--space-5);
}

article {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(1.1rem, 1.5vw + 0.8rem, 2rem);
}

article > header h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.2;
}

article > header p {
  color: var(--color-text-muted);
  margin-top: var(--space-2);
  margin-bottom: var(--space-4);
}

.recipe-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-strong);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
}

.recipe-meta div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.recipe-meta dt {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--color-text-muted);
}

.recipe-meta dd {
  font-size: 1.05rem;
  font-weight: 700;
}

article section {
  margin-bottom: var(--space-5);
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

article section h3 {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 1.2vw + 1rem, 1.65rem);
  margin-bottom: var(--space-2);
  color: var(--color-accent-strong);
}

article section ul,
article section ol {
  padding-left: 1.2rem;
}

article section ul {
  list-style: none;
  padding-left: 0;
}

article section li {
  margin-bottom: 0.7rem;
}

article section li label {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  cursor: pointer;
}

article section li input[type="checkbox"] {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.28rem;
  accent-color: var(--color-accent);
  cursor: pointer;
}

article section li.is-done label span {
  text-decoration: line-through;
  color: var(--color-text-muted);
  opacity: 0.65;
}

#instruction-steps li {
  padding: 0.2rem 0.3rem;
  border-radius: var(--radius-sm);
}

#instruction-steps li.is-current-step {
  background: #fff1db;
  border-inline-start: 4px solid var(--color-accent);
  box-shadow: inset 0 0 0 1px rgba(159, 47, 20, 0.18);
  padding-inline: 0.65rem 0.35rem;
}

.a11y-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.a11y-controls button {
  min-height: 44px;
  padding: 0.62rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-accent-strong);
  background: #fffef9;
  color: var(--color-accent-strong);
  font-family: var(--font-body);
  font-weight: 700;
  cursor: pointer;
}

.a11y-controls button:hover,
.a11y-controls button:focus-visible,
.a11y-controls button[aria-pressed="true"] {
  background: var(--color-accent-strong);
  color: #ffffff;
}

footer {
  margin-top: var(--space-4);
  padding-block: var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

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

body.large-text {
  font-size: clamp(1.2rem, 0.8vw + 1rem, 1.35rem);
}

body.high-contrast {
  --color-bg: #080808;
  --color-bg-top: #080808;
  --color-surface: #111111;
  --color-surface-strong: #1a1a1a;
  --color-text: #f6f6f6;
  --color-text-muted: #d5d5d5;
  --color-border: #f6f6f6;
  --color-accent: #ffca3a;
  --color-accent-strong: #ffd85f;
  --color-focus: #9ad5ff;
  --shadow-soft: none;
  background: #080808;
}

body.high-contrast a {
  color: #9ad5ff;
}

body.high-contrast article,
body.high-contrast article section {
  border-width: 2px;
}

body.high-contrast article section {
  background: var(--color-surface);
}

body.high-contrast #instruction-steps li.is-current-step {
  background: var(--color-surface-strong);
  box-shadow: inset 0 0 0 1px var(--color-accent);
}

/* === Manual dark mode toggle (data-theme on <html>) === */
/* Setting on html = :root so all var() references throughout the sheet update automatically */
html[data-theme="dark"] {
  --color-bg: #161311;
  --color-bg-top: #221b17;
  --color-surface: #231d18;
  --color-surface-strong: #312821;
  --color-text: #f3ede6;
  --color-text-muted: #d4c8ba;
  --color-border: #7f6c58;
  --color-accent: #f87f4f;
  --color-accent-strong: #ffa270;
  --color-focus: #7eb8ff;
  --shadow-soft: 0 6px 16px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] body:not(.high-contrast) {
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(159, 47, 20, 0.14), transparent 55%),
    radial-gradient(900px 380px at 95% 2%, rgba(130, 103, 56, 0.18), transparent 45%),
    linear-gradient(180deg, #221b17 0%, #161311 35%, #161311 100%);
  color: #f3ede6;
}

html[data-theme="dark"] article section {
  background: #1b1714;
}

html[data-theme="dark"] #instruction-steps li.is-current-step {
  background: #2e1f0f;
  box-shadow: inset 0 0 0 1px rgba(248, 127, 79, 0.2);
}

html[data-theme="dark"] .a11y-controls button,
html[data-theme="dark"] .nav-toggle {
  background: #201a16;
  color: #f1dfcf;
}

html[data-theme="dark"] .a11y-controls button:hover,
html[data-theme="dark"] .a11y-controls button:focus-visible,
html[data-theme="dark"] .a11y-controls button[aria-pressed="true"] {
  background: var(--color-accent-strong);
  color: #ffffff;
}

@media (max-width: 640px) {
  body {
    padding: var(--space-2);
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    margin-bottom: var(--space-2);
    border: 2px solid var(--color-accent-strong);
    border-radius: var(--radius-sm);
    background: #fffef9;
    color: var(--color-accent-strong);
    font-family: var(--font-body);
    font-weight: 700;
    padding: 0.5rem 0.85rem;
  }

  .site-nav ul {
    display: none;
    flex-direction: column;
  }

  .site-nav ul.is-open {
    display: flex;
  }

  .recipe-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .recipe-meta {
    grid-template-columns: 1fr;
  }
}

@media (prefers-color-scheme: dark) {
  body:not(.high-contrast) {
    --color-bg: #161311;
    --color-bg-top: #221b17;
    --color-surface: #231d18;
    --color-surface-strong: #312821;
    --color-text: #f3ede6;
    --color-text-muted: #d4c8ba;
    --color-border: #7f6c58;
    --color-accent: #f87f4f;
    --color-accent-strong: #ffa270;
    --color-focus: #7eb8ff;
    --shadow-soft: 0 6px 16px rgba(0, 0, 0, 0.45);
  }

  body:not(.high-contrast) article section {
    background: #1b1714;
  }

  body:not(.high-contrast) #instruction-steps li.is-current-step {
    background: #2e1f0f;
    box-shadow: inset 0 0 0 1px rgba(248, 127, 79, 0.2);
  }

  body:not(.high-contrast) .a11y-controls button,
  body:not(.high-contrast) .nav-toggle {
    background: #201a16;
    color: #f1dfcf;
  }

  body:not(.high-contrast) .a11y-controls button:hover,
  body:not(.high-contrast) .a11y-controls button:focus-visible,
  body:not(.high-contrast) .a11y-controls button[aria-pressed="true"] {
    background: var(--color-accent-strong);
    color: #ffffff;
  }

  /* Forced light mode: user toggled light while system is dark */
  html[data-theme="light"] body:not(.high-contrast) {
    --color-bg: #f8f6ef;
    --color-bg-top: #ebe4d5;
    --color-surface: #fffcf5;
    --color-surface-strong: #fff4d7;
    --color-text: #15120f;
    --color-text-muted: #4f4338;
    --color-border: #cebda0;
    --color-accent: #9f2f14;
    --color-accent-strong: #7a220f;
    --color-focus: #005fcc;
    --shadow-soft: 0 8px 24px rgba(64, 38, 11, 0.12);
    background:
      radial-gradient(1200px 500px at 10% -10%, rgba(159, 47, 20, 0.14), transparent 55%),
      radial-gradient(900px 380px at 95% 2%, rgba(130, 103, 56, 0.18), transparent 45%),
      linear-gradient(180deg, #ebe4d5 0%, #f8f6ef 35%, #f8f6ef 100%);
    color: #15120f;
  }

  html[data-theme="light"] article section {
    background: #ffffff;
  }

  html[data-theme="light"] .a11y-controls button,
  html[data-theme="light"] .nav-toggle {
    background: #fffef9;
    color: var(--color-accent-strong);
  }
}

/* === Recipe Actions (Scaler + Print) === */

.recipe-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.servings-scaler {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.servings-scaler label {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.servings-scaler input[type="number"] {
  width: 4.5rem;
  padding: 0.45rem 0.6rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-strong);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  -moz-appearance: textfield;
}

.servings-scaler input[type="number"]::-webkit-inner-spin-button,
.servings-scaler input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

.btn-print {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-accent-strong);
  background: transparent;
  color: var(--color-accent-strong);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-print:hover,
.btn-print:focus-visible {
  background: var(--color-accent-strong);
  color: #ffffff;
}

/* === Recipe Index === */

.page-intro {
  margin-bottom: var(--space-4);
  color: var(--color-text-muted);
  font-size: 1.05rem;
}

.recipe-grid {
  list-style: none;
  padding: 0 0 var(--space-5);
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.recipe-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: var(--space-4);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.recipe-card:hover,
.recipe-card:focus-visible {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-soft), 0 0 0 3px rgba(159, 47, 20, 0.12);
  outline: none;
}

.recipe-card h3 {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 2vw + 0.8rem, 1.9rem);
  color: var(--color-accent-strong);
  line-height: 1.2;
  margin: 0;
}

.recipe-card p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  flex: 1;
  margin: 0;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

.card-meta div {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.card-meta dt {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--color-text-muted);
}

.card-meta dd {
  font-size: 0.95rem;
  font-weight: 700;
}

@media (forced-colors: active) {
  .button {
    /* Use 'ButtonText' system keyword so it matches the user's chosen theme */
    border: 2px solid ButtonText;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    background: #ffffff;
    color: #000000;
    padding: 0;
    font-size: 12pt;
  }

  .a11y-controls,
  .site-nav,
  footer,
  .skip-link,
  .btn-print,
  .servings-scaler {
    display: none;
  }

  article,
  article section {
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0 0 1rem 0;
    background: #ffffff;
  }

  article > header h2,
  article section h3 {
    color: #000000;
  }
}

/* === Home Page === */

.hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(2rem, 4vw + 1rem, 4rem) clamp(1.5rem, 3vw + 0.5rem, 3rem);
  margin-bottom: var(--space-6);
  text-align: center;
}

.hero h2 {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  color: var(--color-accent-strong);
  margin-bottom: var(--space-3);
}

.hero p {
  color: var(--color-text-muted);
  font-size: clamp(1rem, 1vw + 0.85rem, 1.2rem);
  max-width: 58ch;
  margin-inline: auto;
  margin-bottom: var(--space-4);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.7rem 1.6rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-accent-strong);
  background: var(--color-accent-strong);
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: transparent;
  color: var(--color-accent-strong);
}

.section-heading {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 2vw + 0.8rem, 2rem);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}
