/* ── Dishbook — main.css ─────────────────────────────────────────────────── */

/* ── Design tokens ── */
:root {
    --cream:    #faf7f2;
    --ink:      #4c6444;
    --muted:    #464240;
    --accent:   #9b4729;
    --border:   #e7e2da;
    --card-bg:  #ffffff;
    --font-serif: 'Lora', serif;
    --font-sans:  'DM Sans', sans-serif;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--cream);
    color: var(--ink);
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
}

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

img { display: block; max-width: 100%; }

/* ── Header / nav ── */
.top {
    background: var(--ink);
    color: var(--cream);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    height: 56px;
}

#dishbook_title a {
    font-family: var(--font-serif);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--cream);
    text-decoration: none;
    letter-spacing: 0.01em;
}

#dishbook_title a:hover { color: #f5c4b3; text-decoration: none; }

.top .user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.88rem;
    color: rgba(250,247,242,0.75);
}

.top .user-section a {
    color: rgba(250,247,242,0.75);
    text-decoration: none;
    transition: color 0.15s;
}

.top .user-section a:hover { color: var(--accent); text-decoration: none; }

.top .user-section .username-link {
    color: var(--cream);
    font-weight: 500;
}

.top .user-section .username-link:hover {
    color: var(--accent);
    font-weight: 500;
}

.top .user-section .sep {
    opacity: 0.35;
}

.nav {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 0;
    padding: 0 2rem;
}

.nav a {
    display: inline-block;
    padding: 0.7rem 1rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.nav a:hover,
.nav a.active {
    color: var(--ink);
    border-bottom-color: var(--accent);
    text-decoration: none;
}

/* ── Page wrapper ── */
.page-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 2.5rem 2rem 5rem;
}

/* ── Hero / title block ── */
.title {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2.5rem 2rem;
    margin: 2rem auto;
    max-width: 900px;
    text-align: center;
}

.title h1 {
    font-family: var(--font-serif);
    font-size: 2rem;
    margin: 0 0 0.5rem;
}

.title p { color: var(--muted); margin: 0.25rem 0; font-size: 0.95rem; }

/* ── Section header ── */
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 2px solid var(--ink);
    margin-bottom: 1.5rem;
    padding-bottom: 0.4rem;
}

.section-header h2 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    margin: 0;
}

/* ── Cards grid (home / search) ── */
.cards-area {
    max-width: 900px;
    margin: 0 auto 3rem;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
    box-shadow: 0 6px 24px rgba(28,25,23,0.1);
    transform: translateY(-2px);
}

.card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.card h2 {
    font-family: var(--font-serif);
    font-size: 1rem;
    margin: 0 0 0.4rem;
    padding: 1rem 1rem 0;
}

.card h2 a { color: var(--ink); }
.card h2 a:hover { color: var(--accent); text-decoration: none; }

.card p {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0 1rem;
    margin: 0 0 0.5rem;
    line-height: 1.5;
}

.card .tag-row {
    padding: 0.5rem 1rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.card .tag-row a {
    font-size: 0.75rem;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    color: var(--muted);
    text-decoration: none;
}

.card .tag-row a:hover { border-color: var(--accent); color: var(--accent); }

/* ── Profile hero ── */
.profile-hero {
    background: var(--ink);
    color: var(--cream);
    padding: 3rem 2rem 0;
}

.profile-hero-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding-bottom: 2.5rem;
}

.profile-avatar {
    width: 96px; height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
    flex-shrink: 0;
}

.profile-avatar-placeholder {
    width: 96px; height: 96px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-size: 2rem;
    color: #fff;
    flex-shrink: 0;
}

.profile-hero h1 {
    font-family: var(--font-serif);
    font-size: 2rem;
    margin: 0 0 0.25rem;
}

.profile-hero .username { color: var(--cream); font-size: 0.9rem; margin: 0 0 0.5rem; text-decoration: underline; }
.profile-hero .bio { font-size: 0.95rem; opacity: 0.8; margin: 0; }

/* ── Stats strip ── */
.profile-stats {
    border-top: 1px solid rgba(255,255,255,0.08);
}

.profile-stats-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    display: flex;
    gap: 2.5rem;
    font-size: 0.85rem;
    color: rgba(250,247,242,0.65);
}

.profile-stats-inner span strong { color: var(--cream); }

/* ── Profile body ── */
.profile-body {
    max-width: 900px;
    margin: 0 auto;
    padding: 2.5rem 2rem 4rem;
}

