/* Cookbook Theme - Custom CSS Variables
   Override Pico CSS defaults for theming
   Users can customize by modifying these variables
*/

/* Prevent horizontal overflow on mobile */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

:root {
  /* Primary accent color - used for links, buttons, focus states */
  --pico-primary: #b5651d;
  --pico-primary-hover: #8b4513;
  --pico-primary-focus: rgba(181, 101, 29, 0.25);
  --pico-primary-inverse: #fff;

  /* Typography */
  --pico-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --pico-font-size: 100%;
  --pico-line-height: 1.6;

  /* Spacing */
  --pico-spacing: 1rem;
  --pico-block-spacing-vertical: 1.5rem;
  --pico-block-spacing-horizontal: 1rem;
  --pico-nav-element-spacing-horizontal: 0;

  /* Border radius */
  --pico-border-radius: 0.375rem;

  /* Custom cookbook variables */
  --cookbook-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --cookbook-header-height: 4rem;
}

/* Light theme adjustments */
[data-theme="light"] {
  --pico-background-color: #faf9f7;
  --pico-card-background-color: #ffffff;
  --pico-card-border-color: #e8e4df;
  --pico-muted-color: #6b6b6b;
  --pico-muted-border-color: #e0dcd7;
}

/* Dark theme adjustments */
[data-theme="dark"] {
  --pico-primary: #d4915c;
  --pico-primary-hover: #e8a76b;
  --pico-background-color: #1a1a1a;
  --pico-card-background-color: #242424;
  --pico-card-border-color: #3a3a3a;
}

/* ===========================================
   htmx Transitions & Loading States
   =========================================== */

/* Smooth fade for htmx content swaps */
.htmx-swapping {
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

.htmx-settling {
  opacity: 1;
  transition: opacity 0.15s ease-in;
}

/* Loading indicator for htmx requests */
.htmx-request {
  position: relative;
}

.htmx-request::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--pico-primary), transparent);
  animation: htmx-loading 1s ease-in-out infinite;
}

@keyframes htmx-loading {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

/* Subtle pulse for elements being updated */
.htmx-added {
  animation: htmx-highlight 0.5s ease-out;
}

@keyframes htmx-highlight {
  0% {
    background-color: var(--pico-primary-focus);
  }

  100% {
    background-color: transparent;
  }
}

/* View Transitions API support */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.2s;
}

/* Header/nav styling */
body>header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--pico-background-color);
  border-bottom: 1px solid var(--pico-muted-border-color);
  padding: 0.75rem 0;
  margin-bottom: var(--pico-block-spacing-vertical);
}

body>header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

body>header nav ul {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  min-width: 0;
  flex-shrink: 1;
}

@media (max-width: 640px) {
  body>header nav ul:first-child {
    overflow: hidden;
  }

  body>header nav ul:first-child li {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

body>header nav li {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Ensure nav buttons have consistent height */
body>header nav a[role="button"],
body>header nav button,
body>header nav [type="submit"],
body>header nav [type="button"] {
  padding: 0.5rem 0.75rem;
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.2;
  white-space: nowrap;
}

/* ===========================================
   Landing Page / Import Page
   =========================================== */

.landing-page {
  max-width: 1100px;
  margin: 0 auto;
  padding-top: 2rem;
}

.landing-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  min-width: 0;
}

.landing-layout > * {
  min-width: 0;
}

@media (min-width: 768px) {
  .landing-layout {
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: start;
  }
}

/* Import Card */
.import-section {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.import-card {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-card-border-color);
  border-radius: var(--pico-border-radius);
  padding: 1.5rem 1rem;
  text-align: center;
  width: 100%;
  max-width: 400px;
}

@media (min-width: 576px) {
  .import-card {
    padding: 2.5rem 2rem;
  }
}

.import-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  line-height: 1;
}

.import-card h1 {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.import-card>p {
  color: var(--pico-muted-color);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.import-card form {
  max-width: none;
  text-align: left;
}

.import-card input[type="url"] {
  text-align: center;
}

.import-card button {
  width: 100%;
  margin-top: 0.5rem;
}

/* Recent Cookbooks */
.recent-repos {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--pico-muted-border-color);
  text-align: left;
}

.recent-repos h3 {
  font-size: 0.9rem;
  color: var(--pico-muted-color);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.recent-repos ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.recent-repos li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.recent-repos li:last-child {
  border-bottom: none;
}

.recent-repos a {
  color: var(--pico-color);
  text-decoration: none;
  font-size: 0.9rem;
}

.recent-repos a:hover {
  color: var(--pico-primary);
}

/* About Section */
.about-section {
  padding: 1rem 0;
}

.about-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--pico-primary);
}

.about-section h3 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.about-section p {
  color: var(--pico-muted-color);
  line-height: 1.7;
}

.about-section a {
  color: var(--pico-primary);
}

/* Code Example */
.code-example {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-card-border-color);
  border-radius: var(--pico-border-radius);
  padding: 1rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.code-example pre {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-example code {
  background: transparent;
  padding: 0;
}

/* Feature List */
.feature-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.feature-list li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--pico-muted-color);
}

