:root {
    /* warm neutrals, matching the cream/taupe of the GdI banner */
    --bg: #f6f2ee;
    --surface: #ffffff;
    --surface-2: #f2ece7;
    --ink: #1a1614;
    --ink-2: #453d38;
    --muted: #6b625c; /* WCAG AA: >= 4.5:1 */
    --line: #e3dbd4;
    --line-strong: #c6bbb2;
    --brand: #e0d3cb; /* banner background */
    --accent: #1d4ed8;
    --accent-soft: #dbe6fb;
    --ok: #1f5f2a;
    --ok-soft: #e3f1e5;
    --shaky: #b45309;
    --shaky-soft: #fdf0dc;
    --confident: #6d28d9;
    --confident-soft: #efe7fd;
    --unknown: #938880;
    --radius-lg: 28px;
    --radius: 14px;
    --shadow: 0 1px 2px rgb(60 40 30 / 0.05), 0 4px 16px rgb(60 40 30 / 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

button {
    cursor: pointer;
}

a {
    color: inherit;
}

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

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

.page {
    container-type: inline-size;  /* cqw in the header = 1% of its width */
    max-width: 1240px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* --- Header ------------------------------------------------------------- */

/*
 * Tall GdI banner (1920x1080) as header background. The title sits on the empty lower part of the
 * image, below the logo. The banner scales with the header width, so its geometry is in cqw:
 *   image height          1080/1920 = 56.25cqw
 *   logo + shadow end     y = 600   -> 31.25cqw from the image top
 * Wide screens shift the image up by c (the same crop as a 360px tall strip around the logo),
 * and the text starts 16px below the logo shadow. Should the header ever be taller than the
 * image, it fades softly into the image's bottom colour.
 */
.page-head {
    --crop: calc((38.86cqw - min(38.86cqw, 360px)) / 2);
    --img-bottom: calc(56.25cqw - var(--crop));
    margin-bottom: 24px;
    padding-top: calc(31.25cqw - var(--crop) + 16px);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(transparent calc(var(--img-bottom) - 120px), #ccbfbe var(--img-bottom)),
        url("../img/brand/GdI_banner_tall.jpg") center calc(-1 * var(--crop)) / 100% auto no-repeat,
        #ccbfbe;
    overflow: hidden;
}

/* keep the text left of the balloons: the leftmost one starts at x = 1140 of 1920 (59.4cqw) */
.hero-text {
    position: relative;
    max-width: calc(59.4cqw - 24px);
    padding: 0 32px 26px;
}

.eyebrow {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6b5d55;
}

h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.lede {
    margin: 8px 0 0;
    max-width: 60ch;
    font-size: 17px;
    color: var(--ink-2);
}

/* link to the Abenteuerkarte (karte.html), with the ship of the tile map */
.map-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding: 6px 16px 6px 8px;
    border: 2px solid var(--ink);
    border-radius: 12px;
    background: #61a2ff;
    box-shadow: 3px 3px 0 var(--ink);
    color: #fff;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    transition: transform 0.1s, box-shadow 0.1s;
}

.map-link[hidden] {
    display: none;
}

.map-link:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--ink);
}

.map-link small {
    display: block;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
}

.map-link-ship {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: url("../assets/tilemap/sprites/MSFloatingPoint.png") -64px 0 / 512px 32px no-repeat;
    image-rendering: pixelated;
}

.map-link:hover .map-link-ship {
    animation: map-link-rock 0.5s steps(1) infinite;
}

@keyframes map-link-rock {
    50% {
        background-position: -96px 0;
    }
}

/* --- Knowledge profile -------------------------------------------------- */

.profile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.profile.is-new {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}

.profile-head {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 18px 24px;
    background: none;
    border: 0;
    text-align: left;
}

.profile-head-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.profile-title {
    font-size: 19px;
    font-weight: 700;
}

.profile-summary {
    color: var(--ink-2);
    font-size: 14px;
}

.summary-shaky {
    color: var(--shaky);
    font-weight: 600;
}

.summary-icon {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
    vertical-align: -4px;
    margin-right: 3px;
}

.profile-head-action {
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
}

.profile.is-new .profile-head-action {
    display: none;
}

.profile-body {
    padding: 0 24px 20px;
}

.profile-steps {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 32px;
    padding: 16px 0 20px;
    border-top: 1px solid var(--line);
}

.step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);  /* the chapter <select> must not force its width */
    gap: 4px 12px;
    align-content: start;
}

