/* Heartopia layout primitives with accessible orange archive tokens. */

body[data-theme] {
    --font-display: "Fredoka", sans-serif;
    --font-body: "Quicksand", sans-serif;
    --font-accent: "Nunito", sans-serif;
    --font-main: var(--font-body);

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    --space-4xl: 5rem;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    --primary: #e4593a;
    --primary-light: #ffd3c4;
    --primary-dark: #a04630;
    --secondary: #2cb1a6;
    --secondary-light: #ddf3f1;
    --secondary-dark: #2c786f;
    --accent: #ff7a59;
    --accent-light: #ffe2d6;
    --accent-dark: #a04630;
    --gold: #5b9dff;
    --tertiary: #a97be0;
    --success: #2c786f;
    --success-dark: #2c786f;
    --warning: #a04630;
    --bg-main: #fff6ee;
    --bg-gradient: linear-gradient(135deg, #fff6ee 0%, #ffe2d6 50%, #fde9e0 100%);
    --bg-cream: #ffe2d6;
    --bg-warm: #fde9e0;
    --card-bg: #ffffff;
    --border: #fadace;
    --shadow: rgba(228, 89, 58, 0.16);
    --text-dark: #2b2620;
    --text-medium: #66605a;
    --text-light: #66605a;

    --color-primary: var(--primary);
    --color-primary-light: var(--primary-light);
    --color-primary-dark: var(--primary-dark);
    --color-secondary: var(--secondary);
    --color-secondary-light: var(--secondary-light);
    --color-secondary-dark: var(--secondary-dark);
    --color-accent: var(--accent);
    --color-accent-light: var(--accent-light);
    --color-accent-dark: var(--accent-dark);
    --color-accent-hover: var(--accent-dark);
    --color-success: var(--success);
    --color-success-light: var(--accent-light);
    --color-success-dark: var(--success-dark);
    --color-gold: var(--gold);
    --color-gold-light: var(--primary-light);
    --color-gold-dark: var(--primary-dark);
    --color-warning: var(--warning);
    --color-border: var(--border);
    --color-bg-main: var(--bg-main);
    --color-bg-gradient: var(--bg-gradient);
    --color-bg-card: var(--card-bg);
    --color-bg-cream: var(--bg-cream);
    --color-bg-primary: var(--primary-light);
    --color-bg-secondary: var(--secondary-light);
    --color-text-primary: var(--text-dark);
    --color-text-secondary: var(--text-medium);
    --color-text-muted: var(--text-light);
    --color-text-white: #ffffff;
    --color-cream: var(--bg-cream);
    --color-cream-light: #fff6ee;
    --color-cream-dark: #a04630;
    --color-action: var(--primary-dark);
    --color-action-light: var(--primary-light);
    --color-action-dark: var(--primary-dark);
    --color-accent-text: var(--primary-dark);
    --color-heading: var(--text-dark);
    --color-highlight: #ffd3c4;
    --color-success-soft: #ddf3f1;
    --color-border-soft: #fadace;
    --color-warm-neutral: #ffd3c4;
    --color-sunshine: #ffe2d6;
    --color-sage-dark: #2c786f;
    --color-warm-brown: #a04630;

    --focus-ring: var(--accent-dark);
    --chrome-surface: rgba(255, 255, 255, 0.9);
    --chrome-surface-strong: rgba(255, 255, 255, 0.96);
    --shadow-sm: 0 4px 16px var(--shadow);
    --shadow-md: 0 8px 24px var(--shadow);
    --shadow-lg: 0 14px 40px var(--shadow);
    --shadow-xl: 0 22px 64px var(--shadow);
    --chrome-shadow: 0 10px 32px var(--shadow);
    --surface-muted: color-mix(in srgb, var(--card-bg) 75%, var(--bg-main) 25%);
    --active-surface: var(--primary-light);
    --active-border: var(--primary-dark);
    --link-hover-surface: color-mix(in srgb, var(--primary-light) 55%, transparent);
    --interactive-hover-border: var(--primary-dark);
    --interactive-hover-text: var(--primary-dark);
    --container-max: var(--shell-main, 900px);
    --container-narrow: 760px;

    --site-bg: var(--bg-main);
    --site-surface: var(--card-bg);
    --site-surface-subtle: var(--bg-cream);
    --site-surface-soft: var(--bg-warm);
    --site-text: var(--text-dark);
    --site-text-muted: var(--text-medium);
    --site-line: var(--border);
    --site-line-strong: var(--primary-dark);
    --site-primary: var(--primary);
    --site-primary-strong: var(--primary-dark);
    --site-primary-soft: var(--primary-light);
    --site-primary-softer: var(--bg-warm);
    --site-success-bg: color-mix(in srgb, var(--success) 20%, white);
    --site-success-text: var(--success-dark);
    --site-on-primary: var(--color-text-white);
    --site-glass: var(--chrome-surface);
    --site-glass-line: var(--border);
    --site-shadow-soft: var(--shadow-sm);
    --site-shadow: var(--shadow-lg);
    --site-focus-ring: color-mix(in srgb, var(--accent-dark) 32%, transparent);
    --site-radius-sm: var(--radius-sm);
    --site-radius-md: var(--radius-md);
    --site-radius-lg: var(--radius-lg);
    --site-shell-main: 1400px;
    --site-shell-wide: 1400px;
    --site-shell-header: 1600px;
    --heartopia-hero-height: 100vh;
    color-scheme: light;
}

body[data-shell="article"] {
    --shell-main: 900px;
    --shell-header: 1400px;
}

body[data-shell="hub"] {
    --shell-main: 1100px;
    --shell-header: 1400px;
}

body[data-shell="explorer"] {
    --shell-main: 1400px;
    --shell-header: 1600px;
}

body[data-theme] {
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    line-height: 1.7;
    overflow-x: hidden;
}

body[data-theme]::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        var(--color-bg-gradient),
        radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--secondary) 18%, transparent) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--gold) 10%, transparent) 0%, transparent 60%);
    pointer-events: none;
}

