/* ==========================================================================
   Mineskin – stylesheet
   ========================================================================== */

/* Fonts (self-hosted) ----------------------------------------------------- */
@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/open-sans-v34-latin-regular.woff2') format('woff2');
}
@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/open-sans-v34-latin-700.woff2') format('woff2');
}

/* Design tokens ----------------------------------------------------------- */
:root {
    color-scheme: dark;

    --bg: #0f1115;
    --bg-glow: rgba(93, 187, 99, 0.16);
    --surface: #171a21;
    --surface-2: #1f232c;
    --border: #2a2f3a;
    --text: #e6e8ec;
    --muted: #9aa3b2;

    --accent: #5dbb63;
    --accent-strong: #4ea654;
    --accent-contrast: #0b1a0c;

    --tok-path: #d2a8ff;
    --tok-name: #7ee787;
    --tok-size: #ff7b72;
    --tok-ext: #79c0ff;

    --danger: #ff7b72;

    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);

    --font: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, 'SFMono-Regular', 'JetBrains Mono', Menlo, Consolas, monospace;
}

/*
 * Light theme. Applied when the system prefers light (and the visitor has not
 * explicitly chosen dark), or when the visitor chose light via the toggle.
 * The token list is duplicated on purpose: a media query and an attribute
 * selector cannot share one rule.
 */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        color-scheme: light;

        --bg: #f6f7f9;
        --bg-glow: rgba(47, 143, 58, 0.12);
        --surface: #ffffff;
        --surface-2: #f0f2f5;
        --border: #e1e4e8;
        --text: #1b1f24;
        --muted: #5b6472;

        --accent: #2f8f3a;
        --accent-strong: #277a31;
        --accent-contrast: #ffffff;

        --tok-path: #8250df;
        --tok-name: #1a7f37;
        --tok-size: #cf222e;
        --tok-ext: #0969da;

        --danger: #cf222e;

        --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
    }
}

:root[data-theme="light"] {
    color-scheme: light;

    --bg: #f6f7f9;
    --bg-glow: rgba(47, 143, 58, 0.12);
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e1e4e8;
    --text: #1b1f24;
    --muted: #5b6472;

    --accent: #2f8f3a;
    --accent-strong: #277a31;
    --accent-contrast: #ffffff;

    --tok-path: #8250df;
    --tok-name: #1a7f37;
    --tok-size: #cf222e;
    --tok-ext: #0969da;

    --danger: #cf222e;

    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background:
        radial-gradient(1000px 500px at 15% -10%, var(--bg-glow), transparent 70%),
        radial-gradient(800px 400px at 100% 0%, var(--bg-glow), transparent 70%),
        var(--bg);
    background-repeat: no-repeat;
    -webkit-font-smoothing: antialiased;
}

main {
    flex: 1;
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

p {
    margin: 0;
}

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

img {
    max-width: 100%;
}

code,
.code,
.anatomy {
    font-family: var(--mono);
}

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

.container {
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 24px;
}

.muted {
    color: var(--muted);
}

.accent {
    color: var(--accent);
}

.pixelated {
    image-rendering: pixelated;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -100px;
    z-index: 100;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-contrast);
}
.skip-link:focus {
    top: 12px;
}

/* Buttons ----------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
    white-space: nowrap;
}
.btn:hover {
    text-decoration: none;
}
.btn:active {
    transform: translateY(1px);
}
.btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
}
.btn-primary:hover {
    background: var(--accent-strong);
}
.btn-secondary {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}
.btn-secondary:hover {
    border-color: var(--muted);
}
.btn-sm {
    height: 36px;
    padding: 0 14px;
    font-size: 14px;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
}
.link-button:hover {
    color: var(--text);
    text-decoration: underline;
}

/* Top bar ----------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    backdrop-filter: saturate(160%) blur(12px);
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 19px;
    letter-spacing: -0.01em;
}
.brand:hover {
    text-decoration: none;
}
.brand img {
    border-radius: 4px;
}
.nav {
    display: flex;
    gap: 4px;
}
.nav a {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 15px;
}
.nav a:hover {
    color: var(--text);
    background: var(--surface-2);
    text-decoration: none;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
    color: var(--text);
    border-color: var(--muted);
}
/* Show the sun in dark mode (click -> light) and the moon in light mode (click -> dark) */
.theme-toggle .icon-moon {
    display: none;
}
:root[data-theme="light"] .theme-toggle .icon-sun {
    display: none;
}
:root[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .theme-toggle .icon-sun {
        display: none;
    }
    :root:not([data-theme]) .theme-toggle .icon-moon {
        display: block;
    }
}

