/*
Theme Name: Alteryse
Theme URI: https://alteryse.com
Author: Alteryse
Description: A clean, modern, SEO-friendly WordPress theme with full CMS capabilities — responsive, accessible, block-editor ready.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 8.0
License: GPL-2.0+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: alteryse
Tags: blog, custom-logo, custom-menu, featured-images, footer-widgets, full-width-template, sticky-post, theme-options, threaded-comments, translation-ready, block-styles, wide-blocks, editor-style
*/

/* =========================================================================
   CSS CUSTOM PROPERTIES
   ========================================================================= */
:root {
    --color-primary:    #2563eb;
    --color-primary-h:  #1d4ed8;
    --color-text:       #1e293b;
    --color-text-muted: #64748b;
    --color-bg:         #ffffff;
    --color-bg-soft:    #f8fafc;
    --color-border:     #e2e8f0;
    --color-accent:     #f59e0b;

    --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;
    --font-mono:  'Fira Code', 'Courier New', monospace;

    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.25rem;
    --text-2xl:  1.5rem;
    --text-3xl:  1.875rem;
    --text-4xl:  2.25rem;

    --radius:    0.5rem;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow:    0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

    --container: 1200px;
    --content:   760px;
    --sidebar:   300px;
    --gap:       2rem;
}

/* =========================================================================
   RESET & BASE
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.7;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-h); text-decoration: underline; }
p { margin-bottom: 1.25rem; }
ul, ol { margin: 0 0 1.25rem 1.5rem; }
li { margin-bottom: 0.25rem; }

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.75rem;
    color: var(--color-text);
}
h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

blockquote {
    border-left: 4px solid var(--color-primary);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    background: var(--color-bg-soft);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    color: var(--color-text-muted);
}

pre, code {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background: var(--color-bg-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
code { padding: 0.15em 0.4em; }
pre { padding: 1.25rem; overflow-x: auto; margin-bottom: 1.5rem; }
pre code { border: none; padding: 0; background: transparent; }

hr { border: none; border-top: 1px solid var(--color-border); margin: 2rem 0; }

table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
th, td { padding: 0.75rem 1rem; border: 1px solid var(--color-border); text-align: left; }
th { background: var(--color-bg-soft); font-weight: 600; }
tr:nth-child(even) td { background: var(--color-bg-soft); }

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

.site-main { padding: 3rem 0; }

.content-area { flex: 1; min-width: 0; }

.has-sidebar .inner-wrap {
    display: grid;
    grid-template-columns: 1fr var(--sidebar);
    gap: var(--gap);
    align-items: start;
}

/* =========================================================================
   SKIP LINK (ACCESSIBILITY)
   ========================================================================= */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--radius);
    font-size: var(--text-sm);
}
.skip-link:focus { top: 1rem; }

/* =========================================================================
   HEADER
   ========================================================================= */
.site-header {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 1.5rem;
}

.site-branding a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-text);
    text-decoration: none;
}
.site-branding a:hover { text-decoration: none; }

.site-logo img { height: 40px; width: auto; }

.site-title {
    font-size: var(--text-xl);
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.site-tagline {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    display: none;
}

/* Primary Navigation */
.primary-nav ul {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.primary-nav a {
    display: block;
    padding: 0.5rem 0.875rem;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
    border-radius: var(--radius);
    transition: background 0.15s, color 0.15s;
}
.primary-nav a:hover,
.primary-nav .current-menu-item > a,
.primary-nav .current-page-ancestor > a {
    background: var(--color-bg-soft);
    color: var(--color-primary);
    text-decoration: none;
}

/* Dropdown menus */
.primary-nav li { position: relative; }
.primary-nav .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 0.5rem;
    z-index: 200;
    flex-direction: column;
    gap: 0;
    list-style: none;
    margin: 0;
}
.primary-nav li:hover > .sub-menu { display: flex; }
.primary-nav .sub-menu a { white-space: nowrap; width: 100%; }

/* Mobile toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--color-text);
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    margin: 4px 0;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

/* =========================================================================
   HERO / PAGE HEADER
   ========================================================================= */
.page-header {
    background: var(--color-bg-soft);
    border-bottom: 1px solid var(--color-border);
    padding: 3rem 0 2.5rem;
    margin-bottom: 2.5rem;
    text-align: center;
}
.page-header .page-title { font-size: var(--text-3xl); margin-bottom: 0.5rem; }
.page-header .page-description { color: var(--color-text-muted); font-size: var(--text-lg); max-width: 600px; margin: 0 auto; }

/* =========================================================================
   POSTS / ARCHIVE
   ========================================================================= */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--gap);
}

.post-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}
.post-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.post-card-thumb img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }

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

.post-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    align-items: center;
}

