/* ============================================
   BLOG SYSTEM — Manuel Dalla Santa
   Styles for blog, article, and admin pages
   ============================================ */

/* ============================================
   HOMEPAGE — Blog Preview Section
   ============================================ */

.blog-section {
    padding: 8rem 2rem;
    background: var(--off-white);
}

.blog-section-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.blog-section-header {
    text-align: center;
    margin-bottom: 4rem;
}

.blog-section-header h2 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2.5rem, 5vw, 4rem);
    color: var(--black);
    margin-bottom: 0.5rem;
}

.blog-section-header p {
    color: var(--mid-gray);
    font-size: 1.05rem;
    font-weight: 400;
}

#blog-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 3rem;
}

/* Homepage 3D bookshelf */
.book-shelf {
    align-items: end;
    background: linear-gradient(180deg, transparent 0 72%, #c9a47a 72% 75%, #765238 75% 79%, #3f2a22 79%);
    border-bottom: 0.7rem solid #2b1c18;
    column-gap: clamp(1.5rem, 5vw, 5rem);
    display: flex !important;
    justify-content: center;
    min-height: 31rem;
    padding: 3rem clamp(1rem, 5vw, 4rem) 4.5rem;
    perspective: 1200px;
}

.book-unit {
    height: 24rem;
    max-width: 15rem;
    position: relative;
    width: min(25vw, 12rem);
}

.book-toggle {
    left: -9999px;
    position: absolute;
}

.book-card,
.book-pages {
    height: 100%;
    position: absolute;
    top: 0;
    transform-style: preserve-3d;
    width: 100%;
}

.book-card {
    cursor: pointer;
    display: block;
    transform-origin: left center;
    transition: transform 0.65s cubic-bezier(0.2, 0.75, 0.25, 1), box-shadow 0.65s ease;
    z-index: 2;
}

.book-cover {
    background: var(--light-gray);
    border: 0.35rem solid #181818;
    box-shadow: inset -0.6rem 0 rgba(0, 0, 0, 0.22), 0.5rem 0.35rem 0 rgba(37, 23, 16, 0.35);
    display: block;
    height: 100%;
    overflow: hidden;
    position: relative;
    transform: translateZ(0.7rem);
}

.book-cover img {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.book-cover-placeholder {
    align-items: center;
    background: #242424;
    color: #f4f0e8;
    display: flex;
    font-family: var(--font-display);
    font-size: 2rem;
    height: 100%;
    justify-content: center;
}

.book-spine {
    background: #191919;
    color: #f4f0e8;
    font-size: 0.65rem;
    left: -1.7rem;
    letter-spacing: 0.08em;
    overflow: hidden;
    padding: 0.75rem 0.35rem;
    position: absolute;
    text-overflow: ellipsis;
    top: 0;
    transform: rotateY(-90deg);
    transform-origin: right center;
    white-space: nowrap;
    width: 1.7rem;
    writing-mode: vertical-rl;
}

.book-pages {
    background: #f6f0e4;
    box-shadow: 0.3rem 0.35rem 0 rgba(37, 23, 16, 0.25);
    color: var(--black);
    left: 0;
    opacity: 0;
    overflow: hidden;
    padding: 2rem 1.5rem 1.5rem 3rem;
    transform: translateX(1rem) translateZ(-0.1rem);
    transition: opacity 0.35s ease 0.25s;
    width: min(24rem, 38vw);
    z-index: 1;
}

.book-pages h3 {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 2vw, 1.75rem);
    line-height: 1.1;
    margin: 0.35rem 0 0.75rem;
}

.book-pages p {
    color: var(--dark-gray);
    font-size: 0.82rem;
    line-height: 1.55;
}

.book-page-kicker {
    color: var(--mid-gray);
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.book-page-meta {
    color: var(--mid-gray) !important;
    font-size: 0.68rem !important;
    margin-bottom: 1rem;
}

.book-page-link {
    bottom: 1.25rem;
    color: var(--black);
    font-size: 0.75rem;
    font-weight: 600;
    position: absolute;
    text-decoration: none;
}

.book-page-link span {
    font-size: 1rem;
    margin-left: 0.3rem;
}

.book-toggle:checked + .book-card {
    transform: translateX(100%) rotateY(-72deg);
    z-index: 1;
}

.book-toggle:checked ~ .book-pages {
    opacity: 1;
    z-index: 2;
}

.book-toggle:focus-visible + .book-card {
    outline: 3px solid var(--black);
    outline-offset: 5px;
}

.blog-section-footer {
    text-align: center;
}

.blog-see-all {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--black);
    text-decoration: none;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--black);
    padding-bottom: 2px;
    transition: opacity 0.3s ease;
}

