/* ==========================================================
   FONTS – @font-face
   ========================================================== */

@font-face {
    font-family: 'Space Grotesk';
    src: url('../fonts/spacegrotesk-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Space Grotesk';
    src: url('../fonts/spacegrotesk-medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Space Grotesk';
    src: url('../fonts/spacegrotesk-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ==========================================================
   RESET & VARIABLEN
   ========================================================== */

* {
    box-sizing: border-box;
}

:root {
    --bg: #f5f4ef;
    --text: #1d1d1f;
    --muted: #5d5d66;
    --card: #ffffff;
    --line: #dcdad2;
    --accent: #3b5bdb;

    /* Code-Panel (dunkel, wie im Editor) */
    --code-bg: #1e1f29;
    --code-text: #e6e6ea;
    --code-comment: #7c7f93;
    --code-selector: #f9c74f;
    --code-prop: #7dd3fc;
    --code-value: #fca5a5;
    --code-tag: #f472b6;
    --code-attr: #c4b5fd;

    /* Box-Model-Farben (wie in den Chrome DevTools) */
    --bm-margin: #f9cc9d;
    --bm-border: #fddd9b;
    --bm-padding: #c3d08b;
    --bm-content: #8cb6c0;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
}

/* nur Seitentitel – die Beispiel-Headings in der Vorschau bleiben unberührt */
.page-header h1,
section > .container > h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    line-height: 1.2;
}

.page-header h1 {
    font-size: 2.5rem;
    margin: 0 0 0.5rem;
}

section > .container > h2 {
    font-size: 1.75rem;
    margin: 0 0 0.75rem;
}

code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95em;
    background-color: #e9e7df;
    padding: 0.05em 0.3em;
    border-radius: 3px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==========================================================
   GRID-HILFSKLASSEN
   ========================================================== */

.grid {
    display: grid;
    gap: 20px;
}

.grid-col-2 {
    grid-template-columns: 1fr 1fr;
}

.grid-col-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.grid-col-4 {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

@media screen and (max-width: 1000px) {
    .grid-col-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media screen and (max-width: 900px) {
    .grid-col-2,
    .grid-col-3 {
        grid-template-columns: 1fr;
    }

    .grid-col-4 {
        grid-template-columns: 1fr 1fr;
    }
}

/* ==========================================================
   SEITENAUFBAU
   ========================================================== */

.page-header {
    padding: 48px 0 24px;
    border-bottom: 1px solid var(--line);
}

.lead {
    max-width: 70ch;
    color: var(--muted);
    margin: 0 0 1.25rem;
}

.toc {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.toc a {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--line);
    background-color: var(--card);
    padding: 6px 14px;
    border-radius: 999px;
}

.toc a:hover {
    border-color: var(--accent);
    color: var(--accent);
}

section {
    padding: 48px 0;
    border-bottom: 1px solid var(--line);
}

section > .container > p {
    max-width: 75ch;
    margin: 0 0 1.5rem;
}

.demo {
    align-items: start;
}

/* ==========================================================
   CODE-PANEL (links)
   ========================================================== */

.code-panel {
    background-color: var(--code-bg);
    color: var(--code-text);
    border-radius: 10px;
    padding: 16px 20px 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    min-width: 0; /* verhindert, dass langer Code das Grid sprengt */
}

.code-title {
    font-family: system-ui, sans-serif;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--code-comment);
    margin-bottom: 8px;
}

.code-title--sub {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid #33354a;
}

.code {
    margin: 0;
    font-family: inherit;
    white-space: pre;
    overflow-x: auto;
    scrollbar-color: #44465a transparent;
}

.punct {
    color: var(--code-text);
}

.code + .rule {
    margin-top: 16px;
}

/* Syntax-Farben */
.c   { color: var(--code-comment); }
.sel { color: var(--code-selector); }
.at  { color: var(--code-tag); }
.p   { color: var(--code-prop); }
.v   { color: var(--code-value); }
.t   { color: var(--code-tag); }
.a   { color: var(--code-attr); }

/* Interaktive Regel */
.rule-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.rule-head .sel {
    margin-right: auto;
}

.reset {
    font-family: system-ui, sans-serif;
    font-size: 0.75rem;
    color: var(--code-comment);
    background: none;
    border: 1px solid #3a3c52;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
}

.reset:hover {
    color: var(--code-text);
    border-color: var(--code-comment);
}

.decl {
    display: block;
    padding: 1px 6px 1px 4px;
    margin-left: 4px;
    border-radius: 4px;
    cursor: pointer;
}

.decl:hover {
    background-color: #2a2c3a;
}

.decl input[type="checkbox"] {
    accent-color: var(--accent);
    margin: 0 4px 0 0;
    vertical-align: middle;
    cursor: pointer;
}

/* Deaktivierte Zeile: durchgestrichen wie in den DevTools */
.decl.off {
    opacity: 0.45;
}

.decl.off .p,
.decl.off .v,
.decl.off select {
    text-decoration: line-through;
}

.decl select {
    font: inherit;
    color: var(--code-value);
    background-color: transparent;
    border: none;
    border-bottom: 1px dashed var(--code-value);
    padding: 0 2px;
    cursor: pointer;
}

.decl select option {
    color: var(--text);
    background-color: var(--card);
}

/* ==========================================================
   PREVIEW-PANEL (rechts)
   ========================================================== */

.preview-panel {
    background-color: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px 20px 20px;
    min-width: 0;
}

.preview-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 12px;
}

.hint {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 16px 0 0;
}

/* Label mit Klassenname */
.tag {
    position: absolute;
    top: 6px;
    left: 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background-color: var(--code-bg);
    padding: 4px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

.tag--inline {
    position: static;
    display: inline-block;
    vertical-align: middle;
}

/* HTML-Zeile mit Checkbox (z.B. <link>) */
.decl--html {
    margin-left: 12px;
}

/* ---------- CSS einbinden ---------- */

/* Ohne .is-styled: nackte Browser-Standards (wie ohne Stylesheet) */
.css-preview {
    font-family: 'Times New Roman', Times, serif;
    color: #000;
    background: #fff;
    padding: 8px;
    outline: 1px solid var(--line);
}

.css-preview h3 {
    font-size: 1.5em;
    margin: 0.5em 0;
}

.css-preview a {
    color: #0000ee;
}

.css-preview.is-styled {
    font-family: system-ui, sans-serif;
    background-color: #fce8df;
    padding: 24px;
    border-radius: 10px;
    outline: none;
}

.css-preview.is-styled h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.75rem;
    color: #1e2a2f;
    margin: 0 0 8px;
}

.css-preview.is-styled a {
    display: inline-block;
    margin-top: 8px;
    padding: 10px 18px;
    background-color: #e85d2a;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: 999px;
}

/* ---------- Headings ---------- */

.headings-preview {
    font-family: 'Times New Roman', Times, serif; /* Browser-Standard */
}

/* Browser-Standardgrössen, Einrückung zeigt die Gliederung */
.headings-preview h1,
.headings-preview h2,
.headings-preview h3,
.headings-preview h4,
.headings-preview h5,
.headings-preview h6 {
    margin: 0.35em 0;
    padding-left: 10px;
    border-left: 3px solid var(--line);
    line-height: 1.25;
}

.headings-preview h1 { font-size: 2em; }
.headings-preview h2 { font-size: 1.5em;  margin-left: 20px; }
.headings-preview h3 { font-size: 1.17em; margin-left: 40px; }
.headings-preview h4 { font-size: 1em;    margin-left: 60px; }
.headings-preview h5 { font-size: 0.83em; margin-left: 80px; }
.headings-preview h6 { font-size: 0.67em; margin-left: 100px; }

.headings-preview .tag {
    margin-right: 4px;
    font-size: 11px;
}

/* ---------- Bilder ---------- */

.img-parent {
    position: relative;
    width: 60%;
    min-width: 120px;
    max-width: 100%;
    padding: 36px 12px 12px;
    border: 2px dashed #9aa5c8;
    border-radius: 6px;
    background-color: #eef1fb;
    overflow: auto;
    resize: horizontal; /* Container mit der Maus breiter/schmaler ziehen */
}

/* ---------- Fonts ---------- */

.font-preview {
    margin: 0;
    padding: 16px;
    background-color: var(--bg);
    border-radius: 6px;
}

/* ---------- Box-Model ---------- */

.bm-stage {
    display: flow-root; /* verhindert margin-collapsing */
    width: fit-content;
    max-width: 100%;
    background-color: var(--bm-margin);
}

.box {
    box-sizing: content-box; /* Browser-Standard – der Reset oben setzt sonst border-box */
    background-color: var(--bm-padding);
    border-color: var(--bm-border);
}

.box-content {
    background-color: var(--bm-content);
    padding: 8px;
    font-weight: 600;
    text-align: center;
}

.legend {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    padding: 0;
    margin: 16px 0 0;
    font-size: 0.85rem;
}

.legend li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 2px;
}

.swatch--margin  { background-color: var(--bm-margin); }
.swatch--border  { background-color: #222; }
.swatch--padding { background-color: var(--bm-padding); }
.swatch--content { background-color: var(--bm-content); }

.measure {
    margin: 12px 0 0;
}

.measure .hint {
    margin: 0;
}

/* ---------- Flexbox & Grid ---------- */

.layout-container {
    position: relative;
    min-height: 300px;
    padding: 36px 12px 12px;
    border: 2px dashed #9aa5c8;
    border-radius: 6px;
    background-color: #eef1fb;
}

.item {
    padding: 10px 12px;
    border-radius: 6px;
    color: #fff;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    line-height: 1.3;
}

.item .tag {
    display: block;
    width: fit-content;
    margin-bottom: 6px;
    background-color: rgba(0, 0, 0, 0.35);
}

.item:nth-child(6n + 2) { background-color: #3b5bdb; }
.item:nth-child(6n + 3) { background-color: #e8590c; }
.item:nth-child(6n + 4) { background-color: #2b8a3e; }
.item:nth-child(6n + 5) { background-color: #ae3ec9; }
.item:nth-child(6n + 6) { background-color: #c92a2a; }
.item:nth-child(6n + 1) { background-color: #0b7285; }

/* Im Grid etwas kleinere Mindesthöhe */
.grid-container.layout-container {
    min-height: 0;
}
