/* ============================================================
   Tatyana's Kitchen - Main Stylesheet
   Mobile-first, static site, file:// protocol compatible
   ============================================================ */

/* ------------------------------------------------------------
   1. CSS CUSTOM PROPERTIES
   ------------------------------------------------------------ */

:root {
  /* Spacing scale */
  --space-2xs: 0.25rem;
  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Border radius */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-pill: 9999px;

  /* Shadows (overridden per theme) */
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl:  0 12px 36px rgba(0, 0, 0, 0.16);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-base:   250ms ease;
  --transition-slow:   350ms ease;
  --transition-panel:  300ms ease;

  /* Typography scale using clamp() */
  --text-xs:   clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);
  --text-sm:   clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
  --text-base: clamp(0.9rem, 0.85rem + 0.3vw, 1rem);
  --text-lg:   clamp(1.05rem, 1rem + 0.35vw, 1.125rem);
  --text-xl:   clamp(1.15rem, 1.05rem + 0.5vw, 1.25rem);
  --text-2xl:  clamp(1.35rem, 1.15rem + 0.75vw, 1.5rem);
  --text-3xl:  clamp(1.6rem, 1.3rem + 1vw, 1.875rem);
  --text-4xl:  clamp(1.9rem, 1.5rem + 1.25vw, 2.25rem);

  /* Fixed colors (not theme-dependent) */
  --color-primary:       #C0392B;
  --color-primary-hover: #A93226;
  --color-primary-light: rgba(192, 57, 43, 0.1);
  --color-secondary:       #2E7D32;
  --color-secondary-hover: #256D29;
  --color-secondary-light: rgba(46, 125, 50, 0.1);
  --color-accent:       #E8A838;
  --color-accent-hover: #D49A2E;
  --color-timer:        #1565C0;
  --color-timer-hover:  #0D47A1;
  --color-timer-light:  rgba(21, 101, 192, 0.1);
  --color-success:      #2E7D32;
  --color-danger:       #C0392B;

  /* Font stacks */
  --font-heading: Georgia, "Times New Roman", "Noto Serif", serif;
  --font-body:    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
                  Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
                  "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono:    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
                  "Liberation Mono", monospace;

  /* Z-index scale */
  --z-base:    1;
  --z-sticky:  100;
  --z-overlay: 200;
  --z-panel:   300;
  --z-toast:   400;
  --z-modal:   500;

  /* Layout */
  --container-max: 1280px;
  --header-height: 60px;
}

/* ------------------------------------------------------------
   2. THEME: LIGHT
   ------------------------------------------------------------ */

[data-theme="light"] {
  --color-bg:          #FBF7F2;
  --color-surface:     #FFFFFF;
  --color-surface-alt: #F5F0E8;
  --color-text:        #2D2417;
  --color-text-muted:  #6B5D4F;
  --color-text-light:  #8C7E6E;
  --color-border:      #E8DFD3;
  --color-border-light:#F0E8DD;
  --color-input-bg:    #FFFFFF;
  --color-input-border:#D4C9BB;
  --color-backdrop:    rgba(45, 36, 23, 0.4);
  --color-header-bg:   rgba(251, 247, 242, 0.85);
  --color-skeleton:    linear-gradient(90deg, #F0E8DD 25%, #F5F0E8 50%, #F0E8DD 75%);

  --shadow-sm:  0 1px 2px rgba(45, 36, 23, 0.06);
  --shadow-md:  0 4px 12px rgba(45, 36, 23, 0.08);
  --shadow-lg:  0 8px 24px rgba(45, 36, 23, 0.1);
  --shadow-xl:  0 12px 36px rgba(45, 36, 23, 0.14);

  color-scheme: light;
}

/* ------------------------------------------------------------
   3. THEME: DARK
   ------------------------------------------------------------ */

[data-theme="dark"] {
  --color-bg:          #1A1612;
  --color-surface:     #2D2417;
  --color-surface-alt: #362D20;
  --color-text:        #F0E8DD;
  --color-text-muted:  #B8A898;
  --color-text-light:  #8C7E6E;
  --color-border:      #3D3228;
  --color-border-light:#332A1F;
  --color-input-bg:    #362D20;
  --color-input-border:#4A3E30;
  --color-backdrop:    rgba(0, 0, 0, 0.6);
  --color-header-bg:   rgba(26, 22, 18, 0.85);
  --color-skeleton:    linear-gradient(90deg, #2D2417 25%, #362D20 50%, #2D2417 75%);

  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-xl:  0 12px 36px rgba(0, 0, 0, 0.4);

  color-scheme: dark;
}

/* ------------------------------------------------------------
   4. MODERN CSS RESET
   ------------------------------------------------------------ */

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

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--transition-base),
              color var(--transition-base);
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.25;
  overflow-wrap: break-word;
}