.post-card-title {
    font-size: var(--text-xl);
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}
.post-card-title a { color: var(--color-text); }
.post-card-title a:hover { color: var(--color-primary); text-decoration: none; }

.post-card-excerpt { color: var(--color-text-muted); font-size: var(--text-sm); margin-bottom: 1rem; }

.read-more {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-primary);
}
.read-more:hover { gap: 0.6rem; text-decoration: none; }

/* Category badge */
.cat-badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    background: var(--color-primary);
    color: #fff;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 600;
    text-decoration: none;
}
.cat-badge:hover { background: var(--color-primary-h); color: #fff; text-decoration: none; }

/* =========================================================================
   SINGLE POST / PAGE
   ========================================================================= */
.post-header { margin-bottom: 2rem; }

.post-title { font-size: clamp(var(--text-3xl), 4vw, 2.75rem); margin-bottom: 1rem; }

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    align-items: center;
    margin-bottom: 1.5rem;
}
.post-meta a { color: var(--color-text-muted); }
.post-meta a:hover { color: var(--color-primary); }

.post-thumbnail {
    margin-bottom: 2rem;
    border-radius: var(--radius);
    overflow: hidden;
}
.post-thumbnail img { width: 100%; max-height: 480px; object-fit: cover; }

.entry-content { max-width: var(--content); }
.entry-content > * + * { margin-top: 1.25rem; }
.entry-content h2, .entry-content h3, .entry-content h4 { margin-top: 2rem; }
.entry-content img { border-radius: var(--radius); }

/* Post footer */
.post-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
}

.post-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.tag-link {
    padding: 0.3em 0.75em;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    transition: border-color 0.15s, color 0.15s;
}
.tag-link:hover { border-color: var(--color-primary); color: var(--color-primary); text-decoration: none; }

/* Post navigation */
.post-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 3rem;
}
.nav-prev, .nav-next {
    padding: 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.nav-prev:hover, .nav-next:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); }
