/* ============================================================
   Variables & Reset
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;1,400&family=DM+Sans:wght@400;500;600&display=swap');

:root {
    --ink:        #1a1a1a;
    --ink-light:  #555;
    --rule:       #e0ddd8;
    --paper:      #faf9f7;
    --cream:      #f3f1ee;
    --accent:     #b85c38;
    --accent-dark:#8f3f22;
    --success:    #2d7a4f;
    --error:      #b0200e;
    --radius:     6px;
    --max-w:      760px;
    --admin-max:  900px;
}

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

html { font-size: 16px; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.7;
}

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

/* ============================================================
   Layout
   ============================================================ */
.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ============================================================
   Public Header
   ============================================================ */
.site-header {
    background: var(--paper);
    width: 100%;
    overflow: hidden;
}

.site-banner {
    display: block;
    width: 100%;
    max-width: 760px;
    height: auto;
    margin: 1.5rem auto 0;
    border-radius: var(--radius);
    object-fit: cover;
}

.site-banner-placeholder {
    height: 1rem;
    background: var(--paper);
}

.header-identity {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    max-width: var(--max-w);
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.header-bottom {
    width: 100%;
    box-sizing: border-box;
    border-bottom: 1px solid var(--rule);
}

.header-title-row {
    text-align: center;
    padding: 0.75rem 1.5rem 0.5rem;
}

.header-nav-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.5rem 1.5rem 0.75rem;
    max-width: 1400px;
    margin: 0 auto;
}

a.header-center-title {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    letter-spacing: -0.02em;
    text-align: center;

    text-decoration: none;
    display: inline-block;

    transition: text-shadow 0.25s ease;
}

a.header-center-title:hover {
    text-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    text-decoration: none;
}

.header-nav-bar {
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    padding: 0.75rem 1.5rem;
    width: 100%;
    box-sizing: border-box;
}

.header-nav-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1.5rem;
}

.header-nav-bar .site-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.site-logo {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--paper);
    margin-top: -40px;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.site-title {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.02em;
}

.header-link {
    text-decoration: none;
    color: inherit;
}

.header-link:hover {
    text-decoration: none;
    text-shadow: 0 1px 8px rgba(0,0,0,0.15);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: var(--max-w);
    margin: 0 auto;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.site-nav a {
    font-size: 1rem;
    font-family: 'Lora', Georgia, serif;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: 0.02em;
    border-bottom: 2px solid transparent;
    padding-bottom: 2px;
    transition: border-color 0.2s;
}

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

/* ============================================================
   Post Grid (Homepage)
   ============================================================ */
main.container {
    padding-top: 3rem;
    padding-bottom: 4rem;
}

.post-grid {
    display: grid;
    gap: 2.5rem;
}

.post-card {
    border-bottom: 1px solid var(--rule);
    padding-bottom: 2.5rem;
}

.post-card:last-child { border-bottom: none; }

.post-card-img {
    width: 100%;
    max-height: 340px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: block;
}

.post-card-title {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    margin-top: 0.25rem;
}

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

.post-date {
    font-size: 0.8rem;
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.no-posts { color: var(--ink-light); font-style: italic; }

/* ============================================================
   Single Post
   ============================================================ */
.post-single { max-width: var(--max-w); }

.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--ink-light);
}

.post-hero-img {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    display: block;
}

.post-title {
    font-family: 'Lora', Georgia, serif;
    font-size: 2.2rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.post-body {
    margin-top: 2rem;
    font-family: 'Lora', Georgia, serif;
    font-size: 1.1rem;
    line-height: 1.85;
    color: var(--ink);
}

.post-body h1, .post-body h2, .post-body h3 {
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
}
.post-body p        { margin-bottom: 1.25rem; }
.post-body ul,
.post-body ol       { margin: 0 0 1.25rem 1.5rem; }
.post-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.25rem;
    color: var(--ink-light);
    font-style: italic;
    margin: 1.5rem 0;
}
.post-body pre,
.post-body code {
    background: var(--cream);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}
.post-body pre  { padding: 1rem; overflow-x: auto; margin-bottom: 1.25rem; }
.post-body code { padding: 0.15em 0.35em; }
.post-body img  { max-width: 100%; border-radius: var(--radius); }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
    border-top: 1px solid var(--rule);
    padding: 2rem 0;
    font-size: 0.85rem;
    color: var(--ink-light);
    text-align: center;
    margin-top: 2rem;
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.alert-success { background: #e6f4ed; color: var(--success); border: 1px solid #a8d5bb; }
.alert-error   { background: #fdecea; color: var(--error);   border: 1px solid #f0b0a8; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-block;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: background 0.15s;
}
.btn-primary   { background: var(--accent);    color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--cream); color: var(--ink); border: 1px solid var(--rule); }
.btn-secondary:hover { background: var(--rule); }
.btn-link      { background: none; border: none; padding: 0; cursor: pointer; font-size: 0.875rem; font-family: inherit; }
.btn-danger    { color: var(--error); }
.btn-danger:hover { text-decoration: underline; }

/* ============================================================
   Login Page
   ============================================================ */
.admin-body {
    background: var(--cream);
    min-height: 100vh;
}

