/* styles.css */

/* 1. Tokens */
:root {
    /* Palette: graphite + muted teal, sand as a single helper */
    --c-bg: #0f1115;
    --c-bg-deep: #0b0d10;
    --c-surface: #161a20;
    --c-raised: #1d232b;
    --c-line: #2a313b;
    --c-line-soft: #222831;

    --c-text: #e2e5ea;
    --c-text-2: #c3c9d2;
    --c-muted: #9aa3ae;
    --c-heading: #f1f3f6;
    --c-visited: #aab0c0;

    --c-accent: #6fc3b8;
    --c-accent-strong: #8fd6cc;
    --c-accent-soft: rgba(111, 195, 184, 0.12);
    --c-accent-line: rgba(111, 195, 184, 0.4);

    --c-helper: #d9b98a;
    --c-helper-soft: rgba(217, 185, 138, 0.1);

    --c-focus: #a6eee4;
    --c-selection: rgba(111, 195, 184, 0.28);

    /* Spacing scale */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 24px;
    --s-6: 32px;
    --s-7: 48px;
    --s-8: 64px;

    /* Layout */
    --gutter: 16px;
    --container: 1120px;
    --measure: 68ch;
    --header-h: 56px;

    /* Radii & borders */
    --r-sm: 6px;
    --r: 12px;
    --r-lg: 16px;
    --r-pill: 999px;
    --bw: 1px;

    /* Typography */
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --fs-body: 1rem;
    --fs-small: 0.875rem;
    --fs-xs: 0.75rem;
    --lh-body: 1.7;
    --lh-heading: 1.3;
    --fs-h1: clamp(1.25rem, 1.05rem + 0.9vw, 2rem);
    --fs-h2: clamp(1.125rem, 1rem + 0.5vw, 1.4rem);
    --fs-h3: clamp(1.0625rem, 1rem + 0.3vw, 1.2rem);

    --transition: 160ms ease;
}

@media (min-width: 480px) {
    :root {
        --gutter: 20px;
    }
}

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

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

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

html {
    color-scheme: dark;
    background-color: var(--c-bg-deep);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--c-line) var(--c-bg-deep);
}

body {
    min-height: 100vh;
    background-color: var(--c-bg);
    background-image: linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 48px 48px;
    color: var(--c-text);
    font-family: var(--font-body);
    font-size: var(--fs-body);
    font-weight: 400;
    line-height: var(--lh-body);
    overflow-wrap: break-word;
    word-wrap: break-word;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

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

img,
video {
    border-radius: var(--r);
    filter: brightness(0.94);
}

/* 3. Selection, scrollbars, forms defaults */
::selection {
    background: var(--c-selection);
    color: var(--c-heading);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--c-bg-deep);
}

::-webkit-scrollbar-thumb {
    background: var(--c-line);
    border-radius: var(--r-pill);
    border: 2px solid var(--c-bg-deep);
}

::-webkit-scrollbar-thumb:hover {
    background: #3a4350;
}

input,
textarea,
select,
button {
    font: inherit;
    color: var(--c-text);
    background-color: var(--c-surface);
    color-scheme: dark;
    border: var(--bw) solid var(--c-line);
    border-radius: var(--r-sm);
    padding: var(--s-2) var(--s-3);
    min-height: 44px;
    max-width: 100%;
}

input::placeholder,
textarea::placeholder {
    color: var(--c-muted);
    opacity: 1;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

button {
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

button:hover {
    background-color: var(--c-raised);
    border-color: var(--c-accent-line);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 4. Focus */
:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--c-focus);
    outline-offset: 3px;
    border-radius: var(--r-sm);
}

/* 5. Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--c-heading);
    font-weight: 600;
    line-height: var(--lh-heading);
    letter-spacing: -0.01em;
    text-wrap: balance;
    overflow-wrap: anywhere;
}

h1 {
    font-size: var(--fs-h1);
}

h2 {
    font-size: var(--fs-h2);
}

h3 {
    font-size: var(--fs-h3);
}

h4 {
    font-size: 1rem;
}

p {
    margin-bottom: var(--s-5);
    color: var(--c-text-2);
    max-width: var(--measure);
}

small {
    font-size: var(--fs-small);
    color: var(--c-muted);
}

strong,
b {
    color: var(--c-heading);
    font-weight: 600;
}

em,
i {
    font-style: italic;
}

mark {
    background: var(--c-helper-soft);
    color: var(--c-heading);
    padding: 0 var(--s-1);
    border-radius: var(--r-sm);
    box-shadow: inset 0 -0.45em 0 rgba(217, 185, 138, 0.22);
}

kbd {
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--c-heading);
    background: var(--c-raised);
    border: var(--bw) solid var(--c-line);
    border-bottom-width: 2px;
    border-radius: var(--r-sm);
    padding: 1px var(--s-2);
    white-space: nowrap;
}

/* Links */
a {
    color: var(--c-accent);
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    text-decoration-color: var(--c-accent-line);
    transition: color var(--transition), text-decoration-color var(--transition);
}

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

a:visited {
    color: var(--c-visited);
}

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

/* 6. Lists */
ul,
ol {
    padding-left: var(--s-5);
    margin-bottom: var(--s-5);
    max-width: var(--measure);
}

li {
    margin-bottom: var(--s-2);
    color: var(--c-text-2);
}

li::marker {
    color: var(--c-accent);
}

ul ul,
ol ol,
ul ol,
ol ul {
    margin-top: var(--s-2);
    margin-bottom: var(--s-2);
}

ul.plain,
.plain {
    list-style: none;
    padding-left: 0;
}

/* 7. Code */
code,
kbd,
samp,
pre {
    font-family: var(--font-mono);
}

:not(pre) > code {
    font-size: 0.875em;
    color: var(--c-heading);
    background: var(--c-raised);
    border: var(--bw) solid var(--c-line-soft);
    border-radius: var(--r-sm);
    padding: 0.1em var(--s-1);
    overflow-wrap: anywhere;
}

pre {
    background: var(--c-bg-deep);
    border: var(--bw) solid var(--c-line);
    border-radius: var(--r);
    padding: var(--s-4);
    margin-bottom: var(--s-5);
    overflow-x: auto;
    max-width: 100%;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--c-text-2);
    white-space: pre;
    -webkit-overflow-scrolling: touch;
}

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

