/* cerbnet – gemeinsames Layout und Bedienelemente der Werkzeuge */

:root {
    --edge: 120px;
}

@media (max-width: 1100px) {
    :root { --edge: 48px; }
}
@media (max-width: 700px) {
    :root { --edge: 16px; }
}

/* ---------- Kopf, Einblenden, Zurück ---------- */

.tool-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 40px var(--edge) 0 max(16px, calc(var(--edge) - 64px));
}

.back-button {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: 2px solid currentColor;
    border-radius: 50%;
    color: var(--text);
    text-decoration: none;
}

.back-button .icon {
    width: 22px;
    height: 22px;
    stroke-width: 2;
}

.back-button:hover {
    background: color-mix(in srgb, var(--text) 14%, transparent);
}

.back-button:active {
    background: var(--text);
    color: var(--bg);
}

.tool-title {
    margin: 0;
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    font-weight: 300;
    line-height: 1.2;
}

.tool-main {
    max-width: calc(1180px + 2 * var(--edge));
    padding: 28px var(--edge) 48px;
}

.tool-intro {
    max-width: 70ch;
    margin: 0 0 24px;
    color: var(--text-muted);
}

.tool-footer {
    flex-wrap: wrap;
    padding: 0 var(--edge) 28px;
}

.tool-header,
.tool-main {
    animation: tool-enter 420ms var(--ease-out) both;
}

.tool-main {
    animation-delay: 50ms;
}

@keyframes tool-enter {
    from {
        opacity: 0;
        transform: translateX(48px);
    }
}

/* Farbfläche aus der Startseite blendet aus */
html.is-launched body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--accent);
    pointer-events: none;
    animation: splash-out 260ms ease-out 80ms both;
}

@keyframes splash-out {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

html.is-leaving .tool-header,
html.is-leaving .tool-main {
    opacity: 0;
    transform: translateX(48px);
    transition: opacity 150ms ease-in, transform 150ms ease-in;
}

@media (max-width: 700px) {
    .tool-header {
        padding: 20px var(--edge) 0;
        gap: 14px;
    }
    .back-button {
        width: 38px;
        height: 38px;
    }
    .tool-main {
        padding-top: 20px;
    }
}

/* ---------- Typografie & Abschnitte ---------- */

.tool-main h2 {
    margin: 36px 0 14px;
    font-size: 1.5rem;
    font-weight: 300;
    line-height: 1.3;
}

.tool-main h2:first-child {
    margin-top: 0;
}

.tool-main h3 {
    margin: 24px 0 10px;
    font-size: 1.125rem;
    font-weight: 400;
}

.tool-main p {
    max-width: 75ch;
}

.tool-main a {
    color: var(--text);
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

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

.mono {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--surface-2);
    padding: 1px 5px;
}

/* ---------- Layout-Helfer ---------- */

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    /* Unten ausrichten: Bricht eine Beschriftung um, wächst sie nach oben und die Eingaben bleiben auf einer Linie */
    align-items: end;
    gap: 16px 20px;
}

.columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 32px;
    align-items: start;
}

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

.panel {
    background: var(--surface);
    padding: 20px;
}

[hidden] {
    display: none !important;
}

/* ---------- Formulare ---------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field > span,
.field-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.field small {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 2px solid var(--border);
    border-radius: 0;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 400;
}

/* Einzeilige Felder immer gleich hoch – egal welche Schrift oder welcher Feldtyp */
input[type="text"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="date"],
select {
    height: 42px;
    padding-top: 0;
    padding-bottom: 0;
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--border-strong);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--focus);
}

textarea {
    min-height: 10rem;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.5;
}

input[type="checkbox"],
input[type="radio"],
input[type="range"] {
    accent-color: var(--accent);
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

input[type="range"] {
    width: 100%;
}

input[type="color"] {
    width: 56px;
    height: 42px;
    padding: 2px;
    border: 2px solid var(--border);
    background: var(--surface);
}

/* Für Werkzeuge mit wenigen Feldern: nicht über die ganze Breite ziehen */
.narrow-tool {
    max-width: 760px;
}

/* Mehrere Checkboxen in Spalten */
.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    gap: 10px 16px;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.input-error {
    border-color: var(--fail) !important;
}

/* Umschalter aus Radio-Buttons */
.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    border: 2px solid var(--border-strong);
}

.segmented label {
    position: relative;
    padding: 7px 16px;
    cursor: pointer;
    font-weight: 400;
}

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

.segmented label:has(input:checked) {
    background: var(--accent);
    color: #fff;
}

.segmented label:has(input:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: -4px;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 6px 18px;
    border: 2px solid var(--border-strong);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 400;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

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

.btn:active {
    background: var(--text);
    color: var(--bg);
}

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

.btn--primary:hover {
    background: color-mix(in srgb, var(--accent) 85%, #fff);
}

.btn--small {
    min-height: 32px;
    padding: 2px 10px;
    font-size: 0.875rem;
}

.btn .icon {
    width: 18px;
    height: 18px;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ---------- Ausgaben ---------- */

.output {
    margin: 0;
    padding: 12px 14px;
    background: var(--surface);
    border-left: 4px solid var(--accent);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 2.75rem;
}

.output-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.output-row .output {
    flex: 1;
    min-width: 0;
}

.result-big {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 300;
    line-height: 1.2;
    word-break: break-all;
}

.kv {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 8px 24px;
    margin: 0;
}

.kv dt {
    color: var(--text-muted);
}

.kv dd {
    margin: 0;
    font-weight: 400;
    overflow-wrap: anywhere;
}

@media (max-width: 500px) {
    .kv {
        grid-template-columns: minmax(0, 1fr);
        gap: 2px;
    }
    .kv dd {
        margin-bottom: 10px;
    }
}

.badge {
    display: inline-block;
    padding: 1px 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.6;
    color: #fff;
    background: #5a5a5a;
    white-space: nowrap;
}

.badge--pass { background: #1e7145; }
.badge--fail { background: #b91d47; }
.badge--warn { background: #8a4a00; }
.badge--info { background: #2b5797; }

.notice {
    max-width: 75ch;
    margin: 0;
    padding: 12px 16px;
    background: var(--surface);
    border-left: 4px solid var(--accent);
}

.notice--warn { border-left-color: var(--warn); }
.notice--error { border-left-color: var(--fail); }
.notice--ok { border-left-color: var(--pass); }

.notice-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

table.data {
    width: 100%;
    border-collapse: collapse;
}

table.data th,
table.data td {
    padding: 8px 16px 8px 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

table.data th {
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.table-wrap {
    overflow-x: auto;
}

details {
    background: var(--surface);
    padding: 0 16px;
}

details > summary {
    padding: 12px 0;
    cursor: pointer;
    font-weight: 400;
}

details[open] {
    padding-bottom: 16px;
}

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 16px;
    border: 2px dashed var(--border-strong);
    text-align: center;
}

.dropzone.is-over {
    border-color: var(--text);
    background: var(--surface);
}

@media (prefers-reduced-motion: reduce) {
    html.is-launched body::before {
        display: none;
    }
}

.field--narrow {
    max-width: 420px;
}

/* Impressum & Datenschutz */
.legal {
    max-width: calc(80ch + 2 * var(--edge));
}

.legal .notice {
    margin-bottom: 8px;
}
