/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Color palette: subtle, warm, darker pastels */
:root {
  --color-bg: #f2e8d8;
  --color-surface: #fdf8ef;
  --color-surface-muted: #f6ecdd;
  --color-divider: #f0e5d3;

  --color-border: #d9c3a6;
  --color-border-soft: #e6d7c0;

  --color-text: #4a372a;
  --color-text-muted: #7d6650;
  --color-text-subtle: #96826c;
  --color-label: #6b5443;
  --color-heading: #6b3f2c;

  --color-primary: #a85f42;
  --color-primary-hover: #8c4c35;
  --color-primary-soft: rgba(168, 95, 66, 0.25);

  --color-btn-bg: #ecdfc9;
  --color-btn-hover-bg: #e3cfae;

  --color-danger: #a3543f;
  --color-danger-hover: #8a4433;
  --color-danger-bg: #f1ddd2;
  --color-danger-border: #e2c1ac;
  --color-danger-text: #6b3324;

  --color-success-bg: #e3e6cf;
  --color-success-border: #ccd2a8;
  --color-success-text: #4d5230;

  --color-shadow: rgba(107, 63, 44, 0.12);
  --color-shadow-strong: rgba(107, 63, 44, 0.18);
}

/* Base styles */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 20px;
  background-color: var(--color-bg);
  color: var(--color-text);
}

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

/* Typography */
@font-face {
  font-family: "Marck Script";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/marck-script/marck-script-latin-400-normal-4d9e1efb.woff2") format("woff2"),
       url("/assets/marck-script/marck-script-latin-400-normal-93829bd0.woff") format("woff");
}

h1, h2, h3 {
  margin-top: 0;
  color: var(--color-heading);
  font-family: "Marck Script", cursive;
}

h1 { font-size: 2.5rem; margin-bottom: 0; }
h2 { font-size: 2rem; margin-bottom: 0; }
h3 { font-size: 1.5rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 16px;
  background-color: var(--color-btn-bg);
  color: var(--color-label);
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn:hover {
  background-color: var(--color-btn-hover-bg);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

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

.btn-danger {
  background-color: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background-color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--color-border-soft);
}

.tag-filter {
  margin-bottom: 20px;

  a {
    color: var(--color-text);
    margin-right: 10px;
    text-decoration: none;
  }
}

/* Recipe grid */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.recipe-card {
  position: relative;
  background: var(--color-surface);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px var(--color-shadow);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.recipe-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--color-shadow-strong);
}

.recipe-card h3 {
  margin-bottom: 10px;
}

.recipe-card h3 a {
  color: var(--color-heading);
  text-decoration: none;
}

.recipe-card h3 a:hover {
  color: var(--color-primary);
}

.recipe-card .recipe-thumbnail {
  width: 100%;
}

.stretched-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.recipe-card .recipe-tags,
.recipe-card .recipe-card-photo {
  position: relative;
  z-index: 2;
}

.recipe-card .description {
  color: var(--color-text-subtle);
}

.recipe-card-meta {
  color: var(--color-text-muted);
  font-size: 14px;
  margin: 10px 0;
  border-collapse: collapse;
}

.recipe-card-meta th {
  padding: 2px 15px 2px 0;
  font-weight: 500;
  text-align: left;
  color: var(--color-label);
}

.recipe-card-meta td {
  padding: 2px 0;
}

.recipe-actions {
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
}

.actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--color-surface);
  border-radius: 8px;
  box-shadow: 0 2px 4px var(--color-shadow);
}

/* Recipe show page */
.recipe-header {
}
.recipe-title-section {
  padding-bottom: 20px;
}
.recipe-header .recipe-photo {
  margin-top: 30px;
}

.recipe-photo-frame {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  cursor: zoom-in;
  border-radius: 6px;
}

.recipe-photo-bg {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  object-fit: cover;
  filter: blur(18px) brightness(0.75);
  pointer-events: none;
  user-select: none;
}

.recipe-photo-frame img.recipe-main-photo {
  position: relative;
  max-height: 300px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
  transition: max-height 0.4s ease;
}

.recipe-photo-frame.is-expanded {
  cursor: zoom-out;
}