.feature-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--pico-primary);
  font-weight: bold;
}

/* ===========================================
   Recipe Page Layout
   Desktop: 2 columns (content left, sidebar right)
   Mobile: 1 column (collapsible sidebar on top)
   =========================================== */

.recipe-page {
  max-width: 1200px;
  margin: 0 auto;
}

.recipe-header h1 {
  margin-bottom: 0.5rem;
  font-size: 2rem;
}

.source-link {
  color: var(--pico-muted-color);
  text-decoration: none;
  vertical-align: middle;
  display: inline-grid;
  place-content: center;
}

.source-link:hover {
  color: var(--pico-primary);
}

.source-icon {
  width: 0.6em;
  height: 0.6em;
}

/* Recipe metadata (source, time, servings, etc.) */
.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 0 0 1.5rem 0;
  padding: 0;
  font-size: 0.875rem;
  color: var(--pico-muted-color);
}

.recipe-meta-item {
  display: flex;
  gap: 0.4rem;
}

.recipe-meta dt {
  font-weight: 500;
  text-transform: capitalize;
}

.recipe-meta dt::after {
  content: ":";
}

.recipe-meta dd {
  margin: 0;
}

.recipe-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

/* Main content area (steps) */
.recipe-content {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

/* Sidebar with ingredient panels */
.recipe-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Individual collapsible panels */
.recipe-panel {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-card-border-color);
  border-radius: var(--pico-border-radius);
  overflow: hidden;
}

.recipe-panel summary {
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--pico-primary);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--pico-card-border-color);
  background: var(--pico-card-background-color);
}

.recipe-panel[open] summary {
  border-bottom: 1px solid var(--pico-card-border-color);
}

.recipe-panel:not([open]) summary {
  border-bottom: none;
}

.recipe-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
}

.recipe-panel li {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
  font-size: 0.9rem;
}

.recipe-panel li:last-child {
  border-bottom: none;
}

/* Desktop: 2-column layout */
@media (min-width: 768px) {
  .recipe-header h1 {
    font-size: 2.5rem;
  }

  .recipe-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-areas: "content sidebar";
    gap: 2rem;
    align-items: start;
  }

  .recipe-content {
    grid-area: content;
    order: 1;
  }

  .recipe-sidebar {
    grid-area: sidebar;
    order: 2;
    position: sticky;
    top: 5rem;
    /* below sticky header */
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
  }

  /* On desktop, panels are open by default and not collapsible-looking */
  .recipe-panel summary {
    pointer-events: auto;
  }

  .recipe-panel ul {
    max-height: none;
  }

  /* Limit sidebar scroll area for individual panels */
  .recipe-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .recipe-panel {
    flex-shrink: 0;
  }

  /* If sidebar content is too tall, individual panels scroll */
  .recipe-panel ul {
    max-height: 250px;
    overflow-y: auto;
  }
}

/* Large desktop: wider sidebar */
@media (min-width: 1200px) {
  .recipe-layout {
    grid-template-columns: 1fr 380px;
  }
}

