
/* ==============================
   Design tokens
   light-dark(LIGHT, DARK) follows the OS setting by default.
   Force a theme with <html data-theme="light"> or "dark".
============================== */

:root {
    color-scheme: light dark;

    /* Accent hue (OKLCH). header.js overrides this from the saved choice. */
    --h: 150;

    --bg: light-dark(#f4f5f8, #17191f);
    --logo-bg: light-dark(#242832, #242832);
    --panel: light-dark(#ffffff, #222630);
    --card: light-dark(#ffffff, #242832);
    --inset: light-dark(#eff1f5, #1d2028);
    --border: light-dark(#d6dae2, #383d49);
    --border-strong: light-dark(#b7bec9, #454c5b);
    --text: light-dark(#1c2230, #eeeeee);
    --muted: light-dark(#596273, #aeb5c2);
    --faint: light-dark(#778092, #858b98);
    --accent: light-dark(oklch(0.52 0.18 var(--h)), oklch(0.78 0.14 var(--h)));
    --code: light-dark(oklch(0.45 0.14 var(--h)), oklch(0.86 0.08 var(--h)));

    --btn: light-dark(#e8ebf1, #303746);
    --btn-hover: light-dark(#dce1ea, #3b465a);
    --btn-primary: light-dark(oklch(0.52 0.16 var(--h)), oklch(0.45 0.12 var(--h)));
    --btn-primary-border: light-dark(oklch(0.45 0.16 var(--h)), oklch(0.58 0.13 var(--h)));
    --btn-primary-hover: light-dark(oklch(0.45 0.16 var(--h)), oklch(0.5 0.13 var(--h)));
    --btn-primary-text: light-dark(#ffffff, #eeeeee);
    --btn-danger: light-dark(#fbe9ec, #402c32);
    --btn-danger-border: light-dark(#e3aab4, #63414a);
    --btn-danger-hover: light-dark(#f6d2d9, #59343d);
    --btn-danger-hover-border: light-dark(#c4546a, #a75b69);

    --valid-border: light-dark(#2f8a57, #397a55);
    --valid-text: light-dark(#1b6a3d, #a9e3bd);
    --invalid-border: light-dark(#c25555, #995050);
    --invalid-text: light-dark(#a12f2f, #f0b0b0);

    --shadow-tooltip: light-dark(rgba(20, 30, 50, 0.18), rgba(0, 0, 0, 0.35));
    --shadow-modal: light-dark(rgba(20, 30, 50, 0.25), rgba(0, 0, 0, 0.5));
    --backdrop: light-dark(rgba(20, 25, 40, 0.45), rgba(0, 0, 0, 0.7));
}

:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;
}

/* Yellow is too light for white button text, so it gets its own shades. */
:root[data-accent="yellow"] {
    --accent: light-dark(oklch(0.55 0.14 85), oklch(0.85 0.17 95));
    --btn-primary: light-dark(oklch(0.84 0.17 95), oklch(0.8 0.16 95));
    --btn-primary-border: light-dark(oklch(0.72 0.16 90), oklch(0.7 0.15 92));
    --btn-primary-hover: light-dark(oklch(0.8 0.17 93), oklch(0.85 0.16 95));
    --btn-primary-text: #1c2230;
}

/* ==============================
   Global styles
============================== */

*,
*::before,
*::after {
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) var(--bg);
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ==============================
   Header
============================== */

site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: block;
}

.site-header {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.header-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    min-height: 48px;
    padding: 6px 20px;
}

.brand {
    justify-self: start;
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}

.brand:hover {
    color: var(--accent);
    text-decoration: none;
}

.page-title {
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-self: end;
}

.theme-toggle,
.accent-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.theme-toggle:hover,
.accent-toggle:hover {
    background: var(--btn);
    border-color: var(--accent);
    color: var(--text);
}

/* Accent colour picker */

.accent-picker {
    position: relative;
}

.accent-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
}

.accent-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 110;
    display: grid;
    grid-template-columns: repeat(3, 32px);
    gap: 12px;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: 0 8px 24px var(--shadow-tooltip);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.accent-picker.is-open .accent-menu {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.swatch {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 2px solid var(--panel);
    border-radius: 50%;
    background: oklch(0.7 0.17 var(--sw));
    cursor: pointer;
    transition: transform 0.15s;
}

.swatch:hover {
    transform: scale(1.1);
}

.swatch[aria-pressed="true"] {
    box-shadow: 0 0 0 2px var(--text);
}

/* Navigation row */

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 20px;
    border-top: 1px solid var(--border);
}

.site-nav a {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.site-nav a:hover {
    background: var(--btn);
    color: var(--text);
    text-decoration: none;
}

.site-nav a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Current page: plain links */

.site-nav > a[aria-current="page"] {
    background: var(--btn);
    box-shadow: inset 0 -2px 0 var(--accent);
    color: var(--accent);
}

/* Dropdown: link + caret button + menu */

.nav-item {
    position: relative;
    display: flex;
    align-items: stretch;
    border-radius: 6px;
    transition: background 0.15s;
}

.nav-item > a {
    border-radius: 6px 0 0 6px;
    padding-right: 8px;
}

.nav-caret {
    display: inline-grid;
    place-items: center;
    width: 26px;
    padding: 0;
    border: none;
    border-radius: 0 6px 6px 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.nav-caret svg {
    transition: transform 0.2s;
}

.nav-item.is-open,
.nav-item.has-current {
    background: var(--btn);
}

.nav-item.has-current {
    box-shadow: inset 0 -2px 0 var(--accent);
}

.nav-item.has-current > a,
.nav-item.has-current > .nav-caret {
    color: var(--accent);
}

.nav-item.is-open > .nav-caret svg {
    transform: rotate(180deg);
}

.nav-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 110;
    min-width: 220px;
    max-width: calc(100vw - 24px);
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--shadow-tooltip);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

/* Invisible bridge so the menu stays open while the pointer crosses the gap */
.nav-menu::before {
    content: "";
    position: absolute;
    inset: -8px 0 auto;
    height: 8px;
}

.nav-menu a {
    display: block;
}

.nav-menu a[aria-current="page"] {
    background: var(--btn);
    color: var(--accent);
}

.nav-item.is-open > .nav-menu {
    opacity: 1;
    visibility: visible;
    transform: none;
}

@media (hover: hover) {
    .nav-item:hover {
        background: var(--btn);
    }

    .nav-item:hover > .nav-menu {
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    .nav-item:hover > .nav-caret svg {
        transform: rotate(180deg);
    }
}

/* ==============================
   Main container
============================== */

.container {
    width: 90%;
    margin: 35px auto;
    padding: 0 20px;
}

/* ==============================
   Homepage cards
============================== */

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    transition: border-color 0.2s, transform 0.2s;
}

.tool-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    text-decoration: none;
}

.tool-card h3 {
    color: var(--muted);
    margin-top: 5px;
    margin-bottom: 2px;
}

.tool-card p {
    color: var(--muted);
    margin: 0;
    text-align: center;
}

.tool-card span {
    display: inline-block;
    color: var(--accent);
}

.tool-card img {
    display: block;
    width: 50%;
    height: auto;
    margin: 10px;
}

[data-theme="dark"] .can-invert {
    filter: invert(1);
}

/* ==============================
   Configuration editor
============================== */

#editor {
    width: 100%;
}

#editor h2 {
    margin: 0 0 8px;
    font-size: 24px;
}

#editor > p {
    color: var(--muted);
    margin-bottom: 25px;
}

/* ==============================
   Editor layout
============================== */

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
    align-items: start;
    gap: 20px;
    margin-top: 25px;
}

.editor-form-panel,
.json-preview-panel {
    min-width: 0;
}

.json-preview-panel > button {
    margin-bottom: 15px;
}

/* ==============================
   Form fields
============================== */

#configuration-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    padding: 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.form-field label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.form-field input:not([type="checkbox"]),
.form-field select,
.form-field textarea {
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--accent);
}

.form-field input:focus-visible,
.form-field select:focus-visible,
.form-field textarea:focus-visible {
    outline: 1px solid var(--accent);
}

.form-field input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
}

.form-field small {
    color: var(--muted);
    font-size: 12px;
}

/* ==============================
   Horizontal field layout
============================== */

.field-row {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.field-label-row {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 35%;
    min-width: 0;
}

.field-row > input:not([type="checkbox"]),
.field-row > select,
.field-row > textarea {
    flex: 1;
    width: auto;
    min-width: 0;
}

.field-row > input[type="checkbox"] {
    flex: 0 0 20px;
}

.field-row > .modal-open-button {
    flex: 1;
}

.field-array-container {
    flex: 1;
    min-width: 0;
}

/* ==============================
   Nested objects
============================== */

.nested-object {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px;
    padding-left: 16px;
    border-left: 2px solid var(--border-strong);
}

/* ==============================
   Arrays
============================== */

.array-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.array-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--inset);
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* ==============================
   Buttons (shared base)
============================== */

:is(
    .array-add-button,
    .array-remove-button,
    .modal-open-button,
    .modal-add-button,
    .modal-remove-button,
    .modal-save-button,
    .modal-cancel-button,
    .modal-close-button
) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 85px;
    padding: 9px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--btn);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}

:is(
    .array-add-button,
    .array-remove-button,
    .modal-open-button,
    .modal-add-button,
    .modal-remove-button,
    .modal-cancel-button
):hover {
    background: var(--btn-hover);
    border-color: var(--accent);
}

:is(
    .array-add-button,
    .array-remove-button,
    .modal-add-button,
    .modal-remove-button
):disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ==============================
   Array buttons
============================== */

.array-add-button {
    align-self: flex-start;
    margin: 12px 0 8px;
}

.array-remove-button {
    align-self: flex-end;
    margin: 4px 0 8px;
}

/* ==============================
   JSON preview
============================== */

.json-preview-panel {
    position: sticky;
    top: 20px;
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.json-preview-panel h3 {
    margin: 0 0 6px;
    font-size: 18px;
}

.json-preview-panel > p {
    margin: 0 0 15px;
    color: var(--muted);
    font-size: 13px;
}

.json-preview {
    width: 100%;
    max-height: 650px;
    overflow: auto;
    margin: 0;
    padding: 15px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--code);
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    tab-size: 2;
}

.json-preview code {
    font-family: inherit;
}

/* ==============================
   Validation
============================== */

.validation-status {
    margin-top: 15px;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--panel);
    font-size: 13px;
}

.validation-status.is-valid {
    border-color: var(--valid-border);
    color: var(--valid-text);
}

.validation-status.is-invalid {
    border-color: var(--invalid-border);
    color: var(--invalid-text);
}

.validation-status ul {
    margin: 10px 0 0;
    padding-left: 20px;
}

.validation-status li {
    margin: 5px 0;
    overflow-wrap: anywhere;
}

/* ==============================
   Information tooltips
============================== */

.info-tooltip {
    position: relative;
    display: inline-flex;
    margin-left: 7px;
    vertical-align: middle;
}

.info-button {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid var(--muted);
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: bold;
    line-height: 16px;
    cursor: pointer;
}

.info-button:hover,
.info-button[aria-expanded="true"] {
    color: var(--text);
    border-color: var(--text);
}

.info-button:focus-visible {
    outline-offset: 3px;
}

/* Tooltips are placed in the browser's top layer */

.info-tooltip-content {
    position: fixed;
    inset: auto;
    margin: 0;
    width: max-content;
    max-width: min(260px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--card);
    color: var(--text);
    font-size: 13px;
    font-weight: normal;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
    box-shadow: 0 4px 12px var(--shadow-tooltip);
    z-index: 10000;
}

/* ==============================
   Modal editor
============================== */

.editor-modal {
    width: min(800px, calc(100% - 30px));
    max-width: 800px;
    max-height: 85vh;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 15px 50px var(--shadow-modal);
}

.editor-modal::backdrop {
    background: var(--backdrop);
    backdrop-filter: blur(3px);
}

.modal-content {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.modal-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 22px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--border);
}

/* ==============================
   Modal button variants
============================== */

.modal-save-button {
    background: var(--btn-primary);
    border-color: var(--btn-primary-border);
    color: var(--btn-primary-text);
}

.modal-save-button:hover {
    background: var(--btn-primary-hover);
}

.modal-close-button {
    min-width: 36px;
    padding: 5px;
    font-size: 23px;
    border: none;
    background: transparent;
}

.modal-close-button:hover {
    background: var(--btn);
}

.modal-add-button {
    align-self: flex-start;
    margin-top: 10px;
}

.modal-remove-button {
    min-width: 75px;
    background: var(--btn-danger);
    border-color: var(--btn-danger-border);
}

.modal-remove-button:hover {
    background: var(--btn-danger-hover);
    border-color: var(--btn-danger-hover-border);
}

.modal-remove-button:disabled,
.modal-add-button:disabled {
    opacity: 0.4;
}

/* ==============================
   Modal arrays
============================== */

.modal-array-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    width: 100%;
}

.modal-array-entry {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
    padding: 12px;
    background: var(--inset);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.modal-array-entry-title {
    flex: 1;
    min-width: 100px;
    overflow-wrap: anywhere;
}

/* Keep array-entry tooltips aligned with their titles */

.modal-array-entry .info-tooltip {
    flex: 0 0 auto;
    margin-left: 0;
}

/* ==============================
   Footer
============================== */

site-footer {
    display: block;
    margin-top: auto;
}

.site-footer {
    background: var(--panel);
    border-top: 1px solid var(--border);
    color: var(--faint);
    font-size: 13px;
}

.footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    min-height: 44px;
    padding: 8px 20px;
}

.footer-copy {
    margin: 0;
}

.footer-links {
    display: flex;
    gap: 16px;
}

.footer-links a {
    color: var(--muted);
    transition: color 0.15s;
}

.footer-links a:hover {
    color: var(--accent);
    text-decoration: none;
}

.footer-links a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ==============================
   Loading state and content reveal
============================== */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px 20px;
    color: var(--muted);
    text-align: center;
    /* Short delay so fast loads never flash the spinner */
    animation: fade-in 0.3s ease 0.2s backwards;
}

.loading p {
    margin: 0;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.loading-dots::after {
    content: "";
    animation: dots 1.4s infinite;
}

#editor > :not(.loading) {
    animation: fade-in-up 0.4s ease backwards;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes dots {
    0%   { content: ""; }
    25%  { content: "."; }
    50%  { content: ".."; }
    75%  { content: "..."; }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* ==============================
   Home page
============================== */

.hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: 140px 24px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    text-align: center;
}

.hero-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0;
    transition: opacity 1s ease;
}

.hero-bg.is-ready {
    opacity: 1;
}

.hero-bg.is-ready::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--bg);
    opacity: 0.2;
}

.hero-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1.6s ease;
}

.hero-slide.is-active {
    opacity: 1;
}

.hero-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(5px);
    transform: scale(1.15);
}

.hero-slide.is-active img,
.hero-slide.is-leaving img {
    animation: hero-drift 16s ease-in-out infinite alternate;
}

@keyframes hero-drift {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.28);
    }
}

