/* styles.css — "Paper & Ink" light editorial theme */

:root {
    /* Palette: warm paper + ink blue + terracotta accent */
    --bg: #f6f3ec;
    --bg-tint: #f2eee4;
    --surface: #efe9dd;
    --card: #fffdf9;
    --code-bg: #ebe5d6;

    --text: #1f2228;
    --text-soft: #3a3e47;
    --muted: #5a5e66;

    --accent: #1f3a5f;
    --accent-hover: #142944;
    --accent2: #a24a30;
    --accent2-soft: rgba(162, 74, 48, 0.1);
    --accent-soft: rgba(31, 58, 95, 0.08);

    --line: rgba(31, 34, 40, 0.12);
    --line-strong: rgba(31, 34, 40, 0.22);

    --shadow-sm: 0 1px 2px rgba(31, 34, 40, 0.06);
    --shadow: 0 8px 24px -14px rgba(31, 34, 40, 0.22);

    /* Typography */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    --fs-body: 1rem;
    --lh-body: 1.7;
    --lh-heading: 1.3;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 2.5rem;
    --space-8: 3rem;
    --space-10: 4rem;
    --section-gap: clamp(2.5rem, 6vw, 4.5rem);

    /* Radii & layout */
    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 16px;
    --container: 1120px;
    --gutter: clamp(1rem, 4vw, 2rem);
    --hit-size: 44px;
}

/* 1. Reset & base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    min-height: 100vh;
    overflow-x: hidden;
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 8% 0%, rgba(31, 58, 95, 0.045), transparent 42%),
        radial-gradient(circle at 92% 100%, rgba(162, 74, 48, 0.05), transparent 46%);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: anywhere;
}

::selection {
    background: rgba(162, 74, 48, 0.2);
    color: var(--text);
}

img,
video,
iframe,
svg,
canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

img,
video {
    font-style: italic;
}

/* 2. Typography */
h1,
h2,
h3,
h4 {
    font-family: var(--font-serif);
    font-weight: 700;
    line-height: var(--lh-heading);
    letter-spacing: -0.01em;
    color: var(--text);
    overflow-wrap: anywhere;
    text-wrap: balance;
}

p {
    overflow-wrap: anywhere;
}

ul,
ol {
    list-style: none;
}

strong {
    font-weight: 700;
}

small {
    font-size: 0.875em;
}

/* 3. Links & controls */
a {
    color: var(--accent);
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    text-decoration-color: rgba(31, 58, 95, 0.4);
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

a:hover {
    color: var(--accent2);
    text-decoration-color: currentColor;
    text-decoration-thickness: 2px;
}

a:active {
    color: var(--accent-hover);
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    min-height: var(--hit-size);
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--card);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

button:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

button:active {
    background: var(--surface);
}

:focus {
    outline: none;
}

:focus-visible {
    outline: 3px solid var(--accent2);
    outline-offset: 3px;
    border-radius: 4px;
}

/* 4. Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(246, 243, 236, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--space-3) var(--gutter);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2) var(--space-4);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--hit-size);
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.01em;
    color: var(--text);
}

.lang-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    font-size: 0.9rem;
    font-weight: 600;
}

.lang-switcher a {
    display: inline-flex;
    align-items: center;
    min-height: var(--hit-size);
    padding: 0 var(--space-3);
    color: var(--muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    position: relative;
}

.lang-switcher a::after {
    content: "";
    position: absolute;
    left: var(--space-3);
    right: var(--space-3);
    bottom: 8px;
    height: 2px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease;
}

.lang-switcher a.active,
.lang-switcher a:hover {
    color: var(--accent);
    text-decoration: none;
}

.lang-switcher a.active::after,
.lang-switcher a:hover::after {
    transform: scaleX(1);
}

/* 5. Main layout */
main {
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--space-7) var(--gutter);
    min-width: 0;
}

.article-title {
    max-width: 40em;
    margin-bottom: var(--space-6);
    font-size: clamp(1.125rem, 1rem + 1.2vw, 2rem);
    font-weight: 700;
    line-height: 1.35;
    padding-bottom: var(--space-5);
    border-bottom: 1px solid var(--line);
}

/* 6. Hero */
.hero {
    display: grid;
    gap: var(--space-6);
    margin-bottom: var(--section-gap);
    min-width: 0;
}

.hero-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.hero-content .lead {
    margin-bottom: var(--space-5);
    font-size: clamp(1.02rem, 0.98rem + 0.2vw, 1.15rem);
    line-height: 1.65;
    color: var(--text-soft);
}

.meta-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    font-size: 0.875rem;
    color: var(--muted);
}

/* Hero visual (image frame) */
.hero-visual {
    position: relative;
    width: 100%;
    height: 300px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.visual-texture {
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(at 85% 0%, rgba(31, 58, 95, 0.1) 0, transparent 50%),
        radial-gradient(at 0% 100%, rgba(162, 74, 48, 0.08) 0, transparent 50%),
        repeating-linear-gradient(-45deg, rgba(31, 34, 40, 0.035) 0 1px, transparent 1px 12px);
    background-size: cover;
}

.hero-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
    border-radius: var(--radius-lg);
}

/* 7. Article content */
.content-body {
    max-width: 70ch;
    margin: 0 auto var(--section-gap);
    min-width: 0;
}

.content-body p {
    margin-bottom: var(--space-5);
    font-size: 1em;
    color: var(--text-soft);
}