.blog-see-all:hover {
    opacity: 0.55;
}

/* ============================================
   BLOG CARD (shared: homepage + blog page)
   ============================================ */

.blog-card {
    display: block;
    text-decoration: none;
    color: var(--black);
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.4s var(--ease-out-expo), box-shadow 0.4s ease;
}

.blog-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
}

.blog-card-image {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--light-gray);
}

.blog-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease-out-expo);
}

.blog-card:hover .blog-card-image img {
    transform: scale(1.05);
}

.blog-card-noimage {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--light-gray) 0%, var(--off-white) 100%);
}

.blog-card-body {
    padding: 1.5rem;
}

.blog-card-date {
    display: block;
    font-size: 0.75rem;
    color: var(--mid-gray);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.blog-card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    margin: 0.5rem 0;
    line-height: 1.3;
}

.blog-card-excerpt {
    font-size: 0.9rem;
    color: var(--dark-gray);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.blog-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--mid-gray);
    flex-wrap: wrap;
}

.blog-card-author {
    font-size: 0.8rem;
    color: var(--mid-gray);
    font-weight: 500;
}

.blog-card-location {
    font-size: 0.8rem;
    color: var(--mid-gray);
    font-weight: 400;
}

.blog-card-sep {
    font-size: 0.65rem;
    color: var(--mid-gray);
}

.blog-empty {
    text-align: center;
    color: var(--mid-gray);
    font-size: 1rem;
    padding: 3rem 0;
    grid-column: 1 / -1;
}

.blog-loading {
    text-align: center;
    color: var(--mid-gray);
    font-size: 1rem;
    padding: 3rem 0;
}

/* ============================================
   BLOG PAGE — Hero + Grid
   ============================================ */

.blog-page-hero {
    padding: 8rem 2rem 3rem;
    text-align: center;
    background: var(--white);
}

.blog-page-hero h1 {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(3rem, 6vw, 5rem);
    color: var(--black);
    margin-bottom: 0.5rem;
}

.blog-page-hero p {
    color: var(--mid-gray);
    font-size: 1.1rem;
}

.blog-grid-section {
    padding: 2rem 2rem 6rem;
    max-width: 1200px;
    margin: 0 auto;
}

#blog-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

/* ============================================
   ARTICLE PAGE
   ============================================ */

.article-page {
    padding: 7rem 2rem 4rem;
    max-width: 800px;
    margin: 0 auto;
    min-height: 60vh;
}

.article-back-link {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--mid-gray);
    text-decoration: none;
    margin-bottom: 2rem;
    transition: color 0.3s ease;
    letter-spacing: 0.02em;
}

.article-back-link:hover {
    color: var(--black);
}

.article-header {
    margin-bottom: 2.5rem;
}

.article-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.15;
    color: var(--black);
    margin-bottom: 1rem;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--mid-gray);
    flex-wrap: wrap;
}

.article-location {
    font-weight: 400;
}

.article-meta-sep {
    font-size: 0.7rem;
}

.article-cover {
    margin-bottom: 2.5rem;
    border-radius: 12px;
    overflow: hidden;
    line-height: 0;
}

.article-cover img {
    width: 100%;
    height: auto;
    display: block;
}

/* ---- Article Content Typography ---- */

.article-content {
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--near-black);
}

.article-content h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.6rem;
    margin: 2.5rem 0 1rem;
    color: var(--black);
}

.article-content h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    margin: 2rem 0 0.75rem;
    color: var(--black);
}

.article-content p {
    margin-bottom: 1.25rem;
}

.article-content a {
    color: var(--black);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity 0.3s ease;
}

.article-content a:hover {
    opacity: 0.6;
}

.article-content ul,
.article-content ol {
    margin: 1rem 0 1.5rem 1.5rem;
}

.article-content li {
    margin-bottom: 0.5rem;
}

.article-content strong {
    font-weight: 600;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1.5rem auto;
    display: block;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.07);
}