p {
  overflow-wrap: break-word;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Remove default number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ------------------------------------------------------------
   5. LAYOUT
   ------------------------------------------------------------ */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-md);
}

.main-content {
  padding-top: var(--space-lg);
  padding-bottom: 12rem;
  min-height: 100vh;
}

/* Recipe card grid */
.recipe-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

/* ------------------------------------------------------------
   6. HEADER
   ------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  height: var(--header-height);
  background-color: var(--color-header-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  transition: background-color var(--transition-base),
              border-color var(--transition-base);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-md);
}

.site-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  transition: color var(--transition-base);
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Theme toggle button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: color var(--transition-fast),
              background-color var(--transition-fast);
}

.theme-toggle:hover {
  color: var(--color-text);
  background-color: var(--color-surface-alt);
}

.theme-toggle svg,
.theme-toggle img {
  width: 20px;
  height: 20px;
}

/* Cart button */
.cart-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: color var(--transition-fast),
              background-color var(--transition-fast);
}

.cart-btn:hover {
  color: var(--color-text);
  background-color: var(--color-surface-alt);
}

.cart-btn svg,
.cart-btn img {
  width: 22px;
  height: 22px;
}

/* Cart badge */
.cart-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  color: #FFFFFF;
  background-color: var(--color-primary);
  border-radius: var(--radius-pill);
  pointer-events: none;
  transition: transform var(--transition-fast);
}

.cart-badge:empty,
.cart-badge[data-count="0"] {
  display: none;
}

/* ------------------------------------------------------------
   7. SEARCH & FILTERS
   ------------------------------------------------------------ */

.search-filters {
  padding-block: var(--space-lg);
}

.search-filters-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Search input */
.search-wrapper {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: var(--space-sm);
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: var(--space-xs) var(--space-md) var(--space-xs) calc(var(--space-sm) + 18px + var(--space-xs));
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-input-bg);
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              background-color var(--transition-base);
}

.search-input::placeholder {
  color: var(--color-text-light);
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
  outline: none;
}

/* Debounce visual indicator */
.search-input.is-debouncing {
  border-color: var(--color-accent);
}

/* Category chips */
.category-chips {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: var(--space-2xs);
}

.category-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  min-height: 44px;
  padding: var(--space-2xs) var(--space-md);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  color: var(--color-text-muted);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-user-select: none;
  user-select: none;
}

.chip:hover {
  color: var(--color-text);
  background-color: var(--color-surface-alt);
  border-color: var(--color-text-light);
}

.chip.active,
.chip[aria-pressed="true"] {
  color: #FFFFFF;
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.chip.active:hover,
.chip[aria-pressed="true"]:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

/* Tried-only toggle switch */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 44px;
}

.toggle-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--color-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  flex-shrink: 0;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background-color: #FFFFFF;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-switch:checked {
  background-color: var(--color-primary);
}

.toggle-switch:checked::after {
  transform: translateX(22px);
}

.toggle-switch:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Filters row */
.filters-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

/* ------------------------------------------------------------
   8. RECIPE CARDS
   ------------------------------------------------------------ */

.recipe-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-base),
              box-shadow var(--transition-base),
              background-color var(--transition-base);
}

.recipe-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.recipe-card:active {
  transform: translateY(-2px);
}

/* Card image */
.card-image {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background-color: var(--color-surface-alt);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.recipe-card:hover .card-image img {
  transform: scale(1.03);
}

/* Grocery checkbox on card */
.card-checkbox {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  z-index: var(--z-base);
}

.card-checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  background-color: rgba(255, 255, 255, 0.9);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-checkbox input[type="checkbox"]:checked {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.card-checkbox input[type="checkbox"]:checked::after {
  content: "";
  display: block;
  width: 8px;
  height: 14px;
  border: solid #FFFFFF;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.card-checkbox input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Ensure 44px touch target even if checkbox is smaller */
.card-checkbox label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

/* Card body */
.card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-md);
  flex: 1;
}

.card-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color var(--transition-base);
}

.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: auto;
}

/* Category tag */
.category-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-xs);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-secondary);
  background-color: var(--color-secondary-light);
  border-radius: var(--radius-sm);
}

/* Time badge */
.time-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-xs);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  background-color: var(--color-surface-alt);
  border-radius: var(--radius-sm);
}

.time-badge svg,
.time-badge img {
  width: 14px;
  height: 14px;
}

