/* Global Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 18px;
    max-width: 700px;
    width: 100%;
    margin: auto;
}

body {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    padding-inline: 0.5rem; /* L/R */
    background-color: #f7f1e8;
    font-family:
        'Nunito',
        system-ui,
        -apple-system,
        'Segoe UI',
        Roboto,
        Arial,
        sans-serif;
}

a {
    color: #8b5e34;
    text-decoration: none;
}

a:hover {
    color: #a8570c;
    text-decoration: underline;
}

ul {
    list-style: none;
}

header,
main {
    word-break: normal;
    overflow-wrap: break-word;
}

h1,
h2,
h3,
h4 {
    color: #a8570c;
    font-family: 'Playwrite US Trad', 'Times New Roman', Times, serif;
    font-size: 1.25em;
}

h1 {
    color: #8b5e34;
}

h2 {
    font-size: 1.8em;
}

h4 {
    font-size: 1em;
}

/* Header */

header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.25rem;
}

.first-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: end;
}

.first-row-title {
    flex: 0 0 auto;
}

.first-row-name-and-profile {
    flex: 0 1 auto;
    display: flex;
    flex-direction: row-reverse;
    gap: 0.25rem;
    text-align: right;
}

hr {
    border: none;
    border-top: 2px solid #8b5e34;
}

.second-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.second-row-home-and-cookbook {
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem;
    list-style: none;
}

.second-row-home-and-cookbook li {
    flex: 0 0 auto;
}