/* 8. Blockquote, hr, figure */
blockquote {
    position: relative;
    margin: var(--s-6) 0;
    padding: var(--s-4) var(--s-5);
    background: var(--c-surface);
    border: var(--bw) solid var(--c-line-soft);
    border-left: 3px solid var(--c-accent);
    border-radius: 0 var(--r) var(--r) 0;
    color: var(--c-text-2);
    font-size: 1.05em;
    max-width: var(--measure);
}

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

blockquote cite,
blockquote footer {
    display: block;
    margin-top: var(--s-3);
    font-size: var(--fs-small);
    font-style: normal;
    color: var(--c-muted);
}

hr {
    border: 0;
    height: var(--bw);
    background: linear-gradient(to right, transparent, var(--c-line) 20%, var(--c-line) 80%, transparent);
    margin: var(--s-7) 0;
}

figure {
    margin: var(--s-6) 0;
    max-width: 100%;
}

figcaption {
    margin-top: var(--s-3);
    font-size: var(--fs-small);
    color: var(--c-muted);
    max-width: var(--measure);
}

/* Tables */
table {
    display: block;
    max-width: 100%;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: separate;
    border-spacing: 0;
    border: var(--bw) solid var(--c-line);
    border-radius: var(--r);
    margin-bottom: var(--s-5);
    font-size: var(--fs-small);
}

thead,
tbody,
tfoot,
tr {
    display: table-row-group;
}

tr {
    display: table-row;
}

th,
td {
    padding: var(--s-3) var(--s-4);
    text-align: left;
    vertical-align: top;
    border-bottom: var(--bw) solid var(--c-line-soft);
    overflow-wrap: anywhere;
    min-width: 8ch;
}

th {
    background: var(--c-raised);
    color: var(--c-heading);
    font-weight: 600;
}

tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.012);
}

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

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

@media (min-width: 768px) {
    table {
        display: table;
        overflow-x: visible;
    }

    thead {
        display: table-header-group;
    }

    tbody {
        display: table-row-group;
    }

    tfoot {
        display: table-footer-group;
    }
}

/* 9. Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--c-bg);
    border-bottom: var(--bw) solid var(--c-line-soft);
}

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

.logo {
    display: inline-flex;
    align-items: center;
    gap: var(--s-3);
    min-height: 44px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--c-heading);
    text-decoration: none;
    text-transform: uppercase;
}

.logo:hover {
    color: var(--c-accent-strong);
}

.lang-switcher {
    display: flex;
    align-items: center;
    gap: var(--s-1);
    font-size: var(--fs-small);
    font-weight: 500;
}

.lang-switcher a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: var(--s-2) var(--s-2);
    color: var(--c-muted);
    text-decoration: none;
    border-radius: var(--r-sm);
}

.lang-switcher a:hover {
    color: var(--c-heading);
    background: var(--c-surface);
}

.lang-switcher a.active,
.lang-switcher a[aria-current="true"] {
    color: var(--c-accent);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.35em;
    text-decoration-color: var(--c-accent);
}

/* 10. Main & article */
main {
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--s-7) var(--gutter) var(--s-8);
    min-width: 0;
}

.article-title {
    max-width: 880px;
    margin-bottom: var(--s-6);
    font-size: var(--fs-h1);
    line-height: 1.3;
    color: var(--c-heading);
    letter-spacing: -0.015em;
}

/* 11. Hero */
.hero {
    display: grid;
    gap: var(--s-5);
    margin-bottom: var(--s-7);
    min-width: 0;
}

.hero > * {
    min-width: 0;
}

.hero-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--s-4);
}

.hero-content .lead {
    font-size: 1.0625em;
    line-height: 1.65;
    color: var(--c-text);
    max-width: var(--measure);
    margin-bottom: 0;
}

.meta-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2) var(--s-3);
    font-size: var(--fs-small);
    color: var(--c-muted);
    font-variant-numeric: tabular-nums;
}

