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

html {
  font-size: 18px;
}

body { display: block; padding: 0.5rem; }

main {
  margin-top: 3rem;
  border: 2px solid #8B5E34;
  border-radius: 6px;
  background-color: #FFF9F1;
  padding: 1rem;
  max-width: 1024px;
  text-align: left;
  margin-left: auto;
  margin-right: auto;
}

main > * + * { margin-top: 2rem; }

/* -------------------------
   Main area spacing
------------------------- */
.description {
  margin-bottom: 2rem;
}

/* -------------------------
   Fonts
------------------------- */

h1, h2, h3, h4, h5, h6 {
    font-family: 'Playwrite US Trad';
    margin-top: 1em;
    margin-bottom: 0.5em;
}

body, p, li, a, input, button, label {
    font-family: 'Nunito';
}

/* -------------------------
   Font Sizes
------------------------- */

body {
    font-size: 18px;
}

h2, h3, h4, h5, h6 {
    font-size: 22.5px;
}

#welcome-heading, h1 {
    font-size: 32.4px;
}

.login-form input,
.login-form label,
.login-form button {
    font-size: 22.5px;
}

/* -------------------------
   Font Weights
------------------------- */

strong {
    font-weight: bold;
}

.prep-time, .cook-time, .servings {
    font-weight: 600;
}

/* -------------------------
   Line Heights
------------------------- */

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

/* -------------------------
   Page background
------------------------- */
body {
    background-color: #F7F1E8;
    color: #2E261C;
    margin: 0;
    font-family: 'Nunito', sans-serif;
}

/* -------------------------
   Text & Links
------------------------- */
a {
  color: #8B5E34;
  text-decoration: none;
}

a:hover {
  color: #A8570C;
  text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
  color: #8B5E34;;
}

.tags li:not(:first-child)::before {
    content: "#";
    color: #888;
    margin-right: 0.2em;
}

/* -------------------------
   Buttons
------------------------- */
a.button {
  display: inline-block;
  background-color: #8B5E34;
  color: #F7F1E8;
  padding: 0.5em 1em;
  border-radius: 9999px;
  border: 2px solid #8B5E34;
  text-decoration: none;
}

a.button:hover {
  background-color: #F7F1E8;
  color: #8B5E34;
  border-color: #8B5E34;
  text-decoration: none;
}

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

ol {
  list-style: decimal;
  margin-left: 1.5em;
}

/* -------------------------
   Recipe header (metadata)
------------------------- */
.recipe-header {
    border-bottom: none;
    position:relative;
}

.recipe-header h1 {
  margin-bottom: 0.5rem;
}

