/* Default theme: Hearthstone — generated from themes.ts */
:root {
  --site-bg: #eceae6;
  --site-bg-alt: #e0ddd6;
  --site-text: #28261e;
  --site-text-muted: #787470;
  --site-accent: #9a6b28;
  --site-accent-hover: #866020;
  --site-font: 'Merriweather', Georgia, serif;
  --site-code-font: 'Fira Code', monospace;
  --site-surface: #f7f5f1;
  --site-border: rgba(40,38,30,0.1);
  --tab-color-active: #fff;
  --kr-color-text: #28261e;
  --kr-color-muted: #787470;
  --kr-color-accent: #9a6b28;
  --kr-color-link: #866020;
  --kr-color-quantity: #28261e;
  --kr-color-step-ingredient-highlight: #f2e4cc;
  --kr-color-surface: #f9f7f3;
  --kr-color-border: rgba(40,38,30,0.07);
  --kr-font-family: 'Merriweather', Georgia, serif;
  --kr-font-size-base: 1rem;
  --kr-line-height: 1.7;
  --kr-section-gap: 1.75rem;
  --kr-header-gap: 0.75rem;
  --kr-item-gap: 0.375rem;
  --kr-card-radius: 0.5rem;
  --kr-card-padding: 1.5rem;
}
/* === Reset & Custom Properties === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* Theme colors/fonts are generated at build time from themes.ts */
:root {
  --site-radius: 0.5rem;
  --site-density: 1;
  --site-header-height: 3.25rem;

  /* Tab style variants (default: pills) */
  --tab-bg: transparent;
  --tab-bg-active: var(--site-accent);
  --tab-color: var(--site-text-muted);
  --tab-radius: 999px;
  --tab-border-bottom: none;
}

body {
  font-family: var(--site-font);
  color: var(--site-text);
  background: var(--site-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

p { line-height: 1.6; }

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

button { cursor: pointer; font-family: inherit; }

select {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius);
  background: var(--site-surface);
  color: var(--site-text);
}

label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--site-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

pre {
  background: #1a1a1a;
  color: #e5e5e5;
  padding: 1.25rem;
  border-radius: var(--site-radius);
  overflow-x: auto;
  font-family: var(--site-code-font);
  font-size: 0.8rem;
  line-height: 1.6;
}

code {
  font-family: var(--site-code-font);
}

.section-subtitle {
  color: var(--site-text-muted);
  margin-bottom: 1.5rem;
}

/* === Recipe Viewer Page === */

/* --- Segmented controls (from style-panel.css for standalone bundle) --- */

.segmented {
  display: flex;
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius);
  overflow: hidden;
}

.seg-btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  border-right: 1px solid var(--site-border);
  background: var(--site-surface);
  color: var(--site-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.seg-btn:last-child {
  border-right: none;
}

.seg-btn:hover {
  color: var(--site-text);
}

.seg-btn.active {
  background: var(--site-accent);
  color: var(--tab-color-active);
}

/* --- Header --- */

.recipe-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--site-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: var(--site-surface);
  border-bottom: 1px solid var(--site-border);
  z-index: 100;
}

.recipe-header-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--site-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.recipe-header-logo:hover {
  text-decoration: none;
}

.recipe-header-logo svg {
  width: 1.5rem;
  height: 1.5rem;
}

.recipe-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.recipe-control-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.recipe-divider {
  width: 1px;
  height: 1.25rem;
  background: var(--site-border);
}