.nav-next { text-align: right; }
.nav-label { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.nav-title { font-weight: 600; color: var(--color-text); font-size: var(--text-sm); }

/* =========================================================================
   SIDEBAR
   ========================================================================= */
.widget-area { position: sticky; top: 80px; }

.widget {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.widget-title {
    font-size: var(--text-base);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.widget ul { margin: 0; padding: 0; list-style: none; }
.widget ul li { padding: 0.4rem 0; border-bottom: 1px solid var(--color-border); font-size: var(--text-sm); }
.widget ul li:last-child { border-bottom: none; }

.widget_search .search-field {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    background: var(--color-bg-soft);
}
.widget_search .search-field:focus { outline: 2px solid var(--color-primary); border-color: transparent; }
.widget_search .search-submit {
    margin-top: 0.5rem;
    width: 100%;
    padding: 0.625rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.widget_search .search-submit:hover { background: var(--color-primary-h); }

/* =========================================================================
   PAGINATION
   ========================================================================= */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 3rem;
    flex-wrap: wrap;
}
.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pagination .page-numbers:hover { background: var(--color-bg-soft); text-decoration: none; }
.pagination .current { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* =========================================================================
   COMMENTS
   ========================================================================= */
.comments-area { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--color-border); }
.comments-title { font-size: var(--text-2xl); margin-bottom: 1.5rem; }

.comment-list { list-style: none; margin: 0; padding: 0; }
.comment { margin-bottom: 1.5rem; }
.comment-body {
    background: var(--color-bg-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.comment-meta { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.comment-author { font-weight: 600; }
.comment-metadata { font-size: var(--text-xs); color: var(--color-text-muted); }
.comment-content p { margin-bottom: 0; font-size: var(--text-sm); }
.comment-reply-link { font-size: var(--text-xs); font-weight: 600; color: var(--color-primary); }
.children { margin-left: 2rem; margin-top: 1rem; list-style: none; padding: 0; }

.comment-form label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: 0.25rem; }
.comment-form input[type=text],
.comment-form input[type=email],
.comment-form input[type=url],
.comment-form textarea {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    background: var(--color-bg-soft);
    margin-bottom: 1rem;
}
.comment-form input:focus,
.comment-form textarea:focus { outline: 2px solid var(--color-primary); border-color: transparent; }
.comment-form .form-submit input {
    padding: 0.75rem 2rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.comment-form .form-submit input:hover { background: var(--color-primary-h); }

/* =========================================================================
   FOOTER
   ========================================================================= */
.site-footer {
    background: var(--color-text);
    color: rgba(255,255,255,0.7);
    margin-top: 4rem;
}

.footer-widgets {
    padding: 3.5rem 0 2.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.footer-widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2.5rem;
}

.footer-widget .widget-title {
    color: rgba(255,255,255,0.5);
    border-bottom-color: rgba(255,255,255,0.1);
    margin-bottom: 1rem;
}

.footer-widget a { color: rgba(255,255,255,0.7); }
.footer-widget a:hover { color: #fff; text-decoration: none; }
.footer-widget p, .footer-widget li { font-size: var(--text-sm); }
.footer-widget ul { border: none; }
.footer-widget ul li { border-bottom-color: rgba(255,255,255,0.08); }

.footer-bottom {
    padding: 1.5rem 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-size: var(--text-sm);
}

.footer-site-name { color: #fff; font-weight: 600; }

.footer-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.footer-nav a { color: rgba(255,255,255,0.7); font-size: var(--text-sm); }
.footer-nav a:hover { color: #fff; text-decoration: none; }

/* =========================================================================
   SEARCH RESULTS
   ========================================================================= */
.search-form { display: flex; gap: 0.5rem; margin-bottom: 2rem; }
.search-form .search-field {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: var(--text-base);
}
.search-form .search-submit {
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
}
.search-form .search-submit:hover { background: var(--color-primary-h); }

/* =========================================================================
   404 PAGE
   ========================================================================= */
.error-404 { text-align: center; padding: 4rem 0; }
.error-404 .error-number {
    font-size: 8rem;
    font-weight: 900;
    color: var(--color-border);
    line-height: 1;
    margin-bottom: 1rem;
}
.error-404 h2 { margin-bottom: 1rem; }
.error-404 p { color: var(--color-text-muted); margin-bottom: 2rem; }

/* =========================================================================
   BUTTONS
   ========================================================================= */
.btn, button[type=submit], input[type=submit] {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    text-decoration: none;
}
.btn:hover { background: var(--color-primary-h); color: #fff; text-decoration: none; transform: translateY(-1px); }
.btn-outline {
    background: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary); color: #fff; }

/* =========================================================================
   BLOCK EDITOR ALIGNMENT
   ========================================================================= */
.alignnone { margin: 1rem 0; }
.aligncenter { display: block; margin: 1.5rem auto; }
.alignleft { float: left; margin: 0.5rem 1.5rem 1rem 0; }
.alignright { float: right; margin: 0.5rem 0 1rem 1.5rem; }
.alignwide { margin-left: -3rem; margin-right: -3rem; max-width: calc(var(--content) + 6rem); }
.alignfull { margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw); max-width: 100vw; }

.wp-block-image { margin: 1.5rem 0; }
.wp-block-image img { border-radius: var(--radius); }
.wp-block-image figcaption { font-size: var(--text-xs); color: var(--color-text-muted); text-align: center; margin-top: 0.5rem; }

.wp-block-quote { border-left: 4px solid var(--color-primary); padding: 1rem 1.5rem; background: var(--color-bg-soft); border-radius: 0 var(--radius) var(--radius) 0; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1024px) {
    .has-sidebar .inner-wrap { grid-template-columns: 1fr; }
    .widget-area { position: static; }
}

@media (max-width: 768px) {
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }

    .nav-toggle { display: block; }

    .primary-nav {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--color-bg);
        border-bottom: 1px solid var(--color-border);
        padding: 1rem 1.5rem;
        box-shadow: var(--shadow);
    }
    .primary-nav.is-open { display: block; }
    .primary-nav ul { flex-direction: column; gap: 0; }
    .primary-nav .sub-menu { position: static; box-shadow: none; border: none; background: var(--color-bg-soft); margin-top: 0.25rem; display: block; }

    .posts-grid { grid-template-columns: 1fr; }
    .post-navigation { grid-template-columns: 1fr; }
    .alignleft, .alignright { float: none; margin: 1rem 0; }
    .alignwide { margin-left: 0; margin-right: 0; }
    .footer-bottom { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
    :root { --gap: 1.25rem; }
    .container { padding: 0 1rem; }
    .post-card-body { padding: 1rem; }
    .error-404 .error-number { font-size: 5rem; }
}

/* =========================================================================
   ACCESSIBILITY
   ========================================================================= */
*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
}

/* =========================================================================
   GUTENBERG / BLOCK EDITOR COMPATIBILITY
   ========================================================================= */
.wp-block-separator { border: none; border-top: 1px solid var(--color-border); margin: 2rem 0; }
.wp-block-pullquote { border-top: 4px solid var(--color-text); border-bottom: 4px solid var(--color-text); padding: 2rem; text-align: center; margin: 2rem 0; }
.wp-block-pullquote blockquote { border: none; background: transparent; padding: 0; }
.wp-block-cover { position: relative; min-height: 320px; display: flex; align-items: center; justify-content: center; }
.wp-block-button__link { display: inline-block; padding: 0.75rem 1.5rem; border-radius: var(--radius); font-weight: 600; }

/* Print */
@media print {
    .site-header, .site-footer, .widget-area, .post-navigation, .comments-area { display: none; }
    body { font-size: 12pt; }
    a { color: var(--color-text); }
}