.hero h2 {
    margin: 0 0 12px;
    font-size: clamp(28px, 5vw, 42px);
    line-height: 1.2;
    text-shadow: 0 0 15px var(--bg);
}

.hero p {
    max-width: 60ch;
    margin: 0 auto 24px;
    font-size: 18px;
    text-shadow: 0 0 15px var(--bg);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--btn);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s;
}

.button:hover {
    background: var(--btn-hover);
    border-color: var(--accent);
    text-decoration: none;
}

.button-primary {
    background: var(--btn-primary);
    border-color: var(--btn-primary-border);
    color: var(--btn-primary-text);
}

.button-primary:hover {
    background: var(--btn-primary-hover);
}

.home-section {
    margin-top: 48px;
    scroll-margin-top: 130px;
}

.home-section > h2 {
    margin: 0 0 6px;
    font-size: 24px;
}

.section-lead {
    margin: 0;
    color: var(--muted);
}

.mod-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.mod-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.2s;
}

.mod-card:hover {
    border-color: var(--accent);
}

.mod-grid a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.mod-grid a:hover {
    text-decoration: none;
}

.mod-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mod-logo {
    flex: none;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: var(--inset);
    object-fit: contain;
}

.mod-logo-placeholder {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 24px;
    font-weight: 700;
}