/* ── Status tabs ── */
.status-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.6rem 1.1rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--muted);
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}

.tab-btn.active,
.tab-btn:hover { color: var(--ink); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Recipe grid (profile) ── */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.recipe-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s, transform 0.2s;
}

.recipe-card:hover {
    box-shadow: 0 6px 24px rgba(28,25,23,0.1);
    transform: translateY(-2px);
}

.recipe-card img { width: 100%; height: 160px; object-fit: cover; }

.recipe-card-img-placeholder {
    width: 100%; height: 160px;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.card-body {
    padding: 1rem 1rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-body h3 {
    font-family: var(--font-serif);
    font-size: 1rem;
    margin: 0 0 0.4rem;
}

.card-body h3 a { color: var(--ink); }
.card-body h3 a:hover { color: var(--accent); text-decoration: none; }

.card-meta { font-size: 0.78rem; color: var(--muted); margin: 0 0 0.5rem; }
.card-desc { font-size: 0.85rem; color: var(--muted); margin: 0 0 auto; line-height: 1.5; }

/* ── Status badge ── */
.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.badge-published { background: #dcfce7; color: #166534; }
.badge-draft     { background: #fef9c3; color: #854d0e; }
.badge-archived  { background: #f1f5f9; color: #475569; }

/* ── Card actions (owner) ── */
.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.btn-sm {
    flex: 1;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-family: var(--font-sans);
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    transition: background 0.15s;
}

.btn-sm:hover { background: var(--cream); text-decoration: none; }
.btn-sm.btn-danger { color: var(--accent); border-color: #fca5a5; }
.btn-sm.btn-danger:hover { background: #fff1f0; }

.delete-form { flex: 1; display: flex; }
.delete-form .btn-sm { width: 100%; }

/* ── Timestamps ── */
.timestamp { font-size: 0.72rem; color: var(--muted); margin-top: 0.4rem; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}
.empty-state p { margin: 0.25rem 0 0; font-size: 0.9rem; }

/* ── Add recipe button ── */
.btn-add {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.45rem 1.1rem;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-add:hover { background: #9a3412; text-decoration: none; }

/* ── Recipe detail page ── */
.recipe-detail {
    max-width: 900px;
    margin: 0 auto;
    padding: 2.5rem 2rem 5rem;
}

.recipe-detail .recipe-hero img {
    width: 100%;
    max-height: 380px;
    object-fit: cover;
    border-radius: 8px;
    margin: 1.5rem 0;
}

.recipe-detail h1 {
    font-family: var(--font-serif);
    font-size: 2.2rem;
    margin: 0 0 0.5rem;
}

.recipe-detail .recipe-byline {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0 0 0.75rem;
}

.recipe-detail .recipe-byline a { color: var(--accent); }

.recipe-detail .recipe-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.recipe-detail .recipe-tags a {
    font-size: 0.78rem;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    color: var(--muted);
}
.recipe-detail .recipe-tags a:hover { border-color: var(--accent); color: var(--accent); }

.recipe-detail .recipe-description {
    font-size: 1rem;
    color: var(--muted);
    line-height: 1.7;
    margin: 0 0 2rem;
}

/* Recipe meta strip */
.recipe-info {
    display: flex;
    gap: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 0 0 2.5rem;
    flex-wrap: wrap;
}

.recipe-info p { margin: 0; font-size: 0.88rem; }
.recipe-info strong { display: block; font-size: 0.75rem; color: var(--muted); font-weight: 500; margin-bottom: 0.15rem; }

/* Two-column layout for ingredients + steps */
.recipe-columns {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2.5rem;
    align-items: start;
}

.recipe-columns h2 {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    border-bottom: 2px solid var(--ink);
    padding-bottom: 0.35rem;
    margin: 0 0 1rem;
}

.recipe-columns ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recipe-columns ul li {
    font-size: 0.9rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--ink);
}

.recipe-columns ol {
    padding: 0 0 0 1.25rem;
    margin: 0;
}

.recipe-columns ol li {
    font-size: 0.9rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.6;
}

/* ── Search page ── */
.search-block {
    max-width: 900px;
    margin: 2rem auto 2rem;
    padding: 0 2rem;
}

.search-block form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.search-block label {
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
}

.search-block input[type="search"] {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.55rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    background: var(--card-bg);
    color: var(--ink);
    transition: border-color 0.15s;
}

.search-block input[type="search"]:focus {
    outline: none;
    border-color: var(--accent);
}

.search-block button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.55rem 1.25rem;
    border-radius: 5px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.search-block button:hover { background: #9a3412; }

.search-results-heading {
    max-width: 900px;
    margin: 1.5rem auto 0.5rem;
    padding: 0 2rem;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--muted);
}

/* ── Login page ── */
.login-wrap {
    max-width: 400px;
    margin: 5rem auto;
    padding: 2.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.login-wrap h1 {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    margin: 0 0 1.5rem;
    text-align: center;
}

.login-form p { margin: 0 0 1.1rem; }

.login-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.55rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.15s;
}

.login-form input:focus { outline: none; border-color: var(--accent); }

.login-form button {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.65rem 1rem;
    border-radius: 5px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background 0.15s;
}

.login-form button:hover { background: #9a3412; }

.login-error {
    background: #fff1f0;
    border: 1px solid #fca5a5;
    color: var(--accent);
    font-size: 0.85rem;
    padding: 0.6rem 0.85rem;
    border-radius: 5px;
    margin-bottom: 1.25rem;
    text-align: center;
}

/* ── Form page (recipe add / edit) ── */
.form-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 2.5rem 2rem 5rem;
}

.form-page h1 {
    font-family: var(--font-serif);
    font-size: 1.9rem;
    margin: 0 0 0.25rem;
}

.form-page .subtitle { color: var(--muted); font-size: 0.9rem; margin: 0 0 2.5rem; }

.form-section-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    border-bottom: 2px solid var(--ink);
    padding-bottom: 0.35rem;
    margin: 2.5rem 0 1.25rem;
}

.field-row { margin-bottom: 1.25rem; }

.field-row label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.field-row input[type="text"],
.field-row input[type="number"],
.field-row input[type="file"],
.field-row textarea,
.field-row select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.55rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.15s;
}

.field-row input:focus,
.field-row textarea:focus,
.field-row select:focus { outline: none; border-color: var(--accent); }

.field-row.inline-group {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

select option[value="draft"]     { color: #854d0e; }
select option[value="published"] { color: #166534; }
select option[value="archived"]  { color: #475569; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.tag-list label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 400;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

.tag-list label:hover { border-color: var(--accent); }

.tag-list input[type="checkbox"]:checked + span { color: var(--accent); font-weight: 500; }

/* Steps */
.step-block {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.step-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.step-block-header h3 {
    font-family: var(--font-serif);
    font-size: 1rem;
    margin: 0;
}

.step-block textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.55rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    resize: vertical;
}

.ingredient-row {
    display: grid;
    grid-template-columns: 100px 100px 1fr auto;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.ingredient-row input {
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.4rem 0.6rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
}

.ingredient-row input:focus { outline: none; border-color: var(--accent); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1.1rem;
    border-radius: 5px;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    transition: background 0.15s;
}

.btn:hover { background: var(--cream); text-decoration: none; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #9a3412; }

.btn.btn-danger { color: var(--accent); border-color: #fca5a5; padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn.btn-danger:hover { background: #fff1f0; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--accent); font-size: 0.83rem; }
.btn-ghost:hover { background: #fff1f0; }

.form-actions { display: flex; gap: 0.75rem; margin-top: 2.5rem; }

.timestamps-note { font-size: 0.78rem; color: var(--muted); margin-bottom: 1.5rem; }

/* ── Delete confirm page ── */
.confirm-wrap {
    max-width: 480px;
    margin: 6rem auto;
    padding: 2.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: center;
}

.confirm-wrap .icon { font-size: 3rem; margin-bottom: 1rem; }

.confirm-wrap h1 {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    margin: 0 0 0.5rem;
}

.confirm-wrap p { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.25rem; }
.confirm-wrap .meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 2rem; }

.confirm-actions { display: flex; gap: 0.75rem; justify-content: center; }

/* ── Responsive ── */
@media (max-width: 660px) {
    .cards-area { grid-template-columns: 1fr; padding: 0 1rem; }
    .recipe-grid { grid-template-columns: 1fr; }
    .recipe-columns { grid-template-columns: 1fr; gap: 1.5rem; }
    .field-row.inline-group { grid-template-columns: 1fr 1fr; }
    .ingredient-row { grid-template-columns: 90px 90px 1fr auto; }
    .profile-hero { padding: 2rem 1rem 0; }
    .profile-hero-inner { flex-direction: column; align-items: flex-start; gap: 1rem; padding-bottom: 1.5rem; }
    .profile-body { padding: 1.5rem 1rem 3rem; }
    .top { padding: 0 1rem; }
    .nav { padding: 0 1rem; }
}