/* ------------------------------------------------------------
   9. RECIPE DETAIL VIEW
   ------------------------------------------------------------ */

.recipe-detail {
  animation: fadeIn var(--transition-base) ease;
}

/* Back button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 44px;
  padding: var(--space-xs) var(--space-md);
  margin-top: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-lg);
}

.back-btn:hover {
  color: var(--color-text);
  background-color: var(--color-surface-alt);
  border-color: var(--color-text-light);
}

.back-btn svg,
.back-btn img {
  width: 16px;
  height: 16px;
}

/* Hero image */
.recipe-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background-color: var(--color-surface-alt);
  margin-bottom: var(--space-xl);
}

.recipe-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Recipe header info */
.recipe-header {
  margin-bottom: var(--space-xl);
}

.recipe-title {
  font-family: var(--font-heading);
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-md);
  line-height: 1.15;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

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

.meta-item svg,
.meta-item img {
  width: 18px;
  height: 18px;
  color: var(--color-text-light);
}

/* Two-column detail layout (mobile: stacked) */
.recipe-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

/* ------------------------------------------------------------
   10. SERVINGS SLIDER
   ------------------------------------------------------------ */

.servings-control {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-sm);
  background-color: var(--color-surface-alt);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
}

.servings-control label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

.servings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-user-select: none;
  user-select: none;
}

.servings-btn:hover {
  background-color: var(--color-primary-light);
  border-color: var(--color-primary);
}

.servings-btn:active {
  transform: scale(0.95);
}

.servings-slider {
  flex: 1;
  min-width: 50px;
  height: 22px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border-radius: var(--radius-pill);
  outline: none;
  margin: 0;
}

.servings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background-color: var(--color-primary);
  border: 3px solid var(--color-surface);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
  margin-top: -8px;
}

.servings-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.servings-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background-color: var(--color-primary);
  border: 3px solid var(--color-surface);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* Range track fill (WebKit) */
.servings-slider::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
}

.servings-slider::-moz-range-track {
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  border: none;
}

.servings-output {
  display: inline-block;
  min-width: 2ch;
  font-size: var(--text-xl);
  font-weight: 700;
  text-align: center;
  color: var(--color-primary);
}

/* ------------------------------------------------------------
   11. INGREDIENTS
   ------------------------------------------------------------ */

.ingredients-section {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid var(--color-border-light);
  transition: background-color var(--transition-base),
              border-color var(--transition-base);
}

.ingredients-section h2 {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.ingredient-group-header {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  padding-top: var(--space-md);
  margin-top: var(--space-md);
  margin-bottom: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.ingredient-group-header:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.ingredient-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.ingredient-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
  padding: var(--space-xs) 0;
  font-size: var(--text-base);
  color: var(--color-text);
  line-height: 1.5;
  border-bottom: 1px solid var(--color-border-light);
}

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

.ingredient-qty {
  font-weight: 600;
  white-space: nowrap;
  color: var(--color-primary);
  min-width: fit-content;
}

/* Items without quantity */
.ingredient-item.no-qty {
  color: var(--color-text-muted);
  font-style: italic;
}

/* ------------------------------------------------------------
   12. INSTRUCTIONS
   ------------------------------------------------------------ */

.instructions-section {
  flex: 1;
}

.instructions-section h2 {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-lg);
  color: var(--color-text);
}

.instruction-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.instruction-step {
  display: flex;
  gap: var(--space-md);
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  color: #FFFFFF;
  background-color: var(--color-primary);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-content {
  flex: 1;
}

.step-text {
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text);
}

/* Timer button inline with instructions */
.timer-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: var(--space-2xs) var(--space-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-timer);
  background-color: var(--color-timer-light);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  vertical-align: middle;
  margin-left: var(--space-2xs);
}

.timer-btn:hover {
  background-color: rgba(21, 101, 192, 0.15);
  border-color: var(--color-timer);
}

.timer-btn svg,
.timer-btn img {
  width: 16px;
  height: 16px;
}

/* ------------------------------------------------------------
   13. TIMER TOAST
   ------------------------------------------------------------ */

.timer-container {
  position: fixed;
  bottom: var(--space-md);
  right: var(--space-md);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-xs);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.timer-toast {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  width: 280px;
  padding: var(--space-md);
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--color-timer);
  box-shadow: var(--shadow-lg);
  animation: slideInRight var(--transition-panel) ease;
  transition: border-color var(--transition-fast),
              background-color var(--transition-base);
}

