/* styles.css */

/* 1. Design tokens */
:root {
    /* Palette: ivory paper + forest green + clay accent */
    --bg: #f7f4ec;
    --bg-soft: #efeadf;
    --surface: #fbf9f3;
    --card: #ffffff;

    --text: #1d211e;
    --text-soft: #3a413c;
    --muted: #5a6159;

    --accent: #2c5a45;
    --accent-hover: #1f4433;
    --accent-2: #8a4f2c;

    --line: rgba(29, 33, 30, 0.12);
    --line-strong: rgba(29, 33, 30, 0.22);
    --code-bg: #ece7d9;
    --quote-bg: rgba(138, 79, 44, 0.07);
    --focus: #2c5a45;

    /* Shape & elevation */
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(29, 33, 30, 0.05);
    --shadow-md: 0 12px 28px -18px rgba(29, 33, 30, 0.28);

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

    --fs-body: 1rem;
    --lh-body: 1.7;
    --lh-head: 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: 3rem;
    --space-8: 4rem;

    --gutter: 1rem;
    --container: 1080px;
    --touch: 44px;
}

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

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

body {
    min-height: 100vh;
    background-color: var(--bg);
    background-image: radial-gradient(900px 480px at 8% -8%, rgba(44, 90, 69, 0.05), transparent 65%);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    overflow-x: hidden;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

iframe {
    width: 100%;
}

table {
    border-collapse: collapse;
}

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

ul,
ol {
    list-style: none;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-head);
    font-weight: 700;
    line-height: var(--lh-head);
    color: var(--text);
    overflow-wrap: anywhere;
}

p,
li,
blockquote,
td,
th,
dd,
dt,
figcaption {
    overflow-wrap: break-word;
}

strong,
b {
    font-weight: 700;
}

/* 3. Links & focus */
a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    text-decoration-color: rgba(44, 90, 69, 0.35);
    transition: color 0.2s ease, text-decoration-color 0.2s ease, background-color 0.2s ease;
    overflow-wrap: anywhere;
}

a:hover {
    color: var(--accent-hover);
    text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

::selection {
    background: rgba(44, 90, 69, 0.18);
    color: var(--text);
}

/* 4. Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(247, 244, 236, 0.92);
    -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: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.0625rem;
    letter-spacing: 0.01em;
    color: var(--text);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.875rem;
    font-weight: 600;
}

.lang-switcher a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch);
    min-width: var(--touch);
    padding: 0 var(--space-3);
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
}

.lang-switcher a:hover {
    background: var(--bg-soft);
    color: var(--accent);
}

.lang-switcher a.active {
    background: var(--accent);
    color: #ffffff;
}

.lang-switcher a.active:hover {
    background: var(--accent-hover);
    color: #ffffff;
}

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

.article-title,
main h1 {
    font-size: 1.3125rem;
    line-height: 1.4;
    font-weight: 700;
    letter-spacing: -0.005em;
    max-width: 44ch;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--accent-2);
    text-wrap: balance;
}

/* 6. Hero */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
    margin-bottom: var(--space-7);
    min-width: 0;
}

.hero-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--space-4);
    min-width: 0;
}

.hero-content .lead {
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text-soft);
    max-width: 60ch;
}

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

.meta-info > * + * {
    padding-left: var(--space-3);
    border-left: 1px solid var(--line-strong);
}

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

.visual-texture {
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(at 85% 0%, rgba(44, 90, 69, 0.14) 0, transparent 50%),
        radial-gradient(at 0% 100%, rgba(138, 79, 44, 0.12) 0, transparent 50%),
        repeating-linear-gradient(-45deg, rgba(29, 33, 30, 0.035) 0 1px, transparent 1px 12px);
}

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

/* 7. Article content */
.content-body {
    max-width: 68ch;
    margin-bottom: var(--space-7);
    min-width: 0;
}

