/* SPDX-License-Identifier: EUPL-1.2
   Teil des Terminfinders. Lizenz: EUPL 1.2, siehe LICENSE.
   Gestaltung: Orange #fab200 als Hausfarbe, Signalrot #e32b23 für Auszeichnungen und „Nein“, Grün für „Ja“,
   Schrift Calibri (ersatzweise Carlito und Systemschriften), Schriftfarbe schwarz.
   Eigene Farben: die Werte unter :root anpassen. Orange und Rot sind zugleich die Farben für „Vielleicht“ und
   „Nein“ – bei anderen Hausfarben auf ausreichenden Kontrast der Abstimm-Knöpfe achten. */

:root {
    --orange: #fab200;
    --orange-600: #e0a000;
    --orange-ink: #93600a;
    --orange-100: #fff3d6;
    --orange-50: #fffaf0;

    --red: #e32b23;
    --red-600: #c11f18;
    --red-100: #fbe2e0;

    --green: #1a8f55;
    --green-600: #147144;
    --green-100: #e0f5ea;

    --ink: #1a1a17;
    --gray-50: #faf9f7;
    --gray-100: #f2f1ed;
    --gray-200: #e4e2db;
    --gray-300: #d1cec3;
    --gray-500: #8c8879;
    --gray-700: #57544a;

    --surface: #ffffff;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 22px;
    --shadow-sm: 0 1px 2px rgba(30, 25, 10, 0.06), 0 1px 1px rgba(30, 25, 10, 0.05);
    --shadow-md: 0 16px 32px -16px rgba(30, 25, 10, 0.28);
    --font-sans: Calibri, Carlito, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--gray-50);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.55;
}

h1, h2, h3 {
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 0.6em;
}

h1 { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem); }
h2 { font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.5rem); margin-top: 2rem; }

p { margin: 0 0 1em; }

a {
    color: var(--orange-ink);
    text-decoration-color: var(--orange-600);
    text-underline-offset: 0.15em;
}

a:hover {
    color: var(--red);
}

/* ---------- Layout shell ---------- */

.brand-bar {
    height: 6px;
    background: linear-gradient(90deg, var(--orange), var(--red));
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--gray-200);
}

.site-header__inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.1rem clamp(1rem, 4vw, 1.75rem);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-header__logo {
    height: 46px;
    width: auto;
    flex-shrink: 0;
}

.site-header__divider {
    width: 1px;
    align-self: stretch;
    background: var(--gray-200);
}

.site-header__brand {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.site-header__title {
    color: var(--ink);
    font-size: 1.35rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: -0.01em;
}

.site-header__tagline {
    margin: 0;
    color: var(--gray-700);
    font-size: 0.92rem;
}

@media (max-width: 480px) {
    .site-header__logo { height: 36px; }
    .site-header__divider { display: none; }
    .site-header__tagline { display: none; }
}

.wrapper {
    max-width: 780px;
    margin: 0 auto;
    padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 1.75rem) 4rem;
}

.site-footer {
    text-align: center;
    padding: 2rem 1rem 3rem;
    color: var(--gray-500);
    font-size: 0.88rem;
}

.site-footer a {
    color: var(--gray-700);
}

/* ---------- Cards & sections ---------- */

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    padding: clamp(1.25rem, 4vw, 2rem);
    margin-bottom: 1.5rem;
}

.intro {
    margin-bottom: 1.75rem;
}

.intro p {
    color: var(--gray-700);
    font-size: 1.05rem;
}

.meta {
    color: var(--gray-700);
}

/* ---------- Forms ---------- */

.form {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form label {
    margin-top: 1rem;
    font-weight: 600;
}

.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form textarea {
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--gray-300);
    background: var(--surface);
    border-radius: var(--radius-sm);
    font: inherit;
    color: var(--ink);
    width: 100%;
}

.form input[type="text"]:focus,
.form input[type="email"]:focus,
.form input[type="password"]:focus,
.form textarea:focus {
    outline: 2px solid var(--orange);
    outline-offset: 1px;
    border-color: var(--orange-600);
}

.form textarea {
    resize: vertical;
}

.form-hint {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.1rem;
    font-weight: 600;
    cursor: pointer;
}

.checkbox-row input {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--orange-600);
}

fieldset {
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius);
    margin-top: 1.25rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

/* Setzt display auf einem Element aus, wird das hidden-Attribut allein
   nicht mehr respektiert (bekannte Falle) - hier explizit erzwingen. */
fieldset[hidden] {
    display: none;
}

legend {
    padding: 0 0.4rem;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--orange-ink);
}

.option-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.option-row input {
    flex: 1;
}