/* Hero -------------------------------------------------------------------- */
.hero {
    padding: 72px 0 48px;
}
.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 48px;
    align-items: center;
}
.eyebrow {
    margin-bottom: 12px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.hero h1 {
    font-size: clamp(36px, 5.2vw, 58px);
    font-weight: 700;
}
.lead {
    margin-top: 18px;
    max-width: 560px;
    color: var(--muted);
    font-size: 18px;
}

.search {
    position: relative;
    display: flex;
    gap: 8px;
    max-width: 560px;
    margin-top: 32px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius-sm) + 6px);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.search:focus-within {
    border-color: var(--accent);
}
.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.search input {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 12px 0 42px;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 16px;
}
.search input:focus {
    outline: none;
}
.search input::placeholder {
    color: var(--muted);
}
.form-error {
    margin-top: 10px;
    color: var(--danger);
    font-weight: 700;
    font-size: 15px;
}

.featured {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    max-width: 600px;
    margin-top: 20px;
}
.featured-label {
    color: var(--muted);
    font-size: 14px;
    margin-right: 2px;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px 0 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    transition: border-color 0.15s, background-color 0.15s;
}
.chip img {
    border-radius: 4px;
}
.chip:hover {
    border-color: var(--accent);
    text-decoration: none;
}
.chip.is-active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 15%, var(--surface));
}

.stat {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 28px;
    color: var(--muted);
}
.stat strong {
    color: var(--text);
    font-size: 28px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* Cards ------------------------------------------------------------------- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

/* 3D viewer */
.viewer {
    margin: 0;
    overflow: hidden;
}
.model3d {
    height: 380px;
    background:
        radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 65%),
        var(--surface-2);
}
.model3d canvas {
    display: block;
}
.model3d-error {
    display: grid;
    place-items: center;
    color: var(--danger);
    font-weight: 700;
}
.viewer-caption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
}
.viewer-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.viewer-name {
    font-size: 18px;
    word-break: break-all;
}

/* Sections ---------------------------------------------------------------- */
.section {
    padding: 56px 0;
}
.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}
.section-head h2 {
    font-size: 30px;
    margin-bottom: 6px;
}

/* URL builder */
.builder {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.builder[hidden] {
    display: none;
}
.segmented {
    display: inline-flex;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.segmented label {
    position: relative;
}
.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.segmented span {
    display: block;
    padding: 6px 12px;
    border-radius: 5px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}
.segmented input:checked + span {
    background: var(--accent);
    color: var(--accent-contrast);
}
.segmented input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.field {
    display: inline-flex;
    align-items: center;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
}
.field:focus-within {
    border-color: var(--accent);
}
.field span {
    padding: 0 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    border-right: 1px solid var(--border);
    align-self: stretch;
    display: flex;
    align-items: center;
    background: var(--surface-2);
}
.field input,
.field select {
    height: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    padding: 0 10px;
}
.field input {
    width: 84px;
}
.field input:focus,
.field select:focus {
    outline: none;
}
.field select:disabled {
    opacity: 0.5;
}

/* Endpoint cards */
.endpoint-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}
.endpoint,
.skin-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.endpoint-preview {
    display: grid;
    place-items: center;
    height: 200px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background:
        radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
        var(--surface-2);
}
.endpoint-preview img {
    max-height: 160px;
    width: auto;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.3));
}
.endpoint-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
}
.endpoint-body h3 {
    font-size: 19px;
}
.endpoint-body .btn {
    align-self: flex-start;
}