/* Steps styling */
.steps-list {
  list-style: none;
  padding-left: 0;
  counter-reset: step-counter;
}

.steps-list li {
  counter-increment: step-counter;
  position: relative;
  padding: 1rem;
  padding-left: 3.5rem;
  margin-bottom: 1rem;
  background: var(--pico-card-background-color);
  border-radius: var(--pico-border-radius);
  border: 1px solid var(--pico-card-border-color);
}

.steps-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 1rem;
  top: 1rem;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--pico-primary);
  color: var(--pico-primary-inverse);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.875rem;
}

/* Step part highlighting */
.step-text {
  /* Plain text - no special styling */
}

.step-ingredient {
  color: var(--pico-primary);
  font-weight: 600;
  background: var(--pico-primary-focus);
  padding: 0.1em 0.3em;
  border-radius: 0.25em;
}

.step-cookware {
  color: var(--cookbook-cookware-color, #6366f1);
  font-weight: 600;
  background: var(--cookbook-cookware-bg, rgba(99, 102, 241, 0.15));
  padding: 0.1em 0.3em;
  border-radius: 0.25em;
}

.step-timer {
  color: var(--cookbook-timer-color, #059669);
  font-weight: 600;
  background: var(--cookbook-timer-bg, rgba(5, 150, 105, 0.15));
  padding: 0.1em 0.3em;
  border-radius: 0.25em;
  font-variant-numeric: tabular-nums;
}

/* Reference numbers for cross-referencing steps and sidebar */
.ref-num {
  font-size: 0.7em;
  font-weight: 600;
  color: var(--pico-muted-color);
  margin-left: 0.1em;
  opacity: 0.7;
}

.recipe-panel .ref-num {
  margin-left: 0;
  margin-right: 0.4em;
}

/* Make ingredient/cookware ref numbers match their highlight color */
.step-ingredient .ref-num {
  color: var(--pico-primary);
}

.step-cookware .ref-num {
  color: var(--cookbook-cookware-color, #6366f1);
}

.step-timer .ref-num {
  color: var(--cookbook-timer-color, #059669);
}

/* Dark theme adjustments for step highlights */
[data-theme="dark"] {
  --cookbook-cookware-color: #a5b4fc;
  --cookbook-cookware-bg: rgba(165, 180, 252, 0.2);
  --cookbook-timer-color: #6ee7b7;
  --cookbook-timer-bg: rgba(110, 231, 183, 0.2);
}

/* ===========================================
   Interactive Timers
   =========================================== */

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

.timer-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0.25rem 0;
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-background-color);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.timer-item:hover {
  background: var(--cookbook-timer-bg, rgba(5, 150, 105, 0.15));
}

.timer-item .timer-display {
  flex: 1;
  font-variant-numeric: tabular-nums;
}

.timer-item .timer-countdown {
  flex: 1;
  font-weight: 700;
  font-size: 1.1em;
  font-variant-numeric: tabular-nums;
  color: var(--cookbook-timer-color, #059669);
}

.timer-btn {
  all: unset;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--cookbook-timer-bg, rgba(5, 150, 105, 0.15));
  color: var(--cookbook-timer-color, #059669);
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.timer-btn:hover {
  background: var(--cookbook-timer-color, #059669);
  color: white;
}

.timer-btn:focus-visible {
  outline: 2px solid var(--cookbook-timer-color, #059669);
  outline-offset: 2px;
}

/* Running state */
.timer-item.running {
  background: var(--cookbook-timer-bg, rgba(5, 150, 105, 0.15));
}

.timer-item.running .timer-btn {
  background: var(--cookbook-timer-color, #059669);
  color: white;
}

/* Paused state */
.timer-item.paused {
  border-color: var(--pico-muted-color);
  opacity: 0.8;
}

.timer-item.paused .timer-countdown {
  color: var(--pico-muted-color);
}

/* Complete state */
.timer-item.complete {
  background: var(--cookbook-timer-color, #059669);
  border-color: var(--cookbook-timer-color, #059669);
}

.timer-item.complete .timer-countdown {
  color: white;
  font-weight: 800;
}

.timer-item.complete .timer-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.timer-item.complete .ref-num {
  color: rgba(255, 255, 255, 0.8);
}

/* Flash animation for completion */
@keyframes timer-flash {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.timer-item.flash {
  animation: timer-flash 0.5s ease-in-out 3;
}

/* Settings UI */
.timer-settings {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--pico-muted-border-color);
  font-size: 0.85rem;
}

.timer-settings summary {
  cursor: pointer;
  color: var(--pico-muted-color);
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.timer-settings label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.3rem 0;
  cursor: pointer;
  font-weight: normal;
}

.timer-settings input[type="checkbox"] {
  margin: 0;
  width: auto;
}

/* ===========================================
   Ingredient Scaling
   =========================================== */

.ingredients-scaler {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.scale-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--pico-muted-border-color);
  font-size: 0.85rem;
  user-select: none;
}

.scale-label {
  color: var(--pico-muted-color);
  margin-right: 0.25rem;
}

.scale-btn {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--pico-border-radius);
  background: var(--pico-secondary-background);
  color: var(--pico-color);
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.15s ease;
  border: 1px solid var(--pico-muted-border-color);
}

.scale-btn:hover:not(:disabled) {
  background: var(--pico-primary);
  color: var(--pico-primary-inverse);
  border-color: var(--pico-primary);
}

.scale-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.scale-input {
  width: 3.5rem;
  height: 1.75rem;
  padding: 0 0.35rem;
  margin: 0;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  background: var(--pico-background-color);
  color: var(--pico-color);
}

.scale-input:focus {
  outline: 2px solid var(--pico-primary-focus);
  outline-offset: 1px;
  border-color: var(--pico-primary);
}

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

.ingredient-list li {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.ingredient-list li:last-child {
  border-bottom: none;
}


/* ===========================================
   Table of Contents Page
   =========================================== */

.toc-page {
  max-width: 1000px;
  margin: 0 auto;
}

/* Search input */
.toc-search {
  margin-bottom: 2rem;
}

.toc-search input[type="search"] {
  width: 100%;
  max-width: 400px;
  margin: 0;
}

/* Transition for search results */
#toc-results {
  min-height: 100px;
}

/* Section container */
.toc-section {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.toc-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

/* Section titles - top level sections are larger */
.toc-section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--pico-color);
  margin: 0 0 1.25rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid var(--pico-primary);
  display: inline-block;
}

/* Nested sections get smaller titles */
.toc-subsections .toc-section {
  margin-bottom: 1.5rem;
  padding-bottom: 0;
  border-bottom: none;
  margin-left: 0;
}

.toc-subsections .toc-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--pico-muted-color);
  border-bottom: 2px solid var(--pico-muted-border-color);
  margin-bottom: 1rem;
}

/* Even deeper nesting */
.toc-subsections .toc-subsections .toc-section-title {
  font-size: 1rem;
  font-weight: 500;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

/* Recipe cards grid */
.toc-recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

/* Recipe card wrapper for hover preview */
.recipe-card-wrapper {
  position: relative;
}

/* Recipe preview popover */
.recipe-preview {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  width: max-content;
  min-width: min(250px, 90vw);
  max-width: min(350px, 90vw);
}

.recipe-preview:empty {
  display: none;
}

.recipe-preview-card {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-card-border-color);
  border-radius: var(--pico-border-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 1rem;
  margin-top: 0.5rem;
  animation: preview-fade-in 0.15s ease-out;
  max-height: 50vh;
  overflow-y: auto;
}

@keyframes preview-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.recipe-preview-card h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: var(--pico-primary);
}

.recipe-preview-card h5 {
  margin: 0.75rem 0 0.25rem 0;
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.85rem;
}

.preview-meta div {
  display: flex;
  gap: 0.25rem;
}

.preview-meta dt {
  color: var(--pico-muted-color);
}

.preview-meta dt::after {
  content: ":";
}

.preview-meta dd {
  margin: 0;
}

.preview-ingredients {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  max-height: 150px;
  overflow-y: auto;
}

.preview-ingredients li {
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.preview-ingredients li:last-child {
  border-bottom: none;
}

/* Individual recipe card */
.recipe-card {
  display: block;
  padding: 1rem 1.25rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-card-border-color);
  border-radius: var(--pico-border-radius);
  text-decoration: none;
  color: var(--pico-color);
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
}

.recipe-card:hover {
  border-color: var(--pico-primary);
  color: var(--pico-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.recipe-card:focus {
  outline: 2px solid var(--pico-primary-focus);
  outline-offset: 2px;
}

/* Subsections container */
.toc-subsections {
  margin-top: 1.5rem;
  padding-left: 1.5rem;
  border-left: 2px solid var(--pico-muted-border-color);
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .toc-recipes-grid {
    grid-template-columns: 1fr;
  }

  .toc-subsections {
    padding-left: 1rem;
  }

  .toc-section-title {
    font-size: 1.25rem;
  }

  .steps-list li {
    padding-left: 2.75rem;
  }

  .steps-list li::before {
    left: 0.5rem;
  }
}

/* Form styling */
form {
  max-width: min(600px, 100%);
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  font-size: 1.25rem;
  color: var(--pico-color);
}

.theme-toggle:hover {
  color: var(--pico-primary);
}

/* Utility classes */
.text-sm {
  font-size: 0.875rem;
}

.text-muted {
  color: var(--pico-muted-color);
}

.mono {
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
}

/* ===========================================
   Print Styles - Professional Cookbook Layout
   =========================================== */

@media print {

  /* === Page Setup === */
  @page {
    size: letter;
    margin: 0.75in 0.875in 0.75in 1in;
    /* Extra inner margin for binding */
  }

  @page :first {
    margin-top: 0.5in;
  }

  /* === Reset for Print === */
  *,
  *::before,
  *::after {
    background: white !important;
    color: #1a1a1a !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  html {
    font-size: 11pt;
  }

  body {
    font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    line-height: 1.5;
    max-width: none;
    padding: 0;
    margin: 0;
  }

  /* === Hide Non-Print Elements === */
  body>header,
  nav,
  .theme-toggle,
  button,
  [role="button"],
  script,
  .toc-search,
  .timer-settings,
  .scale-controls,
  .ref-num {
    display: none !important;
  }

  /* === Recipe Layout for Print === */
  .recipe-page {
    max-width: none;
  }

  .recipe-layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  /* === Recipe Title === */
  .source-link {
    display: none !important;
  }

  .recipe-header {
    margin-bottom: 0.25in;
  }

  .recipe-header h1 {
    font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    font-size: 28pt;
    font-weight: 400;
    text-align: center;
    margin: 0 0 0.15in 0;
    padding-bottom: 0.15in;
    border-bottom: 1.5pt solid #1a1a1a;
    letter-spacing: 0.02em;
    page-break-after: avoid;
  }

  /* Decorative element under title */
  .recipe-header h1::after {
    content: "✦";
    display: block;
    text-align: center;
    font-size: 10pt;
    margin-top: 0.1in;
    color: #666 !important;
  }

  /* Recipe metadata for print */
  .recipe-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.05in 0.25in;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 9pt;
    color: #666 !important;
    margin-bottom: 0.2in;
  }

  .recipe-meta-item {
    display: flex;
    gap: 0.1in;
  }

  .recipe-meta dt {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 8pt;
  }

  .recipe-meta dd {
    font-style: italic;
  }

  /* === Sidebar becomes top section in print === */
  .recipe-sidebar {
    position: static;
    width: 100%;
    max-height: none;
    overflow: visible;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(30%, 1fr));
    gap: 0.25in;
    margin-bottom: 0.3in;
    padding-bottom: 0.2in;
    border-bottom: 0.5pt solid #ccc;
    page-break-inside: avoid;
  }

  /* === Panel Styling (Ingredients, Cookware, Timers) === */
  .recipe-panel {
    background: transparent !important;
    border: none;
    border-radius: 0;
    break-inside: avoid;
  }

  .recipe-panel[open] {
    display: block;
  }

  /* Force details open for print */
  .recipe-panel:not([open]) {
    display: block;
  }

  .recipe-panel:not([open])>*:not(summary) {
    display: block;
  }

  .recipe-panel summary {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 9pt;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #444 !important;
    border-bottom: none;
    padding: 0 0 0.05in 0;
    margin-bottom: 0.1in;
    pointer-events: none;
    list-style: none;
  }

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

  .recipe-panel summary::after {
    display: none;
  }

  /* === Ingredient List with Checkboxes === */
  .recipe-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: none;
    overflow: visible;
  }

  .recipe-panel li {
    font-size: 10pt;
    line-height: 1.6;
    padding: 0.04in 0 0.04in 0.25in;
    border-bottom: none;
    position: relative;
    page-break-inside: avoid;
  }

  /* Reference numbers in print - subtle but visible */
  .ref-num {
    font-size: 7pt;
    color: #888 !important;
    vertical-align: super;
  }

  .recipe-panel .ref-num {
    margin-right: 0.08in;
  }

  /* Checkbox squares for ingredients */
  .recipe-panel:first-of-type li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.08in;
    width: 0.11in;
    height: 0.11in;
    border: 1pt solid #666;
    border-radius: 1pt;
  }

  /* Different marker for cookware */
  .recipe-panel:nth-of-type(2) li::before {
    content: "○";
    position: absolute;
    left: 0;
    top: 0;
    font-size: 8pt;
    color: #666 !important;
  }

  /* Different marker for timers */
  .recipe-panel:nth-of-type(3) li::before {
    content: "◷";
    position: absolute;
    left: 0;
    top: 0;
    font-size: 9pt;
    color: #666 !important;
  }


  /* === Steps Section === */
  .recipe-content {
    padding: 0;
  }

  /* Section heading for steps */
  .steps-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: print-step;
  }

  /* Add "Method" heading before steps */
  .steps-list::before {
    content: "Method";
    display: block;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 9pt;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #444 !important;
    margin-bottom: 0.15in;
  }

  .steps-list li {
    counter-increment: print-step;
    position: relative;
    padding: 0.1in 0 0.15in 0;
    margin: 0;
    border-bottom: 0.5pt dotted #ddd;
    font-size: 10.5pt;
    line-height: 1.65;
    text-align: justify;
    hyphens: auto;
    page-break-inside: avoid;
    background: transparent !important;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
  }

  .steps-list li:last-child {
    border-bottom: none;
  }

  /* Step numbers */
  .steps-list li::before {
    content: counter(print-step);
    position: static;
    display: inline-block;
    width: auto;
    height: auto;
    background: transparent !important;
    color: #1a1a1a !important;
    font-family: "Palatino Linotype", Palatino, Georgia, serif;
    font-size: 10.5pt;
    font-weight: 700;
    margin-right: 0.15in;
    border-radius: 0;
  }

  /* Drop cap on first step */
  .steps-list li:first-child {
    padding-top: 0.05in;
  }

  /* === Step Part Highlighting (subtle for print) === */
  .step-text {
    /* Normal text */
  }

  .step-ingredient {
    font-weight: 600;
    background: transparent !important;
    padding: 0;
  }

  .step-cookware {
    font-style: italic;
    background: transparent !important;
    padding: 0;
  }

  .step-timer {
    font-variant-numeric: tabular-nums;
    background: transparent !important;
    padding: 0;
  }

  /* === Widow and Orphan Control === */
  p,
  li {
    orphans: 3;
    widows: 3;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  /* === Table of Contents Print === */
  .toc-page {
    max-width: none;
  }

  .toc-section {
    break-inside: avoid;
  }

  .recipe-card {
    border: none;
    padding: 0.05in 0;
    background: transparent !important;
  }

  .recipe-card:hover {
    transform: none;
    box-shadow: none;
  }

  /* === Links === */
  a {
    text-decoration: none;
  }

  /* Don't show URLs after links in print */
  a[href]::after {
    content: none !important;
  }
}