body[data-theme] h1,
body[data-theme] h2,
body[data-theme] h3,
body[data-theme] h4,
body[data-theme] h5,
body[data-theme] h6 {
    color: var(--color-heading);
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.3;
}

body[data-theme] .site-shell-nav {
    background: var(--chrome-surface) !important;
    border-bottom: 1px solid var(--border) !important;
    box-shadow: none;
}

body[data-theme] .site-shell-nav-inner {
    max-width: var(--shell-header) !important;
    padding: 0.85rem 1.5rem !important;
}

body[data-theme] .site-shell-brand {
    color: var(--text-dark);
    font-family: var(--font-display);
    transition: color var(--transition-fast), transform var(--transition-fast);
}

body[data-theme] .site-shell-brand:hover,
body[data-theme] .site-shell-brand:focus-visible {
    transform: translateY(-1px);
    color: var(--interactive-hover-text);
    text-decoration: none;
}

body[data-theme] .site-shell-mark {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: var(--radius-md);
    color: var(--color-text-white);
}

body[data-theme] .site-shell-badge {
    border-color: var(--border);
    background: var(--active-surface);
    color: var(--text-dark);
}

body[data-theme] .site-shell-menu {
    gap: 0.35rem;
    font-family: var(--font-body);
}

body[data-theme] .site-shell-menu a {
    min-height: 2.5rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    color: var(--text-medium) !important;
    font-weight: 700;
    line-height: 1.2;
    transition:
        background var(--transition-fast),
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        color var(--transition-fast),
        transform var(--transition-fast);
}

body[data-theme] .site-shell-menu a:hover,
body[data-theme] .site-shell-menu a:focus-visible {
    transform: translateY(-1px);
    background: var(--link-hover-surface);
    border-color: var(--interactive-hover-border);
    color: var(--interactive-hover-text) !important;
    text-decoration-line: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.2em;
}

body[data-theme] .mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    min-height: 2.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--chrome-surface-strong);
    cursor: pointer;
}

body[data-theme] .mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-dark);
    border-radius: var(--radius-full);
}