.recipe-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius);
  background: var(--site-surface);
  color: var(--site-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.recipe-action-btn svg {
  width: 1rem;
  height: 1rem;
}

.recipe-action-btn:hover {
  color: var(--site-text);
  border-color: var(--site-text-muted);
}

.recipe-action-btn.active {
  background: var(--site-accent);
  color: var(--tab-color-active);
  border-color: var(--site-accent);
}

.recipe-action-btn.copied {
  color: #16a34a;
  border-color: #16a34a;
}

/* --- Main content --- */

.recipe-main {
  padding-top: calc(var(--site-header-height) + 1rem);
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Loading / error states --- */

.recipe-loading,
.recipe-error {
  display: none;
}

.recipe-loading.visible {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 0;
}

.loading-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--site-border);
  border-top-color: var(--site-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.recipe-error.visible {
  display: block;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--site-text-muted);
}

.recipe-error p {
  margin-bottom: 1rem;
}

/* --- Side-by-side container --- */

.recipe-container {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0 1rem;
}

/* --- Editor card (hidden by default) --- */

.recipe-editor {
  flex: 0 0 0;
  min-width: 0;
  overflow: hidden;
  opacity: 0;
  background: var(--site-surface);
  border: 1px solid transparent;
  border-radius: var(--site-radius);
  transition: flex 0.35s ease, opacity 0.25s ease, border-color 0.25s ease;
}

.recipe-container.editor-open .recipe-editor {
  flex: 0 1 730px;
  max-width: 730px;
  opacity: 1;
  border-color: var(--site-border);
  transition: flex 0.35s ease, opacity 0.25s ease 0.1s, border-color 0.25s ease;
}

.editor-wrap {
  display: flex;
  overflow: hidden;
  max-height: 80vh;
  position: relative;
}

/* 80-character ruler */
.editor-ruler {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-right: 1px dotted var(--site-border);
  pointer-events: none;
  z-index: 1;
}

.line-numbers {
  width: 3rem;
  padding: 0.75rem 0.5rem 0.75rem 0;
  text-align: right;
  font-family: var(--site-code-font);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--site-text-muted);
  opacity: 0.5;
  background: var(--site-bg-alt);
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
  border-right: 1px solid var(--site-border);
}

#markdown-editor {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 0.75rem;
  min-height: 20rem;
  field-sizing: content;
  font-family: var(--site-code-font);
  font-size: 0.8rem;
  line-height: 1.5;
  background: var(--site-surface);
  color: var(--site-text);
  tab-size: 2;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  overflow-x: hidden;
}

/* --- Preview card --- */

.recipe-preview {
  flex: 1 1 0;
  max-width: 720px;
  min-width: 0;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius);
  padding: 1rem;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

/* Without editor, preview centers itself */
.recipe-container:not(.editor-open) .recipe-preview {
  max-width: 720px;
  margin: 0 auto;
}

/* --- Edit mode: accent border on recipe --- */

.recipe-preview.edit-mode {
  border-color: var(--site-accent);
  box-shadow: 0 0 0 1px var(--site-accent);
}

/* --- Toast --- */

.recipe-toast {
  position: fixed;
  top: calc(var(--site-header-height) + 0.75rem);
  left: 50%;
  transform: translateX(-50%) translateY(-0.5rem);
  opacity: 0;
  padding: 0.5rem 1rem;
  background: var(--site-text);
  color: var(--site-surface);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--site-radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  z-index: 200;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.recipe-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.recipe-toast.error {
  background: #dc2626;
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .recipe-control-group,
  .recipe-divider {
    display: none;
  }

  .recipe-actions {
    gap: 0.25rem;
  }

  .recipe-header {
    padding: 0 0.5rem;
  }

  .recipe-container {
    flex-direction: column;
    padding: 0 0.5rem;
  }

  .recipe-editor {
    display: none;
  }

  .recipe-container.editor-open .recipe-editor {
    display: block;
    flex: none;
    max-width: none;
    width: 100%;
    max-height: 40vh;
  }

  .editor-wrap {
    max-height: 40vh;
  }

  .recipe-preview {
    width: 100%;
    border: none;
    background: none;
    padding: 0 0.5rem;
    border-radius: 0;
  }

  kr-recipe {
    --kr-card-padding: 1rem;
    overflow-wrap: break-word;
  }
}

