/**
 * Base Styles - Reset and Typography
 * Premium Editorial Design System
 *
 * @package Messlier
 */

/* ========================================
   CSS RESET
   ======================================== */

/* Box Sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Reset margins */
* {
    margin: 0;
    padding: 0;
}

/* ========================================
   DOCUMENT
   ======================================== */

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern" 1, "liga" 1;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Selection */
::selection {
    background-color: var(--selection);
    color: var(--text);
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: var(--leading-tight);
    color: var(--text);
    letter-spacing: var(--tracking-tight);
    transition: color var(--transition-base);
}

h1 {
    font-size: var(--text-4xl);
    font-weight: 500;
    margin-bottom: var(--space-6);
    letter-spacing: var(--tracking-tighter);
}

h2 {
    font-size: var(--text-3xl);
    font-weight: 500;
    margin-bottom: var(--space-5);
}

h3 {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-4);
}

h4 {
    font-size: var(--text-xl);
    margin-bottom: var(--space-3);
}

h5 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-3);
}

h6 {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

/* Body text */
p {
    margin-bottom: var(--space-5);
}

/* Lead text - for intros */
.lead {
    font-size: var(--text-lg);
    line-height: var(--leading-loose);
    color: var(--text-muted);
}

/* Small text */
small,
.small {
    font-size: var(--text-sm);
}

/* Strong/Bold */
strong,
b {
    font-weight: 600;
    color: var(--text);
}

/* Emphasis */
em,
i {
    font-style: italic;
}

/* ========================================
   LINKS
   ======================================== */

a {
    color: var(--link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--link-hover);
}

a:focus {
    color: var(--link-hover);
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

a:focus:not(:focus-visible) {
    outline: none;
}

a:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Content links - underlined for clarity */
.entry-content a,
.comment-content a {
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-underline-offset: 3px;
    transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

.entry-content a:hover,
.comment-content a:hover {
    text-decoration-color: var(--link);
}

/* ========================================
   LONG-FORM CONTENT TYPOGRAPHY
   Optimized for calm, structured reading
   Applies to both Block Editor and Classic Editor
   ======================================== */

/* Paragraphs - generous spacing between ideas */
.entry-content p,
.wp-block-post-content p {
    margin-bottom: var(--space-6);
    line-height: var(--leading-loose);
}

/* Headings in content - section anchors with breathing room */
.entry-content h2,
.wp-block-post-content h2 {
    margin-top: var(--space-16);
    margin-bottom: var(--space-6);
    padding-top: var(--space-4);
}

.entry-content h3,
.wp-block-post-content h3 {
    margin-top: var(--space-12);
    margin-bottom: var(--space-5);
}

.entry-content h4,
.wp-block-post-content h4 {
    margin-top: var(--space-10);
    margin-bottom: var(--space-4);
}

.entry-content h5,
.entry-content h6,
.wp-block-post-content h5,
.wp-block-post-content h6 {
    margin-top: var(--space-8);
    margin-bottom: var(--space-4);
}

/* First heading after intro needs less top margin */
.entry-content > h2:first-child,
.entry-content > h3:first-child,
.entry-content > h4:first-child,
.wp-block-post-content > h2:first-child,
.wp-block-post-content > h3:first-child,
.wp-block-post-content > h4:first-child {
    margin-top: 0;
    padding-top: 0;
}

/* Element following heading - reduce gap for cohesion */
.entry-content h2 + p,
.entry-content h3 + p,
.entry-content h4 + p,
.wp-block-post-content h2 + p,
.wp-block-post-content h3 + p,
.wp-block-post-content h4 + p {
    margin-top: 0;
}

/* Lists - distinct structure, not wrapped sentences */
.entry-content ul,
.entry-content ol,
.wp-block-post-content ul,
.wp-block-post-content ol {
    margin-top: var(--space-6);
    margin-bottom: var(--space-8);
    padding-left: var(--space-8);
}

.entry-content li,
.wp-block-post-content li {
    margin-bottom: var(--space-3);
    padding-left: var(--space-2);
    line-height: var(--leading-loose);
}

.entry-content li:last-child,
.wp-block-post-content li:last-child {
    margin-bottom: 0;
}

/* Nested lists - indented subsections */
.entry-content ul ul,
.entry-content ol ol,
.entry-content ul ol,
.entry-content ol ul,
.wp-block-post-content ul ul,
.wp-block-post-content ol ol,
.wp-block-post-content ul ol,
.wp-block-post-content ol ul {
    margin-top: var(--space-3);
    margin-bottom: var(--space-3);
    padding-left: var(--space-6);
}

/* List following a paragraph - clear separation */
.entry-content p + ul,
.entry-content p + ol,
.wp-block-post-content p + ul,
.wp-block-post-content p + ol {
    margin-top: var(--space-4);
}

/* Blockquotes - breathing room */
.entry-content blockquote,
.wp-block-post-content blockquote {
    margin-top: var(--space-10);
    margin-bottom: var(--space-10);
    padding: var(--space-6) var(--space-8);
}

.entry-content blockquote p,
.wp-block-post-content blockquote p {
    margin-bottom: var(--space-4);
    line-height: var(--leading-loose);
}

/* Code blocks - section-like spacing */
.entry-content pre,
.wp-block-post-content pre {
    margin-top: var(--space-8);
    margin-bottom: var(--space-8);
    padding: var(--space-6);
}

/* Figures/Images - generous margins */
.entry-content figure,
.wp-block-post-content figure {
    margin-top: var(--space-12);
    margin-bottom: var(--space-12);
}

/* Horizontal rules - major section breaks */
.entry-content hr,
.wp-block-post-content hr {
    margin-top: var(--space-16);
    margin-bottom: var(--space-16);
}

/* Tables - clear separation */
.entry-content table,
.wp-block-post-content table {
    margin-top: var(--space-8);
    margin-bottom: var(--space-8);
}

/* ========================================
   LISTS
   ======================================== */

ul, ol {
    margin-bottom: var(--space-5);
    padding-left: var(--space-6);
}

li {
    margin-bottom: var(--space-2);
    line-height: var(--leading-relaxed);
}

li::marker {
    color: var(--text-light);
}

/* Nested lists */
ul ul,
ol ol,
ul ol,
ol ul {
    margin-top: var(--space-2);
    margin-bottom: 0;
}

/* ========================================
   IMAGES & FIGURES
   Paper-integrated, not inserted
   ======================================== */

img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-sm);
}

/* Entry content images get paper framing */
.entry-content img,
.single-post__featured-image img {
    border-radius: var(--radius-md);
}

figure {
    margin: var(--space-10) 0;
    padding: var(--space-4);
    background-color: var(--surface-2);
    border-radius: var(--radius-lg);
}

figure img {
    border-radius: var(--radius-md);
}

figcaption {
    font-size: var(--text-sm);
    color: var(--text-light);
    margin-top: var(--space-4);
    text-align: center;
    font-style: italic;
}

/* ========================================
   BLOCKQUOTE
   ======================================== */

blockquote {
    margin: var(--space-8) 0;
    padding: var(--space-5) var(--space-6);
    border-left: 3px solid var(--accent);
    background-color: var(--surface);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
    color: var(--text-muted);
    transition: background-color var(--transition-base), border-color var(--transition-base);
}

blockquote p {
    margin-bottom: var(--space-3);
}

blockquote p:last-child {
    margin-bottom: 0;
}

blockquote cite {
    display: block;
    margin-top: var(--space-4);
    font-size: var(--text-sm);
    font-style: normal;
    color: var(--text-light);
}

blockquote cite::before {
    content: "— ";
}

/* ========================================
   CODE
   ======================================== */

code, kbd, samp, pre {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

code {
    background-color: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: background-color var(--transition-base);
}

kbd {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.15em 0.4em;
    font-size: 0.85em;
    box-shadow: 0 1px 0 var(--border-strong);
}

pre {
    background-color: var(--code-bg);
    padding: var(--space-5);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin-bottom: var(--space-5);
    border: 1px solid var(--border-light);
    transition: background-color var(--transition-base), border-color var(--transition-base);
}

pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

/* ========================================
   HORIZONTAL RULE
   ======================================== */

hr {
    border: 0;
    height: 1px;
    background-color: var(--border-light);
    margin: var(--space-10) 0;
    transition: background-color var(--transition-base);
}

/* Decorative divider */
hr.divider {
    height: auto;
    background: none;
    text-align: center;
}

hr.divider::before {
    content: "• • •";
    color: var(--text-light);
    font-size: var(--text-sm);
    letter-spacing: 0.5em;
}

/* ========================================
   TABLES
   ======================================== */

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-6);
    font-size: var(--text-sm);
}

th, td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

th {
    font-weight: 600;
    color: var(--text);
    background-color: var(--surface);
}

tbody tr:hover {
    background-color: var(--surface);
}

/* ========================================
   FORMS
   ======================================== */

input,
textarea,
select,
button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

/* Focus states */
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Screen Reader Text */
.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;
    width: 1px;
    word-wrap: normal !important;
}

.screen-reader-text:focus {
    background-color: var(--bg);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 3px var(--focus-ring);
    clip: auto !important;
    clip-path: none;
    color: var(--text);
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    height: auto;
    left: var(--space-2);
    line-height: normal;
    padding: var(--space-4);
    text-decoration: none;
    top: var(--space-2);
    width: auto;
    z-index: 100000;
}

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