.timer-toast.is-done {
  border-left-color: var(--color-success);
  animation: slideInRight var(--transition-panel) ease,
             pulse 1.5s ease-in-out infinite;
}

.timer-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
}

.timer-toast-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.timer-toast-time {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-timer);
  letter-spacing: 0.02em;
}

.timer-toast.is-done .timer-toast-time {
  color: var(--color-success);
}

/* Timer progress bar */
.timer-progress {
  width: 100%;
  height: 4px;
  background-color: var(--color-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.timer-progress-bar {
  height: 100%;
  background-color: var(--color-timer);
  border-radius: var(--radius-pill);
  transition: width 1s linear;
}

.timer-toast.is-done .timer-progress-bar {
  background-color: var(--color-success);
}

/* Timer action buttons */
.timer-actions {
  display: flex;
  gap: var(--space-xs);
}

.timer-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 36px;
  padding: var(--space-2xs) var(--space-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.timer-pause-btn {
  color: var(--color-timer);
  background-color: var(--color-timer-light);
}

.timer-pause-btn:hover {
  background-color: rgba(21, 101, 192, 0.2);
}

.timer-cancel-btn {
  color: var(--color-text-muted);
  background-color: var(--color-surface-alt);
}

.timer-cancel-btn:hover {
  color: var(--color-danger);
  background-color: rgba(192, 57, 43, 0.1);
}

/* ------------------------------------------------------------
   14. GROCERY PANEL
   ------------------------------------------------------------ */

/* Backdrop overlay */
.grocery-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-panel);
  background-color: var(--color-backdrop);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-panel),
              visibility var(--transition-panel);
}

.grocery-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* Panel */
.grocery-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: calc(var(--z-panel) + 1);
  display: flex;
  flex-direction: column;
  width: 100%;
  background-color: var(--color-surface);
  box-shadow: var(--shadow-xl);
  transform: translateX(100%);
  transition: transform var(--transition-panel),
              background-color var(--transition-base);
}

.grocery-panel.is-open {
  transform: translateX(0);
}

/* Panel header */
.grocery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.grocery-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
}

.grocery-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.grocery-close-btn:hover {
  color: var(--color-text);
  background-color: var(--color-surface-alt);
}

.grocery-close-btn svg,
.grocery-close-btn img {
  width: 20px;
  height: 20px;
}

/* Scrollable item list */
.grocery-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-lg);
  -webkit-overflow-scrolling: touch;
}

.grocery-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border-light);
  min-height: 44px;
}

.grocery-item:last-child {
  border-bottom: none;
}

.grocery-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  min-width: 22px;
  background-color: var(--color-input-bg);
  border: 2px solid var(--color-input-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.grocery-item input[type="checkbox"]:checked {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
}

.grocery-item input[type="checkbox"]:checked::after {
  content: "";
  display: block;
  width: 6px;
  height: 12px;
  margin: 1px auto 0;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.grocery-item-text {
  font-size: var(--text-base);
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.grocery-item.is-checked .grocery-item-text {
  text-decoration: line-through;
  color: var(--color-text-light);
}

/* Empty state */
.grocery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
  color: var(--color-text-light);
}

.grocery-empty svg,
.grocery-empty img {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

/* Panel footer */
.grocery-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  width: 100%;
  min-height: 44px;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-base);
  font-weight: 600;
  color: #FFFFFF;
  background-color: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.copy-btn:hover {
  background-color: var(--color-primary-hover);
}

.copy-btn:active {
  transform: scale(0.98);
}

.copy-btn.is-copied {
  background-color: var(--color-success);
}

.copy-btn svg,
.copy-btn img {
  width: 18px;
  height: 18px;
}

/* ------------------------------------------------------------
   15. PLACEHOLDER IMAGE
   ------------------------------------------------------------ */

.placeholder-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-light);
  text-align: center;
  padding: var(--space-md);
}

[data-theme="light"] .placeholder-image {
  background: linear-gradient(135deg, #F5F0E8 0%, #E8DFD3 50%, #F0E8DD 100%);
}

[data-theme="dark"] .placeholder-image {
  background: linear-gradient(135deg, #2D2417 0%, #362D20 50%, #2D2417 100%);
}

/* ------------------------------------------------------------
   16. UTILITIES
   ------------------------------------------------------------ */

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

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  color: #FFFFFF;
  background-color: var(--color-primary);
  border-radius: var(--radius-pill);
}

/* Skeleton loading state */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--color-surface-alt);
  border-radius: var(--radius-md);
  color: transparent !important;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--color-skeleton);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}

.skeleton * {
  visibility: hidden;
}

