/*
 * SilverWell - UI Enhancements
 * Version 1.0.0
 *
 * Cross-page aesthetic and layout improvements for desktop and mobile.
 */

:root {
    --header-height: 64px;
}

/* === Hero CTA Safety === */
.hero-cta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-4);
    margin-top: var(--space-8);
}

.hero-btn {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    white-space: normal;
    overflow-wrap: break-word;
}

@media (max-width: 1100px) {
    .hero-section {
        padding-bottom: var(--space-24);
    }

    .hero-content {
        position: relative;
        z-index: 2;
    }

    .hero-section::after {
        height: 30px;
        z-index: 1;
    }

    .hero-cta {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-btn {
        width: 100%;
        max-width: none;
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .hero-btn {
        padding: var(--space-2) var(--space-4);
        font-size: var(--text-sm);
        min-height: 44px;
    }
}

/* === Global Overflow Prevention === */
html,
body {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100%;
}

body {
    position: relative;
}

body > * {
    max-width: 100%;
}

img,
video,
iframe,
embed,
object,
svg {
    max-width: 100%;
    height: auto;
}

pre,
code {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

a {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* === Header Optimization === */
.header-inner {
    min-height: var(--header-height);
    padding: var(--space-2) var(--space-5);
}

.site-logo img {
    max-height: 40px;
}

.site-title {
    font-size: var(--text-lg);
}

.font-size-btn {
    width: 28px;
    height: 28px;
}

.site-header .search-form input[type="search"] {
    padding: var(--space-1) var(--space-3);
    min-height: 36px;
}

.site-header .search-form button {
    min-height: 36px;
    padding: var(--space-1) var(--space-3);
}

.main-navigation a {
    padding: var(--space-2) var(--space-3);
    min-height: 40px;
}

.site-header .search-form input[type="search"]:focus {
    width: 200px;
}

@media (max-width: 1100px) {
    .font-size-controls {
        display: none;
    }

    .site-branding {
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
    }

    .site-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
}

/* === Global Interactive Elements === */
a {
    transition: color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--color-primary-light);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(156, 74, 50, 0.1);
}

.btn-primary,
.btn-secondary,
button[type="submit"],
input[type="submit"] {
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover,
.btn-secondary:hover,
button[type="submit"]:hover,
input[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active,
.btn-secondary:active,
button[type="submit"]:active,
input[type="submit"]:active {
    transform: translateY(0);
}

/* === Cards Unified Hover & Alignment === */
.category-card,
.post-card,
.related-post-card,
.error-post-card {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.category-card:hover,
.post-card:hover,
.related-post-card:hover,
.error-post-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-card-hover);
}

.post-card .post-title,
.related-post-card .related-post-title,
.error-post-card h3 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
}

.post-card .post-excerpt,
.related-post-card .related-post-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* === Homepage Hero === */
.hero-section {
    position: relative;
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-content h1 {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    text-wrap: balance;
}

.hero-subtitle {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.hero-btn {
    transition: all var(--transition-fast);
}

.hero-btn:hover {
    transform: translateY(-3px);
}

.hero-btn:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.8);
    outline-offset: 3px;
}

/* === Category Cards Enhancement === */
.category-card {
    border: 1px solid var(--color-border-light);
    background: linear-gradient(145deg, var(--color-surface) 0%, var(--color-bg-warm) 100%);
}

.category-card-icon {
    transition: transform var(--transition-normal);
}

.category-card:hover .category-card-icon {
    transform: scale(1.1) rotate(-3deg);
}

/* === Article Page Typography === */
.entry-content blockquote {
    position: relative;
    background: var(--color-bg-warm);
    border-left: 4px solid var(--color-accent);
    padding: var(--space-6) var(--space-6) var(--space-6) var(--space-8);
    margin: var(--space-8) 0;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    font-style: italic;
}

.entry-content blockquote::before {
    content: '"';
    position: absolute;
    top: var(--space-4);
    left: var(--space-4);
    font-family: var(--font-heading);
    font-size: 3rem;
    color: var(--color-accent);
    line-height: 1;
    opacity: 0.4;
}

.entry-content blockquote p {
    margin-bottom: var(--space-3);
}

.entry-content blockquote cite {
    font-style: normal;
    font-weight: 700;
    color: var(--color-text-muted);
}

.entry-content ul,
.entry-content ol {
    padding-left: var(--space-6);
}

.entry-content ul li {
    list-style-type: none;
    position: relative;
    padding-left: var(--space-5);
}

.entry-content ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.65em;
    width: 8px;
    height: 8px;
    background: var(--color-primary-light);
    border-radius: 50%;
}

.entry-content ol li {
    padding-left: var(--space-2);
}

.entry-content code {
    background: var(--color-bg-alt);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.9em;
    color: var(--color-primary-dark);
}

.entry-content pre {
    background: var(--color-text);
    color: var(--color-bg);
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    overflow-x: hidden;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    margin: var(--space-6) 0;
}

.entry-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.entry-content figure,
.entry-content table {
    margin: var(--space-8) 0;
    max-width: 100%;
}

.entry-content table {
    width: 100%;
}

@media (max-width: 640px) {
    .entry-content table {
        display: block;
        overflow-x: auto;
        white-space: normal;
        -webkit-overflow-scrolling: touch;
    }
}

.entry-content figcaption {
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin-top: var(--space-3);
    font-style: italic;
}

/* === Author Box Enhancement === */
.author-box {
    background: linear-gradient(145deg, var(--color-bg-warm) 0%, var(--color-surface) 100%);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
}

.author-avatar img {
    border: 3px solid var(--color-surface);
    box-shadow: var(--shadow-md);
}

/* === Table of Contents Enhancement === */
.table-of-contents {
    position: relative;
}

.toc-list li::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--color-border);
    border-radius: 50%;
    margin-right: var(--space-3);
    transition: background var(--transition-fast);
}

