/**
 * Arke Child Theme - Custom Styles
 * Non-critical CSS loaded after page render
 *
 * Note: Color tokens, base typography, and nav positioning are in
 * functions.php critical CSS to prevent FOUC.
 */

/* ===== Header Navigation Links ===== */
.nav .nav-links {
    display: flex;
    gap: 1.75rem;
    list-style: none;
    align-items: center;
    margin: 0;
    padding: 0;
}

.nav .nav-links a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    position: relative;
    transition: color 0.2s;
}

.nav .nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.25s ease;
}

.nav .nav-links a:hover {
    color: var(--accent-hover);
}

.nav .nav-links a:hover::after {
    width: 100%;
}

.nav .nav-links a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 2px;
}

.nav .nav-links a[aria-current="page"] {
    color: var(--text);
}

.nav .nav-links a[aria-current="page"]::after {
    width: 100%;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 6px;
    color: var(--muted);
    transition: color 0.2s, background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.theme-toggle:hover {
    color: var(--accent-hover);
    background: var(--accent-light);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: block;
}

.theme-toggle-mobile {
    margin-top: 0.25rem;
}

.theme-toggle-mobile .theme-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--muted);
    margin-left: 0.5rem;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

/* ===== Mobile Navigation ===== */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 6px;
    transition: background-color 0.2s;
    min-width: 44px;
    min-height: 44px;
}

.nav-toggle:hover {
    background: var(--accent-light);
}

.nav-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    margin: 4px 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    border-radius: 1px;
    will-change: transform, opacity;
}

/* Hamburger to X animation when menu is open */
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

.mobile-menu {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    padding: 0 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 101;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease, visibility 0.3s ease;
    contain: layout style;
}

.mobile-menu.open {
    max-height: 300px;
    opacity: 1;
    visibility: visible;
    padding: 1rem 1.5rem 1.5rem;
}

.mobile-menu ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
}

.mobile-menu a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
    border-radius: 4px;
}

.mobile-menu a:hover {
    color: var(--accent-hover);
}

.mobile-menu a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.mobile-menu a[aria-current="page"] {
    color: var(--text);
}

/* Mobile menu backdrop overlay */
.mobile-menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mobile-menu-backdrop.visible {
    display: block;
    opacity: 1;
}

[data-theme="dark"] .mobile-menu-backdrop {
    background: rgba(0, 0, 0, 0.6);
}