.mod-card h3 {
    margin: 0 0 6px;
    font-size: 18px;
}

.mod-card p {
    flex: 1;
    margin: 0;
    color: var(--muted);
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 5px;
}

.badges p {
    margin: 0;
    padding: 0 10px;
}

.badge {
    padding: 2px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.accented {
    border-color: var(--accent);
    color: var(--accent);
}

.mod-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    margin: 0 0 0 auto;
}

.mod-links a {
    padding: 6px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--btn-primary);
    color: var(--btn-primary-text);
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s;
}

.mod-links a:hover {
    background: var(--btn-primary-hover);
    border-color: var(--accent);
    text-decoration: none;
}

/* ==============================
   About page
============================== */

.about-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.about-text {
    padding: 25px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.about-text h2 {
    margin: 0 0 10px;
    font-size: 24px;
}

.about-text p {
    margin: 0;
    color: var(--muted);
}

.about-image {
    margin: 0;
}

.about-image img {
    margin:auto;
    display: block;
    width: 100%;
    height: auto;
    min-height: 220px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--inset);
    object-fit: cover;
}

@media (max-width: 700px) {
    .about-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .about-image img {
        height: auto;
        aspect-ratio: 16 / 10;
    }
}

/* ==============================
   Mod info page
============================== */
.mod-support {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
}