.recipe-photo-frame.is-expanded img.recipe-main-photo {
  max-height: none;
  width: 100%;
  object-fit: cover;
}

.recipe-description {
  margin: 8px 0;
}

.recipe-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.meta-item {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.recipe-content {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 30px;
}

.ingredients-column, .instructions-column {
  display: flex;
  flex-direction: column;
}

.recipe-tags code {
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  font-family: mono;
  font-size: 0.8em;
  padding: 0 10px;

  a {
    color: var(--color-label);
    font-style: italic;
    text-decoration: none;

    &:before {
      content: "#";
    }
  }
}

.ingredients-section, .instructions-section {
  background: var(--color-surface);
  padding: 25px;
  border-radius: 8px;
  box-shadow: 0 2px 4px var(--color-shadow);
}

.ingredients-list {
  list-style: none;
  padding: 0;
}

.ingredients-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--color-divider);
  margin: 16px;

  &.section-title {
    font-weight: bold;
    padding: 16px 0 8px 0;

    &:before {
      display: none;
    }
  }
}

.ingredients-list li:before {
  content: "•";
  color: var(--color-primary);
  margin-left: -15px;
  margin-right: 5px;
}

.instructions-list {
  padding-left: 20px;
}

.instructions-list li {
  margin-bottom: 15px;
  line-height: 1.8;
}

.instructions-list li::marker {
  font-family: "Marck Script", cursive;
  margin-inline-end: 12px;
}

.step-ingredients-list {
  list-style: none;
  margin: 10px 0 0 0;
  padding: 10px 15px;
  background: var(--color-surface-muted);
  border-radius: 4px;
  font-size: 14px;
}

.step-ingredients-list li {
  padding: 2px 0;
}

.servings-input {
  width: 80px;
  display: inline-block;
}

/* Forms */
.recipe-form {
  background: var(--color-surface);
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 4px var(--color-shadow);
  max-width: 800px;
}

.form-group {
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: var(--color-label);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 16px;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-soft);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border-soft);
}

.danger-zone {
  margin-top: 50px;
  padding-top: 20px;
  text-align: center;
}

.btn-subtle-danger {
  display: inline-block;
  padding: 6px 12px;
  background: none;
  border: none;
  color: var(--color-text-subtle);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.btn-subtle-danger:hover {
  color: var(--color-danger);
}

.form-hint {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: -10px 0 15px 0;
}

.nested-fields {
  border: 1px solid var(--color-border-soft);
  border-radius: 4px;
  padding: 15px;
  margin-bottom: 15px;
}

.step-fields-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.step-fields-title {
  font-weight: 500;
  color: var(--color-label);
}

.step-ingredients {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px dashed var(--color-border);
}

.step-ingredients .nested-fields {
  padding: 10px;
  margin-bottom: 10px;
}

.step-ingredient-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.step-ingredient-amount {
  width: 90px;
  flex: 0 1 90px;
}

.step-ingredient-unit {
  width: 120px;
  flex: 0 1 120px;
}

.step-ingredient-name {
  flex: 1 1 160px;
  min-width: 160px;
}

.btn-add-fields {
  margin-top: 5px;
}

.btn-remove-fields {
  padding: 4px 10px;
  font-size: 13px;
}

.btn-remove-ingredient {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  background: none;
  border: none;
  color: var(--color-text-subtle);
  cursor: pointer;
}

.btn-remove-ingredient:hover {
  color: var(--color-danger);
}

/* Footer */
.app-footer {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 100;
}

/* Alerts */
.alert {
  padding: 15px 20px;
  margin-bottom: 20px;
  border-radius: 4px;
}

.alert-error {
  background-color: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  color: var(--color-danger-text);
}

.alert ul {
  margin: 10px 0 0 0;
  padding-left: 20px;
}

/* Responsive design */
@media (max-width: 768px) {
  .recipe-content {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .recipe-header {
    flex-direction: column;
    gap: 15px;
  }

  .recipe-meta {
    flex-direction: row;
    gap: 12px;
  }

  .recipes-grid {
    grid-template-columns: 1fr;
  }
}
