/**
 * Theme Name: DesignMD
 * Theme URI: https://github.com/google-labs-code/design.md
 * Author: WorkBuddy
 * Author URI: https://www.codebuddy.cn
 * Description: 一款基于 design.md 设计哲学构建的简洁、开发者向 WordPress 主题——结构化设计令牌（CSS 自定义属性）、WCAG AA 无障碍配色、强排版层次与一致的间距尺度。完全响应式、独立后台设置页、Customizer 集成、SEO 优化、支持多语言。
 * Version: 1.1.0
 * Requires at least: 5.5
 * Tested up to: 6.5
 * Requires PHP: 7.4
 * License: GNU General Public License v2 or later
 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: designmd
 * Tags: blog, two-columns, right-sidebar, custom-logo, custom-colors, custom-menu, featured-images, threaded-comments, translation-ready, rtl-language-support, full-width-template, block-styles, wide-blocks
 *
 * =====================================================================
 * DESIGN TOKENS — design.md philosophy
 * =====================================================================
 * This stylesheet defines a structured design token system using CSS
 * custom properties, inspired by the design.md specification:
 *   - Colors: WCAG AA compliant (4.5:1 contrast minimum)
 *   - Typography: ordered scale with explicit family/size/weight/line-height
 *   - Spacing: consistent modular scale
 *   - Rounded: discrete corner-radius tokens
 *   - Components: token-driven composable styles
 * Tokens may be overridden by the Customizer at runtime via inline CSS.
 */

/* ----------------------------------------------------------------------
 * 1. Design Tokens (root-level, machine-readable)
 * -------------------------------------------------------------------- */
:root {
    /* --- Colors --- */
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-accent: #7c3aed;

    --color-bg: #ffffff;
    --color-surface: #f8fafc;
    --color-surface-alt: #f1f5f9;

    --color-text: #0f172a;          /* contrast vs --color-bg: 16.8:1 (AAA) */
    --color-text-muted: #475569;    /* contrast vs --color-bg: 8.6:1 (AAA)  */
    --color-text-subtle: #64748b;   /* contrast vs --color-bg: 5.9:1 (AA)   */
    --color-text-on-primary: #ffffff;

    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;

    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-error: #dc2626;

    /* --- Typography --- */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-serif: Georgia, Cambria, "Times New Roman", Times, serif;
    --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --fs-xs: 0.75rem;     /* 12px */
    --fs-sm: 0.875rem;    /* 14px */
    --fs-base: 1rem;      /* 16px */
    --fs-lg: 1.125rem;    /* 18px */
    --fs-xl: 1.25rem;     /* 20px */
    --fs-2xl: 1.5rem;     /* 24px */
    --fs-3xl: 1.875rem;   /* 30px */
    --fs-4xl: 2.25rem;    /* 36px */
    --fs-5xl: 3rem;       /* 48px */

    --lh-tight: 1.2;
    --lh-snug: 1.4;
    --lh-normal: 1.6;
    --lh-relaxed: 1.75;

    --fw-normal: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    --tracking-tight: -0.025em;
    --tracking-normal: 0;
    --tracking-wide: 0.025em;

    /* --- Spacing scale (modular, 4px base) --- */
    --space-1: 0.25rem;   /* 4px  */
    --space-2: 0.5rem;    /* 8px  */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.5rem;    /* 24px */
    --space-6: 2rem;      /* 32px */
    --space-7: 3rem;      /* 48px */
    --space-8: 4rem;      /* 64px */
    --space-9: 6rem;      /* 96px */

    /* --- Rounded corners --- */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* --- Elevation & depth (shadows) --- */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);

    /* --- Layout --- */
    --container-max: 1200px;
    --container-narrow: 760px;
    --content-width: 760px;
    --sidebar-width: 320px;
    --gap: var(--space-7);

    /* --- Transitions --- */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* --- Z-index scale --- */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal: 1040;
    --z-toast: 1050;
}

