:root{ 
    --cream:#F7F1E8;
    --cast-iron:#2E261C;   /* body text */
    --cacao:#A8570C;       /* hover, headings */
    --paper:#FFF9F1;       /* content area bg */
    --ash:#888888;         /* subtle UI, hashtag */
    --oak:#8B5E34;         /* links, accents, borders */
    --white:#FFFFFF;
}

/* ---------- reset / global ---------- */

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

html,
body {
    margin: 0;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    font-family: "Nunito", system-ui, sans-serif;
    color: var(--cast-iron);
    background-color: #e9dcc9;
}

ul{
    list-style: none;
}

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

h1, h2, h3, h4, h5, h6 {
    font-family: "Playwrite US Trad", cursive;
    color: var(--cacao);
    text-decoration: none;
}

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

input[type="textarea"],
textarea{
    width: 100%;
}

/* ---------- layout: main & cards ---------- */

/* main container centered on page */
main {
    width: 100%;
    max-width: 960px;
    margin: 2rem auto 4rem;
    padding: 0;
}

/* big rounded card used on the edit page (and any page with main > form) */
main > form {
    background: #fdf6ee;
    border-radius: 1.8rem;
    padding: 1.5rem 2rem 2.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    position: relative;
}

/* ---------- header / nav ---------- */

#headers{
    display: flex;
    flex-wrap: wrap;
    row-gap: 0.5rem;
    width: 100%;
}

#header-top{
    width: 100%;
    display: flex;
    justify-content:space-between;
    border-bottom:2px solid var(--oak);
    align-items: baseline;
}

#header-bottom{
    width: 100%;
    display: flex;
    justify-content:space-between; 
    align-items:start;  
}

#links{
    display: flex;
    gap: 1rem;
}

.search-bar{
    display:flex;
    max-width: 100%;
    margin: 1rem 0;
}

.search-bar input{
    flex: 1 1 auto;
    width: 100%;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--cast-iron);
    border-radius: 2px;
}

.search-form{
    display:flex;
    gap:0.5rem;
}
.search-form input[type="search"],
.search-form button{
    padding:0.25rem;
}

/* ---------- homepage recipe cards ---------- */

#recipies {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
}

/* SEARCH RESULTS LAYOUT */
.results-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ensure grid fits page */
.results-container #recipies {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

/* keep cards from stretching too wide */
.results-container .recipe-card {
    width: 100%;
}

/* IMAGE SCALING FIX — MOST IMPORTANT PART */
.results-container .card-image {
    width: 100%;
    height: 200px;             /* controls image height */
    object-fit: cover;         /* crop instead of distort */
    border-radius: 8px;
    padding: 0;
    margin: 0;
}

/* Each card gets .5rem padding and clean layout */
.recipe-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 8px 8px -8px rgba(0,0,0,0.25);
    padding: 0.5rem;     /* EXACT requirement */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* --- Card Images --- */
.card-image {
    width: 100%;             /* never wider than card */
    max-width: 100%;
    height: 200px;           /* reasonable height for grid cards */
    object-fit: cover;       /* keeps aspect ratio + crops nicely */
    border-radius: 6px;
    display: block;
}

/* ---------- login page ---------- */

.login{
    display: flex;
    flex-direction: column;
    row-gap: 2rem;
    align-items: baseline;
    padding-top: 1rem;
}

.login input{
    width: 100%;
    margin-left: auto;
    padding: 0.25rem;
    vertical-align: baseline;
}

.login button{
    display: flex;
    justify-content: center;
    align-self: center;
    width: 50%;
    min-width: 200px;
    padding: 0.5rem 1rem;
    font-size: larger;
}

/* ---------- profile / misc ---------- */

#profile-pic{
    width: 5rem;
    height: 5rem;
    display: flex;
    justify-self: flex-start;
}

.tags{
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-right: 1rem;
    text-wrap: nowrap;
}

.button-row{
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}
  
.button{
    background: var(--cream);
    color: var(--oak);
    border: 2px solid var(--oak);
    padding: 0.5em 1em;
    border-radius: 9999px;
    font-weight: 600;
    display: inline-block;
}

.button:hover{
    background: var(--cacao);
    color: var(--paper);
    border-color: var(--cacao);
}

/* ---------- RECIPE EDIT PAGE ---------- */

/* big fancy title input */
#title {
    width: 100%;
    border: none;
    background: transparent;
    font-family: "Playwrite US Trad", "Nunito", cursive;
    font-size: 3rem;
    color: #a0551a;
    margin-bottom: 0.75rem;
}

/* make it look like plain text until focused */
#title:focus {
    outline: none;
    background: #fff7ec;
}