.mod-support th {
    width: 1%;
    white-space: nowrap;
    padding-right: 10px;
    text-align: left;
    vertical-align: top;
}

.mod-support td {
    vertical-align: top;
}

.red {
    border-color: indianred;
    color: indianred;
}

.mod-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 25px;
    margin: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
}

.mod-header h2 {
    margin: 0 0 25px;
}

.version-support {
    width: 90%;
}

.mod-header img {
    margin: auto;
    width: 10%;
    background: var(--logo-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}

/* ==============================
   Wiki page
============================== */

.wiki-card {
    align-items: center;
    padding: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    transition: border-color 0.2s, transform 0.2s;
    margin-bottom: 15px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.wiki-page {
    text-align: center;
    width: 100%;
    border: 1px solid #383d49;
    background: #242832;
    border-radius: 10px;
    padding: 25px;
    color: #eeeeee;
    margin-bottom: 15px
}

.wiki-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 10px;
    text-align: left;
}

.wiki-table tr {
    border: 1px solid var(--border-strong);
}

.wiki-table th {
    border: 1px solid var(--border-strong);
    background: var(--btn-hover);
    padding: 5px;
}

.wiki-table td {
    padding: 5px;
}

.wiki-table tr:nth-child(even) {
    background-color: var(--btn);
}

.wiki-table img {
    vertical-align: middle;
    margin: 3px;
}

.wiki-list {
    align-items: center;
    padding: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    transition: border-color 0.2s, transform 0.2s;
    margin-bottom: 15px;
}

.wiki-list p {
    border-left: 4px solid var(--border-strong);
    margin-left: 20px;
    padding-left: 10px;
}

/* ==============================
   Theme switch fade
   (class is added by header.js only while the theme is changing)
============================== */

html.theme-changing,
html.theme-changing *,
html.theme-changing *::before,
html.theme-changing *::after {
    transition:
            background-color 0.5s ease,
            color 0.5s ease,
            border-color 0.5s ease,
            box-shadow 0.5s ease !important;
}

/* ==============================
   Motion preferences
============================== */

@media (prefers-reduced-motion: reduce) {
    .hero-bg,
    .hero-slide,
    .hero-slide img {
        transition: none;
        animation: none;
    }

    .loading,
    .loading-spinner,
    .loading-dots::after,
    #editor > :not(.loading) {
        animation: none;
    }

    .tool-card,
    .button,
    .mod-card,
    .mod-links a,
    .theme-toggle,
    .accent-toggle,
    .accent-menu,
    .swatch,
    .site-nav a,
    .nav-item,
    .nav-menu,
    .nav-caret svg,
    .footer-links a {
        transition: none;
    }

    .tool-card:hover {
        transform: none;
    }
}