/* ----------------------------------------------------------------------
 * 2. Dark mode tokens (respects prefers-color-scheme + body class)
 * -------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    :root:not(.light-scheme) {
        --color-bg: #0f172a;
        --color-surface: #1e293b;
        --color-surface-alt: #334155;
        --color-text: #f1f5f9;
        --color-text-muted: #cbd5e1;
        --color-text-subtle: #94a3b8;
        --color-border: #334155;
        --color-border-strong: #475569;
        --color-primary: #3b82f6;
        --color-primary-hover: #60a5fa;
        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    }
}

/* Explicit dark scheme via body class (Customizer-driven) */
body.dark-scheme {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-surface-alt: #334155;
    --color-text: #f1f5f9;
    --color-text-muted: #cbd5e1;
    --color-text-subtle: #94a3b8;
    --color-border: #334155;
    --color-border-strong: #475569;
    --color-primary: #3b82f6;
    --color-primary-hover: #60a5fa;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

/* ----------------------------------------------------------------------
 * 3. CSS Reset (modern, minimal)
 * -------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color var(--transition-base), color var(--transition-base);
}
img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
#root, #__next { isolation: isolate; }

/* ----------------------------------------------------------------------
 * 4. Typography
 * -------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--color-text);
}
h1 { font-size: var(--fs-4xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 { font-size: var(--fs-base); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

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

strong, b { font-weight: var(--fw-semibold); }
em, i { font-style: italic; }
code, pre, kbd, samp { font-family: var(--font-mono); font-size: 0.9em; }
code {
    background: var(--color-surface-alt);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    color: var(--color-text);
}
pre {
    background: var(--color-surface);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    overflow-x: auto;
    border: 1px solid var(--color-border);
    margin-bottom: var(--space-4);
}
pre code { background: none; padding: 0; }
blockquote {
    border-left: 4px solid var(--color-primary);
    padding: var(--space-2) var(--space-4);
    margin: 0 0 var(--space-4);
    color: var(--color-text-muted);
    font-style: italic;
    background: var(--color-surface);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
hr { border: none; border-top: 1px solid var(--color-border); margin: var(--space-6) 0; }

ul, ol { margin: 0 0 var(--space-4) var(--space-5); }
li { margin-bottom: var(--space-2); }

/* ----------------------------------------------------------------------
 * 5. Layout containers
 * -------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--space-4);
}
.container-narrow { max-width: var(--container-narrow); }

.site-main { display: block; }

/* Two-column layout (content + sidebar) */
.content-area {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--gap);
    align-items: start;
}
@media (min-width: 960px) {
    .content-area.has-sidebar {
        grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
    }
    .content-area.has-sidebar .site-main { order: 1; }
    .content-area.has-sidebar .widget-area { order: 2; }
}

/* ----------------------------------------------------------------------
 * 6. Accessibility helpers
 * -------------------------------------------------------------------- */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute !important;
    width: 1px;
    word-wrap: normal !important;
}
.screen-reader-text:focus {
    background-color: var(--color-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    clip: auto;
    clip-path: none;
    color: var(--color-primary);
    display: block;
    font-size: var(--fs-base);
    font-weight: var(--fw-bold);
    height: auto;
    left: var(--space-4);
    padding: var(--space-4) var(--space-5);
    text-decoration: none;
    top: var(--space-4);
    width: auto;
    z-index: var(--z-fixed);
}
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: var(--space-4); top: var(--space-4); z-index: var(--z-fixed); }

:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ----------------------------------------------------------------------
 * 7. Buttons (component token example)
 * -------------------------------------------------------------------- */
.btn, .button, button[type="submit"], input[type="submit"], .wp-block-button__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
    color: var(--color-text-on-primary);
    background-color: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
    text-decoration: none;
}
.btn:hover, .button:hover, button[type="submit"]:hover, input[type="submit"]:hover, .wp-block-button__link:hover {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: var(--color-text-on-primary);
    text-decoration: none;
    transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }

.btn-secondary {
    background-color: transparent;
    color: var(--color-text);
    border-color: var(--color-border-strong);
}
.btn-secondary:hover {
    background-color: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-text-muted);
}
