/* Happy Poop Premium Article Theme (v3) — Systematic UX/UI Overhaul */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&display=swap');

:root {
    /* Brand Colors */
    --primary: #A78BFA;
    --primary-light: #DDD6FE;
    --primary-dark: #7C3AED;
    --secondary: #FB7185;
    --accent: #2DD4BF;

    /* Functional Colors */
    --text-main: #1A1A2E;
    --text-body: #374151;
    --text-muted: #6B7280;
    --bg-body: #F8F9FC;
    --bg-surface: #FFFFFF;
    --border: #E8ECF1;

    /* Semantic Colors */
    --info-bg: #EFF6FF;
    --info-border: #BFDBFE;
    --info-text: #1E40AF;
    --warn-bg: #FFF5F5;
    --warn-border: #FEB2B2;
    --warn-text: #9B2C2C;
    --success-bg: #F0FFF4;
    --success-border: #9AE6B4;
    --success-text: #276749;
    --tip-bg: #FFFBEB;
    --tip-border: #FDE68A;
    --tip-text: #92400E;

    /* Spacing & Radius */
    --container-width: 720px;
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
    --space-xs: 8px;
    --space-sm: 16px;
    --space-md: 24px;
    --space-lg: 40px;
    --space-xl: 56px;

    /* Gradient */
    --gradient: linear-gradient(135deg, #A78BFA, #C4B5FD);
}

/* Category Theming */
[data-theme="bowel"]     { --primary: #A78BFA; --primary-dark: #7C3AED; --primary-light: #EDE9FE; --gradient: linear-gradient(135deg, #8B5CF6, #A78BFA, #C4B5FD); }
[data-theme="urinary"]   { --primary: #60A5FA; --primary-dark: #2563EB; --primary-light: #DBEAFE; --gradient: linear-gradient(135deg, #3B82F6, #60A5FA, #93C5FD); }
[data-theme="menstrual"] { --primary: #F472B6; --primary-dark: #DB2777; --primary-light: #FCE7F3; --gradient: linear-gradient(135deg, #EC4899, #F472B6, #FBCFE8); }
[data-theme="hydration"] { --primary: #2DD4BF; --primary-dark: #0D9488; --primary-light: #CCFBF1; --gradient: linear-gradient(135deg, #14B8A6, #2DD4BF, #99F6E4); }
[data-theme="fitness"]   { --primary: #FB7185; --primary-dark: #E11D48; --primary-light: #FFE4E6; --gradient: linear-gradient(135deg, #F43F5E, #FB7185, #FECDD3); }
[data-theme="nutrition"] { --primary: #34D399; --primary-dark: #059669; --primary-light: #D1FAE5; --gradient: linear-gradient(135deg, #10B981, #34D399, #A7F3D0); }

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Source Serif 4', Georgia, serif;
    background-color: var(--bg-body);
    color: var(--text-body);
    line-height: 1.85;
    font-size: 17px;
    font-optical-sizing: auto;
    padding-bottom: 100px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .sans-serif {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

strong { color: var(--text-main); font-weight: 600; }
em { font-style: italic; color: var(--text-main); }

/* ========== READING PROGRESS BAR ========== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--gradient);
    z-index: 9999;
    transition: width 0.1s linear;
}

/* ========== HERO SECTION ========== */
.hero-section {
    position: relative;
    background: var(--bg-surface);
    overflow: hidden;
    padding-bottom: 48px;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    box-shadow: 0 8px 32px rgba(0,0,0,0.04);
}

.hero-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--gradient);
    opacity: 0.08;
    z-index: 0;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 24px 24px 0;
    text-align: center;
}

.article-meta-top {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary-dark);
    background: var(--primary-light);
    padding: 6px 18px;
    border-radius: 50px;
    margin-bottom: 20px;
    margin-top: 16px;
    font-family: 'Inter', sans-serif;
}

.hero-title {
    font-size: clamp(26px, 5vw, 36px);
    font-weight: 800;
    line-height: 1.18;
    margin-bottom: 16px;
    color: var(--text-main);
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.hero-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    color: var(--text-muted);
    max-width: 520px;
    margin: 0 auto 12px;
    line-height: 1.6;
}

/* ========== SUMMARY CARD (TL;DR) ========== */
.summary-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin: -24px 20px var(--space-lg);
    box-shadow:
        0 1px 3px rgba(0,0,0,0.04),
        0 8px 24px rgba(0,0,0,0.06);
    position: relative;
    z-index: 2;
    max-width: calc(var(--container-width) - 40px);
    margin-left: auto;
    margin-right: auto;
}

.summary-title {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary-dark);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-light);
}

.summary-list {
    list-style: none;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-body);
}

.summary-list li {
    position: relative;
    padding-left: 28px;
    margin-bottom: 10px;
}

.summary-list li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 7px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 2px solid var(--primary);
}