.recipe-header .metadata ul {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recipe-header .tags {
    display: flex;
    gap: 0.5rem;
    list-style: none;
}

.recipe-top {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.recipe-photo {
    max-width: 250px;
    width: 100%;
    border: 5px solid #FFF;
    border-radius: 3px;
    transform: rotate(2deg);
}

.recipe-info {
    flex: 1;
}

/* -------------------------
   Recipe Body
------------------------- */
.recipe-body {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.ingredients-section {
  flex: 1;
}

.steps-section {
  flex: 2;
}

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

.steps {
  list-style: decimal;
  margin: 0;
  padding-left: 2rem;
  text-indent: 0;
  line-height: 1.5;
}

/* -------------------------
   Ingredients list (hanging indent)
------------------------- */
.ingredients, section ol {
    padding-left: 1rem;
    text-indent: -1rem;
}

/* -------------------------
   Steps list alignment
------------------------- */
.steps, section ol {
    padding-left: 1em;
}

/* -------------------------
   Recipe photo
------------------------- */
main img {
    max-width: 100%;
    margin-bottom: 0.5rem;
    display: block;
}

/* -------------------------
   Prep/Cook/Total/Yield layout
------------------------- */
.recipe-stats {
  display: grid;
  grid-template-columns: 1fr; /* four rows */
  row-gap: 0.5rem;
  margin-top: 0.5rem;
}

/* -------------------------
   Card grid container
------------------------- */
.card-grid {
    align-items: start;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem 0;
}

/* -------------------------
   Individual cards
------------------------- */
.card {
    border: 2px solid #8B5E34;
    border-radius: 6px;
    padding: 0.5rem;
    display: inline-block;
    gap: 0.5rem;
    background-color: #FFF9F1;
    vertical-align:top;
}

.card img {
    max-width: 100%;
    height: auto;
    border-radius: 3px;
}

/* -------------------------
   Tags inside cards
------------------------- */
.card .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.card .tags li { white-space: nowrap; }

.card .tags li::before {
    content: "#";
    color: #888;
}

.search-form {
    max-width: 600px;
    margin: 0 auto 2em auto;
}

.search-form input[type="search"] {
    width: 100%;
    padding: 0.5em;
    font-size: 18px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  border-radius: 6px;
  padding: 1rem;
  background-color: #FFF9F1;
  margin-bottom: 2rem;
}

.profile-info h1 {
  margin-bottom: 0.25rem;
}


.profile-info p:first-of-type {
  margin-top: 0;
  margin-bottom: 1rem;
}

.profile-info p:last-of-type {
  margin-top: 1rem;
}

.profile-pic {
  max-width: 100px;
  border-radius: 8px;
  border: 2px solid #8B5E34;
}

.login-box {
    padding: 1.5rem;
    max-width: 400px;
    margin: 2rem auto;
    background-color: #FFF9F1;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-box label {
    font-weight: 600;
}

.login-box input {
    padding: 0.5rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.login-box button {
    padding: 0.5rem;
    font-size: 1rem;
    background-color: #8B5E34;
    color: #FFF9F1;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.login-box button:hover {
    background-color: #A8570C;
}

/* -------------------------
   Recipe Top & Body Wrappers
------------------------- */
.recipe-top-wrapper {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.recipe-top-wrapper > .recipe-top {
    flex: 1 1 33.333%;
}

.recipe-top-wrapper > .recipe-stats {
    flex: 2 1 66.666%;
}

.recipe-body-wrapper {
    display: flex;
    gap: 1rem;
    flex-wrap: nowrap;
}

.recipe-body-wrapper > .ingredients-section {
    flex: 1 1 33.333%;
}

.recipe-body-wrapper > .steps-section {
    flex: 2 1 66.666%;
}

/* -------------------------
   Narrow screen adjustments
------------------------- */
@media (max-width: 500px) {
    body {
        padding: 0;
    }

    main {
        border: none;
        padding: 0;
    }

    main > header hr {
        margin-left: 0;
        margin-right: 0;
    }

    .recipe-top-wrapper,
    .recipe-body-wrapper {
        display: block;
        gap: 2rem;
    }

    .recipe-top-wrapper > *,
    .recipe-body-wrapper > * {
        width: 100%;
        flex: unset;
    }
}

/* -------------------------
   Login form layout
------------------------- */
.login-box form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-box form .form-row {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 1rem;
}

.login-box .form-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    width: 100%;
}


.login-box label {
    flex: 0 0 auto;
}

.login-box input {
    flex: 1;
    padding: 0.25rem;
    text-align: right;
    box-sizing: border-box;
    max-width: 100%;
}

.login-box button {
    width: 50%;
    min-width: 200px;
    margin: 1rem auto 0 auto;
    padding: 0.5rem;
    font-size: 1rem;
    background-color: #8B5E34;
    color: #FFF9F1;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.login-box button:hover {
    background-color: #A8570C;
}

/* -------------------------
   Responsive adjustments
------------------------- */
@media (max-width: 700px) {
    .login-box form .form-row {
        flex-direction: column;
        gap: 0;
    }

    .login-box form #email {
        margin-bottom: 1rem;
    }

    .login-box input {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 400px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* -------------------------
   Site header
------------------------- */
.site-header {
  display: block;
  max-width: 1200px;
  margin: 0 auto 0.5rem;
}

.site-header__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.site-header__rule {
  border-bottom: 2px solid #8B5E34;
  margin: 0.25rem 0 0.5rem;
}

.site-header__bottom {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  font-family: 'Playwrite US Trad', serif;
  font-weight: 700;
  font-size: 2rem;
  color: #8B5E34;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav ul {
  display: flex;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-search { display: flex; gap: 0.25rem; }
.site-search input, .site-search button { padding: 0.25rem; }

form[action*="/edit"] .recipe-stats {
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-auto-flow: row;
  row-gap: 0.5rem;
}


/* -------------------------
   Steps
------------------------- */
.step-ingredients {
  list-style: disc;
  margin-left: 1.5rem;
  padding-left: 1rem;
}

.step-ingredients li {
  padding: 0.25rem 0;
}

.steps .step {
  margin-bottom: 1rem;
}

/* -------------------------
   Title & Save Button
------------------------- */
.title-input {
  flex: 1;
  font-family: 'Playwrite US Trad', serif;
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 3rem);
  color: #8B5E34;
  padding: 0.4rem 0.75rem;
}

.save-btn {
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
}

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

.recipe-info textarea {
  width: 100%;
  resize: vertical;
}

.recipe-stats li {
    list-style: none;
}

.recipe-stats input[type="number"] { width: 7ch; }
.step-editor {
  display: inline-block;
  vertical-align: top;
  width: 100%;
}

.step-editor textarea {
    width: 100%;
    resize: vertical;
}

.ingredient-line {
    display:flex; gap:0.5rem;
     align-items:baseline;
}

.ingredient-line .ing-amount {
    width:8ch;
}

.ingredient-line .ing-unit {
    width:12ch;
}

.ingredient-line .ing-name {
    flex:1;
    min-width: 16ch;
}

form[action*="/edit"] .recipe-stats li{
  display:grid;
  grid-template-columns: max-content auto;
  align-items: baseline;
  column-gap:.5rem;
}

form[action*="/edit"] .recipe-stats li > div{
  display:flex;
  align-items: baseline;
  gap:.4rem;
}

form[action*="/edit"] .recipe-stats li strong,
form[action*="/edit"] .recipe-stats li div{
  flex: 0 0 auto;
}

form[action*="/edit"] .recipe-stats input[type="number"]{
  width:6ch;
  text-align:right;
  padding:.15rem .35rem;
}

h1.title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

h1.title-row .title-input {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  max-width: 38ch;
}

h1.title-row .save-btn {
  position: static;
  flex: 0 0 auto;
  align-self: flex-start;
}

.description-label {
  display: block;
  margin-bottom: 0.25rem;
  font-family: 'Nunito', sans-serif;
}

.title-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
}

/* -------------------------
   Form Errors
------------------------- */

.form-errors {
  display: block;
  border: 2px solid #c0392b;
  background: #fdecea;
  color: #c0392b;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.form-errors ul {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0;
}

.recipe-header > div > h1 form {
  margin-left: auto;
}

.recipe-header > div > h1 {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin: 0;
}

.action-btn.edit-btn {
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
}