.article-content figure,
.article-content figure.article-inline-image {
    margin: 2.5rem auto;
    text-align: center;
    max-width: 100%;
}

.article-content figure img,
.article-content figure.article-inline-image img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

.article-content figcaption {
    font-size: 0.88rem;
    color: var(--mid-gray);
    margin-top: 0.75rem;
    text-align: center;
    font-style: italic;
    line-height: 1.4;
}

.article-content figcaption:empty {
    display: none;
}

.article-not-found {
    text-align: center;
    padding: 6rem 2rem;
}

.article-not-found h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--black);
}

/* ============================================
   GALLERY / CAROUSEL
   ============================================ */

.article-gallery {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--light-gray);
}

.gallery-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    color: var(--black);
}

.gallery-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 480px;
    overflow: hidden;
    border-radius: 12px;
    background: #0d0e11;
}

.gallery-track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.45s var(--ease-out-expo);
    will-change: transform;
}

.gallery-slide {
    flex: 0 0 100%;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d0e11;
    overflow: hidden;
}

.gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.gallery-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: var(--black);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, background 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 10;
    line-height: 1;
}

.gallery-viewport:hover .gallery-btn {
    opacity: 1;
    pointer-events: auto;
}

.gallery-btn:hover {
    background: var(--white);
    transform: translateY(-50%) scale(1.1);
}

.gallery-prev { left: 1rem; }
.gallery-next { right: 1rem; }

.gallery-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.25rem 0;
}

.gallery-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: var(--light-gray);
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
    padding: 0;
}

.gallery-dot.active {
    background: var(--black);
    transform: scale(1.3);
}

/* ============================================
   ADMIN — Login
   ============================================ */

#admin-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--off-white);
    padding: 2rem;
}

.admin-login-card {
    background: var(--white);
    padding: 3rem;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.06);
}

.admin-login-card h1 {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 2.5rem;
    color: var(--black);
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.admin-login-card h1 span {
    color: var(--mid-gray);
}

.admin-login-card h2 {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1rem;
    color: var(--mid-gray);
    margin-bottom: 2rem;
}

.admin-login-card .editor-field {
    margin-bottom: 1rem;
}

.admin-login-card .editor-field input {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: border-color 0.3s ease;
    outline: none;
    background: var(--white);
}

.admin-login-card .editor-field input:focus {
    border-color: var(--black);
}

#login-error {
    color: #d32f2f;
    font-size: 0.85rem;
    min-height: 1.25rem;
    margin-bottom: 0.5rem;
}

#login-btn {
    width: 100%;
    padding: 0.9rem;
    background: var(--black);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

#login-btn:hover { opacity: 0.8; }
#login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   ADMIN — Dashboard
   ============================================ */

#admin-dashboard {
    display: none;
    min-height: 100vh;
    background: var(--off-white);
}

.admin-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    background: var(--white);
    border-bottom: 1px solid var(--light-gray);
    position: sticky;
    top: 0;
    z-index: 50;
}

.admin-nav-logo {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1.4rem;
    color: var(--black);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.admin-nav-logo span { color: var(--mid-gray); }

#btn-logout {
    padding: 0.5rem 1.25rem;
    background: none;
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--mid-gray);
    cursor: pointer;
    transition: all 0.3s ease;
}

#btn-logout:hover {
    border-color: var(--black);
    color: var(--black);
}

.admin-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

/* ---- Article List ---- */

.admin-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.admin-list-header h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--black);
}

#btn-new-article {
    padding: 0.7rem 1.5rem;
    background: var(--black);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

#btn-new-article:hover { opacity: 0.8; }

.admin-article-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: var(--white);
    border-radius: 10px;
    margin-bottom: 0.75rem;
    transition: box-shadow 0.3s ease;
}

.admin-article-row:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.admin-article-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.admin-article-info strong {
    font-weight: 600;
    font-size: 1rem;
    color: var(--black);
}

