* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 18px;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #2E261C;
  background-color: #F7F1E8;
}

/* Constrain page content and center it */
.site-header__inner,
.site-nav__inner,
#main,
.site-footer {
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  padding-left: .5rem;
  padding-right: .5rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Playwrite US Trad', Georgia, 'Times New Roman', serif;
  font-size: 22.5px;
  color: #2E261C;
}

h1 {
  font-size: 32.4px;
}

.login-form input,
.login-form label,
.login-form button {
  font-size: 22.5px;
}

strong,
b {
  font-weight: bold;
}

dt,
.recipe__meta dt {
  font-weight: 600;
}


.recipe__description p,
.recipe__ingredients,
.recipe__ingredients ul,
.recipe__ingredients li,
.recipe__steps,
.recipe__steps ol,
.recipe__steps li,
.profile__about p {
  line-height: 1.25;
}

/* Recipe header: title on first line, metadata wraps horizontally */
.recipe__header {
  display: flex;
  flex-wrap: wrap;
  column-gap: 1.5rem;
  row-gap: 0;
  align-items: baseline;
}

.recipe__header .recipe__title {
  flex: 0 0 100%;
}

.recipe__tags {
  display: flex;
  flex-wrap: wrap;
  column-gap: .5rem;
  row-gap: 0;
  list-style: none;
}

.recipe__tags::before {
  content: "Tags:";
  margin-right: .5rem;
}

.recipe__tags li::before {
  content: "#";
  color: #888;
}

.recipe__tags a {
  white-space: nowrap;
}

main {
  background-color: #FFF9F1;
  border: 2px solid #888;
  border-radius: 12px;
}

.site-header {
  border-bottom: 2px solid #888;
}

/* Header: two items, brand left and profile right; align text baselines */
.site-header__inner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.site-header__profile {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
}

.profile__meta {
  text-align: right;
}

.login-form {
  border: 2px solid #888;
  border-radius: 12px;
  padding: 1rem;
}

a {
  color: #8B5E34;
  text-decoration: none;
}

a:hover {
  color: #A8570C;
  text-decoration: underline;
}

/* Brand wordmark in script font */
.brand {
  font-family: 'Playwrite US Trad', Georgia, 'Times New Roman', serif;
}


.btn {
  display: inline-block;
  padding: .5em 1em;
  background-color: #F7F1E8;
  color: #8B5E34;
  border: 2px solid #8B5E34;
  border-radius: 2em;
  text-decoration: none;
}

.btn:hover {
  background-color: #A8570C;
  color: #FFF9F1;
  border-color: #A8570C;
  text-decoration: none;
}

.recipe__sidebar img {
  transform: rotate(2deg);
  border: 5px solid #FFF;
  border-radius: 3px;
  max-width: 100%;
  height: auto;
  margin-bottom: .5rem;
}

.tags li::before {
  content: "#";
  color: #888;
}

/* Tag lists should wrap lines with no row gap and .5rem column gap */
.tags {
  display: flex;
  flex-wrap: wrap;
  column-gap: .5rem;
  row-gap: 0;
}

.tags a {
  white-space: nowrap;
}

.site-nav__links,
.tags,
.recipe__ingredients ul,
.card-grid {
  list-style: none;
}

.visually-hidden {
  display: none;
}

/* Home page hero actions: center buttons with gaps and spacing */
.hero .actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* Navigation row layout */
.site-nav__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: .25rem;
  /* small gap below header bottom border */
}

.site-nav__links {
  display: flex;
  gap: 1rem;
}

.site-nav__search {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
}

.site-nav__search input,
.site-nav__search button {
  padding: .25rem;
}

/* Card grid: 3 per row with 1rem gaps and top/bottom padding */
.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 0;
}

.card-grid>li {
  flex: 0 0 calc((100% - 2rem) / 3);
}

.recipe-card {
  border: 2px solid #888;
  background-color: #FFF9F1;
  border-radius: 6px;
}

.recipe-card .card__media img {
  max-width: 100%;
  height: auto;
  display: block;
}

.recipe-card .card__media:empty {
  display: none;
  /* collapse media area if image is removed (e.g., load failure) */
}

.recipe-card .card__media {
  padding: .5rem;
  /* add small gap to edges for a Polaroid feel */
}

.recipe-card .card__body {
  padding: .5rem;
}

/* Main content spacing */
#main {
  margin-top: 3rem;
  padding: 1rem;
}

#main h1 {
  margin-bottom: 2rem;
}

/* Recipe-specific spacing */
.recipe__ingredients {
  margin-top: 2rem;
  /* default gap after description */
}

.recipe__ingredients li {
  padding-left: 1rem;
  text-indent: -1rem;
  /* hanging indent */
}

.recipe__steps ol {
  padding-left: 1em;
  /* align numbers with "Steps" label */
}

/* Recipe meta list (Prep/Cook/Total/Yield) */
.recipe__meta {
  display: flex;
  flex-wrap: wrap;
  column-gap: .5rem;
  /* gap between label and value */
  row-gap: .25rem;
  /* gap between rows */
}

.recipe__meta dt {
  flex: 0 0 calc(25% - .25rem);
}

.recipe__meta dd {
  flex: 0 0 calc(75% - .25rem);
}

/* Recipe two-row layout with sidebars */
.recipe__row {
  display: flex;
  gap: 1rem;
  align-items: start;
}

.recipe__row>.recipe__sidebar,
.recipe__row>.recipe__ingredients {
  flex: 0 0 calc((100% - 1rem) / 3);
}