/* Touch target helper -- ensures at least 44px */
.touch-target {
  min-width: 44px;
  min-height: 44px;
}

/* Hidden but present in DOM */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* No results state */
.no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-3xl) var(--space-md);
  text-align: center;
  color: var(--color-text-muted);
  grid-column: 1 / -1;
}

.no-results h3 {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
}

/* Body scroll lock when panel/modal open */
body.no-scroll {
  overflow: hidden;
}

/* ------------------------------------------------------------
   17. KEYFRAME ANIMATIONS
   ------------------------------------------------------------ */

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% {
    box-shadow: var(--shadow-lg);
  }
  50% {
    box-shadow: var(--shadow-lg), 0 0 0 6px rgba(46, 125, 50, 0.15);
  }
}

@keyframes skeletonShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ------------------------------------------------------------
   18. REDUCED MOTION
   ------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  html {
    scroll-behavior: auto;
  }

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

  .recipe-card:hover .card-image img {
    transform: none;
  }

  .grocery-panel {
    transition: none;
  }

  .timer-toast {
    animation: none;
  }

  .timer-toast.is-done {
    animation: none;
  }
}

/* ------------------------------------------------------------
   19. RESPONSIVE: 480px+
   ------------------------------------------------------------ */

@media (min-width: 480px) {
  .container {
    padding-inline: var(--space-lg);
  }

  .site-title {
    font-size: var(--text-2xl);
  }

  .card-body {
    padding: var(--space-md) var(--space-lg);
  }

  .timer-toast {
    width: 300px;
  }
}

/* ------------------------------------------------------------
   20. RESPONSIVE: 768px+ (Tablet)
   ------------------------------------------------------------ */

@media (min-width: 768px) {
  :root {
    --header-height: 68px;
  }

  .container {
    padding-inline: var(--space-xl);
  }

  /* 2-column recipe grid */
  .recipe-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Search grows but maxes out */
  .search-wrapper {
    max-width: 400px;
  }

  .search-filters-inner {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md);
  }

  /* Chips can wrap */
  .category-chips {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .recipe-meta {
    gap: var(--space-lg);
  }

  /* Grocery panel: right side */
  .grocery-panel {
    width: 400px;
  }
}

/* ------------------------------------------------------------
   21. RESPONSIVE: 1024px+ (Desktop)
   ------------------------------------------------------------ */

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

  /* Two-column detail layout */
  .recipe-content {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--space-2xl);
  }

  .ingredients-section {
    position: sticky;
    top: calc(var(--header-height) + var(--space-lg));
    width: 300px;
    min-width: 300px;
    max-height: calc(100vh - var(--header-height) - var(--space-xl));
    overflow-y: auto;
    flex-shrink: 0;
  }

  .instructions-section {
    flex: 1;
    min-width: 0;
  }

  /* Grocery panel: side panel, no full-overlay needed */
  .grocery-panel {
    width: 400px;
  }
}

/* ------------------------------------------------------------
   22. RESPONSIVE: 1280px+ (Large Desktop)
   ------------------------------------------------------------ */

@media (min-width: 1280px) {
  /* 4-column recipe grid */
  .recipe-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .container {
    padding-inline: var(--space-xl);
  }

  .ingredients-section {
    width: 340px;
    min-width: 340px;
  }
}

/* ------------------------------------------------------------
   23. TIMER TOAST: MOBILE OVERRIDE
   ------------------------------------------------------------ */

@media (max-width: 479px) {
  .timer-container {
    bottom: 0;
    right: 0;
    left: 0;
    padding: var(--space-xs);
  }

  .timer-toast {
    width: 100%;
  }
}

/* ------------------------------------------------------------
   24. PRINT STYLES
   ------------------------------------------------------------ */

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  /* Hide non-essential elements */
  .site-header,
  .search-filters,
  .timer-container,
  .timer-toast,
  .grocery-panel,
  .grocery-backdrop,
  .theme-toggle,
  .cart-btn,
  .back-btn,
  .card-checkbox,
  .timer-btn,
  .servings-control,
  .category-chips,
  .toggle-wrapper,
  .header-actions {
    display: none !important;
  }

  .main-content {
    padding-top: 0;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  .recipe-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .recipe-card {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }

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

  .recipe-content {
    flex-direction: column;
  }

  .ingredients-section {
    position: static;
    width: 100%;
    max-height: none;
    border: 1px solid #ccc;
  }

  .recipe-hero {
    max-height: 300px;
  }

  .recipe-title {
    font-size: 24pt;
  }

  a::after {
    content: none;
  }

  img {
    max-width: 100% !important;
  }

  .instruction-step {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