body[data-theme] .mobile-nav {
    display: none;
    width: 100%;
    margin-top: 0.9rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--chrome-surface-strong);
    box-shadow: var(--chrome-shadow);
}

body[data-theme] .mobile-nav.active {
    display: block !important;
}

body[data-theme] .mobile-nav-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

body[data-theme] .mobile-nav-list a {
    display: block;
    min-height: 2.5rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    color: var(--text-dark) !important;
    font-weight: 700;
    text-decoration: none;
    transition:
        background var(--transition-fast),
        border-color var(--transition-fast),
        color var(--transition-fast),
        transform var(--transition-fast);
}

body[data-theme] .mobile-nav-list a:hover,
body[data-theme] .mobile-nav-list a:focus-visible {
    transform: translateY(-1px);
    border-color: var(--interactive-hover-border);
    background: var(--link-hover-surface);
    color: var(--interactive-hover-text) !important;
    text-decoration-line: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.2em;
}

body[data-theme] .heartopia-hero {
    min-height: 100vh;
    padding-top: 80px;
}

body[data-theme] .heartopia-hero--compact {
    min-height: 100vh;
}

body[data-theme] .heartopia-hero-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--accent) 22%, transparent) 0%,
        color-mix(in srgb, var(--bg-main) 90%, transparent) 50%,
        var(--color-bg-primary) 100%
    );
}

body[data-theme] .heartopia-hero-bg::after {
    display: none;
}

body[data-theme] .heartopia-hero-content {
    max-width: 900px;
    padding: var(--space-2xl);
}

body[data-theme] .heartopia-hero-badge {
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
    border: 0;
    background: var(--chrome-surface);
    color: var(--color-accent-text);
    box-shadow: var(--shadow-sm);
    padding: var(--space-sm) var(--space-lg);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    animation: fadeInUp 0.6s ease forwards;
}

body[data-theme] .heartopia-hero-badge-dot {
    width: 8px;
    height: 8px;
    background: var(--color-success);
    box-shadow: none;
    animation: pulse 2s infinite;
}

body[data-theme] .heartopia-hero-title {
    margin-bottom: var(--space-lg);
    color: var(--color-heading);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    line-height: 1.3;
    animation: fadeInUp 0.6s ease forwards;
}

body[data-theme] .heartopia-highlight {
    color: var(--color-action);
}

body[data-theme] .heartopia-highlight::after {
    bottom: 0;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--color-action-light), var(--color-highlight));
    opacity: 0.5;
}

body[data-theme] .heartopia-hero-tagline {
    margin: 0 0 var(--space-md);
    color: var(--color-action);
    font-family: var(--font-accent);
    font-size: 1.6rem;
    font-style: italic;
    line-height: 1.45;
}

body[data-theme] .heartopia-hero-description {
    max-width: 700px;
    margin: 0 auto var(--space-2xl);
    color: var(--color-text-secondary);
    font-size: 1.25rem;
    animation: fadeInUp 0.6s ease forwards;
}

body[data-theme] .heartopia-hero-actions {
    gap: var(--space-md);
    margin: 0 0 var(--space-3xl);
    animation: fadeInUp 0.6s ease forwards;
}

body[data-theme] .site-primary-button,
body[data-theme] .site-secondary-button,
body[data-theme] .tool-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    min-height: auto;
    padding: var(--space-md) var(--space-xl);
    text-decoration: none;
    transition: all var(--transition-normal);
}

body[data-theme] .heartopia-hero-actions .site-primary-button,
body[data-theme] .heartopia-hero-actions .site-secondary-button {
    padding: var(--space-lg) var(--space-2xl);
    font-size: 1.125rem;
}

body[data-theme] .site-primary-button,
body[data-theme] .tool-action {
    border: 2px solid var(--primary);
    background: var(--primary-dark);
    color: var(--color-text-white);
    box-shadow: var(--shadow-md), 0 8px 22px rgba(228, 89, 58, 0.28);
}