/* ==============================
   Responsive layout
============================== */

@media (max-width: 850px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .json-preview-panel {
        position: static;
    }

    .json-preview {
        max-height: 450px;
    }
}

@media (max-width: 600px) {
    .header-bar {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 4px 12px;
        padding: 8px 12px;
    }

    .page-title {
        display: none;
    }

    .site-nav {
        --edge: color-mix(in oklab, var(--accent) 55%, transparent);
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }

    .site-nav::before,
    .site-nav::after {
        content: "";
        flex: 0 0 16px;
        position: sticky;
        z-index: 1;
        opacity: 0;
        pointer-events: none;
        animation-fill-mode: both;
        animation-timing-function: linear;
        animation-timeline: scroll(nearest inline);
    }

    .site-nav::before {
        left: -20px;
        margin: -6px -20px -6px 0;
        background: linear-gradient(to right, var(--edge), transparent);
        animation-name: edge-in;
        animation-range: 0 75%;
    }

    .site-nav::after {
        right: -20px;
        margin: -6px 0 -6px -20px;
        background: linear-gradient(to left, var(--edge), transparent);
        animation-name: edge-out;
        animation-range: calc(100% - 50%) 100%;
    }

    @keyframes edge-in  { from { opacity: 0; } to { opacity: 1; } }
    @keyframes edge-out { from { opacity: 1; } to { opacity: 0; } }

    .site-nav::-webkit-scrollbar {
        display: none;
    }

    .site-nav > a,
    .nav-item {
        flex: 0 0 auto;
    }

    /* Each nav item is its own anchor, scoped so they don't clash */
    .nav-item {
        anchor-name: --nav-item;
        anchor-scope: --nav-item;
    }

    /* Menu is fixed to the viewport (so the scroller can't clip it),
       but positioned relative to its parent item */
    .nav-menu {
        position: fixed;
        position-anchor: --nav-item;
        inset: auto;
        position-area: bottom span-right;
        position-try-fallbacks: flip-inline;
        margin: 6px 0 0;
    }

    .footer-bar {
        flex-direction: column;
        padding: 10px 12px;
        text-align: center;
    }

    .container {
        width: 95%;
        margin: 25px auto;
        padding: 0 10px;
    }

    .form-field {
        padding: 14px;
    }

    .field-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .field-label-row {
        flex: none;
        width: 100%;
    }

    .field-row > input:not([type="checkbox"]),
    .field-row > select,
    .field-row > textarea {
        flex: none;
        width: 100%;
    }

    .field-row > .modal-open-button {
        width: 100%;
    }

    .nested-object {
        padding-left: 10px;
    }

    .array-item {
        padding: 10px;
    }

    .array-add-button,
    .array-remove-button {
        padding: 9px 12px;
    }

    .editor-modal {
        width: calc(100% - 20px);
        max-height: 90vh;
    }

    .modal-content {
        max-height: 90vh;
    }

    .modal-header,
    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 14px 16px;
    }

    .modal-array-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .modal-array-entry {
        align-items: stretch;
    }

    .badges {
        display: block;
    }

    .mod-grid {
        grid-template-columns: repeat(auto-fit, 100%);
    }
}
 