.admin-article-info span {
    font-size: 0.8rem;
    color: var(--mid-gray);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.admin-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-badge.published {
    background: #e8f5e9;
    color: #2e7d32;
}

.admin-badge.draft {
    background: #fff3e0;
    color: #ef6c00;
}

.admin-list-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-article-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.admin-btn-copy,
.admin-btn-edit,
.admin-btn-delete {
    padding: 0.45rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--light-gray);
    background: var(--white);
    font-family: var(--font-body);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.admin-btn-copy:hover,
.admin-btn-edit:hover {
    border-color: var(--black);
    color: var(--black);
}

.admin-btn-delete {
    color: #d32f2f;
    border-color: #ffcdd2;
}

.admin-btn-delete:hover {
    background: #ffebee;
    border-color: #d32f2f;
}

/* ---- Sitemap Modal ---- */
.sitemap-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.sitemap-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.sitemap-modal-card {
    position: relative;
    z-index: 2;
    background: var(--white);
    border-radius: 16px;
    width: 100%;
    max-width: 650px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.sitemap-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.sitemap-modal-header h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--mid-gray);
    padding: 4px;
    line-height: 1;
}

.btn-close-modal:hover { color: var(--black); }

.sitemap-modal-desc {
    font-size: 0.88rem;
    color: var(--dark-gray);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.sitemap-textarea {
    width: 100%;
    height: 220px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.8rem;
    padding: 1rem;
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    background: var(--off-white);
    color: var(--near-black);
    resize: none;
    outline: none;
    margin-bottom: 1.25rem;
    white-space: pre;
    box-sizing: border-box;
}

.sitemap-modal-footer {
    display: flex;
    justify-content: flex-end;
}

/* ---- Image Modal Styling ---- */
.image-modal-card {
    max-width: 580px;
}

.image-modal-upload {
    margin-bottom: 1rem;
    padding: 1.5rem;
    text-align: center;
    background: var(--off-white);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.image-modal-upload.dragover {
    border-color: var(--black);
    background: #f0f0f0;
}

.inline-image-preview-container {
    margin-top: 1.25rem;
    padding: 1rem;
    background: var(--off-white);
    border: 1px solid var(--light-gray);
    border-radius: 8px;
}

.inline-preview-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 0.5rem;
}

.inline-preview-box {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.inline-preview-box img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 6px;
    display: block;
    object-fit: contain;
}

.inline-preview-box .btn-close-modal {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: background 0.2s ease;
}

.inline-preview-box .btn-close-modal:hover {
    background: #d32f2f;
}

.admin-loading,
.admin-empty {
    text-align: center;
    color: var(--mid-gray);
    font-size: 0.95rem;
    padding: 3rem 0;
}

/* ============================================
   ADMIN — Editor
   ============================================ */

#admin-editor {
    display: none;
}

.editor-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--mid-gray);
    background: none;
    border: none;
    cursor: pointer;
    margin-bottom: 1.5rem;
    padding: 0;
    font-family: var(--font-body);
    transition: color 0.3s ease;
}

.editor-back-btn:hover { color: var(--black); }

.editor-card {
    background: var(--white);
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.editor-field {
    margin-bottom: 1.5rem;
}

.editor-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--mid-gray);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.editor-field input[type="text"],
.editor-field input[type="date"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s ease;
    background: var(--white);
}

.editor-field input:focus {
    border-color: var(--black);
}

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

.editor-field-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

#editor-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    padding: 0.85rem 1rem;
}

/* ---- Rich Text Toolbar ---- */

#editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--off-white);
    border: 1px solid var(--light-gray);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}

#editor-toolbar button {
    padding: 0.4rem 0.75rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--dark-gray);
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.2;
}

#editor-toolbar button:hover {
    background: var(--white);
    border-color: var(--light-gray);
    color: var(--black);
}

/* ---- Contenteditable Area ---- */

#editor-content {
    min-height: 300px;
    padding: 1.25rem;
    border: 1px solid var(--light-gray);
    border-radius: 0 0 8px 8px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.7;
    outline: none;
    transition: border-color 0.3s ease;
    overflow-y: auto;
}

#editor-content:focus {
    border-color: var(--black);
}

#editor-content:empty::before {
    content: attr(data-placeholder);
    color: var(--mid-gray);
    pointer-events: none;
}

#editor-content h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.4rem;
    margin: 1rem 0 0.5rem;
}

#editor-content h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    margin: 0.75rem 0 0.5rem;
}

#editor-content figure,
#editor-content figure.article-inline-image {
    margin: 1.5rem auto;
    text-align: center;
    position: relative;
    max-width: 100%;
}

#editor-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 1rem auto;
    cursor: pointer;
    transition: outline 0.15s ease, box-shadow 0.15s ease;
}

#editor-content img:hover,
#editor-content img.is-selected {
    outline: 3px solid var(--black);
    outline-offset: 2px;
}