/* Raw skin */
.skin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 20px;
}
.checkerboard {
    background-color: var(--surface-2);
    background-image:
        linear-gradient(45deg, var(--border) 25%, transparent 25%),
        linear-gradient(-45deg, var(--border) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--border) 75%),
        linear-gradient(-45deg, transparent 75%, var(--border) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.skin-texture {
    width: 160px;
    height: auto;
}
.skin-card:not(:has(.endpoint-preview)) .endpoint-body {
    height: 100%;
    justify-content: center;
}

/* Code blocks */
.code {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 6px 6px 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 13.5px;
}
.code code {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
    color: var(--muted);
}
.copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--muted);
    font: inherit;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.copy:hover {
    color: var(--text);
    border-color: var(--muted);
}
.copy.is-copied {
    color: var(--accent);
    border-color: var(--accent);
}

.tok-path { color: var(--tok-path); }
.tok-name { color: var(--tok-name); }
.tok-size { color: var(--tok-size); }
.tok-ext  { color: var(--tok-ext); }

/* How it works */
.usage {
    padding: 28px;
}
.anatomy {
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--muted);
    font-size: clamp(14px, 2.2vw, 20px);
    overflow-x: auto;
    white-space: nowrap;
}
.legend {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 20px 0 0;
}
.legend div {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.legend dt {
    font-family: var(--mono);
    font-weight: 700;
}
.legend dd {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}
.legend em {
    font-style: normal;
    opacity: 0.75;
}
.legend code {
    font-size: 13px;
}
.snippets {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 28px;
}
.snippets h3 {
    margin-bottom: 8px;
    font-size: 15px;
}

/* Ads --------------------------------------------------------------------- */
.ad-slot {
    padding-top: 16px;
    padding-bottom: 16px;
    text-align: center;
    overflow: hidden;
}
.ad-slot[hidden] {
    display: none;
}
.ad-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* 404 --------------------------------------------------------------------- */
.not-found {
    display: grid;
    place-items: center;
    padding: 80px 0;
}
.not-found-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.not-found-head {
    width: 140px;
    margin-bottom: 28px;
    filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.35));
    animation: float 4s ease-in-out infinite;
}
.not-found h1 {
    font-size: clamp(30px, 4.5vw, 46px);
}
.not-found .lead {
    margin-bottom: 28px;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}

/* Footer ------------------------------------------------------------------ */
.footer {
    margin-top: 40px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 14px;
}
.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-top: 24px;
    padding-bottom: 24px;
}
.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}
.footer a {
    color: var(--muted);
}
.footer a:hover {
    color: var(--text);
}

/* Consent banner ---------------------------------------------------------- */
.consent {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 200;
    width: min(420px, calc(100% - 40px));
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    font-size: 14px;
    animation: slide-up 0.25s ease-out;
}
.consent[hidden] {
    display: none;
}
.consent h2 {
    margin-bottom: 8px;
    font-size: 17px;
}
.consent p {
    color: var(--muted);
}
.consent-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

/* Responsive -------------------------------------------------------------- */
@media (max-width: 960px) {
    .hero {
        padding-top: 48px;
    }
    .hero-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 36px;
    }
    .legend {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .snippets {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 720px) {
    .container {
        padding: 0 16px;
    }
    .nav {
        display: none;
    }
    .endpoint-grid,
    .skin-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .model3d {
        height: 320px;
    }
    .section {
        padding: 40px 0;
    }
    .section-head h2 {
        font-size: 26px;
    }
    .usage {
        padding: 18px;
    }
    .legend {
        grid-template-columns: minmax(0, 1fr);
    }
    .search .btn {
        padding: 0 14px;
    }
    .consent {
        right: 12px;
        bottom: 12px;
        width: calc(100% - 24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
