* { margin: 0; padding: 0; box-sizing: border-box; }

/* Variable names for colors */
:root {
  --cream: #F7F1E8;
  --cast-iron: #2E261C;
  --cacao: #A8570C;
  --paper: #FFF9F1;
  --ash: #888888;
  --oak: #8B5E34;
  --pure-white: #FFF;
}

html {
    font-size: 18px;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Playwrite US Trad', cursive;
  color: var(--cacao);
}
header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.header-row1 {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin: 0;
    border-bottom: 3px solid var(--oak);
}
header h3,
header p.border-line {
  display: flex;
  align-items: flex-end;
  margin: 0;
}
header p.border-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin: 0;
  gap: 0.25rem;
}
header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.25rem;
}

/* Nav links layout */
header nav ul {
  display: flex;
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Search form layout */
header nav form {
  display: flex;
  gap: 0.25rem;
}

/* Search input and button padding */
header nav form input,
header nav form button {
  padding: 0.25rem;
}

/* Body text */
body {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 0 0.5rem;
  font-family: 'Nunito', sans-serif;
  font-size: 18px;
  color: var(--cast-iron);
  background-color: var(--cream); /* current background */
}

/* Non-title headings */
h2, h3, h4, h5, h6 {
  font-size: 22.5px; /* 25% larger than body */
}

/* Title headings */
h1 {
  font-size: 32.4px; /* 80% larger than body */
  font-weight: bold;
}

/* Login page */
.login-form, .login-form input, .login-form label, .login-form button {
  font-size: 22.5px; /* 25% larger than body */
}

/* Semi-bold text */
.semi-bold {
  font-weight: 600;
}

/* Line height */
.ingredients, .steps, .description {
  line-height: 1.25;
}

/* Links */
a {
  color: var(--oak);
  text-decoration: none;
}
a:hover {
  color: var(--cacao);
  text-decoration: underline;
}

/* Main page buttons */
.main-page a.button {
  display: inline-block;
  background-color: var(--oak);
  color: var(--cream);
  padding: 0.5em 1em;
  border-radius: 17px;
}

.main-page a.button:hover {
  background-color: var(--cacao);
  color: var(--paper);
}

/* Recipe photo */
.recipe-photo {
  transform: rotate(2deg);
  border: 5px solid var(--pure-white);
  border-radius: 3px;
  display: block;
  max-width: 100%;
}

/* Main backgrounds */
main {
  background-color: var(--paper);
  border: 2px solid var(--ash);
  padding: 1rem;
  margin: 0 auto;
  max-width: 700px;
  border-radius: 40px;
  width: 100%;
}

.description {
  margin-bottom: 2rem;
}

/* Recipe backgrounds */
article {
  background-color: var(--pure-white);
  box-shadow: 0 4px 8px rgba(0,0,0,0.5);
  padding: 1em;
  margin: 1em auto;
  max-width: 1500px;
  border-radius: 40px;
}

/* Hide bullets */
ul {
  list-style: none;
  padding-left: 0;
}

/* Keep numbers */
ol {
  list-style: decimal;
  padding-left: 1.5em;
}

/* Visually hide */
.visually-hidden {
  display: none;
}

/* Keep spacing from header to rest of article */
article > header {
  margin-bottom: 2rem;
}

/* Wrap metadata row with gaps */
article > header .metadata {
  display: flex;
  flex-wrap: wrap;
  column-gap: 1.5rem;
  row-gap: 0rem;
  align-items: center;
}

/* Tags list horizontal with 0.5rem gap */
article > header ul {
  display: flex;
  gap: 0.5rem;
  padding-left: 0;
  margin: 0;
  list-style: none;
}

/* Ingredients list */
.ingredients {
  padding-left: 1rem;
}
.ingredients li {
  text-indent: -1rem;
}

/* Steps list */
.steps {
  padding-left: 1em;
  margin-left: 0;
}

.recipe-body {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}
/* Ingredients column */
.ingredients-block {
  flex: 1;
}
/* Steps column */
.steps-block {
  flex: 2;
}

.recipe-photo {
  max-width: 100%;
  height: auto;
  display: block;
  margin-bottom: 0.5rem;
}

.sidebar dl {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin: 0;
  padding: 0;
}

.sidebar dt,
.sidebar dd {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: baseline;
}

.sidebar dt {
  flex: 0 0 calc(25% - 0.5rem);
  font-weight: bold;
}
.sidebar dd {
  flex: 0 0 calc(75% - 0.5rem);
}

.main-page {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
}

section ul {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 1rem 0;
  list-style: none;
  margin: 0;
}

/* Card style */
section ul li article {
  background: var(--pure-white);
  border: 1px solid var(--ash);
  border-radius: 0.5rem;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Card photo */
section ul li article img {
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
}

/* Tags inside cards */
section ul li article ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  row-gap: 0;
  margin: 0;
  padding: 0;
}

/* Individual tag */
section ul li article ul li a {
  white-space: nowrap;
  display: inline-block;
}

/* Search page form */
main section form {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  margin-bottom: 1rem;
}

main section form input[name="q"] {
  width: 100%;
  padding: 0.25rem;
  font-size: 1rem;
}

/* Profile header layout */
.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.profile-info {
  flex: 1;
}
.profile-photo img {
  width: 5rem;
  height: 5rem;
  object-fit: cover;
}

.top-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.sidebar {
  flex: 1;
}

.description-block {
  flex: 2;
}

.recipe-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.ingredients {
  padding-left: 1rem;
  display: block;
  column-count: unset;
  column-gap: unset;
  flex-shrink: 1;
  min-width: 0;
}
.ingredients-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.steps-block {
  flex: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 600px;
  margin: 0 auto;
}

.login-form label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.login-form input {
  width: 80%;
  padding: 0.25rem;
  text-align: right;
}

.login-form button {
  width: 50%;
  min-width: 200px;
  margin: 0 auto;
  padding: 0.5rem;
}

/* Narrow screen specific things */
/* < 500px */
@media (max-width: 500px) {
  .top-body {
    flex-direction: column;
    gap: 2rem;
  }
  .sidebar {
    flex: unset;
    width: 100%;
  }
  .description-block {
    flex: unset;
    width: 100%;
  }
  .recipe-body {
    flex-direction: column;
    gap: 2rem;
  }
  .ingredients-block,
  .steps-block {
    flex: unset;
    width: 100%;
  }
  .page {
    display: block;
    gap: 2rem;
    padding: 0;
    border-left: none;
    border-right: none;
  }
  header {
    padding: 0.5rem;
  }
  header hr {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
  }
}

/* < 700px */
@media (max-width: 700px) {
  .login-form label {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .login-form input[name="username"] {
    margin-bottom: 1rem;
  }
  .login-form input {
    width: 100%;
    text-align: left;
  }
}

/* < 600px */
@media (max-width: 600px) {
  section ul {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* < 400px */
@media (max-width: 400px) {
  section ul {
    grid-template-columns: 1fr;
  }
}

/* edit page stuff */

/* edit page title and button */
.edit-page header h1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.edit-page header h1 input#title {
    flex: 1;
    font-family: 'Playwrite US Trad', cursive;
    font-weight: bold;
    color: var(--cacao);
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    width: 100%;
    border: 1px solid var(--ash);
    padding: 0.25rem 0.5rem;
    box-sizing: border-box;
}
.edit-page header h1 button.save-btn {
    align-self: flex-start;
    padding: 0.5rem 1rem;
}

/* Textareas full width, vertical resize only */
.edit-page textarea {
    width: 100%;
    resize: vertical;
}

/* Steps inputs alignment */
.edit-page .steps-block input,
.edit-page .steps-block textarea {
    vertical-align: top;
}

/* Ingredients & Steps spacing */
.edit-page .ingredients li {
    padding: 0.25rem 0;
}
.steps-block li {
    padding: 1rem 0;
}

/* Step ingredients flex layout */
.step-ingredients li {
    padding: 0;
    display: flex;
    gap: 0rem;
    align-items: baseline;
}

.step-ingredients li {
    display: flex;
    gap: 0.5rem; 
    align-items: baseline;
}

.step-ingredients li input[type="number"] {
    width: 4rem;
}

.step-ingredients li input[name*="_unit"] {
    width: 3rem;
}

.step-ingredients li input[name*="_name"] {
    flex: 1;
    min-width: 5rem;
}

/* Steps block adjustments */
.steps-block ol li {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}
.steps-block ol li ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.steps-block ol li ul li {
    margin: 0;
    padding: 0.1rem 0;
    display: block;
}

/* Error list */
.error-list {
    color: red;
    font-weight: bold;
    margin: 1rem 0;
}