.step-no {
    grid-row: span 2;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

.step-text h2 {
    margin: 2px 0 2px;
    font-size: 16px;
    font-weight: 700;
}

.step-text p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.stepper {
    grid-column: 2;
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.stepper select {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1.5px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    font-weight: 600;
}

.stepper-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: 1.5px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    font-size: 20px;
    line-height: 1;
}

.stepper-btn:hover {
    background: var(--surface-2);
}

.legend {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    color: var(--ink-2);
}

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

.rate-glyph {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.rate-glyph.state-unknown,
.rate-btn.state-unknown[aria-pressed="true"] {
    background: var(--unknown);
}

.rate-glyph.state-shaky,
.rate-btn.state-shaky[aria-pressed="true"] {
    background: var(--shaky);
}

.rate-glyph.state-known,
.rate-btn.state-known[aria-pressed="true"] {
    background: var(--ok);
}

.rate-glyph.state-confident,
.rate-btn.state-confident[aria-pressed="true"] {
    background: var(--confident);
}

/* Learning path: one tile per chapter/concept */
.path {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: none;
}

.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1.5px solid var(--line);
    border-radius: 16px;
    background: var(--surface-2);
    transition: border-color 0.15s, background 0.15s;
}

.tile.is-heard {
    background: var(--surface);
    border-color: var(--line-strong);
}

.tile.state-shaky {
    border-color: var(--shaky);
    background: var(--shaky-soft);
}

.tile.state-confident {
    border-color: var(--confident);
}

.tile.is-last {
    border-color: var(--ink);
    box-shadow: 0 0 0 2px var(--ink);
}

.tile-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px 6px;
    border: 0;
    background: none;
    border-radius: 14px 14px 0 0;
    text-align: center;
}

.tile-main:hover .tile-icon {
    transform: translateY(-2px);
}

.tile-no {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tile.is-last .tile-no {
    color: var(--ink);
}

.tile-icon {
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
    transition: transform 0.15s, filter 0.15s, opacity 0.15s;
}

.tile.state-unknown .tile-icon {
    filter: grayscale(1);
    opacity: 0.45;
}

.tile-label {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    min-height: 2.4em;
    display: flex;
    align-items: center;
    hyphens: auto;
    overflow-wrap: anywhere;
}

.tile.state-unknown .tile-label {
    color: var(--muted);
}

.tile-rate {
    display: flex;
    justify-content: center;
    gap: 3px;
    padding: 0 6px 8px;
}

.rate-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}

.rate-btn:hover {
    border-color: var(--ink-2);
    color: var(--ink);
}

.rate-btn[aria-pressed="true"] {
    border-color: transparent;
    color: #fff;
}

.profile-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: 14px;
    font-size: 14px;
    color: var(--ink-2);
}

.link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* --- Controls ----------------------------------------------------------- */

.controls {
    margin-bottom: 20px;
}

.scope {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.scope-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 0;
    border-radius: 999px;
    background: none;
    font-weight: 600;
    color: var(--ink-2);
}

.scope-btn:hover:not(:disabled) {
    background: var(--surface-2);
}

.scope-btn[aria-checked="true"] {
    background: var(--ink);
    color: #fff;
}

.scope-btn:disabled {
    cursor: default;
    opacity: 0.5;
}