.content-body p:last-child {
    margin-bottom: 0;
}

.content-body h2,
.content-body h3 {
    margin-top: var(--space-8);
    margin-bottom: var(--space-4);
    color: var(--accent);
}

.content-body h2 {
    font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem);
    padding-top: var(--space-2);
    border-top: 1px solid var(--line);
}

.content-body h3 {
    font-size: clamp(1.1rem, 1rem + 0.4vw, 1.3rem);
}

.content-body h2:first-child,
.content-body h3:first-child {
    margin-top: 0;
}

.content-body blockquote {
    position: relative;
    margin: var(--space-7) 0;
    padding: var(--space-5) var(--space-5) var(--space-5) var(--space-6);
    background: linear-gradient(90deg, var(--accent2-soft), transparent 80%);
    border-left: 3px solid var(--accent2);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: clamp(1.05rem, 1rem + 0.3vw, 1.2rem);
    line-height: 1.6;
    color: var(--text);
}

.content-body blockquote p {
    color: inherit;
    margin-bottom: var(--space-3);
}

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

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

.content-body ul {
    list-style: disc;
}

.content-body ol {
    list-style: decimal;
}

.content-body ul li,
.content-body ol li {
    margin-bottom: var(--space-2);
    color: var(--text-soft);
}

.content-body ul li::marker,
.content-body ol li::marker {
    color: var(--accent2);
    font-weight: 700;
}

.content-body ul li strong,
.content-body ol li strong {
    color: var(--text);
}

.content-body hr {
    margin: var(--space-8) 0;
    border: 0;
    height: 1px;
    background: var(--line-strong);
}

/* Inline code & code blocks */
code,
kbd,
samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--code-bg);
    color: var(--text);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    overflow-wrap: anywhere;
}

pre {
    max-width: 100%;
    margin: var(--space-5) 0;
    padding: var(--space-4);
    overflow-x: auto;
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text);
    white-space: pre;
    -webkit-overflow-scrolling: touch;
}

pre code {
    padding: 0;
    background: none;
    border-radius: 0;
    font-size: inherit;
    overflow-wrap: normal;
    white-space: inherit;
}

/* Tables: horizontal scroll on mobile */
table {
    display: block;
    width: max-content;
    max-width: 100%;
    margin: var(--space-5) 0;
    overflow-x: auto;
    border-collapse: collapse;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    -webkit-overflow-scrolling: touch;
}

th,
td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
    min-width: 8rem;
}

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

tbody tr:nth-child(even) {
    background: rgba(31, 34, 40, 0.025);
}

tbody tr:hover {
    background: var(--accent-soft);
}

/* 8. Related materials (cards) */
.related-materials {
    margin-top: var(--section-gap);
}

.section-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.section-header h2 {
    font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem);
    white-space: nowrap;
}

.divider-line {
    flex-grow: 1;
    height: 1px;
    background: var(--line-strong);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: var(--space-5);
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: var(--space-5);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(31, 58, 95, 0.28);
    box-shadow: var(--shadow);
}

.card-top {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    font-size: 0.8rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.badge.accent-badge {
    background: var(--accent2-soft);
    color: var(--accent2);
}

.date {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.card h4 {
    margin-bottom: var(--space-2);
    font-size: 1.1rem;
    color: var(--text);
}

.card p {
    flex-grow: 1;
    margin-bottom: var(--space-4);
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    display: flex;
    justify-content: flex-end;
    color: var(--muted);
    font-size: 0.85rem;
}

/* 9. Footer */
footer {
    margin-top: var(--section-gap);
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.footer-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--space-6) var(--gutter);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-5);
    text-align: center;
}

.footer-left {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.9rem;
    color: var(--muted);
}

.footer-center {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2) var(--space-5);
}

.footer-center a {
    display: inline-flex;
    align-items: center;
    min-height: var(--hit-size);
    font-size: 0.92rem;
    color: var(--text-soft);
    text-decoration-color: rgba(31, 34, 40, 0.3);
}

.footer-center a:hover {
    color: var(--accent2);
    text-decoration-color: currentColor;
}

.dmca-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: 0.75rem;
    color: var(--muted);
    cursor: default;
}

/* 10. Breakpoints (mobile-first) */
@media (min-width: 480px) {
    .article-title {
        margin-bottom: var(--space-7);
    }
}

@media (min-width: 600px) {
    .footer-inner {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }

    .footer-left,
    .footer-center {
        justify-content: flex-start;
    }
}

@media (min-width: 768px) {
    :root {
        --fs-body: 1.0625rem;
    }

    main {
        padding-top: var(--space-8);
    }

    .hero-visual {
        height: 360px;
    }

    table {
        display: table;
        width: 100%;
        overflow: visible;
    }

    .content-body p {
        margin-bottom: var(--space-6);
    }
}

@media (min-width: 900px) {
    .hero {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
        gap: var(--space-8);
        align-items: center;
    }

    .hero-visual {
        height: 100%;
        min-height: 420px;
    }
}

@media (min-width: 1024px) {
    :root {
        --fs-body: 1.125rem;
    }

    .content-body p,
    .content-body ul li,
    .content-body ol li {
        font-size: 1em;
    }

    .card p {
        font-size: 0.95rem;
    }
}

/* 11. Motion preferences */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }

    .card:hover {
        transform: none;
    }
}