body[data-theme] .site-primary-button:hover,
body[data-theme] .site-primary-button:focus-visible,
body[data-theme] .tool-action:hover,
body[data-theme] .tool-action:focus-visible {
    transform: translateY(-2px);
    color: var(--color-text-white);
    box-shadow: var(--shadow-lg), 0 12px 32px rgba(43, 38, 32, 0.28);
    text-decoration-line: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.2em;
}

body[data-theme] .site-secondary-button {
    border: 2px solid var(--color-cream-dark);
    background: var(--color-bg-card);
    color: var(--color-accent-text);
}

body[data-theme] .site-secondary-button:hover,
body[data-theme] .site-secondary-button:focus-visible {
    transform: translateY(-2px);
    border-color: var(--interactive-hover-border);
    background: var(--color-cream);
    color: var(--interactive-hover-text);
    text-decoration-line: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.2em;
}

body[data-theme] .heartopia-hero-stats {
    gap: var(--space-3xl);
    margin-top: 0;
    animation: fadeInUp 0.6s ease forwards;
}

body[data-theme] .heartopia-hero-stat-value {
    color: var(--color-action);
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
}

body[data-theme] .heartopia-hero-stat-label {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

body[data-theme] .heartopia-section,
body[data-theme] .heartopia-quick-nav {
    padding: var(--space-4xl) 0;
}

body[data-theme] .heartopia-section--surface {
    background: var(--color-cream);
}

body[data-theme] .heartopia-section-header {
    margin-bottom: var(--space-3xl);
}

body[data-theme] .heartopia-section-header h2 {
    margin-bottom: var(--space-md);
    color: var(--color-heading);
    font-size: clamp(1.5rem, 4vw, 2.5rem);
}

body[data-theme] .heartopia-section-header p {
    max-width: 700px;
    color: var(--color-text-secondary);
}

body[data-theme] .heartopia-kicker {
    display: none;
}

body[data-theme] .heartopia-quick-nav-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-lg);
}

body[data-theme] .heartopia-quick-nav-item,
body[data-theme] .heartopia-route-card,
body[data-theme] .topic-link-card {
    min-height: auto;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--color-bg-card);
    box-shadow: var(--shadow-sm);
    color: inherit;
    padding: var(--space-xl);
    transition: all var(--transition-normal);
}

body[data-theme] .heartopia-quick-nav-item:hover,
body[data-theme] .heartopia-quick-nav-item:focus-visible,
body[data-theme] .heartopia-route-card:hover,
body[data-theme] .heartopia-route-card:focus-visible,
body[data-theme] .topic-link-card:hover,
body[data-theme] .topic-link-card:focus-visible {
    transform: translateY(-8px);
    border-color: var(--interactive-hover-border);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

body[data-theme] .heartopia-quick-nav-icon,
body[data-theme] .heartopia-route-icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-md);
    border: 0;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--primary) 18%, var(--card-bg));
    color: var(--color-accent-text);
    font-size: 2rem;
    transition: all var(--transition-normal);
}

body[data-theme] .heartopia-quick-nav-item:nth-child(2) .heartopia-quick-nav-icon { background: color-mix(in srgb, var(--secondary) 20%, var(--card-bg)); }
body[data-theme] .heartopia-quick-nav-item:nth-child(3) .heartopia-quick-nav-icon { background: color-mix(in srgb, var(--gold) 20%, var(--card-bg)); }
body[data-theme] .heartopia-quick-nav-item:nth-child(4) .heartopia-quick-nav-icon { background: color-mix(in srgb, var(--accent) 22%, var(--card-bg)); }
body[data-theme] .heartopia-quick-nav-item:nth-child(5) .heartopia-quick-nav-icon { background: color-mix(in srgb, var(--tertiary) 20%, var(--card-bg)); }
body[data-theme] .heartopia-quick-nav-item:nth-child(6) .heartopia-quick-nav-icon { background: color-mix(in srgb, var(--secondary) 16%, var(--card-bg)); }
body[data-theme] .heartopia-quick-nav-item:nth-child(7) .heartopia-quick-nav-icon { background: color-mix(in srgb, var(--primary) 16%, var(--card-bg)); }
body[data-theme] .heartopia-quick-nav-item:nth-child(8) .heartopia-quick-nav-icon { background: color-mix(in srgb, var(--tertiary) 16%, var(--card-bg)); }