#editor-content figcaption {
    font-size: 0.85rem;
    color: var(--mid-gray);
    margin-top: 0.5rem;
    text-align: center;
    font-style: italic;
    min-height: 1.2em;
}

#editor-content figcaption:empty::before {
    content: "Scrivi didascalia (opzionale)...";
    color: var(--mid-gray);
    font-style: italic;
    opacity: 0.6;
}

/* Floating delete button for inline images */
.editor-image-delete-btn {
    position: absolute;
    z-index: 20;
    background: #d32f2f;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: background 0.2s ease, transform 0.1s ease;
    user-select: none;
}

.editor-image-delete-btn:hover {
    background: #b71c1c;
    transform: scale(1.04);
}

/* ---- Upload Areas ---- */

.editor-upload-area {
    border: 2px dashed var(--light-gray);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    transition: border-color 0.3s ease;
    cursor: pointer;
    position: relative;
}

.editor-upload-area:hover {
    border-color: var(--mid-gray);
}

.editor-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.editor-upload-text {
    font-size: 0.9rem;
    color: var(--mid-gray);
}

.editor-upload-text strong {
    color: var(--black);
}

.editor-url-row {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.editor-url-sep {
    font-size: 0.75rem;
    color: var(--mid-gray);
    letter-spacing: 0.04em;
}

.editor-url-input-group {
    display: flex;
    gap: 0.5rem;
}

.editor-url-input-group input[type="url"] {
    flex: 1;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.3s ease;
    background: var(--white);
}

.editor-url-input-group input[type="url"]:focus {
    border-color: var(--black);
}

.btn-subtle {
    padding: 0.65rem 1.1rem;
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--black);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.btn-subtle:hover {
    border-color: var(--black);
    background: var(--off-white);
}

#editor-cover-preview {
    display: none;
    margin-top: 1rem;
    position: relative;
}

#editor-cover-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 8px;
}

.remove-cover {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: var(--white);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.remove-cover:hover {
    background: rgba(0, 0, 0, 0.85);
}

#editor-gallery-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.editor-gallery-item {
    position: relative;
    width: 120px;
    height: 90px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--light-gray);
}

.editor-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.editor-gallery-item.uploading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--light-gray);
    border-top-color: var(--black);
    border-radius: 50%;
    animation: blogSpin 0.6s linear infinite;
}

@keyframes blogSpin {
    to { transform: rotate(360deg); }
}

.editor-gallery-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: var(--white);
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.editor-gallery-item:hover .editor-gallery-remove {
    opacity: 1;
}

.upload-progress {
    color: var(--mid-gray);
    font-size: 0.85rem;
}

.upload-error {
    color: #d32f2f;
    font-size: 0.85rem;
}

/* ---- Editor Actions ---- */

.editor-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--light-gray);
}

.editor-actions button {
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--black);
    color: var(--white);
    border: none;
}

.btn-primary:hover { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: var(--white);
    color: var(--black);
    border: 1px solid var(--light-gray);
}

.btn-secondary:hover { border-color: var(--black); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   RESPONSIVE
   ============================================ */

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

    .editor-field-row,
    .editor-field-row-3 {
        grid-template-columns: 1fr;
    }
}

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

    .blog-section {
        padding: 5rem 1.25rem;
    }

    .blog-page-hero {
        padding: 6rem 1.25rem 2rem;
    }

    .blog-grid-section {
        padding: 1.5rem 1.25rem 4rem;
    }

    .article-page {
        padding: 6rem 1.25rem 3rem;
    }

    .article-title {
        font-size: 1.8rem;
    }

    .gallery-viewport {
        aspect-ratio: 4 / 3;
        max-height: 320px;
    }

    .gallery-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        opacity: 0.85;
        pointer-events: auto;
    }

    .gallery-prev { left: 0.5rem; }
    .gallery-next { right: 0.5rem; }

    .admin-login-card {
        padding: 2rem;
    }

    .admin-content {
        padding: 1.5rem 1rem;
    }

    .editor-card {
        padding: 1.5rem;
    }

    .admin-article-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .admin-article-actions {
        width: 100%;
    }

    .admin-article-actions button {
        flex: 1;
    }

    .editor-actions {
        flex-direction: column;
    }

    .editor-actions button {
        width: 100%;
        text-align: center;
    }
}