.content-body > * + * {
    margin-top: 0;
}

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

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

.content-body h2 {
    font-size: 1.25rem;
    padding-left: var(--space-3);
    border-left: 3px solid var(--accent);
}

.content-body h3 {
    font-size: 1.0625rem;
    color: var(--accent);
}

.content-body blockquote {
    position: relative;
    margin: var(--space-6) 0;
    padding: var(--space-4) var(--space-5);
    background: var(--quote-bg);
    border-left: 3px solid var(--accent-2);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-family: var(--font-head);
    font-style: italic;
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--text);
}

.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 li {
    margin-bottom: var(--space-2);
    color: var(--text-soft);
}

.content-body li::marker {
    color: var(--accent);
    font-weight: 700;
}

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

.content-body code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 0.1em 0.35em;
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--text);
    overflow-wrap: anywhere;
}

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

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

.content-body table {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: var(--space-5) 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.9375rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

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

.content-body th {
    background: var(--bg-soft);
    color: var(--text);
    font-weight: 700;
}

.content-body tbody tr:nth-child(even) {
    background: rgba(29, 33, 30, 0.025);
}

.content-body tbody tr:hover {
    background: rgba(44, 90, 69, 0.07);
}

.content-body tbody tr:last-child td {
    border-bottom: 0;
}

.content-body hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: var(--space-6) 0;
}

.content-body img {
    margin: var(--space-5) 0;
    border-radius: var(--radius-sm);
}

/* 8. Related materials */
.related-materials {
    margin-top: var(--space-7);
}

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

.section-header h2 {
    font-size: 1.25rem;
    white-space: nowrap;
}

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

.cards-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
}

.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);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(44, 90, 69, 0.35);
    box-shadow: var(--shadow-md);
}

.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.8125rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(44, 90, 69, 0.1);
    color: var(--accent);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.badge.accent-badge {
    background: rgba(138, 79, 44, 0.1);
    color: var(--accent-2);
}

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

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

.card p {
    flex-grow: 1;
    margin-bottom: var(--space-4);
    font-size: 0.9375rem;
    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;
    align-items: center;
    min-height: var(--touch);
    margin-top: auto;
    padding-top: var(--space-2);
    border-top: 1px solid var(--line);
    opacity: 0.85;
}

.card-footer a {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch);
    font-size: 0.875rem;
    font-weight: 600;
}

.card:hover .card-footer {
    opacity: 1;
}

/* 9. Footer */
footer {
    margin-top: var(--space-7);
    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-4);
    text-align: center;
}

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

.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(--touch);
    color: var(--text-soft);
    font-size: 0.9375rem;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.footer-center a:hover {
    color: var(--accent);
    border-bottom-color: currentColor;
}

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

/* 10. Breakpoints (mobile-first) */
@media (min-width: 480px) {
    :root {
        --gutter: 1.25rem;
    }

    .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

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

    .footer-center {
        justify-content: flex-end;
    }
}

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

    .article-title,
    main h1 {
        font-size: 1.625rem;
        max-width: 40ch;
    }

    .hero-visual {
        height: 320px;
    }

    .content-body table {
        display: table;
        overflow-x: visible;
    }

    .content-body th,
    .content-body td {
        min-width: 0;
    }

    .content-body h2 {
        font-size: 1.4rem;
    }

    .content-body h3 {
        font-size: 1.15rem;
    }

    .content-body p {
        font-size: 1.0625rem;
    }

    .content-body blockquote {
        font-size: 1.125rem;
    }

    .hero-content .lead {
        font-size: 1.125rem;
    }
}

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

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

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

    .article-title,
    main h1 {
        font-size: 2rem;
        max-width: 38ch;
    }

    .cards-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: var(--space-5);
    }

    .site-header .header-inner {
        flex-wrap: nowrap;
    }
}

/* 11. Motion preferences */
@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;
    }

    .card:hover {
        transform: none;
    }
}