.option-row__remove {
    flex-shrink: 0;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 999px;
    border: 1px solid var(--gray-300);
    background: var(--surface);
    color: var(--gray-700);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.option-row__remove:hover {
    background: var(--red-100);
    border-color: var(--red);
    color: var(--red-600);
}

.option-row--date {
    align-items: stretch;
    flex-wrap: wrap;
}

.date-time-field {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 160px;
}

.date-time-field input[type="text"] {
    flex: 1;
    padding-right: 2.4rem;
}

.date-time-field__icon {
    position: absolute;
    right: 0.15rem;
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
}

.date-time-field__icon:hover {
    background: var(--orange-100);
}

.native-picker {
    position: absolute;
    inset: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    border: none;
}

@media (max-width: 560px) {
    .option-row--date {
        flex-direction: column;
    }

    /* flex-basis: 160px war fuer die Breite in der Zeilen-Anordnung
       gedacht - in Spaltenrichtung wuerde es sonst wieder als Hoehe
       interpretiert (gleiche Falle wie bei .vote-option__label). */
    .date-time-field {
        flex: none;
    }
}

.type-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.type-switch__option {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1rem;
    border: 1.5px solid var(--gray-300);
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    background: var(--surface);
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.type-switch__option input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
}

.type-switch__option:has(input:checked) {
    background: var(--orange-100);
    border-color: var(--orange);
}

.type-switch__option:has(input:focus-visible) {
    outline: 2px solid var(--orange-600);
    outline-offset: 2px;
}

.options-fieldset code {
    background: var(--gray-100);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}

.honeypot {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 1.25rem;
    padding: 0.7rem 1.4rem;
    border: none;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.08s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.button:active {
    transform: translateY(1px);
}

.button--primary {
    background: var(--orange);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

.button--primary:hover {
    background: var(--orange-600);
    box-shadow: var(--shadow-md);
}

.button--secondary {
    background: var(--gray-100);
    color: var(--ink);
}

.button--secondary:hover {
    background: var(--gray-200);
}

.button--danger {
    background: var(--red);
    color: #fff;
}

.button--danger:hover {
    background: var(--red-600);
}

.button--small {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    margin-top: 0;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin: 1.25rem 0;
}

.button-row form {
    margin: 0;
}

/* ---------- Flash messages ---------- */

.flash {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
    margin: 0 0 1.25rem;
    font-weight: 600;
}

.flash ul {
    margin: 0;
    padding-left: 1.2rem;
    font-weight: 400;
}

.flash--success {
    background: var(--green-100);
    color: var(--green-600);
}

.flash--error {
    background: var(--red-100);
    color: var(--red-600);
}

/* ---------- Share/admin link boxes ---------- */

.link-field {
    margin-top: 1rem;
}

.link-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.link-field input {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88rem;
    background: var(--gray-50);
    color: var(--ink);
}

/* ---------- Vote options (segmented choice controls) ---------- */

.vote-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 1rem 0 0;
}

.vote-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.85rem 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.vote-option__label {
    font-weight: 600;
    flex: 1 1 200px;
    min-width: 0;
}

.vote-option__choices {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.choice {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.95rem;
    border-radius: 999px;
    border: 1.5px solid var(--gray-300);
    background: var(--surface);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.choice input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
}

.choice:has(input:focus-visible) {
    outline: 2px solid var(--orange-600);
    outline-offset: 2px;
}

.choice--yes { color: var(--green-600); border-color: var(--green-100); background: var(--green-100); }
.choice--no { color: var(--red-600); border-color: var(--red-100); background: var(--red-100); }
.choice--maybe { color: var(--orange-ink); border-color: var(--orange-100); background: var(--orange-100); }

.choice--yes:has(input:checked) { background: var(--green); border-color: var(--green); color: #fff; }
.choice--no:has(input:checked) { background: var(--red); border-color: var(--red); color: #fff; }
.choice--maybe:has(input:checked) { background: var(--orange); border-color: var(--orange); color: var(--ink); }

@media (max-width: 560px) {
    .vote-option {
        flex-direction: column;
        align-items: stretch;
    }

    .vote-option__label {
        /* flex-basis lief in Spaltenrichtung sonst auf Hoehe statt Breite. */
        flex: none;
    }

    .vote-option__choices {
        justify-content: stretch;
    }

    .choice {
        flex: 1;
    }
}

/* ---------- Results table ---------- */

.table-scroll {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    background: var(--surface);
}

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

table.results th,
table.results td {
    padding: 0.7rem 0.9rem;
    text-align: center;
    white-space: nowrap;
    border-bottom: 1px solid var(--gray-200);
}

table.results th {
    background: var(--gray-50);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--gray-700);
}

table.results td:first-child,
table.results th:first-child {
    text-align: left;
    white-space: normal;
    position: sticky;
    left: 0;
    background: var(--surface);
    font-weight: 600;
    box-shadow: 1px 0 0 var(--gray-200);
}

table.results th:first-child {
    background: var(--gray-50);
    z-index: 1;
}

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

table.results tfoot th {
    background: var(--gray-100);
    border-top: 2px solid var(--gray-200);
    border-bottom: none;
}

.vote--yes { background: var(--green-100); }
.vote--no { background: var(--red-100); }
.vote--maybe { background: var(--orange-100); }

/* Termin(e) mit den meisten Ja-Stimmen. */
table.results th.is-best,
table.results td.is-best {
    box-shadow: inset 0 0 0 2px var(--orange);
}

table.results th.is-best {
    background: var(--orange-100);
    color: var(--orange-ink);
}

/* ---------- Comments ---------- */

.comment {
    padding: 0.9rem 1.1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
}

.comment__meta {
    margin: 0 0 0.3rem;
    font-size: 0.85rem;
    color: var(--gray-700);
}

.comment p:last-child {
    margin-bottom: 0;
}

/* ---------- Admin ---------- */

.status-pill {
    display: inline-flex;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-pill--open { background: var(--green-100); color: var(--green-600); }
.status-pill--closed { background: var(--gray-200); color: var(--gray-700); }

.admin-note {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--gray-700);
}

.option-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.option-edit input[type="text"] {
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--gray-300);
    background: var(--surface);
    border-radius: var(--radius-sm);
    font: inherit;
    color: var(--ink);
    min-width: 12rem;
}

.option-edit input[type="text"]:focus {
    outline: 2px solid var(--orange);
    outline-offset: 1px;
    border-color: var(--orange-600);
}

.option-locked {
    font-size: 0.85rem;
    color: var(--gray-700);
    white-space: nowrap;
}