/* save button in the top right corner of the card */
.save_edit {
    position: absolute;
    top: 1.6rem;
    right: 2rem;
    padding: 0.4rem 1.2rem;
    border-radius: 0.5rem;
    border: 1px solid #b97339;
    background: #f8d4a7;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
}

.save_edit:hover {
    background: #f0c28a;
}

/* meta line below title */
#recipe-meta-data {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}

#recipe-meta-data p {
    margin: 0;
}

#recipe-meta-data a {
    color: #8f4b17;
    text-decoration: none;
    font-weight: 600;
}

/* photo + description row */
#photo_description {
    display: grid;
    grid-template-columns: minmax(220px, 260px) 1fr;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* main recipe photo on the recipe page and edit page */
.recipe_image {
    display: block;
    width: 100%;        /* no wider than its parent */
    max-width: 100%;
    height: auto;       /* keep aspect ratio */
    margin: 0 0 0.5rem 0;  /* .5rem space below the image */
    border-radius: 0.75rem;
    object-fit: cover;
}


/* description block on the right */
#photo_description label[for="description"] {
    display: block;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

#description {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid #d0b08a;
    background: #fffdf7;
    font-size: 0.95rem;
}

/* prep / cook / total / yield row */

#recipe-meta-data + section,
dl {
    margin: 0;
}

/* display the facts in a little grid */
dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 2rem;
    margin-bottom: 1.5rem;
}

dt.fact {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
}

dt .label {
    font-weight: 700;
    min-width: 3.2rem;
}

dt .value {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* the numeric inputs in prep, cook, total, yield */
#prep,
#cook,
#total,
#yield {
    width: 4.2rem;
    padding: 0.2rem 0.35rem;
    border-radius: 0.3rem;
    border: 1px solid #cfb08c;
    background: #fffdf7;
}

#total[readonly] {
    background: #f5ece1;
}

/* bottom split: ingredients vs steps */

.recipe-bottom {
    display: flex;
    gap: 2.5rem;
}

/* left column */
#ingredients {
    flex: 0 0 32%;
}

/* right column */
#steps {
    flex: 1 1 auto;
}

/* headings in script font */
#ingredients h2,
#steps h2 {
    font-family: "Playwrite US Trad", "Nunito", cursive;
    font-size: 2rem;
    color: #a0551a;
    margin-top: 0;
    margin-bottom: 0.6rem;
}

/* ingredient list look */
#ingredients ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
    font-size: 0.95rem;
}

#ingredients li {
    margin-bottom: 0.18rem;
}

/* steps list styling */
#steps ol {
    margin: 0;
    padding-left: 1.4rem;
}

#steps > ol > li {
    margin-bottom: 0.6rem;
}

/* the step description input */
#steps input[type="textarea"],
#steps textarea {
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid #d0b08a;
    background: #fffdf7;
    padding: 0.35rem 0.4rem;
    font-size: 0.9rem;
}

/* ingredient rows under each step */
#steps ul {
    list-style: circle;
    margin: 0.3rem 0 0.6rem 1.3rem;
    padding: 0;
}

#steps ul li {
    margin-bottom: 0.25rem;
}

/* inline ingredient inputs */
.ingredient-amount,
.ingredient-unit,
.ingredient-name {
    border-radius: 0.45rem;
    border: 1px solid #d0b08a;
    background: #fffdf7;
    padding: 0.15rem 0.35rem;
    font-size: 0.85rem;
}

.ingredient-amount {
    width: 3.5rem;
    text-align: right;
}

.ingredient-unit {
    width: 5rem;
}

.ingredient-name {
    width: 9rem;
}

/* errors on edit page */
.errors {
    margin-bottom: 1rem;
    color: #8b1d1d;
}
.errors ul {
    margin: 0.25rem 0 0;
}

/* ---------- search page layout ---------- */

.search-main {
    max-width: 1200px;       /* a bit wider than edit page */
    margin: 2rem auto 4rem;
    padding: 0 1rem;
}

/* tweak the card grid when on the search page */
.search-main #recipies {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* Search page main search bar */
.search-bar input[type="search"] {
    width: 100%;
    padding: 0.25rem;       /* EXACT requirement */
    border: 1px solid var(--cast-iron);
    border-radius: 4px;
}


/* ---------- media queries ---------- */

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

@media (max-width: 400px) {
    #recipies{
        grid-template-columns: repeat(1, 1fr);
    }
}

@media (max-width: 500px) {
    .recipe-bottom {
        flex-direction: column;
        gap: 2rem;
    }

    html,
    body,
    main{
        padding-left: 0;
        padding-right: 0;
    }

    main{
        /* let card touch edges a bit on mobile */
        max-width: 100%;
    }

    #header-top,
    #header-bottom{
      padding-left: 0.5rem;
      padding-right: 0.5rem;
      width: 100%;
    }
}