.recipe__row>.recipe__description,
.recipe__row>.recipe__steps {
  flex: 0 0 calc((100% - 1rem) * 2 / 3);
}

.recipe__row--bottom {
  margin-top: 2rem;
  /* gap between description row and ingredients/steps row */
}

.recipe__row--bottom .recipe__ingredients {
  margin-top: 0;
  /* align Ingredients header with Steps header */
}

/* Narrow screens: stack sections, adjust gaps and page chrome */
@media (max-width: 500px) {
  .recipe__row {
    display: block;
  }

  .recipe__row+.recipe__row,
  .recipe__description,
  .recipe__ingredients,
  .recipe__steps {
    margin-top: 2rem;
  }

  /* Remove outer horizontal padding and borders; header gains inner padding */
  .site-header__inner,
  .site-nav__inner,
  #main,
  .site-footer {
    padding-left: 0;
    padding-right: 0;
  }

  main {
    border-left: 0;
    border-right: 0;
  }

  .site-header {
    border-bottom: 2px solid #888;
    /* ensure full-width rule */
  }

  .site-header__inner {
    padding-left: .5rem;
    padding-right: .5rem;
  }
}

/* Login form layout */
.login-form>div {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .25rem;
}

.login-form input[type="email"],
.login-form input[type="password"] {
  width: 100%;
  padding: .25rem;
  margin-left: 0;
  border-radius: 8px;
}

.login-form button[type="submit"] {
  width: 50%;
  min-width: 200px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  border-radius: 8px;
}

/* Spacing between stacked rows */
.login-form>div+div {
  margin-top: 1rem;
}

/* Card grid responsiveness */
@media (max-width: 600px) {
  .card-grid>li {
    flex: 0 0 calc((100% - 1rem) / 2);
  }
}

@media (max-width: 400px) {
  .card-grid>li {
    flex: 0 0 100%;
  }
}

/* Search page: make main search input full-width with comfy padding */
.search-form__row input[type="search"] {
  width: 100%;
  padding: .25rem;
}

/* Profile header: photo on right, fixed size, 1rem gap */
.profile__header {
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 1rem;
}

.profile__photo {
  width: 5rem;
  height: 5rem;
  object-fit: cover;
}

/* Edit form styles */
.recipe__title {
  position: relative;
}

.recipe__title input[type="text"] {
  font-family: 'Playwrite US Trad', Georgia, 'Times New Roman', serif;
  font-size: 22.5px;
  width: 100%;
  border: 2px solid #ccc;
  background: #fff;
  outline: none;
  padding: 0.25rem;
  padding-right: 4rem;
  color: #2E261C;
  border-radius: 4px;
}

.recipe__title input[type="text"]:focus {
  border-color: #8B5E34;
  box-shadow: 0 0 0 2px rgba(139, 94, 52, 0.2);
}

.recipe__title button {
  position: absolute;
  top: 0;
  right: 0;
  background: #F7F1E8;
  color: #8B5E34;
  border: 2px solid #8B5E34;
  border-radius: 2em;
  padding: .5em 1em;
  cursor: pointer;
}

.recipe__title button:hover {
  background-color: #A8570C;
  color: #FFF9F1;
  border-color: #A8570C;
}

/* Number input sizing - Chrome/webkit only */
input[type=number][size] {
  width: calc(attr(size number, 5) * 1ch + 2rem);
}

/* Fallback for other browsers */
input[type=number][size="2"] {
  width: 3.5ch;
}

input[type=number][size="3"] {
  width: 4.5ch;
}

input[type=number][size="4"] {
  width: 6ch;
}

/* Textarea styles */
textarea {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.25;
  padding: 0.25rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Input field sizing */
input[type="text"][size="6"] {
  width: 7ch;
}

input[type="text"][size="15"] {
  width: 16ch;
}

/* Step description alignment */
.recipe__steps li textarea {
  vertical-align: top;
}

/* Ingredient list styles */
.step__ingredients {
  list-style-type: disc;
  margin-left: 2rem;
  margin-top: 0.5rem;
  padding-left: 0;
}

.step__ingredients li {
  list-style-type: disc;
  margin-left: 1rem;
}

.ingredient__row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.25rem 0;
}

/* Step spacing */
.recipe__steps>ol>li {
  padding: 1rem 0;
}

.recipe__steps>ol>li:first-child {
  padding-top: 0;
}

.recipe__steps textarea {
  margin-bottom: 0.5rem;
}

/* Ingredient input styling */
.ingredient__row input {
  padding: 0.2rem;
  border: 1px solid #ccc;
  border-radius: 3px;
}

/* Make sure textareas and inputs have consistent styling */
textarea,
input[type="text"],
input[type="number"] {
  font-family: inherit;
  font-size: inherit;
}

/* Recipe meta input styling */
.recipe__meta input {
  padding: 0.2rem;
  border: 1px solid #ccc;
  border-radius: 3px;
}

/* Error display styling */
output.errors {
  display: block;
  background-color: #ffebee !important;
  border: 2px solid #f44336 !important;
  border-radius: 4px;
  padding: 1rem !important;
  margin: 1rem 0 !important;
  color: #c62828 !important;
  font-family: inherit;
}

output.errors h3 {
  color: #c62828 !important;
  font-size: 18px !important;
  margin-bottom: 0.5rem !important;
  margin-top: 0 !important;
}

output.errors ul {
  margin-left: 1.5rem !important;
  margin-bottom: 0 !important;
  margin-top: 0 !important;
  list-style-type: disc !important;
}

output.errors li {
  margin-bottom: 0.25rem !important;
  line-height: 1.3 !important;
  color: #c62828 !important;
}