.summary-list li::after {
    content: "✓";
    position: absolute;
    left: 6px;
    top: 5px;
    font-size: 10px;
    font-weight: 800;
    color: var(--primary-dark);
}

/* ========== MAIN CONTENT ========== */
.content-container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 24px;
}

.intro-text {
    font-size: 18px;
    line-height: 1.9;
    color: var(--text-main);
    margin-bottom: var(--space-lg);
    position: relative;
    padding-left: 20px;
    border-left: 3px solid var(--primary-light);
}

.content-block h2 {
    font-size: clamp(20px, 4vw, 26px);
    font-weight: 700;
    margin: var(--space-xl) 0 var(--space-md);
    color: var(--text-main);
    letter-spacing: -0.015em;
    line-height: 1.3;
    position: relative;
    padding-left: 0;
    display: block;
}

.content-block h2::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    background: var(--gradient);
    border-radius: 2px;
    margin-bottom: 14px;
}

.content-block h3 {
    font-size: 19px;
    font-weight: 600;
    margin: var(--space-lg) 0 var(--space-sm);
    color: var(--text-main);
}

.content-block p {
    margin-bottom: var(--space-md);
    color: var(--text-body);
    word-wrap: break-word;
}

.content-block ul,
.content-block ol {
    margin: 0 0 var(--space-md);
    padding-left: 24px;
    color: var(--text-body);
}

.content-block li {
    margin-bottom: 10px;
    padding-left: 4px;
}

/* ========== INFO BOX ========== */
.info-box {
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-lg) 0;
    position: relative;
    overflow: hidden;
}

.info-box::before {
    content: "";
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #3B82F6, #60A5FA);
    border-radius: 2px 0 0 2px;
}

.info-box-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    color: var(--info-text);
    margin-bottom: 12px;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.info-box p {
    margin: 0;
    font-size: 15px;
    line-height: 1.75;
    color: #1E3A5F;
    font-family: 'Inter', sans-serif;
}

/* ========== WARNING BOX ========== */
.warning-box {
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-lg) 0;
    position: relative;
    overflow: hidden;
}

.warning-box::before {
    content: "";
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #EF4444, #F87171);
    border-radius: 2px 0 0 2px;
}

.warning-box::after {
    content: "!";
    position: absolute;
    top: -16px;
    right: -8px;
    font-size: 140px;
    font-family: 'Inter', sans-serif;
    font-weight: 900;
    color: var(--warn-text);
    opacity: 0.04;
    transform: rotate(12deg);
    pointer-events: none;
}