.count {
    min-width: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.scope-btn[aria-checked="true"] .count {
    background: rgb(255 255 255 / 0.2);
    color: #fff;
}

.scope-hint {
    margin: 8px 0 14px 4px;
    font-size: 14px;
    color: var(--muted);
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
    margin-bottom: 14px;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-track {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--line-strong);
    transition: background 0.15s;
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
    transition: transform 0.15s;
}

.switch input:checked + .switch-track {
    background: var(--ink);
}

.switch input:checked + .switch-track::after {
    transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.switch:has(input:disabled) {
    cursor: default;
    opacity: 0.45;
}

.search-row {
    display: flex;
    gap: 8px;
}

.search {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 16px 0 42px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23776d67' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m17 17-4.5-4.5'/%3E%3C/svg%3E") no-repeat 14px center;
}

.search:focus {
    border-color: var(--ink-2);
    outline: none;
}

.more-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 16px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    font-weight: 600;
    white-space: nowrap;
}

.more-btn[aria-expanded="true"] {
    border-color: var(--ink);
}

.badge {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 12px;
}

.more {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px 24px;
    margin-top: 10px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.more[hidden] {
    display: none;
}

.facet-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

/* a second label + control inside the same facet cell */
.facet-label-stacked {
    margin-top: 14px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px 5px 12px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 14px;
    font-weight: 500;
}

.chip:hover {
    border-color: var(--line-strong);
}

.chip[aria-pressed="true"] {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
}

.chip[aria-pressed="true"] .count {
    background: rgb(255 255 255 / 0.2);
    color: #fff;
}

.chip[aria-pressed="true"] .dot {
    background: rgb(255 255 255 / 0.35);
}

.chip[aria-pressed="true"] .dot.on {
    background: #fff;
}

.select {
    height: 36px;
    padding: 0 10px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    font-size: 14px;
}

/* Eigener Pfeil statt des nativen, der in Chrome direkt am Rand klebt; currentColor folgt dem Theme */
.select,
.stepper select {
    appearance: none;
    padding-right: 34px;
    background-image:
        linear-gradient(45deg, transparent calc(50% - 1px), currentColor calc(50% - 1px), currentColor calc(50% + 1px), transparent calc(50% + 1px)),
        linear-gradient(135deg, transparent calc(50% - 1px), currentColor calc(50% - 1px), currentColor calc(50% + 1px), transparent calc(50% + 1px));
    background-position: right 18px center, right 12px center;
    background-size: 6px 6px;
    background-repeat: no-repeat;
}

/* --- Results bar -------------------------------------------------------- */

.results-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.results-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.results-count {
    font-size: 15px;
    color: var(--ink-2);
}

.results-count b {
    color: var(--ink);
    font-size: 17px;
}

.active-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.active-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 0;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}

.active-chip span {
    font-size: 15px;
    line-height: 1;
}

.chip-icon {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

.results-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sort {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--muted);
}

.sort .select {
    color: var(--ink);
    font-weight: 600;
}

.seg {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.seg button {
    padding: 5px 14px;
    border: 0;
    border-radius: 7px;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
}

.seg button[aria-pressed="true"] {
    background: var(--ink);
    color: #fff;
}

/* --- Shared bits -------------------------------------------------------- */

.dots {
    display: inline-flex;
    gap: 4px;
    vertical-align: middle;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #c9beb6;
}

.dot.on {
    background: var(--ink);
}

.pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* Table: icon + label pill (icons only at whole-number scales: 16/32/48 px) */
.pill {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px 0 5px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

.pill:hover {
    border-color: var(--ink-2);
}

.pill .concept-icon {
    display: block;
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

.pill-unknown {
    border-style: dashed;
    color: var(--muted);
}

.pill-unknown .concept-icon,
.concept-unknown .concept-icon {
    filter: grayscale(1);
    opacity: 0.5;
}

.pill-shaky {
    border-color: var(--shaky);
    background: var(--shaky-soft);
}

.pill-confident {
    border-color: var(--confident);
}

.pill.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Cards: bare icons with a tooltip; the learning state shows as a small dot */
.concepts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 2px;
}

.concept {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    transition: transform 0.15s;
}

.concept:hover {
    transform: translateY(-2px);
}

.concept .concept-icon {
    display: block;
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.concept-shaky::before,
.concept-confident::before {
    content: "";
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 10px;
    height: 10px;
    border: 2px solid var(--type-bg, var(--surface));
    border-radius: 50%;
    background: var(--shaky);
}

.concept-confident::before {
    background: var(--confident);
}

.concept.is-active {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.concept::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    padding: 5px 9px;
    border-radius: 7px;
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    transform: translate(-50%, 4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s, transform 0.12s;
}

.concept:hover,
.concept:focus-visible {
    z-index: 3;
}

.concept:hover::after,
.concept:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

.features {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
}

.feature {
    font-size: 15px;
    color: var(--ok);
}

.feature::before {
    content: "✔";
    margin-right: 4px;
}

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

.feature-none::before {
    content: "✎";
}

/* "Neu" / "Versteckt" / "Entwurf": same box as the type badge, so they line up */
.new,
.hidden-badge,
.draft-badge {
    display: inline-flex;
    align-items: center;
    height: 24px;
    margin-left: 8px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    vertical-align: 2px;
}

.new {
    background: #fde047;
    color: #422006;
}

.hidden-badge {
    border: 1px dashed var(--ink-2);
    color: var(--ink-2);
}

.draft-badge {
    background: #ffedd5;
    border-color: #ea580c;
    color: #9a3412;
}

.reason {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--ok);
}

.reason::before {
    content: "●";
    font-size: 9px;
}

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

.reason-missing::before {
    content: "🔒";
    font-size: 11px;
}

.reason-shaky {
    color: var(--shaky);
}

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

.reason-easy,
.reason-done {
    color: var(--muted);
}

/* --- Cards -------------------------------------------------------------- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
    gap: 20px;
}

/* Exercise types: colours used by cards, badges and filter chips */
/* muted, slightly warm purple: sits well with the warm banner tones */
.type-lecture { --type: #6b3fa0; --type-soft: #ede5f6; --type-line: #cfbde6; --type-bg: #faf7fc; }
/* Sandkasten: same green as the sandbox slides in the lecture (#74A537) */
.type-sandbox { --type: #3d6a10; --type-soft: #e7f2d8; --type-line: #b5d48c; --type-bg: #74a537; }
.type-exercise { --type: #9a3f28; --type-soft: #f8e5de; --type-line: #e7b7a8; --type-bg: #fdf8f6; }
.type-test { --type: #0f766e; --type-soft: #dcf0ed; --type-line: #a9d6d0; --type-bg: #f6fbfa; }
.type-tool { --type: #4b5563; --type-soft: #e8eaee; --type-line: #c9cdd4; --type-bg: #f8f9fa; }

.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    padding: 0 9px 0 4px;
    border: 1px solid var(--type-line);
    border-radius: 999px;
    background: var(--type-soft);
    color: var(--type);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

/* the chalkboard fills its whole height, so it needs more room at the round edge */
.type-badge.type-lecture {
    padding-left: 7px;
}

.type-icon {
    display: block;
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.card {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 124px; /* preview: 124 x 186 = 2:3 */
    grid-template-rows: auto auto 1fr;
    column-gap: 18px;
    padding: 20px 20px 18px 22px;
    border: 1.5px solid var(--type-line);
    border-radius: 24px;
    background-color: var(--type-bg);
    transition: box-shadow 0.15s;
}

.card:hover {
    box-shadow: 0 8px 28px rgb(16 24 40 / 0.1);
}

/* subtle per-type patterns */
/* concentric rings from the top left corner */
.card.type-lecture {
    background-image: repeating-radial-gradient(circle at 0 0, rgb(107 63 160 / 0.07) 0 1.5px, transparent 1.5px 22px);
}

/* solid lecture green, no pattern */
.card.type-sandbox {
    border-color: #5e8c29;
}

.card.type-sandbox .done-btn {
    border-color: rgb(18 36 2 / 0.22);
    background: rgb(255 255 255 / 0.22);
    color: #16310a;
}

.card.type-sandbox .done-btn:hover {
    border-color: rgb(18 36 2 / 0.5);
}

.card.type-sandbox .done-btn[aria-pressed="true"] {
    border-color: #16310a;
    background: rgb(255 255 255 / 0.4);
    color: #16310a;
}

.card.type-sandbox .card-desc,
.card.type-sandbox .feature-none {
    color: rgb(18 36 2 / 0.75);
}

.card.type-sandbox .card-flag,
.card.type-sandbox .feature,
.card.type-sandbox .reason {
    color: #16310a;
}

.card.type-sandbox .dot {
    background: rgb(18 36 2 / 0.25);
}

.card.type-sandbox .dot.on {
    background: var(--ink);
}

.card.type-sandbox .type-badge {
    border-color: transparent;
    background: rgb(255 255 255 / 0.88);
}

/* fine dots */
.card.type-exercise {
    background-image: radial-gradient(rgb(154 63 40 / 0.14) 1px, transparent 1.4px);
    background-size: 12px 12px;
}

.card.type-test {
    background-image: repeating-linear-gradient(0deg, rgb(15 118 110 / 0.06) 0 1px, transparent 1px 13px);
}

.card.type-tool {
    background-image:
        repeating-linear-gradient(45deg, rgb(75 85 99 / 0.05) 0 1px, transparent 1px 10px),
        repeating-linear-gradient(-45deg, rgb(75 85 99 / 0.05) 0 1px, transparent 1px 10px);
}

.card-body {
    grid-column: 1;
    grid-row: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.card-flag {
    margin-bottom: -4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
}

/* title and badges flow like text: badges follow the title and wrap as a whole */
/* same metrics as the title, so vertical-align: middle centres the badges on it */
.card-head {
    font-size: 20px;
    line-height: 1.2;
}

.card-head .card-title {
    display: inline;
}

/* "middle" instead of a baseline offset: the type badge starts with an icon (no text baseline) */
.card-head .type-badge,
.card-head .new,
.card-head .hidden-badge,
.card-head .draft-badge {
    margin: 0 3px 0 0;  /* separated by spaces, which vanish at the start of a wrapped line */
    vertical-align: middle;
}

.card-title {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.card-title a {
    text-decoration: none;
}

.card-title a::after {
    /* makes the whole card clickable */
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 24px;
}

/* colour instead of underline: an underline would collide with wrapped badges */
.card-title a {
    transition: color 0.15s;
}

.card:hover .card-title a,
.card-title a:focus-visible {
    color: var(--type);
}

.card.type-sandbox:hover .card-title a {
    color: #fff;
}

.card-desc {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--muted);
}

.card-level {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
}

.card-level .dot {
    width: 13px;
    height: 13px;
}

.card-media {
    position: relative;
    grid-column: 2;
    grid-row: 1;
    display: grid;
    place-items: center;
    width: 124px;
    aspect-ratio: 2 / 3;
    border-radius: 16px;
    background: linear-gradient(160deg, hsl(var(--hue) 45% 26%), hsl(calc(var(--hue) + 40) 45% 17%));
    overflow: hidden;
    z-index: 1;
}

/* no background behind previews: it would bleed through the anti-aliased rounded corners */
.card-media.has-image {
    background: none;
}

.card-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    /* no own radius: .card-media's overflow clip already uses the inner (border-adjusted) radius;
       inheriting the outer radius left light gaps in the corners of bordered themes */
    object-fit: cover;
    transition: transform 0.2s;
}

.card:hover .card-image {
    transform: scale(1.04);
}

.card-icon {
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    filter: drop-shadow(0 6px 0 rgb(0 0 0 / 0.25));
    transition: transform 0.2s;
}

.card:hover .card-icon {
    transform: translateY(-4px) scale(1.03);
}

.card-chapter {
    position: absolute;
    left: 10px;
    bottom: 9px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgb(15 20 35 / 0.55);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.card-chapter:hover {
    background: rgb(15 20 35 / 0.8);
}

.card-chapter.is-active {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* sits directly under the preview image */
.done-btn {
    position: relative;
    z-index: 1;
    grid-column: 2;
    grid-row: 2;
    margin-top: 9px;
    padding: 5px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

.done-btn:hover {
    border-color: var(--ink-2);
    color: var(--ink);
}

.done-btn[aria-pressed="true"] {
    border-color: var(--ok);
    background: var(--ok-soft);
    color: var(--ok);
    font-weight: 600;
}

.card.is-locked {
    border-style: dashed;
}

/* the solid green already reads as a frame, a dashed line on top looks doubled */
.card.type-sandbox.is-locked {
    border-style: solid;
    border-color: var(--type-bg);
}

.card.is-locked .card-media {
    filter: saturate(0.3);
    opacity: 0.75;
}

.card.is-done .card-title a {
    color: var(--ink-2);
}

.card.is-done .card-media::after {
    content: "✓";
    position: absolute;
    top: 10px;
    right: 10px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    color: var(--ok);
    font-weight: 800;
}

/* Chapter groups */
.group + .group {
    margin-top: 36px;
}

.group-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    font-size: 20px;
    font-weight: 700;
}

.group-icon {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.group-title {
    display: inline-flex;
    gap: 10px;
    padding: 0 6px;
    margin: 0 -6px;
    border: 0;
    border-radius: 8px;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.group-title:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

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

.group-state {
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.group-state.is-heard {
    background: var(--ok-soft);
    color: var(--ok);
}

.group-count {
    margin-left: auto;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
}

/* --- Table -------------------------------------------------------------- */

.table-wrap {
    container: results-table / inline-size;
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    position: sticky;
    top: 0;
    padding: 10px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-align: left;
    white-space: nowrap;
}

.table th button {
    padding: 0;
    border: 0;
    background: none;
    font-weight: 600;
    color: inherit;
}

.table th[aria-sort="ascending"],
.table th[aria-sort="descending"],
.table th button.is-sorted {
    color: var(--ink);
}

.table th.c-meta[aria-sort] {
    color: var(--muted);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

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

.table tbody tr:hover {
    background: #faf7f4;
}

.table .c-done {
    width: 40px;
    text-align: center;
}

.table .c-done input {
    width: 18px;
    height: 18px;
    accent-color: var(--ok);
    margin-top: 2px;
}

.c-title {
    min-width: 220px;
}

.c-title-inner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.c-thumb {
    flex-shrink: 0;
    width: 44px;
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    object-fit: cover;
    background: #1e2433;
}

.c-thumb-icon {
    display: grid;
    place-items: center;
}

.c-thumb-icon img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.c-title a {
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
}

.c-title a:hover {
    text-decoration: underline;
}

.c-desc {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.c-meta {
    white-space: nowrap;
}

.c-meta-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.c-meta .chapter-btn {
    margin-left: -8px;  /* align the label with the badge; the padding is only for the hover ring */
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 13px;
}

.chapter-btn {
    min-width: 28px;
    padding: 2px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.chapter-btn:hover {
    border-color: var(--line-strong);
}

.chapter-btn.is-active {
    border-color: var(--accent);
    outline: 1px solid var(--accent);
}


.table .dot {
    width: 9px;
    height: 9px;
}

.table .dots {
    gap: 3px;
}

.table .c-reason {
    min-width: 140px;
}

.features-compact {
    flex-direction: column;
    gap: 0;
}

.features-compact .feature {
    font-size: 13px;
    white-space: nowrap;
}

.table .reason {
    font-size: 13px;
    line-height: 1.35;
}

tr.is-locked td:not(:last-child) {
    opacity: 0.6;
}

tr.is-done .c-title a {
    color: var(--muted);
}

/*
 * Narrow tables: no horizontal scrolling. First the concept pills lose their labels (the tooltip
 * keeps the name), then each row turns into a two-line block: title on top, the rest below.
 */
@container results-table (max-width: 900px) {
    .table .pill {
        justify-content: center;
        width: 26px;
        padding: 0;
    }

    .table .pill > span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

@container results-table (max-width: 640px) {
    .table thead {
        display: none;  /* the sort select above the table does the same */
    }

    .table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        column-gap: 16px;
        row-gap: 8px;
        padding: 12px 12px 12px 52px;  /* everything below the title lines up with it */
        border-bottom: 1px solid var(--line);
    }

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

    .table td {
        display: block;
        padding: 0;
        border: 0;
    }

    .table .c-done {
        width: 24px;
        margin-left: -40px;  /* in the padding; with the gap it takes no room in the line */
        align-self: flex-start;
    }

    .table .c-title {
        flex: 1 1 100%;
        min-width: 0;
    }

    .table .c-meta {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .table .c-meta-line {
        margin-top: 0;
    }

    .table .c-meta .chapter-btn {
        margin-left: 0;
    }

    .table .features-compact {
        flex-direction: row;
        flex-wrap: wrap;
        column-gap: 10px;
    }

    .table .c-reason {
        flex-basis: 100%;
        min-width: 0;
    }
}

/* --- Empty state -------------------------------------------------------- */

.empty {
    padding: 48px 24px;
    text-align: center;
    background: var(--surface);
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    color: var(--ink-2);
}

.empty-title {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
}

.empty p {
    margin: 0;
}

.empty-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
}

.btn {
    padding: 8px 16px;
    border: 1.5px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    font-weight: 600;
}

.btn-primary {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
}

/* --- Small screens ------------------------------------------------------ */

@media (max-width: 800px) {
    .profile-steps {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 600px) {
    /* phones: banner scaled to 420px height and cropped from the side to keep the GdI mark;
       the logo shadow then ends 600/1080 * 420 = 233px from the top */
    .page-head {
        padding-top: calc(233px + 16px);
        background:
            linear-gradient(transparent 300px, #ccbfbe 420px),
            url("../img/brand/GdI_banner_tall.jpg") 6% top / auto 420px no-repeat,
            #ccbfbe;
    }

    .hero-text {
        max-width: none;  /* the balloons are outside the phone crop */
        padding: 0 18px 20px;
    }

    .page {
        padding: 20px 16px 48px;
    }

    .profile-head,
    .profile-body {
        padding-left: 16px;
        padding-right: 16px;
    }

    .path {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
        gap: 8px;
    }

    .scope {
        display: grid;
        grid-template-columns: 1fr 1fr;
        border-radius: 18px;
    }

    .scope-btn {
        justify-content: space-between;
        border-radius: 14px;
        padding: 8px 12px;
    }

    .search-row {
        flex-direction: column;
    }

    .more-btn {
        justify-content: center;
    }

    .results-tools {
        width: 100%;
        justify-content: space-between;
    }

    .card {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        padding: 16px 16px 14px;
        border-radius: 20px;
    }

    .card-body {
        grid-row: auto;
    }

    .card-head,
    .card-desc {
        padding-right: 76px;
    }

    .card-title {
        font-size: 18px;
    }

    .card-media {
        position: absolute;
        top: 16px;
        right: 16px;
        width: 64px;
        aspect-ratio: 2 / 3;
        border-radius: 14px;
    }

    .card-icon {
        width: 48px;
        height: 48px;
    }

    .card-chapter {
        display: none;
    }

    .done-btn {
        grid-column: 1;
        grid-row: auto;
        justify-self: start;
        margin-top: 12px;
    }
}