.login-wrap {
    max-width: 380px;
    margin: 8vh auto 0;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 2.5rem;
}

.login-title {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
}

.login-form label,
.settings-form label,
.post-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-form input,
.settings-form input[type="text"],
.settings-form input[type="password"],
.post-form input[type="text"] {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
    margin-bottom: 1.15rem;
    transition: border-color 0.15s;
}

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

/* ============================================================
   Admin Layout
   ============================================================ */
.admin-wrap {
    max-width: var(--admin-max);
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 2rem;
}

.admin-brand {
    font-weight: 600;
    font-size: 0.95rem;
}

.admin-nav { display: flex; gap: 1.5rem; font-size: 0.875rem; }
.admin-nav a { color: var(--ink-light); }
.admin-nav a:hover { color: var(--accent); text-decoration: none; }

.admin-section {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1.75rem 2rem;
    margin-bottom: 2rem;
}

.admin-section h2 {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--rule);
}

/* ============================================================
   Settings Form
   ============================================================ */
.settings-form { max-width: 480px; }
.settings-form small { font-size: 0.78rem; color: var(--ink-light); font-weight: 400; }
.settings-form input[type="file"] { display: block; margin-bottom: 1.15rem; }

.logo-preview {
    display: block;
    max-height: 60px;
    width: auto;
    margin-bottom: 0.75rem;
    border-radius: 4px;
}

/* ============================================================
   Posts Table
   ============================================================ */
.posts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.posts-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--rule);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-light);
}
.posts-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
}
.posts-table tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-published { background: #e6f4ed; color: var(--success); }
.badge-draft     { background: var(--cream); color: var(--ink-light); }

.post-actions { display: flex; gap: 1rem; align-items: center; font-size: 0.875rem; }
.post-actions a { color: var(--ink-light); }
.post-actions a:hover { color: var(--accent); }

/* ============================================================
   Post Form (new/edit)
   ============================================================ */
.post-form label { margin-top: 1.25rem; }
.post-form input[type="text"] { margin-bottom: 0; }
.post-form input[type="file"] { display: block; margin: 0.5rem 0 0; }

.post-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    text-transform: none !important;
    letter-spacing: 0 !important;
    color: var(--ink) !important;
    cursor: pointer;
    margin-top: 0 !important;
}

/* Quill Editor */
#quill-editor {
    min-height: 320px;
    font-family: 'Lora', Georgia, serif;
    font-size: 1rem;
    background: #fff;
    border-radius: 0 0 var(--radius) var(--radius);
}

.ql-toolbar {
    border-radius: var(--radius) var(--radius) 0 0;
}

.ql-container { font-size: 1rem; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 2.5rem 0 1rem;
    border-top: 1px solid var(--rule);
    margin-top: 2rem;
}

.page-btn {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    padding: 0.5rem 1.1rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    transition: background 0.15s;
}

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

.page-btn-disabled {
    color: var(--ink-light);
    border-color: var(--rule);
    cursor: default;
    opacity: 0.4;
}

.page-info {
    font-size: 0.85rem;
    color: var(--ink-light);
}

/* ============================================================
   Search
   ============================================================ */
.search-form {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.search-input {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-family: inherit;
    background: var(--cream);
    color: var(--ink);
    width: 110px;
    transition: border-color 0.15s;
}

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

.search-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--ink-light);
    padding: 0.2rem 0.4rem;
    transition: color 0.15s;
}

.search-btn:hover {
    color: var(--accent);
}

.search-count {
    font-size: 0.875rem;
    color: var(--ink-light);
    margin-top: 0.5rem;
}

/* ============================================================
   Admin Post Filter
   ============================================================ */
.post-filter-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--cream);
    color: var(--ink);
    margin-bottom: 1.25rem;
    transition: border-color 0.15s;
}

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

/* ============================================================
   Responsive — Admin
   ============================================================ */
@media (max-width: 600px) {
    .post-form-footer { flex-direction: column; gap: 1rem; align-items: flex-start; }
    .posts-table { font-size: 0.8rem; }
    .admin-section { padding: 1.25rem 1rem; }
}

/* ============================================================
   Responsive — Public
   ============================================================ */
@media (max-width: 768px) {
    .site-banner {
        max-width: 100%;
        margin: 0.5rem auto 0;
    }

    .header-identity {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
    }

    .header-center-title {
        font-size: 1.2rem;
        flex: 1 1 100%;
        text-align: center;
    }

    .header-nav-inner {
        flex-wrap: wrap;
        gap: 0.75rem;
        justify-content: flex-end;
        padding-right: 0.5rem;
    }

    .header-nav-bar {
        padding: 0.75rem 1rem;
    }

    .search-input {
        width: 100px;
    }
}

/*=========================================
 * Fix Firefox
============================

html, body {
    max-width: 100%;
    overflow-x: hidden;
}
*/

/* ============================================================
   Social Icons
   ============================================================ */
.social-links {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin-bottom: 0.75rem;
}

.social-icon {
    color: var(--ink-light);
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
}

.social-icon:hover {
    color: var(--accent);
    transform: translateY(-2px);
    text-decoration: none;
}