.warning-title {
    color: var(--warn-text);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    margin-bottom: 14px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.warning-list {
    list-style: none;
    font-family: 'Inter', sans-serif;
}

.warning-list li {
    position: relative;
    padding-left: 30px;
    margin-bottom: 14px;
    color: #7F1D1D;
    font-size: 15px;
    line-height: 1.7;
}

.warning-list li::before {
    content: "";
    position: absolute;
    left: 0; top: 6px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #FEE2E2;
    border: 2px solid #FECACA;
}

.warning-list li::after {
    content: "!";
    position: absolute;
    left: 6px; top: 6px;
    font-size: 11px;
    font-weight: 800;
    color: #DC2626;
}

/* ========== CHECKLIST ========== */
.checklist {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow:
        0 1px 2px rgba(0,0,0,0.03),
        0 4px 16px rgba(0,0,0,0.04);
    padding: var(--space-md);
    margin: var(--space-lg) 0;
    border: 1px solid var(--border);
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 0;
    padding: 14px 0;
    border-bottom: 1px solid var(--bg-body);
    transition: background-color 0.2s ease;
    border-radius: var(--radius-sm);
    cursor: default;
}

.checklist-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.checklist-item:first-child {
    padding-top: 0;
}

.check-icon {
    background: var(--success-bg);
    color: var(--success-text);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    margin-top: 2px;
    border: 1.5px solid var(--success-border);
}

.checklist-item div:last-child {
    flex: 1;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.65;
}

.checklist-item div:last-child strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
}

.checklist-item div:last-child p {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ========== NAVIGATION ========== */
.floating-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    max-width: var(--container-width);
    margin: 0 auto;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 50px;
    background: var(--bg-body);
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    text-decoration: none;
}

.share-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    text-decoration: none;
    font-size: 18px;
    transition: all 0.2s ease;
}

.share-btn:hover {
    background: var(--primary-light);
}

/* ========== CALLOUT / LEGACY ========== */
.callout {
    background: var(--tip-bg);
    border: 1px solid var(--tip-border);
    border-left: 4px solid #F59E0B;
    padding: 18px 20px;
    border-radius: var(--radius-sm);
    margin: var(--space-md) 0;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.65;
    color: var(--tip-text);
}

.callout strong { color: var(--tip-text); }

.source {
    margin-top: var(--space-lg);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
}

.source a {
    color: var(--primary-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ========== HERO IMAGE (legacy) ========== */
.hero-image {
    margin: 20px auto;
    max-width: 280px;
    display: block;
    border-radius: var(--radius-md);
    filter: drop-shadow(0 15px 30px rgba(0,0,0,0.1));
}

/* ========== SCROLL ANIMATIONS ========== */
.content-block > *,
.summary-card,
.checklist,
.info-box,
.warning-box,
.callout {
    animation: fadeSlideUp 0.5s ease both;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
    body { font-size: 16px; line-height: 1.8; }
    .hero-content { padding: 16px 20px 0; }
    .hero-title { font-size: 24px; }
    .content-container { padding: 0 20px; }
    .summary-card { margin-left: 16px; margin-right: 16px; padding: 20px; }
    .info-box, .warning-box, .checklist { padding: 18px; }
    .content-block h2 { font-size: 20px; margin-top: var(--space-lg); }
    .floating-nav { padding: 12px 16px; }
}

/* ========== DARK MODE ========== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #0F172A;
        --bg-surface: #1E293B;
        --text-main: #F1F5F9;
        --text-body: #CBD5E1;
        --text-muted: #94A3B8;
        --border: #334155;
        --info-bg: #1E293B;
        --info-border: #1E40AF;
        --info-text: #93C5FD;
        --warn-bg: #1E293B;
        --warn-border: #7F1D1D;
        --warn-text: #FCA5A5;
        --success-bg: #1E293B;
        --success-border: #065F46;
        --success-text: #6EE7B7;
        --tip-bg: #1E293B;
        --tip-border: #92400E;
        --tip-text: #FCD34D;
    }
    .hero-bg { opacity: 0.12; }
    .hero-section { box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
    .summary-card { box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
    .checklist { background: var(--bg-surface); }
    .info-box p { color: #93C5FD; }
    .warning-list li { color: #FCA5A5; }
    .warning-box::after { color: #FCA5A5; }
    .floating-nav { background: rgba(15,23,42,0.92); }
    .back-btn { background: #334155; color: #F1F5F9; }
    .share-btn { background: #334155; }
    .intro-text { border-left-color: var(--primary); color: var(--text-body); }
    .checklist-item div:last-child p { color: var(--text-muted); }
}