body[data-theme] .heartopia-quick-nav-item:hover .heartopia-quick-nav-icon {
    transform: scale(1.1);
}

body[data-theme] .heartopia-quick-nav-title,
body[data-theme] .heartopia-route-card h3,
body[data-theme] .topic-link-card h3 {
    color: var(--color-heading);
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
}

body[data-theme] .heartopia-quick-nav-count,
body[data-theme] .heartopia-route-card p,
body[data-theme] .topic-link-card p {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

body[data-theme] .topic-count,
body[data-theme] .tool-badge,
body[data-theme] .tool-tag,
body[data-theme] .category-tag.active {
    border-color: var(--primary-light);
    background: var(--active-surface);
    color: var(--text-dark);
}

body[data-theme] .category-tag.active:hover,
body[data-theme] .category-tag.active:focus-visible {
    transform: translateY(-1px);
    border-color: var(--interactive-hover-border);
    box-shadow: var(--shadow-sm);
}

body[data-theme] .site-search-panel,
body[data-theme] .site-tool-section,
body[data-theme] .heartopia-index-card,
body[data-theme] .heartopia-qr-card {
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--color-bg-card);
    box-shadow: var(--shadow-sm);
}

body[data-theme] .tool-card {
    border: 0;
    border-radius: var(--radius-xl);
    background: var(--color-bg-card);
    box-shadow: var(--shadow-sm);
}

body[data-theme] .tool-card:hover,
body[data-theme] .tool-card:focus-within {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

body[data-theme] .feature-icon,
body[data-theme] .feature-icon-soft {
    background: linear-gradient(135deg, var(--color-action) 0%, var(--color-action-dark) 100%);
    color: var(--color-text-white);
}

body[data-theme] .usage-panel {
    border: 0;
    border-radius: var(--radius-xl);
    background: var(--color-heading);
    color: var(--color-text-white);
    box-shadow: var(--shadow-lg);
}

body[data-theme] .site-shell-footer {
    margin-top: var(--space-4xl);
    border-top: 1px solid var(--border);
    background: var(--chrome-surface-strong);
}

body[data-theme] .site-shell-footer-inner {
    max-width: var(--shell-header) !important;
    padding: 2.25rem 1.5rem 1.25rem;
    font-family: var(--font-body);
}

body[data-theme] .site-shell-footer-grid {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

/* 移动端：3×minmax(180px) 会把文档撑到 620px（390px 视口下全站横向溢出），
   这里让 footer 在窄屏退化成单列。 */
@media (max-width: 900px) {
    body[data-theme] .site-shell-footer-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

body[data-theme] .site-shell-footer-column h2,
body[data-theme] .site-shell-footer-brand strong {
    color: var(--text-dark);
    font-family: var(--font-display);
}

body[data-theme] .site-shell-footer-copy,
body[data-theme] .site-shell-footer-brand span,
body[data-theme] .site-shell-footer-column a {
    color: var(--text-medium);
}

body[data-theme] .site-shell-footer-column a:hover,
body[data-theme] .site-shell-footer-column a:focus-visible {
    color: var(--interactive-hover-text);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

body[data-theme] :where(a[href], button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@media (max-width: 1120px) {
    body[data-theme] .site-shell-menu {
        display: none !important;
    }

    body[data-theme] .mobile-menu-toggle {
        display: inline-flex !important;
    }

    body[data-theme] .mobile-nav-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body[data-theme] .heartopia-hero-actions .site-primary-button,
    body[data-theme] .heartopia-hero-actions .site-secondary-button {
        width: min(100%, 18.5rem);
        padding: var(--space-md) var(--space-lg);
        font-size: 1rem;
        line-height: 1.35;
    }

    body[data-theme] .heartopia-hero-stats {
        flex-direction: column;
        gap: var(--space-lg);
    }
}

@media (prefers-reduced-motion: reduce) {
    body[data-theme] *,
    body[data-theme] *::before,
    body[data-theme] *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
