/* style.css (v131 - Visual Polish) */

/* --- 1. FONTS & ICONS --- */
@import url('https://fonts.googleapis.com/css2?family=Alfa+Slab+One&family=Crete+Round:ital@0;1&family=Roboto+Slab:wght@400;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

@font-face { font-family: 'Alfa Slab One'; src: url('fonts/alfa.woff2') format('woff2'), url('fonts/alfa.ttf') format('truetype'); font-weight: normal; font-style: normal; }
@font-face { font-family: 'Crete Round'; src: url('fonts/crete.woff2') format('woff2'), url('fonts/crete.ttf') format('truetype'); font-weight: normal; font-style: normal; }
@font-face { font-family: 'Roboto Slab'; src: url('fonts/roboto.woff2') format('woff2'), url('fonts/roboto.ttf') format('truetype'); font-weight: 400; font-style: normal; }
@font-face { font-family: 'Roboto Slab'; src: url('fonts/roboto-bold.woff2') format('woff2'), url('fonts/roboto-bold.ttf') format('truetype'); font-weight: 700; font-style: normal; }

/* --- 2. VARIABLES --- */
:root {
    --bg-cream: #FDF5E6;         
    --text-teal: #1e4d53;        
    --text-body: #2b2b2b;        
    --accent-red: #c24d36;       
    --accent-gold: #dcbfa2;      
    --border-teal: #264e52;      
    --card-bg: #f9f5eb;          
}

/* --- 3. RESET & BODY --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-cream);
    background-image: radial-gradient(#dcbfa2 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--text-body);
    font-family: 'Crete Round', serif; 
    line-height: 1.5;
}

/* --- 4. TYPOGRAPHY --- */
h1, h2, h3, .section-title, .category-header {
    font-family: 'Alfa Slab One', cursive;
    color: var(--text-teal);
    letter-spacing: 1px;
    font-weight: normal; 
    text-transform: capitalize;
}

.cat-edit-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 35px; 
    height: 35px;
    background: #fff;
    border: 2px solid var(--border-teal);
    border-radius: 50%;
    color: var(--text-teal);
    font-size: 0.9rem;
    cursor: pointer;
    margin-left: 15px;
    vertical-align: middle;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
    text-decoration: none;
}
.cat-edit-btn:hover {
    background: var(--accent-red);
    color: #fff;
    transform: scale(1.1) rotate(10deg);
    border-color: var(--accent-red);
}
a { text-decoration: none; color: inherit; transition: 0.2s; }

/* --- 5. HEADER & NAVIGATION --- */
.top-bar { 
    background-color: var(--text-teal); 
    height: 220px; 
    width: 100%; 
    position: absolute; 
    top: 0; 
    z-index: -1; 
}

header { 
    text-align: center; 
    padding: 20px 0 10px; 
    position: relative; 
    border-bottom: 4px solid var(--border-teal); 
    background: transparent; 
}

header a { display: block; width: 100%; }

.logo { 
    width: 340px !important; 
    height: auto !important; 
    display: block !important; 
    margin: 0 auto 10px !important;
}

header h1 { 
    font-size: 4rem; 
    color: var(--text-teal); 
    margin: 0; 
    text-shadow: 3px 3px 0px var(--accent-gold); 
}