/* ===== "All Posts" Link ===== */
/* Matches static site: no border, just margin-top for spacing after post list */
.all-posts-link {
    display: inline-block;
    margin-top: 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

.all-posts-link:hover {
    color: var(--accent-hover);
}

.all-posts-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ===== Footer ===== */
footer.footer,
.footer {
    padding: 2rem 1.5rem;
    margin-top: 4rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-copy {
    font-size: 0.8rem;
    color: var(--muted);
}

.footer-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.footer-links a {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
}

.footer-links a:hover {
    color: var(--accent-hover);
}

.footer-links a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Dark mode explicit overrides for footer */
[data-theme="dark"] .footer,
[data-theme="dark"] footer.footer {
    background: #1A1A2E !important;
    border-top-color: #2D2D4A !important;
}

[data-theme="dark"] .footer-copy {
    color: #A8AEB8 !important;
}

[data-theme="dark"] .footer-links a {
    color: #A8AEB8 !important;
}

[data-theme="dark"] .footer-links a:hover {
    color: #6DC4A4 !important;
}

/* ===== Arke Content Overrides ===== */

/* Reset any parent theme margins on main container */
.site-main,
body .site-main,
body.blog .site-main,
body.home .site-main {
    margin: 0 !important;
    padding: 0 !important;
}

/* Content width - matches static site EXACTLY */
/* Static site: .page-content { max-width: 700px; margin: 0 auto; padding: 7rem 1.5rem 4rem; } */
.site-content,
body .site-content,
body.blog .site-content,
body.home .site-content,
body .site-main .site-content {
    max-width: 700px !important;
    margin: 0 auto !important;
    padding: 7rem 1.5rem 4rem !important;
    box-sizing: border-box !important;
}

/* Child elements inherit container width - NO extra padding (would double it) */
.entry-content,
.entry-header,
.comments-area {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

/* Typography for posts */
.entry-title {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    line-height: 1.2;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.entry-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.entry-title a:hover {
    color: var(--accent-hover);
}

.entry-title a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 2px;
}

/* Back to Writing link on single posts */
.back-to-writing {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 1.5rem;
    transition: color 0.2s ease;
}

.back-to-writing:hover {
    color: var(--accent-hover);
}

.back-to-writing:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

.entry-meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 2rem;
}

.entry-meta a {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s;
}

.entry-meta a:hover {
    color: var(--accent-hover);
}

.entry-content {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--muted);
}

.entry-content strong,
.entry-content b {
    color: var(--text);
    font-weight: 600;
}

.entry-content p {
    margin-bottom: 1.5rem;
}

.entry-content a {
    color: var(--accent);
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

.entry-content a:hover {
    color: var(--accent-hover);
}

/* "Continue reading" link */
.entry-content .more-link {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
}

.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.entry-content h2 {
    font-size: 1.5rem;
}

.entry-content h3 {
    font-size: 1.25rem;
}

.entry-content h4 {
    font-size: 1.1rem;
}

.entry-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: var(--muted);
    font-style: italic;
}

.entry-content code {
    background: var(--accent-light);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

.entry-content pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.entry-content pre code {
    background: none;
    padding: 0;
}

/* Post list on archive/index pages ONLY (not single posts) */
/* WordPress adds .blog, .archive, .search to body on listing pages */
.blog article.post,
.archive article.post,
.search article.post {
    padding: 1.75rem 0;
    border-bottom: 1px solid var(--border);
}

.blog article.post:first-of-type,
.archive article.post:first-of-type,
.search article.post:first-of-type {
    border-top: 1px solid var(--border);
}

/* Last article has no bottom border - cleaner flow into "All posts" link */
.blog article.post:last-of-type,
.archive article.post:last-of-type,
.search article.post:last-of-type {
    border-bottom: none;
}

/* Listing page article styles (smaller titles, summaries) */
.blog article.post .entry-title,
.archive article.post .entry-title,
.search article.post .entry-title {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    margin-bottom: 0.25rem;
}

.blog article.post .entry-meta,
.archive article.post .entry-meta,
.search article.post .entry-meta {
    margin-bottom: 0.75rem;
}

.blog article.post .entry-summary,
.archive article.post .entry-summary,
.search article.post .entry-summary {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.blog article.post .entry-summary p,
.archive article.post .entry-summary p,
.search article.post .entry-summary p {
    margin: 0;
}

/* Page header - matches static site spacing (Projects, About) */
/* Note: top padding is on .site-content, not here */
.page-header,
header.page-header,
.site-content .page-header,
.site-content > .page-header {
    padding: 0 !important;
    margin: 0 !important;
    text-align: left !important;
}

/* Archive/Page titles - matches static site (Projects, About) */
/* Static site: h2 { margin-bottom: 1rem } before writing items */
/* Parent theme has h1 { margin: 0.67em 0 } - must override! */
h1.page-title,
h1.archive-title,
.page-header h1,
.page-header .page-title,
.archive-title,
.page-title,
.archives__heading {
    font-size: clamp(2rem, 4vw, 2.5rem) !important;
    line-height: 1.6 !important;
    margin: 0 0 1rem 0 !important;
    padding: 0 !important;
    color: var(--text);
}

/* ===== Links ===== */
.link-accent {
    color: var(--accent);
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

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

.link-accent:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ===== Utilities ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Comments ===== */
.comments-area {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.comments-title {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.comment-reply-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.comment-notes {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.required {
    color: var(--accent);
}

.comment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.comment {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.comment-author {
    font-weight: 500;
    color: var(--text);
}

.comment-metadata {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.comment-content {
    color: var(--text);
}

.comment-respond {
    margin-top: 2rem;
}

.comment-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text);
}

.comment-form-cookies-consent label {
    display: inline;
    font-size: 0.85rem;
    color: var(--text);
}

.logged-in-as {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.logged-in-as a {
    color: var(--accent);
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

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

.comment-form .submit {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.comment-form .submit:hover {
    background: var(--accent-hover);
}

/* ===== Navigation Pagination ===== */
.pagination,
.post-navigation,
.posts-navigation {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.pagination .nav-links,
.posts-navigation .nav-links,
.post-navigation .nav-links {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.posts-navigation a,
.post-navigation a,
.pagination a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.posts-navigation a:hover,
.post-navigation a:hover,
.pagination a:hover {
    color: var(--accent-hover);
}

/* ===== 404 Page ===== */
.error-404 {
    text-align: center;
    padding: 4rem 1.5rem;
}

.error-404 .page-title {
    font-size: 2rem;
}

/* ===== Search Form ===== */
.search-form {
    display: flex;
    gap: 0.5rem;
}

.search-form .search-field {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
}

.search-form .search-submit {
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-form .search-submit:hover {
    background: var(--accent-hover);
}

/* ===== Archive Page (Parent Theme Template) ===== */
/* Note: .archives__heading styles are defined with .page-title above */

.archives__list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.archives__list li {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.archives__list li:first-child {
    border-top: 1px solid var(--border);
}

.archives__list li:last-child {
    border-bottom: none;
}

.archives__list a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.archives__list a:hover {
    color: var(--accent-hover);
}

.archives__list span {
    font-size: 0.85rem;
    color: var(--muted);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav-inner {
        justify-content: flex-end;
    }

    .nav-toggle {
        display: block;
        margin-left: auto;
    }

    .nav .nav-links {
        display: none;
    }

    .page-header {
        padding-top: 0;
        padding-bottom: 0.75rem;
    }

    .footer-inner {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* ===== WordPress Widgets & Sidebar ===== */
.widget,
.widget-area,
.sidebar {
    color: var(--text);
}

.widget-title,
.widget h2,
.widget h3 {
    color: var(--text);
}

.widget a {
    color: var(--accent);
}

.widget a:hover {
    color: var(--accent-hover);
}

/* ===== Newsletter Widget ===== */
.newsletter {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--metrics-bg) !important;
    border-radius: 10px;
    border: 1px solid var(--border) !important;
}

.newsletter h2 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.newsletter > p {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 1.25rem;
}

.newsletter-form {
    display: flex;
    gap: 0.75rem;
}

.newsletter-form input[type="email"] {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: normal;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.newsletter-form input[type="email"]:focus {
    border-color: var(--accent);
}

.newsletter-form input[type="email"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Error state for invalid email - only show after user interaction */
.newsletter-form input[type="email"]:not(:placeholder-shown):invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 1px #ef4444;
}

.newsletter-form input[type="email"]:not(:placeholder-shown):invalid:focus {
    outline-color: #ef4444;
    border-color: #ef4444;
}

.newsletter-form button {
    padding: 0.7rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: normal;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.newsletter-form button:hover {
    background: var(--accent-hover);
}

.newsletter-form button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Loading/submitting state */
.newsletter-form button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.newsletter-form button.submitting {
    position: relative;
    color: transparent;
}

.newsletter-form button.submitting::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: button-spin 0.8s linear infinite;
}

@keyframes button-spin {
    to { transform: rotate(360deg); }
}

.recaptcha-notice {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.75rem;
}

.recaptcha-notice a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

.recaptcha-notice a:hover {
    color: var(--accent-hover);
}

.grecaptcha-badge {
    visibility: hidden !important;
}

/* Dark mode explicit overrides for newsletter */
[data-theme="dark"] .newsletter {
    background: #1F2E38 !important;
    border-color: #2D2D4A !important;
}

[data-theme="dark"] .newsletter h2 {
    color: #F0F0F5 !important;
}

[data-theme="dark"] .newsletter p,
[data-theme="dark"] .newsletter > p {
    color: #A8AEB8 !important;
}

[data-theme="dark"] .newsletter-form input[type="email"] {
    background: #252540 !important;
    border-color: #2D2D4A !important;
    color: #F0F0F5 !important;
}

[data-theme="dark"] .newsletter-form input[type="email"]::placeholder {
    color: #A8AEB8 !important;
}

[data-theme="dark"] .newsletter-form button {
    background: #5BA88C !important;
    color: white !important;
}

[data-theme="dark"] .newsletter-form button:hover {
    background: #6DC4A4 !important;
}

[data-theme="dark"] .recaptcha-notice {
    color: #A8AEB8 !important;
}

[data-theme="dark"] .recaptcha-notice a {
    color: #5BA88C !important;
}

/* Newsletter responsive */
@media (max-width: 768px) {
    .newsletter-form {
        flex-direction: column;
    }
}

/* ===== Dark Mode Global Fixes ===== */

/* Placeholder text */
::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

/* Text selection */
::selection {
    background: var(--accent);
    color: white;
}

::-moz-selection {
    background: var(--accent);
    color: white;
}

/* Figure captions */
figcaption,
.wp-caption-text,
.wp-element-caption {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.5rem;
    text-align: center;
}

/* WordPress block editor elements */
.wp-block-image figcaption {
    color: var(--muted);
}

.wp-block-quote {
    border-left: 3px solid var(--accent);
    padding-left: 1.25rem;
    color: var(--muted);
    font-style: italic;
}

.wp-block-quote cite {
    font-size: 0.85rem;
    color: var(--muted);
    font-style: normal;
}

/* WordPress tables */
.wp-block-table table {
    border-color: var(--border);
}

.wp-block-table th,
.wp-block-table td {
    border-color: var(--border);
    color: var(--text);
}

.wp-block-table thead {
    background: var(--surface);
}

/* Horizontal rule */
hr,
.wp-block-separator {
    border-color: var(--border);
    background: var(--border);
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