.toc-list li:hover::before {
    background: var(--color-primary);
}

.toc-list a {
    display: inline;
}

/* === Category Page Header === */
.category-page-header {
    position: relative;
    background: linear-gradient(135deg, var(--color-bg-warm) 0%, var(--color-surface) 100%);
    overflow: hidden;
}

.category-page-header h1,
.category-page-header p {
    position: relative;
    z-index: 1;
}

/* === Search Results === */
.search-page-form .search-form input[type="search"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(156, 74, 50, 0.1);
}

.search-highlight {
    background: linear-gradient(120deg, rgba(156, 74, 50, 0.2) 0%, rgba(156, 74, 50, 0.2) 100%);
    color: var(--color-primary-dark);
    font-weight: 700;
    padding: 0 3px;
    border-radius: 3px;
}

.posts-section .post-card:has(.search-highlight) {
    border-color: var(--color-primary-light);
}

/* === 404 Page === */
.error-404 {
    text-align: center;
}

.error-code {
    font-size: clamp(4rem, 15vw, 8rem);
    font-weight: 700;
    line-height: 1;
    color: var(--color-primary);
    opacity: 0.2;
    margin-bottom: var(--space-4);
}

.error-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-4);
}

.error-popular-posts,
.error-categories {
    text-align: left;
}

/* === Share Buttons === */
.share-buttons {
    background: linear-gradient(145deg, var(--color-bg-warm) 0%, var(--color-surface) 100%);
}

/* === Mobile Optimizations === */
@media (max-width: 768px) {
    :root {
        --header-height: 56px;
    }

    .header-inner {
        padding: var(--space-1) var(--space-3);
        gap: var(--space-2);
    }

    .site-logo img {
        max-height: 36px;
    }

    .site-title {
        font-size: var(--text-base);
    }

    .site-description {
        display: none;
    }

    .site-header .search-form input[type="search"] {
        width: 120px;
        padding: var(--space-1) var(--space-2);
    }

    .site-header .search-form input[type="search"]:focus {
        width: 150px;
    }

    .menu-toggle {
        width: 36px;
        height: 36px;
        padding: var(--space-1);
    }

    .menu-toggle .bar {
        width: 18px;
        height: 2px;
    }

    .hero-section {
        padding: var(--space-10) var(--space-4) var(--space-24);
    }

    .hero-content h1 {
        font-size: var(--text-2xl);
    }

    .hero-subtitle {
        font-size: var(--text-base);
    }

    .hero-cta {
        flex-direction: column;
        align-items: stretch;
        margin-top: var(--space-6);
    }

    .hero-btn {
        width: 100%;
        max-width: none;
        justify-content: center;
    }

    .font-size-controls {
        display: none;
    }

    .header-inner {
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .site-branding {
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
    }

    .site-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .search-wrapper {
        flex-shrink: 0;
        margin-left: auto;
    }

    .site-header .search-form input[type="search"] {
        width: 100px;
    }

    .site-header .search-form input[type="search"]:focus {
        width: 130px;
    }

    .post-card .post-title,
    .related-post-card .related-post-title,
    .error-post-card h3 {
        min-height: auto;
    }

    .author-box {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .author-avatar {
        margin-right: 0;
        margin-bottom: var(--space-4);
    }

    .share-buttons {
        justify-content: center;
    }

    .share-title {
        width: 100%;
        text-align: center;
        margin-bottom: var(--space-3);
    }

    .table-of-contents {
        padding: var(--space-4);
    }

    .table-of-contents::before {
        display: none;
    }

    .toc-list li::before {
        display: none;
    }

    .entry-content blockquote {
        padding: var(--space-4) var(--space-4) var(--space-4) var(--space-5);
    }

    .entry-content blockquote::before {
        font-size: 2rem;
        top: var(--space-2);
        left: var(--space-2);
    }
}

@media (max-width: 480px) {
    .hero-content h1 {
        font-size: var(--text-xl);
    }

    .hero-cta .btn-primary,
    .hero-cta .btn-secondary {
        width: 100%;
    }

    .category-grid {
        gap: var(--space-4);
    }

    .category-card {
        padding: var(--space-5);
    }

    .share-buttons {
        gap: var(--space-2);
    }

    .share-link {
        flex: 1;
        min-width: 60px;
    }
}

.alignfull {
    width: 100%;
    max-width: 100%;
    margin-left: calc(-1 * var(--space-5));
    margin-right: calc(-1 * var(--space-5));
}

@media (min-width: 768px) {
    .alignfull {
        margin-left: calc(-1 * var(--space-8));
        margin-right: calc(-1 * var(--space-8));
    }
}

in-width: 768px) {
    .alignfull {
        margin-left: calc(-1 * var(--space-8));
        margin-right: calc(-1 * var(--space-8));
    }
}