.second-row-search {
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.second-row-search input {
    flex: 1 1 auto;
    height: 1.6rem;
    padding: 0.25rem;
}

.second-row-search button {
    height: 1.6rem;
    padding: 0.25rem;
}

/* Main Content */

main {
    background-color: #fff9f1;
    border: 1px solid #888;
    border-bottom: none;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
}

.home,
.login,
.profile,
.recipe,
.search {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1rem;
}

.home-intro {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.home-intro-buttons {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
}

.home-intro-buttons-links {
    flex: 0 0 auto;
    text-align: center;
    color: #f7f1e8;
    background-color: #8b5e34;
    padding: 0.5em 1em;
    border-radius: 15px;
    text-decoration: none;
}

.home-intro-buttons-links:hover {
    color: #a8570c;
    background-color: #fff9f1;
    text-decoration: none;
}

.login-intro {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-intro-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-size: 1.25em;
}

.login-intro-form-label-and-input {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    width: 100%;
    gap: 0rem 0.5rem;
}

.login-intro-form label {
    font-size: smaller;
}

.login-intro-form input {
    width: 80%;
    padding: 0.25rem;
}

.login-intro-form-checkbox {
    width: 80%;
    margin-left: auto;
    justify-content: flex-start;
    align-items: center;
    gap: 0.5rem;
}

.login-intro-form-checkbox input[type='checkbox'] {
    width: auto;
}

.login-intro-form button {
    width: 50%;
    min-width: 200px;
    align-self: center;
    line-height: 1.6rem;
}

/* Profile */

.profile-intro {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.profile-intro-header-and-image {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 1rem;
}

.profile-intro-header {
    display: flex;
    flex-direction: column;
}

.profile-intro-header-meta {
    display: flex;
    flex-direction: row;
    gap: 1rem;
}

.profile-intro-image {
    max-width: 100px;
    width: 5rem;
    height: auto;
    align-self: flex-start;
}

/* Recipe (and edit) */

.recipe-intro {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.recipe-intro-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
}

.recipe-intro-meta-name-and-featured {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.recipe-intro-meta-tags {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
    align-content: flex-start;
    text-wrap: nowrap;
}

.tags li a {
    display: flex;
    flex-direction: row;
    gap: 0.1rem;
    align-items: center;
}

.tags li a span {
    color: #888;
}

.recipe-info {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.recipe-info-row {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    align-items: flex-start;
}

.recipe-info-row > :first-child {
    flex: 0 0 calc((100% - 2rem) / 3);
    min-width: 0;
}

.recipe-info-row > :nth-child(2) {
    flex: 0 0 calc((100% - 2rem) * 2 / 3);
    min-width: 0;
}

.recipe-info-photo-and-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Edit page: photo upload */
.recipe-photo-upload {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.recipe-photo-upload label {
    font-weight: 600;
}

.recipe-photo-upload input[type='file'] {
    font: inherit;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border: 1px dashed #bbb;
    border-radius: 6px;
    background-color: #fff;
}

.recipe-photo-upload input[type='file']:focus {
    outline: none;
    border-color: #666;
}

.recipe-photo-upload .file-chosen {
    font-size: 0.85rem;
    color: #666;
}

.btn {
    display: inline-block;
    height: 1.6rem;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: #fff;
    color: inherit;
}

.btn:hover {
    border-color: #666;
}

/* Keep native file input look, but hide filename text */
.recipe-photo-upload input[type='file'] {
    all: revert;
    display: inline-block;
    color: transparent; /* hide built-in filename */
}

.recipe-info-photo {
    width: 100%;
    transform: rotate(2deg);
    border: 5px solid #fff;
    border-radius: 3px;
    display: block;
}

.recipe-info-stats {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.recipe-info-stat {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.recipe-info-stat dt {
    flex: 0 0 25%;
    font-weight: 600;
}

.recipe-info-stat dd {
    flex: 0 1 75%;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    text-wrap: nowrap;
}

.recipe-info-stat dd input {
    flex: 0 0 3rem;
    width: 3rem;
    padding: 0;
    border: 0;
    outline: 1px solid #ccc;
    outline-offset: 0;
    font: inherit;
    font-size: 0.9rem;
    line-height: inherit;
    height: auto;
    vertical-align: baseline;
    border-radius: 4px;
    box-sizing: border-box;
}

.recipe-info-steps ol {
    padding-left: 1em;
}

.recipe-info-steps ol {
    list-style: decimal;
    list-style-position: outside;
    margin-left: 0;
}

.recipe-info-steps ol li {
    display: list-item;
    margin-bottom: 1rem;
}

.recipe-info-steps ol li textarea {
    width: 100%;
    min-height: 1.4em;
    box-sizing: border-box;
    resize: vertical;
    overflow-y: hidden;
    line-height: 1.4;
    font: inherit;
    font-size: 0.9rem;
    display: block;
}

.recipe-info-ingredients h3 {
    text-wrap: nowrap;
}

.recipe-info-ingredients ul {
    padding-left: 1rem;
    text-indent: -1rem;
}

.recipe-info-steps ul.ingredients {
    list-style-type: circle;
    list-style-position: outside;
    padding-left: 1.25rem;
    margin: 0.35rem 0;
    font: inherit;
}

.recipe-info-steps ul.ingredients li {
    display: list-item;
    margin: 0.25rem 0;
}

.recipe-info-steps ul.ingredients li .ingredient-flex {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
    white-space: nowrap;
}

.recipe-info-steps ul.ingredients li .ingredient-flex input {
    min-width: 0;
    flex: 0 1 auto;
    box-sizing: border-box;
    padding: 0.25rem 0.45rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font: inherit;
    font-size: 0.8rem;
}

.recipe-info-steps ul.ingredients li .ingredient-flex .ingredient-amount {
    flex: 0 0 3.75rem;
}

.recipe-info-steps ul.ingredients li .ingredient-flex .ingredient-unit {
    flex: 0 0 4.25rem;
}

.recipe-info-steps ul.ingredients li .ingredient-flex .ingredient-name {
    flex: 1 1 8rem;
    min-width: 4rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

input,
textarea {
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    box-sizing: border-box;
    padding: 0.3rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 6px;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: #666;
}

textarea {
    width: 100%;
    min-height: 1.4em;
    box-sizing: border-box;
    resize: vertical;
    field-sizing: content;
    overflow: hidden;
}

.recipe-description textarea {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    font: inherit;
    font-size: 1rem;
    line-height: 1.15;
    overflow-y: hidden;
    field-sizing: content;
}

.recipe-title {
    position: relative;
}

.recipe-title-input {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    box-sizing: border-box;
    font: inherit;
    color: inherit;
    background-color: #fff;
}

.recipe-intro h2 {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.recipe-intro h2 .recipe-title-input {
    flex: 1 1 auto;
    min-width: 0;
    font: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    padding: 0;
    border: 0;
    background: transparent;
    background-color: #fff;
    outline: 1px solid #ccc;
    outline-offset: 0;
    display: inline;
    height: auto;
    vertical-align: baseline;
    width: auto;
    box-sizing: content-box;
}

.recipe-intro h2 .recipe-title-input:focus {
    outline: 1px solid #666;
    outline-offset: 0;
}

.recipe-intro h2 button {
    height: 1.6rem;
    padding: 0.25rem;
    cursor: pointer;
}

.recipe-intro h2 button,
.recipe-intro h2 form {
    margin-left: auto;
    display: inline-flex;
    align-items: flex-start;
    justify-content: flex-end;
    white-space: nowrap;
}

.visually-hidden {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.form-errors {
    color: #b3261e;
    margin-top: 0.5rem;
}

/* Shared Recipe Card Styles */

.recipe-cards {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    background-color: #fff9f1;
    gap: 1rem;
}

.recipe-card {
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    flex: 0 0 calc((100% - 2rem) / 3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 0.5rem;
}

.recipe-card a {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recipe-card a img {
    width: 100%;
}

/* Media Queries */

@media (max-width: 600px) {
    .recipe-card {
        flex: 0 0 calc((100% - 1rem) / 2);
    }
}

@media (max-width: 400px) {
    .recipe-card {
        flex: 0 0 100%;
    }
}

@media (max-width: 500px) {
    body {
        padding-inline: 0rem;
    }

    header {
        padding: 0;
    }

    .first-row,
    .second-row {
        padding-inline: 0.25rem;
    }

    main {
        border-left: none;
        border-right: none;
        border-top-left-radius: 0px;
        border-top-right-radius: 0px;
    }

    .recipe-info-row {
        flex-direction: column;
        flex: auto;
    }

    .login-intro-form-label-and-input {
        flex-direction: column;
        align-self: start;
    }

    .login-intro-form-checkbox {
        width: 100%;
        margin-left: 0;
    }

    .login-intro-form input {
        width: 100%;
    }

    .recipe-info-steps ul.ingredients li .ingredient-flex {
        flex-wrap: nowrap;
    }

    .recipe-info-steps ul.ingredients li .ingredient-flex .ingredient-name {
        flex: 1 1 6rem;
        min-width: 0;
    }

    .recipe-intro h2 {
        flex-wrap: nowrap;
    }

    .recipe-intro h2 .recipe-title-input {
        flex: 1 1 auto;
        min-width: 0;
    }
}
