/* ── SWH Technologies Article Styles ── */
/* White content area for readability, dark hero matching index.html */

/* ── Page Enter Animation ── */
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
main {
    animation: pageFadeIn 0.35s ease-out;
}

/* ── Reading Progress Bar ── */
#reading-progress {
    position: fixed;
    top: 0; left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #4a9eff, #7c3aed);
    z-index: 9999;
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}

/* ── Article Hero ── */
.article-hero {
    background: linear-gradient(135deg, #1a1a2e 0%, #0a0a12 100%);
    /* navbar is position:fixed, main has no top offset — clear it here */
    padding: calc(var(--nav-height, 64px) + 56px) 0 60px;
    margin-bottom: 0;
    border-bottom: 1px solid #2a2a3e;
    position: relative;
}
.article-hero::after {
    content: '';
    position: absolute;
    bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100px; height: 3px;
    background: linear-gradient(90deg, #4a9eff, #7c3aed);
    border-radius: 2px;
}
.article-hero h1 {
    font-size: 2.5rem;
    margin-bottom: 16px;
    color: #fff;
    max-width: 900px;
    line-height: 1.25;
    letter-spacing: -0.02em;
    font-weight: 700;
}
.article-hero .article-meta-bar {
    display: flex;
    gap: 16px;
    color: #9898b0;
    font-size: 0.875rem;
    margin-top: 20px;
    align-items: center;
    flex-wrap: wrap;
}
.article-hero .article-tag {
    background: rgba(74, 158, 255, 0.15);
    padding: 4px 14px;
    border-radius: 20px;
    color: #60a5fa;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* ── Back to Articles (fixed position, far left corner) ── */
.back-to-articles-top {
    position: fixed !important;
    left: 16px !important;
    top: 82px !important;
    display: flex !important;
    align-items: center;
    gap: 4px;
    color: rgba(255,255,255,0.25);
    font-size: 0.75rem;
    font-weight: 400;
    text-decoration: none;
    transition: color 0.2s ease;
    font-family: 'Inter', sans-serif;
    z-index: 9999;
    line-height: 1;
}
.back-to-articles-top:hover {
    color: #4a9eff;
}
.back-to-articles-top svg {
    width: 12px;
    height: 12px;
    opacity: 0.4;
    transition: all 0.2s ease;
}
.back-to-articles-top:hover svg {
    opacity: 1;
    transform: translateX(-4px);
}

/* ── Dark Background Wrapper ── */
/* Content sits on a dark background like the main site, with
   white "paper" cards floating on it for readability. */

.article-content-wrap {
    background: var(--bg-primary, #07070e);
    padding: 48px 16px 60px;
}

/* ── Paper card for TOC ── */
.article-toc {
    background: #ffffff;
    border: 1px solid #e8ecf4;
    border-radius: 14px;
    padding: 28px 32px;
    margin: 0 auto 32px;
    max-width: 820px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
.article-toc h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #606070;
}
.article-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
    columns: 2;
    column-gap: 32px;
}
.article-toc li {
    margin-bottom: 6px;
    break-inside: avoid;
}
.article-toc a {
    color: #4a9eff;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 3px 0;
    display: inline-block;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}
.article-toc a:hover {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* ── Paper card for article content ── */
.article-content {
    max-width: 820px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 14px;
    padding: 48px 52px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.25);
    line-height: 1.75;
    color: #1a1a2e;
    font-size: 1.05rem;
}

/* ── Typography ── */
.article-content h2 {
    color: #0a0a12;
    font-size: 1.65rem;
    line-height: 1.25;
    margin-top: 48px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e8ecf4;
    font-weight: 700;
    letter-spacing: -0.01em;
    scroll-margin-top: 80px;
}
.article-content h2:first-of-type { margin-top: 0; }
.article-content h3 {
    color: #0a0a12;
    font-size: 1.25rem;
    line-height: 1.35;
    margin-top: 32px;
    margin-bottom: 14px;
    font-weight: 600;
    scroll-margin-top: 80px;
}
.article-content h4 {
    color: #0a0a12;
    font-size: 1.05rem;
    line-height: 1.4;
    margin-top: 24px;
    margin-bottom: 10px;
    font-weight: 600;
    scroll-margin-top: 80px;
}
.article-content p { margin-bottom: 20px; }
.article-content ul, .article-content ol {
    margin-left: 24px;
    margin-bottom: 24px;
}
.article-content li { margin-bottom: 8px; }
.article-content strong { color: #0a0a12; font-weight: 600; }

/* ── Code Blocks ── */
.article-content pre {
    background: #1a1a2e;
    border: 1px solid #2a2a3e;
    border-radius: 10px;
    padding: 20px 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 24px 0;
    color: #e0e0f0;
    font-size: 0.85rem;
    line-height: 1.6;
    position: relative;
}
.article-content pre:hover::after {
    content: 'Copy';
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(255,255,255,0.08);
    color: #9898b0;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-family: 'Inter', sans-serif;
    pointer-events: none;
}
.article-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
}
.article-content .code-inline {
    background: #e8ecf4;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    color: #1a1a2e;
    font-size: 0.85rem;
}

/* ── Info & ROI Boxes ── */
.article-content .info-box {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0ff 100%);
    border-left: 4px solid #4a9eff;
    border-radius: 8px;
    padding: 20px 24px;
    margin: 24px 0;
    color: #1a1a2e;
    font-size: 0.95rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.article-content .info-box strong { color: #1a1a2e; }
.article-content .roi-box {
    background: linear-gradient(135deg, #f0fbf0 0%, #e8fce8 100%);
    border-left: 4px solid #22c55e;
    border-radius: 8px;
    padding: 20px 24px;
    margin: 24px 0;
    color: #1a1a2e;
    font-size: 0.95rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.article-content .roi-box strong { color: #1a1a2e; }

/* ── Blockquote ── */
.article-content blockquote {
    border-left: 3px solid #4a9eff;
    margin: 24px 0;
    padding: 14px 22px;
    background: #f8f9ff;
    color: #555;
    font-style: italic;
    border-radius: 0 8px 8px 0;
}

/* ── Tables ── */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 0.9rem;
    line-height: 1.5;
    display: block;
    /* no `overflow: hidden` here — the shorthand used to clobber overflow-x
       and clip wide tables off-screen on phones with no way to scroll them */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.article-content thead {
    background: linear-gradient(135deg, #1a1a2e 0%, #2a2a3e 100%);
}
.article-content th {
    background: transparent;
    color: #fff;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid #4a9eff;
}
.article-content td {
    padding: 10px 16px;
    border-bottom: 1px solid #e8ecf4;
    background: #ffffff;
}
.article-content tr:nth-child(even) td {
    background: #f8f8fc;
}
.article-content tr:last-child td {
    border-bottom: none;
}
.article-content table caption {
    text-align: left;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 8px;
    padding-left: 4px;
    font-style: italic;
}

/* ── Images ── */
.article-content img {
    max-width: 100%;
    border-radius: 10px;
    margin: 28px 0;
    border: 1px solid #e8ecf4;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.article-content img + em {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    color: #9898b0;
    margin-top: -20px;
    margin-bottom: 28px;
}

/* ── Citations & References ── */
.article-content sup {
    font-size: 0.7rem;
    line-height: 0;
    color: #4a9eff;
}
.article-content .article-divider {
    border: 0;
    border-top: 1px solid #e8ecf4;
    margin: 44px 0 28px;
}
.article-content ol.references {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.6;
    margin-left: 20px;
}
.article-content ol.references li { margin-bottom: 10px; }

/* ── Article Navigation ── */
.article-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid #e8ecf4;
    flex-wrap: wrap;
    gap: 20px;
}
.article-nav a {
    color: #4a9eff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 8px 0;
    transition: color 0.2s ease;
}
.article-nav a:hover { color: #2563eb; text-decoration: underline; }

/* ── Back to Top ── */
.back-to-top {
    position: fixed;
    bottom: 32px; right: 32px;
    width: 44px; height: 44px;
    background: #1a1a2e;
    border: 1px solid #2a2a3e;
    border-radius: 50%;
    color: #e0e0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: all 0.3s ease;
    z-index: 999;
    font-size: 1.2rem;
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover {
    background: #4a9eff;
    border-color: #4a9eff;
    color: #fff;
    transform: translateY(-2px);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .article-hero h1 { font-size: 1.75rem; }
    .article-hero { padding: calc(var(--nav-height, 64px) + 32px) 0 40px; }
    .article-content-wrap { padding: 24px 12px 40px; }
    .article-content { padding: 28px 20px; border-radius: 12px; font-size: 1rem; }
    .article-content h2 { font-size: 1.4rem; margin-top: 36px; }
    .article-toc { padding: 20px; border-radius: 12px; }
    .article-toc ul { columns: 1; }
    .article-nav { flex-direction: column; gap: 12px; }
    .back-to-top { bottom: 20px; right: 20px; width: 40px; height: 40px; }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .article-content { max-width: 700px; padding: 36px 32px; }
    .article-toc { max-width: 700px; }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    #reading-progress, .back-to-top { transition: none; }
    html { scroll-behavior: auto; }
    main { animation: none !important; }
}

/* ── Print Styles ── */
@media print {
    #reading-progress, .back-to-top, canvas, .grid-bg, .perspective-bg,
    .navbar, .article-nav, .article-toc { display: none !important; }
    .article-hero { padding: 20px 0; background: #fff !important; border: none; }
    .article-hero::after { display: none; }
    .article-hero h1 { color: #000 !important; font-size: 1.8rem; }
    .article-hero .article-meta-bar { color: #666 !important; }
    .article-content-wrap { background: #fff !important; padding: 0; }
    .article-content { box-shadow: none !important; background: transparent !important; max-width: 100%; padding: 20px 0; color: #000; }
    .article-toc { box-shadow: none !important; background: transparent !important; max-width: 100%; padding: 0; border: none; margin-bottom: 20px; }
    .article-content h2 { border-bottom-color: #ccc; }
    .article-content pre { background: #f5f5f5 !important; border: 1px solid #ddd; color: #000; page-break-inside: avoid; }
    .article-content code { color: #000; }
    .article-content table { font-size: 0.8rem; }
    .info-box, .roi-box { border: 1px solid #ddd !important; background: #fafafa !important; }
    a { color: #000 !important; text-decoration: underline; }
}
