/* Color variables for light mode */
:root {
  --color-primary: #e67e22;
  --color-primary-dark: #cf711f;
  --color-bg: #f9f9f9;
  --color-bg-card: #fff;
  --color-bg-hover: #f7e6d6;
  --color-text: #333;
  --color-text-dark: #2c3e50;
  --color-text-muted: #7f8c8d;
  --color-shadow: rgba(0, 0, 0, 0.05);
  --color-shadow-strong: rgba(0, 0, 0, 0.1);
  --color-shadow-btn: rgba(0, 0, 0, 0.07);
  --color-shadow-btn-hover: rgba(0, 0, 0, 0.13);
  --color-marker: #888;
  --color-footer: #888;
  --color-white: #fff;
}

/* Night mode variables */
:root.night-mode {
  --color-primary: #ffb347;
  --color-primary-dark: #e67e22;
  --color-bg: #23272e;
  --color-bg-card: #2c2f36;
  --color-bg-hover: #3a3f47;
  --color-text: #e0e0e0;
  --color-text-dark: #fff;
  --color-text-muted: #b0b0b0;
  --color-shadow: rgba(0, 0, 0, 0.4);
  --color-shadow-strong: rgba(0, 0, 0, 0.7);
  --color-shadow-btn: rgba(0, 0, 0, 0.25);
  --color-shadow-btn-hover: rgba(0, 0, 0, 0.35);
  --color-marker: #b0b0b0;
  --color-footer: #b0b0b0;
  --color-white: #23272e;
}

body,
:root.night-mode body {
  /* Transition is disabled by default to prevent flash */
}

.theme-transition body {
  transition: background-color 0.3s, color 0.3s;
}
/* Collapse All button styling */
button {
  background: var(--color-primary);
  color: var(--color-white);
  border: none;
  border-radius: 4px;
  padding: 0.5em 1.2em;
  font-size: 1rem;
  font-weight: 600;
  margin: 1.2em 0 0.5em 0;
  cursor: pointer;
  box-shadow: 0 2px 4px var(--color-shadow-btn);
  transition: background 0.2s, box-shadow 0.2s;
}
button:hover {
  background: var(--color-primary-dark);
  box-shadow: 0 4px 8px var(--color-shadow-btn-hover);
  outline: none;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
}

nav {
  background-color: var(--color-bg-card);
  padding: 1rem 2rem;
  box-shadow: 0 2px 4px var(--color-shadow-strong);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
}

main {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
}

header h1 {
  color: var(--color-text-dark);
  margin-bottom: 0.5rem;
}

.section-tag {
  color: var(--color-text-muted);
  font-style: italic;
}

.subtitle {
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

.recipe-meta {
  background-color: var(--color-bg-card);
  padding: 1.5rem;
  border-radius: 8px;
  margin: 1.5rem 0;
  box-shadow: 0 2px 4px var(--color-shadow);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.meta-item {
  padding: 0.5rem;
}

section {
  background-color: var(--color-bg-card);
  padding: 2rem;
  margin: 1.5rem 0;
  border-radius: 8px;
  box-shadow: 0 2px 4px var(--color-shadow);
}

/* Two-column layout for ingredients and tools on desktop */
.ingredients-tools-wrapper {
  display: flex;
  gap: 2rem;
}
.ingredients,
.tools {
  flex: 1 1 0;
  min-width: 0;
}

h2,
h3 {
  color: var(--color-primary);
}

h2:hover,
h3:hover {
  color: var(--color-primary-dark);
}

h2 {
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 0.5rem;
}

.ingredient-header {
  color: var(--color-primary);
  font-weight: bold;
  list-style-type: none;
  margin-left: -1.5rem;
}
.ingredient-header.optional {
  color: var(--color-text-muted);
}

ul,
ol {
  margin-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

.ingredients .amount {
  font-weight: 600;
  color: var(--color-primary);
  min-width: 80px;
  display: inline-block;
}

.ingredients .optional {
  color: var(--color-text-muted);
  font-style: italic;
}

.instructions ol {
  counter-reset: step-counter;
  list-style: none;
  margin-left: 0;
}

.instructions li {
  counter-increment: step-counter;
  margin-bottom: 1rem;
  padding-left: 3rem;
  position: relative;
}

.instructions li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  background-color: var(--color-primary);
  color: var(--color-bg);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.recipe-sections {
  margin-top: 2rem;
}

.recipe-list {
  list-style: none;
  margin-left: 0;
}

.recipe-list li {
  background-color: var(--color-bg-card);
  margin-bottom: 0.5rem;
  border-radius: 4px;
  box-shadow: 0 1px 3px var(--color-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  padding: 0;
  overflow: hidden;
}

.recipe-list a {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 1rem;
  color: var(--color-text-dark);
  text-decoration: none;
  font-weight: 500;
  font-size: 1.1rem;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.recipe-list li:hover,
.recipe-list a:hover,
.recipe-list a:focus {
  background-color: var(--color-bg-accent);
  color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--color-shadow-strong);
  outline: none;
}

.recipe-list .meta {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-left: 0.5rem;
}

/* Collapsible chapters/sections (JS-based) */
.collapsible {
  margin-bottom: 0.5em;
}
.section.collapsible {
  margin-left: 1em;
}
.collapsible-header {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: bold;
  user-select: none;
  outline: none;
}
.marker {
  margin-right: 0.5em;
  font-size: 0.8em;
  color: var(--color-text-muted);
  width: 1.2em;
  display: inline-block;
  text-align: center;
}
.marker::after {
  content: "▼";
}
.collapsed .marker::after {
  content: "▲";
}
.collapsible-content {
  display: block;
}
.collapsed .collapsible-content {
  display: none;
}
.collapsible:not(.collapsed) > .collapsible-content {
  display: block;
}

footer {
  text-align: center;
  margin-top: 40px;
  padding: 20px 0 10px 0;
  color: var(--color-text-muted);
  font-size: 1em;
  background: none;
}
footer a {
  color: var(--color-primary);
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .ingredients-tools-wrapper {
    flex-direction: column;
    gap: 0;
  }
}

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

  main {
    padding: 0 0.5rem;
  }

  section {
    padding: 1rem;
  }
}