.nav-bar { background-color: #c24d36 !important; padding: 15px 0; width: 100%; border-bottom: 4px solid var(--border-teal); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }

/* Updated Nav Links to Spread Out (Back Left, Edit Right) */
.nav-links { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0 20px; /* Add padding to sides */
}

/* Center items if there's only one (like Home page) */
.nav-links.center-nav {
    justify-content: center;
}

.nav-links a { 
    color: #fff; 
    font-family: 'Roboto Slab', serif; 
    font-weight: 700; 
    text-transform: uppercase; 
    font-size: 1.2rem; 
    letter-spacing: 1px; 
    text-shadow: 1px 1px 0px rgba(0,0,0,0.3); 
}
.nav-links a:hover { color: var(--accent-gold); }

/* --- 6. LAYOUT & SEARCH --- */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.search-container { display: flex; justify-content: center; align-items: center; margin: 40px auto 20px; }
.search-wrapper { display: flex; align-items: center; justify-content: space-between; background: #f0e6d2; border: 3px solid var(--accent-gold); border-radius: 50px; padding: 5px 8px 5px 25px; width: 100%; max-width: 600px; box-shadow: inset 0 2px 5px rgba(0,0,0,0.05); height: 60px; }
.search-bar { border: none; background: transparent; font-family: 'Crete Round', serif; font-size: 1.2rem; color: var(--text-teal); flex-grow: 1; outline: none; height: 100%; margin: 0; }
.search-bar::placeholder { color: #888; opacity: 0.7; }
.search-bar:focus { background: transparent !important; box-shadow: none !important; border: none !important; outline: none !important; color: var(--text-teal) !important; }

.search-btn { background: var(--accent-red); color: white; border: none; width: 45px; height: 45px; border-radius: 50%; aspect-ratio: 1 / 1; flex-shrink: 0; font-size: 1rem; cursor: pointer; margin-left: 10px; display: flex; justify-content: center; align-items: center; transition: 0.2s; }
.search-btn:hover { transform: scale(1.1); }

/* FILTERS */
.filter-bar { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-bottom: 40px; padding: 0 10px; }
.btn-filter { background: #fff; border: 2px solid var(--border-teal); color: var(--text-teal); padding: 8px 15px; border-radius: 20px; font-family: 'Roboto Slab', serif; font-weight: bold; font-size: 0.9rem; cursor: pointer; transition: 0.2s; text-transform: uppercase; }
.btn-filter:hover { background: var(--accent-gold); transform: translateY(-2px); }
.btn-filter.active { background: var(--text-teal); color: #fff; border-color: var(--text-teal); }

/* --- 7. GRID & CARDS --- */
.category-header { font-size: 3rem; color: var(--text-teal); margin: 50px 0 30px; text-align: center; display: block; position: relative; padding-bottom: 15px; }
.category-header::after { content: ""; display: block; width: 100px; height: 4px; background: var(--accent-red); margin: 10px auto 0; border-radius: 2px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 30px; margin-bottom: 60px; justify-content: center; }

.card { background: var(--card-bg); border: 4px solid var(--border-teal); border-radius: 15px; overflow: hidden; position: relative; box-shadow: 8px 8px 0px rgba(38, 78, 82, 0.2); transition: transform 0.2s; display: flex; flex-direction: column; cursor: pointer; }
.card:hover { transform: translateY(-5px); }

.card-img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; object-position: center; border-bottom: 3px solid var(--border-teal); }

.card-edit-btn { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; background: #fff; color: var(--text-teal); border-radius: 50%; display: flex; justify-content: center; align-items: center; z-index: 10; box-shadow: 0 2px 5px rgba(0,0,0,0.2); opacity: 0.8; transition: all 0.2s ease; border: 2px solid var(--border-teal); }
.card:hover .card-edit-btn { opacity: 1; }
.card-edit-btn:hover { background: var(--accent-red); color: #fff; transform: scale(1.1); }
.card-top-bar { background: var(--accent-red); height: 15px; width: 100%; border-bottom: 2px solid var(--border-teal); }
.card-content { padding: 25px 20px; text-align: center; flex-grow: 1; display: flex; flex-direction: column; align-items: center; }
.card-cat { color: var(--accent-red); font-family: 'Roboto Slab', serif; font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px; margin-bottom: 10px; }
.card h3 { font-size: 2rem; color: var(--text-teal); margin-bottom: 15px; line-height: 1.1; }
.card-sep { height: 2px; background: var(--accent-gold); width: 50%; margin: 0 auto 15px; }
.card p { font-size: 1rem; color: #555; margin-bottom: 20px; }
.btn-read { margin-top: auto; background: var(--accent-red); color: #fff; font-family: 'Roboto Slab', serif; font-weight: 700; text-transform: uppercase; padding: 10px 25px; border-radius: 25px; border: 2px solid var(--text-teal); font-size: 0.9rem; box-shadow: 2px 2px 0px rgba(0,0,0,0.2); }
.btn-read:hover { background: #a0301d; }

.btn-fav { position: absolute; top: 10px; left: 10px; width: 40px; height: 40px; background: #fff; border: 2px solid var(--border-teal); border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; z-index: 10; font-size: 1.2rem; color: #ccc; transition: 0.2s; opacity: 0.9; }
.btn-fav:hover { transform: scale(1.1); }
.btn-fav.active { color: var(--accent-red); border-color: var(--accent-red); }

/* --- 8. FORMS & INPUTS --- */
.recipe-section { background: var(--card-bg); border: 3px solid var(--border-teal); border-radius: 10px; padding: 30px; margin-bottom: 25px; }
form label { font-family: 'Roboto Slab', serif; color: var(--text-teal); font-weight: 800; text-transform: uppercase; font-size: 0.9rem; margin-bottom: 8px; display: block; letter-spacing: 0.5px; }
input, textarea, select { width: 100%; padding: 12px 15px; border: 3px solid var(--border-teal); border-radius: 8px; background: #faf7f0; font-family: 'Crete Round', serif; font-size: 1.05rem; margin-bottom: 20px; transition: 0.2s; color: var(--text-teal); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-red); background: #fff; box-shadow: 0 0 0 3px rgba(194, 77, 54, 0.1); }
.form-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.form-section-header { display: flex; align-items: center; gap: 10px; margin: 30px 0 15px; padding-bottom: 10px; border-bottom: 3px solid var(--accent-gold); }
.form-section-header i { color: var(--accent-red); font-size: 1.2rem; }
.form-section-header span { font-family: 'Alfa Slab One', cursive; color: var(--text-teal); font-size: 1.5rem; }
.form-row { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; }
.form-row input, .form-row select { margin-bottom: 0; }
.form-row.header-row input[name="ing_item[]"] { background-color: var(--accent-gold); color: var(--text-teal); font-weight: bold; font-family: 'Alfa Slab One', cursive; letter-spacing: 1px; border: 2px solid var(--text-teal); text-align: center; }
.btn-add { background: #f0e6d2; border: 2px solid var(--border-teal); color: var(--text-teal); padding: 8px 15px; border-radius: 6px; cursor: pointer; font-weight: bold; margin-bottom: 10px; font-size: 0.9rem; font-family: 'Roboto Slab', serif; text-transform: uppercase; transition: 0.2s; }
.btn-add:hover { background: var(--accent-gold); transform: translateY(-1px); }
.action-group { display: flex; align-items: center; gap: 2px; margin-left: 5px; flex-shrink: 0; }
.btn-icon { background: transparent; border: none; cursor: pointer; font-size: 1rem; padding: 6px; transition: 0.2s; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.btn-icon:hover { background: rgba(0,0,0,0.05); }
.btn-remove { color: var(--accent-red); }
.btn-remove:hover { color: #a0301d; transform: scale(1.1); }
.btn-move { color: #888; }
.btn-move:hover { color: var(--text-teal); transform: scale(1.1); }
.file-upload-label { display: flex; justify-content: center; align-items: center; background-color: #f0e6d2; color: var(--text-teal); padding: 25px; font-family: 'Roboto Slab', serif; font-weight: bold; border: 3px dashed var(--border-teal); border-radius: 8px; cursor: pointer; width: 100%; transition: 0.2s; margin-bottom: 20px; }
.file-upload-label:hover { background-color: #fff; border-color: var(--accent-red); color: var(--accent-red); }
.file-upload-label i { font-size: 1.8rem; margin-right: 15px; }
input[type="file"] { display: none; }
.placeholder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 15px; margin-top: 20px; padding: 15px; background: #fff; border: 3px solid var(--border-teal); border-radius: 8px; }
.placeholder-option { width: 100%; height: 100px; object-fit: cover; border: 4px solid transparent; border-radius: 8px; cursor: pointer; opacity: 0.6; transition: 0.2s; }
.placeholder-option.selected { border-color: var(--accent-red); opacity: 1; transform: scale(1.05); box-shadow: 0 4px 8px rgba(0,0,0,0.2); }
.or-divider { text-align: center; margin: 20px 0; font-family: 'Alfa Slab One', cursive; color: var(--text-teal); position: relative; }
.or-divider::before, .or-divider::after { content: ""; position: absolute; top: 50%; width: 40%; height: 2px; background: var(--accent-gold); }
.or-divider::before { left: 0; } .or-divider::after { right: 0; }
button.btn-retro { background: var(--accent-red); border: none; color: white; padding: 15px 50px; font-family: 'Alfa Slab One', cursive; font-size: 1.3rem; border-radius: 8px; cursor: pointer; box-shadow: 0 5px 0 var(--border-teal); transition: 0.2s; display: block; margin: 30px auto 0; }
button.btn-retro:hover { transform: translateY(2px); box-shadow: 0 3px 0 var(--border-teal); background: #b03d28; }
.delete-section { margin-top: 50px; padding-top: 20px; border-top: 2px dashed var(--accent-red); text-align: center; }
.btn-danger { background: transparent; border: 2px solid var(--accent-red); color: var(--accent-red); padding: 10px 20px; font-family: 'Roboto Slab', serif; font-weight: bold; border-radius: 8px; cursor: pointer; transition: 0.2s; }
.btn-danger:hover { background: var(--accent-red); color: #fff; }

.fav-toggle-wrapper { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; background: #fff; padding: 10px 15px; border: 2px solid var(--accent-gold); border-radius: 8px; cursor: pointer; width: fit-content; }
.fav-toggle-wrapper input { width: auto; margin: 0; }
.fav-toggle-wrapper span { font-family: 'Roboto Slab', serif; font-weight: bold; color: var(--text-teal); }
.fav-toggle-wrapper i { color: var(--accent-red); font-size: 1.2rem; }

.password-wrapper { position: relative; width: 100%; }
.btn-show-pass { position: absolute; right: 15px; top: 40%; transform: translateY(-50%); background: transparent; border: none; color: var(--text-teal); cursor: pointer; font-size: 1.2rem; opacity: 0.6; transition: 0.2s; z-index: 5; }
.btn-show-pass:hover { opacity: 1; color: var(--accent-red); }

/* --- 9. RECIPE VIEW PAGE --- */
.recipe-view-card { background: var(--card-bg); border: 4px solid var(--border-teal); border-radius: 10px; padding: 40px; box-shadow: 10px 10px 0px rgba(30, 77, 83, 0.1); max-width: 1000px; margin: 0 auto; }
.recipe-header-grid { display: grid; grid-template-columns: 400px 1fr; gap: 40px; margin-bottom: 40px; border-bottom: 3px dashed var(--accent-gold); padding-bottom: 40px; }
.recipe-view-img { width: 100%; height: 400px; object-fit: cover; object-position: center; border: 8px solid #fff; box-shadow: 0 4px 15px rgba(0,0,0,0.15); transform: rotate(-2deg); border-radius: 4px; }
.recipe-info h1 { font-size: 3.5rem; line-height: 1; margin-bottom: 10px; color: var(--text-teal); }
.recipe-meta { font-family: 'Roboto Slab', serif; color: var(--accent-red); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 20px; font-size: 0.9rem; }
.recipe-desc { font-size: 1.1rem; color: #555; line-height: 1.6; font-style: italic; }
.recipe-body-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 40px; }
.ingredients-box { background: #fff; border: 2px solid var(--accent-gold); border-radius: 8px; padding: 25px; }
.ing-list { list-style: none; padding: 0; }
.ing-list li { padding: 8px 0; border-bottom: 1px dashed #ddd; font-family: 'Crete Round', serif; font-size: 1.05rem; display: flex; align-items: flex-start; }
.ing-list li::before { content: "☐"; color: var(--accent-gold); margin-right: 10px; font-weight: bold; }
.ing-header { font-family: 'Alfa Slab One', cursive; color: var(--text-teal); font-size: 1.1rem; margin-top: 15px; margin-bottom: 5px; padding-bottom: 5px; border-bottom: 2px solid var(--accent-red); }
.instr-step { display: flex; gap: 15px; margin-bottom: 20px; }
.step-num { background: var(--text-teal); color: #fff; width: 30px; height: 30px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-weight: bold; flex-shrink: 0; font-family: 'Roboto Slab', serif; margin-top: 2px; }
.step-text { font-size: 1.1rem; color: var(--text-body); }

.ing-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--accent-gold);
    padding-bottom: 10px;
    gap: 20px; 
}

.btn-print {
    font-family: 'Roboto Slab', serif !important; 
    font-weight: bold;
    font-size: 0.9rem; 
    padding: 10px 20px; 
    margin: 20px 0 0 0; 
    display: inline-block;
}

/* FIXED: Scale wrapper has no border, only the input does */
.scale-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

.scale-wrapper label {
    margin: 0;
    font-family: 'Roboto Slab', serif;
    font-size: 0.95rem;
    color: var(--text-teal);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.serving-input {
    width: 70px;
    padding: 6px 0;
    margin: 0;
    text-align: center;
    font-family: 'Alfa Slab One', cursive; 
    font-size: 1.2rem;
    color: var(--accent-red); 
    background: #fff;
    border: 3px solid var(--accent-gold);
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    outline: none;
    transition: all 0.2s ease;
}

.serving-input:focus {
    border-color: var(--text-teal);
    transform: scale(1.05);
}

/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 800px) {
    /* DEFAULT HEADER (Home) */
    .logo { 
        display: block !important;
        margin: 0 auto 10px !important;
        max-width: 220px !important; 
        width: 100% !important;
    }
    .top-bar { height: 190px; } 
    header h1 { font-size: 2.2rem; margin-bottom: 5px; }
    
    .nav-links a { display: block; margin: 10px 0; }
    .search-wrapper { width: 95%; padding: 5px 15px; }
    .container { padding: 15px; }
    .form-grid { grid-template-columns: 1fr; gap: 0; }
    .form-row { flex-wrap: wrap; }
    .form-row input, .form-row select { flex: 1; min-width: 80px; }
    .recipe-header-grid { grid-template-columns: 1fr; text-align: center; gap: 20px; }
    .recipe-view-img { height: 280px; width: 100%; max-width: 400px; transform: rotate(0deg); margin: 0 auto; }
    .recipe-body-grid { grid-template-columns: 1fr; }
    .recipe-info h1 { font-size: 2.5rem; }
}

/* Scroll to Top Button */
.scroll-top-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--accent-red);
    color: #fff;
    border: 2px solid var(--border-teal);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 4px 4px 0px rgba(38, 78, 82, 0.4);
    transition: all 0.3s ease;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}
.scroll-top-btn.show { opacity: 1; visibility: visible; transform: translateY(0); }
.scroll-top-btn:hover { background: #a0301d; transform: translateY(-5px); box-shadow: 4px 6px 0px rgba(38, 78, 82, 0.4); }

.card.signature-card { border-color: var(--accent-gold); box-shadow: 8px 8px 0px rgba(220, 191, 162, 0.4); }
.card.signature-card .card-top-bar { background: var(--accent-gold); }
.card.signature-card .card-cat { color: var(--text-teal); }

/* ========================================= */
/* --- COMPACT PAGE REDESIGN (Side-by-Side) --- */
/* ========================================= */

body.compact-page .top-bar {
    height: 120px; 
}

body.compact-page header {
    padding: 10px 0;
    border-bottom: 4px solid var(--border-teal);
}

/* FLEX LAYOUT: Logo Left, Text Right */
body.compact-page header .container a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px; 
    text-decoration: none;
    width: auto;
    margin: 0 auto;
}

/* FIXED: Larger logo for compact header */
body.compact-page .logo {
    width: 110px !important; /* Increased from 80px to 110px */
    height: auto !important;
    margin: 0 !important; 
    display: block;
}

/* COMPACT TITLE */
body.compact-page header h1 {
    font-size: 2.5rem;
    text-align: left;
    margin: 0;
    line-height: 1;
    text-shadow: 2px 2px 0px var(--accent-gold);
}

/* COMPACT MOBILE */
@media (max-width: 600px) {
    body.compact-page .top-bar { height: 100px; }
    body.compact-page .logo { width: 80px !important; }
    body.compact-page header h1 { font-size: 1.8rem; }
}

/* --- PRINT STYLES --- */
@media print {
    .top-bar, .nav-bar, .btn-fav, button, .scale-wrapper, footer, .related-section, .scroll-top-btn { 
        display: none !important; 
    }
    body { background: white; color: black; background-image: none; }
    .container { margin-top: 0 !important; width: 100% !important; max-width: 100% !important; padding: 0 !important; }
    .recipe-view-card { border: none; box-shadow: none; padding: 0; }
    .recipe-header-grid { display: block; border-bottom: 2px solid #000; text-align: left; }
    .recipe-view-img { display: none; }
    .recipe-info h1 { font-size: 2.5rem; color: #000; text-shadow: none; }
    .ingredients-box, .instructions-box { border: 1px solid #ccc; margin-bottom: 20px; }
}