.meta-info > * + *::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 3px;
    margin-right: var(--s-3);
    vertical-align: middle;
    border-radius: 50%;
    background: var(--c-line);
}

.hero-visual {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--c-bg-deep);
    border: var(--bw) solid var(--c-line);
    border-radius: var(--r-lg);
}

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

.visual-texture {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(135deg, rgba(111, 195, 184, 0.06), transparent 55%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 12px);
}

/* 12. Article content */
.content-body {
    max-width: var(--measure);
    margin-bottom: var(--s-7);
    min-width: 0;
}

.content-body > * {
    max-width: 100%;
}

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

.content-body h2,
.content-body h3,
.content-body h4 {
    color: var(--c-heading);
    margin-top: var(--s-7);
    margin-bottom: var(--s-4);
}

.content-body h2 {
    padding-top: var(--s-2);
    border-top: var(--bw) solid var(--c-line-soft);
}

.content-body h2:first-child,
.content-body > h2:first-child {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
}

.content-body h3 {
    color: var(--c-accent-strong);
    margin-top: var(--s-6);
}

.content-body ul {
    padding-left: var(--s-5);
    margin-bottom: var(--s-5);
    list-style: none;
}

.content-body ul > li {
    position: relative;
    padding-left: var(--s-2);
    margin-bottom: var(--s-3);
    color: var(--c-text-2);
}

.content-body ul > li::before {
    content: "";
    position: absolute;
    left: calc(-1 * var(--s-4));
    top: 0.72em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--c-accent);
}

.content-body ol {
    padding-left: var(--s-6);
    margin-bottom: var(--s-5);
}

.content-body ol > li {
    margin-bottom: var(--s-3);
    padding-left: var(--s-1);
}

.content-body ul li strong {
    color: var(--c-heading);
}

.content-body blockquote {
    margin: var(--s-6) 0;
    font-size: 1.05em;
    font-style: normal;
    color: var(--c-text-2);
}

.content-body blockquote p {
    color: var(--c-text-2);
}

.content-body img,
.content-body video,
.content-body iframe {
    margin: var(--s-5) 0;
}

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

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

.section-header h2 {
    flex-shrink: 0;
    font-size: var(--fs-h2);
    margin: 0;
}

.divider-line {
    flex-grow: 1;
    height: var(--bw);
    background: var(--c-line);
    min-width: var(--s-5);
}

.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-4);
    min-width: 0;
}

@media (min-width: 480px) {
    .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .cards-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: var(--s-5);
    }
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: var(--s-5);
    background: var(--c-surface);
    border: var(--bw) solid var(--c-line-soft);
    border-radius: var(--r);
    color: var(--c-text);
    transition: border-color var(--transition), background-color var(--transition);
}

.card:hover {
    background: var(--c-raised);
    border-color: var(--c-accent-line);
}

.card:focus-within {
    border-color: var(--c-accent-line);
}

.card-top {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-2);
    margin-bottom: var(--s-4);
    font-size: var(--fs-xs);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--s-1) var(--s-3);
    background: var(--c-accent-soft);
    color: var(--c-accent);
    border: var(--bw) solid var(--c-accent-line);
    border-radius: var(--r-pill);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.4;
}

.badge.accent-badge {
    background: var(--c-helper-soft);
    color: var(--c-helper);
    border-color: rgba(217, 185, 138, 0.35);
}

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

.card h4 {
    margin-bottom: var(--s-2);
    font-size: 1.0625rem;
    color: var(--c-heading);
}

.card h4 a {
    color: inherit;
    text-decoration: none;
}

.card h4 a::after {
    content: "";
    position: absolute;
    inset: 0;
}

.card h4 a:hover {
    color: var(--c-accent-strong);
}

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

.card-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-top: var(--s-3);
    border-top: var(--bw) solid var(--c-line-soft);
    font-size: var(--fs-small);
}

.card-footer a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

/* 14. Footer */
footer {
    margin-top: var(--s-8);
    background: var(--c-bg-deep);
    border-top: var(--bw) solid var(--c-line-soft);
}

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

.footer-left {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--s-3);
    color: var(--c-muted);
    font-size: var(--fs-small);
}

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

.footer-center a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--c-text-2);
    font-size: var(--fs-small);
    text-decoration: none;
    border-bottom: var(--bw) solid transparent;
}

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

.dmca-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: 36px;
    padding: var(--s-1) var(--s-3);
    border: var(--bw) solid var(--c-line);
    border-radius: var(--r-sm);
    font-size: var(--fs-xs);
    color: var(--c-muted);
    cursor: default;
}

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

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

/* 15. Responsive layout */
@media (min-width: 480px) {
    .article-title {
        margin-bottom: var(--s-6);
    }
}

@media (min-width: 768px) {
    .header-inner {
        flex-wrap: nowrap;
    }

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

    .hero-visual {
        aspect-ratio: 16 / 9;
    }
}

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

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

@media (min-width: 1024px) {
    .card h4 {
        font-size: 1.125rem;
    }
}

/* 16. Reduced 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;
    }
}