/* ============================================
   TCS DOI Template Styles – Refaktor v2
   Struktur:
   1. Design Tokens (CSS Variablen)
   2. Reset & Base
   3. Layout (Body, Logo, Card)
   4. Typografie
   5. Formulare
   6. Buttons
   7. Meldungen & Fehler
   8. Modal
   9. Animationen & Reduced Motion
   10. Responsive Breakpoints
   11. Dark Mode Override (helles CI)
   ============================================ */


/* ============================================
   1. Design Tokens
   ============================================ */

:root {
    /* Farben Basis */
    --tcs-color-text: #000000;
    --tcs-color-bg-page: #f2f2f2;
    --tcs-color-bg-card: #f7f2e9;

    /* Primärfarben */
    --tcs-color-primary: #69a024;
    --tcs-color-primary-dark: #56811f;
    --tcs-color-primary-darker: #476919;
    --tcs-color-primary-disabled: #cbd8b5;

    /* Text sekundär */
    --tcs-color-text-muted: #555555;
    --tcs-color-help-text: #666666;

    /* Rahmen und Linien */
    --tcs-color-border: #cccccc;
    --tcs-color-border-light: #eeeeee;

    /* Fehler */
    --tcs-color-error-bg: #ffebee;
    --tcs-color-error-border: #e57373;
    --tcs-color-error-text: #c62828;
    --tcs-color-error-field-border: #cd0046;
    --tcs-color-error-shadow: rgba(205, 0, 70, 0.15);

    /* OK */
    --tcs-color-ok: #69A023;

    /* Overlays */
    --tcs-color-overlay: rgba(0, 0, 0, 0.5);
    --tcs-color-shadow-card: rgba(0, 0, 0, 0.06); 
    --tcs-color-shadow-modal: rgba(0, 0, 0, 0.3);

    /* Fokus */
    --tcs-color-focus-outline: #69a024;
    --tcs-color-focus-shadow: rgba(105, 160, 36, 0.25);

    /* Typografie */
    --tcs-font-base: "MuseoSans", Arial, Helvetica, sans-serif;
    --tcs-font-heading: "MuseoSlab", serif;

    --tcs-font-size-base: 18px;
    --tcs-font-size-h1: 26px;
    --tcs-font-size-subtitle: 16px;
    --tcs-font-size-input: 18px;
    --tcs-font-size-button: 18px;
    --tcs-font-size-ok-error: 20px;
    --tcs-font-size-help-small: 13px;
}


/* ============================================
   2. Reset & Base
   ============================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

/* Font Faces */
@font-face {
    font-family: "MuseoSans";
    font-style: normal;
    font-weight: 300;
    src: url(https://storage.googleapis.com/static-imgs/TCSTCS/Fonts/MuseoSans-300.woff2) format("woff2");
}

@font-face {
    font-family: "MuseoSans";
    font-style: normal;
    font-weight: 700;
    src: url(https://storage.googleapis.com/static-imgs/TCSTCS/Fonts/MuseoSans_700.woff2) format("woff2");
}

@font-face {
    font-family: "MuseoSlab";
    font-style: normal;
    font-weight: 300;
    src: url(https://storage.googleapis.com/static-imgs/TCSCOM/Fonts/Museo_Slab_300.woff2) format("woff2");
}

@font-face {
    font-family: "MuseoSlab";
    font-style: normal;
    font-weight: 700;
    src: url(https://storage.googleapis.com/static-imgs/TCSCOM/Fonts/Museo_Slab_700.woff2) format("woff2");
}

/* Base HTML */
html {
    font-family: var(--tcs-font-base);
    font-weight: 300;
    font-size: var(--tcs-font-size-base);
    line-height: 1.5;
    color: var(--tcs-color-text);
    transition: 0.3s;
}

/* ============================================
   3. Layout (Body, Logo, Card)
   ============================================ */

body {
    background-color: var(--tcs-color-bg-page);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Logo */
.logo {
    position: absolute;
    top: 0;
    left: 10vw;
    z-index: 1;
    margin: 0 !important;
    padding: 0 !important;
    max-width: 110px;
    box-shadow: none !important;
    background: transparent !important;
}

.logo img {
    display: block;
    width: 100%;
    height: auto;
    max-width: inherit;
}

/* Card / Wrapper */
.wrap {
    max-width: 830px;
    width: 100%;
    padding: 40px;
    background: var(--tcs-color-bg-card);
    border-radius: 4px;
    margin: 20px;
    box-shadow: 0 1px 6px var(--tcs-color-shadow-card);
}

/* ============================================
   4. Typografie
   ============================================ */

h1 {
    font-family: var(--tcs-font-heading);
    font-weight: 700;
    font-size: var(--tcs-font-size-h1);
    line-height: 30px;
    padding: 10px 0;
    margin: 0;
    text-align: left;
}

.wrap > p {
    color: var(--tcs-color-text-muted);
    font-size: var(--tcs-font-size-subtitle);
    margin: 4px 0 24px 0;
}

/* Diagnostics */
pre {
    background: var(--tcs-color-bg-card);
    padding: 12px;
    border-radius: 8px;
    overflow: auto;
    font-size: 13px;
}


/* ============================================
   5. Formulare
   ============================================ */

form {
    width: 100%;
    margin-bottom: 30px;
}

/* Label */
label {
    display: block;
    margin: 20px 0 8px 0;
    font-weight: 700;
}

/* Pflichtfeld-Markierung */
label.required::after {
    content: " *";
    color: var(--tcs-color-text);
}

/* Feldgruppen */
.fld {
    margin: 20px 0;
}

/* Inputs */
.inp {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--tcs-color-border);
    border-radius: 4px;
    font-size: var(--tcs-font-size-input);
    font-family: var(--tcs-font-base);
    font-weight: 300;
    background-color: #ffffff;
    color: var(--tcs-color-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.inp:focus {
    border-color: var(--tcs-color-primary);
    outline: none;
    box-shadow: 0 0 0 2px var(--tcs-color-focus-shadow);
}

.inp:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    color: #999999;
}

/* Browserseitige HTML5-Validierung */
.inp:invalid {
    border-color: var(--tcs-color-error-field-border);
}

/* Nur Salutation verkleinern */
#salutation.inp {
    width: 40%;
    max-width: 260px;
    min-width: 150px;
}

/* Select allgemein */
select.inp {
    appearance: auto;
    cursor: pointer;
    background-color: #ffffff;
}

/* Checkboxen */
.chk-label {
    font-weight: normal;
    display: flex;
    align-items: center;
    column-gap: 8px;
    cursor: pointer;
}

.chk-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* Hilfstext unter AGB */
.help-text {
    color: var(--tcs-color-help-text);
    margin: 4px 0 0 28px;
    display: block;
    font-size: var(--tcs-font-size-help-small);
}

/* Feldfehler */
.fld .fld-msg {
    font-size: 13px;
}

.fld-error .inp {
    border-color: var(--tcs-color-error-field-border);
    box-shadow: 0 0 0 2px var(--tcs-color-error-shadow);
}

.fld-error .fld-msg {
    color: var(--tcs-color-error-field-border);
    font-size: 14px;
    margin-top: 4px;
}


/* ============================================
   6. Buttons & Links
   ============================================ */

.btn {
    background-color: var(--tcs-color-primary);
    color: #ffffff;
    padding: 15px 40px;
    font-size: var(--tcs-font-size-button);
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    margin-top: 20px;
    display: block;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: var(--tcs-color-primary-dark);
}

.btn:active {
    background-color: var(--tcs-color-primary-darker);
}

.btn:disabled {
    background-color: var(--tcs-color-primary-disabled);
    cursor: not-allowed;
}

/* Teilnahmebedingungen Link */
.terms-link {
    color: var(--tcs-color-primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 700;
}

.terms-link:hover,
.terms-link:focus {
    color: var(--tcs-color-primary-dark);
}

/* Fokus für interaktive Elemente */
.btn:focus-visible,
.terms-link:focus-visible,
.modal-close:focus-visible {
    outline: 2px solid var(--tcs-color-focus-outline);
    outline-offset: 3px;
}


/* ============================================
   7. Meldungen & Fehlerblöcke
   ============================================ */

/* Success Message */
.ok {
    font-size: var(--tcs-font-size-ok-error);
    font-weight: 700;
    line-height: 1.2;
}

/* Globaler Fehlerblock */
.error {
    background-color: var(--tcs-color-error-bg);
    border: 1px solid var(--tcs-color-error-border);
    color: var(--tcs-color-error-text);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 16px;
}

/* Page B – OK / Error Zeilenstil mit Icons */
.wrap .ok,
.wrap .error {
    background: none;
    border: none;
    font-weight: 700;
    font-size: var(--tcs-font-size-ok-error);
    margin-top: 16px;
    margin-bottom: 0;
    display: flex;
    align-items: flex-start;
    column-gap: 8px;
}

/* OK grün */
.wrap .ok {
    color: var(--tcs-color-ok);
}

/* Error rot */
.wrap .error {
    color: var(--tcs-color-error-field-border);
}

/* Icons vor den Meldungen */
.wrap .ok::before,
.wrap .error::before {
    display: inline-block;
    font-size: 22px;
    line-height: 1;
    margin-top: 1px;
}

/* Häkchen */
.wrap .ok::before {
    content: "✔";
    color: var(--tcs-color-ok) !important;
}

/* Warnsymbol */
.wrap .error::before {
    content: "⚠";
}


/* ============================================
   8. Modal
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: var(--tcs-color-overlay);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.show {
    display: flex;
    animation-name: fadeIn;
    animation-duration: 0.2s;
    animation-timing-function: ease-out;
}

.modal-content {
    background: #ffffff;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 4px 20px var(--tcs-color-shadow-modal);
    animation-name: slideUp;
    animation-duration: 0.3s;
    animation-timing-function: ease-out;
}

/* Modal Header */
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--tcs-color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-family: var(--tcs-font-heading);
    font-weight: 700;
}

/* Modal Close Button */
.modal-close {
    background: none;
    border: 0;
    font-size: 28px;
    color: #666666;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #000000;
}

/* Modal Body */
.modal-body {
    padding: 24px;
    line-height: 1.6;
    font-size: 15px;
}

.modal-body h3 {
    margin: 16px 0 8px 0;
    font-size: 16px;
    font-family: var(--tcs-font-heading);
    font-weight: 700;
}

.modal-body p {
    margin: 8px 0;
}

.modal-body a {
    color: var(--tcs-color-primary);
    text-decoration: underline;
}

.modal-body a:hover {
    color: var(--tcs-color-primary-dark);
}


/* ============================================
   9. Animationen & Reduced Motion
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .modal.show {
        animation-name: none;
        animation-duration: 0s;
    }
    .modal-content {
        animation-name: none;
        animation-duration: 0s;
    }
    .inp {
        transition: none;
    }
}


/* ============================================
   10. Responsive Breakpoints
   ============================================ */

/* Mobile & Tablet – Inhalt oben statt zentriert */
@media only screen and (max-width: 1024px) {
    body {
        align-items: flex-start;
        padding-top: 120px; /* Logo-Höhe (~100–110px) + Abstand (30–40px) */
    }
}

/* Desktop big */
@media only screen and (max-width: 1600px) {
    .wrap {
        max-width: 60%;
        padding: 40px;
    }
    .logo {
        max-width: 110px;
        left: 8vw;
    }
}

/* Desktop medium */
@media only screen and (max-width: 1440px) {
    html {
        font-size: 17px;
    }

    h1 {
        font-size: 24px;
        line-height: 28px;
    }

    .inp {
        font-size: 17px;
    }

    .btn {
        font-size: 17px;
    }

    .wrap {
        max-width: 60%;
        padding: 30px;
    }

    .logo {
        max-width: 80px;
        left: 6vw;
    }
}

/* Tablet */
@media only screen and (max-width: 768px) {
    html {
        font-size: 16px;
    }

    body {
        background-color: var(--tcs-color-bg-page);
        background-size: contain;
        background-position: center 0;
    }

    .wrap {
        max-width: 90%;
        padding: 30px;
        margin: 60px 10px 10px 10px;
    }

    h1 {
        font-size: 22px;
        line-height: 26px;
    }

    .inp {
        font-size: 16px;
    }

    .btn {
        font-size: 16px;
    }

    .logo {
        left: 5vw;
        max-width: 60px;
    }
}

/* Tablet big portrait */
@media only screen and (min-device-width: 1024px) and (orientation: portrait) {
    html {
        font-size: 18px;
    }

    h1 {
        font-size: 24px;
        line-height: 28px;
    }

    .inp {
        font-size: 18px;
    }

    .btn {
        font-size: 18px;
    }

    body {
        background-color: var(--tcs-color-bg-page);
        background-size: contain;
        background-position: center 0;
    }
}

/* Tablet portrait (Alternative Layout) */
@media only screen and (max-device-width: 768px) and (orientation: portrait) {
    body {
        background-color: var(--tcs-color-bg-page);
        background-size: contain;
        background-position: center 0;
    }

    .wrap {
        max-width: 90%;
        padding: 20px 30px;
    }

    .logo {
        left: 5vw;
        max-width: 60px;
    }
}

/* Tablet landscape */
@media only screen and (max-device-width: 812px) and (orientation: landscape) {
    body {
        background-image: none !important;
        background-color: var(--tcs-color-bg-page);
    }

    .wrap {
        max-width: 90%;
        padding: 20px 30px;
    }

    .logo {
        left: 4vw;
        max-width: 70px;
    }
}

/* Mobile */
@media only screen and (max-width: 450px) {
    html {
        font-size: 15px;
    }

    body {
        background-position: center top;
        padding: 80px 10px 10px 10px;
    }

    .wrap {
        max-width: 100%;
        padding: 20px;
        margin: 0;
    }

    .logo {
        left: 3vw;
        max-width: 60px;
    }

    h1 {
        font-size: 20px;
        line-height: 24px;
    }

    .inp {
        font-size: 15px;
    }

    .btn {
        font-size: 15px;
        padding: 12px 30px;
    }
}

/* Mobile small */
@media only screen and (max-width: 320px) {
    html {
        font-size: 14px;
    }

    .wrap {
        padding: 14px;
    }

    h1 {
        font-size: 18px;
        line-height: 22px;
    }

    .inp {
        font-size: 14px;
    }

    .btn {
        font-size: 14px;
    }

    .logo {
        left: 2vw;
        max-width: 50px;
    }
}

/* Modal Mobile Optimierung + Salutation auf Mobile */
@media (max-width: 480px) {
    .modal-content {
        max-height: 90vh;
        border-radius: 10px;
    }

    .modal-body {
        padding: 16px;
    }

    #salutation.inp {
        width: 100%;
        max-width: none;
        min-width: 0;
    }
}


/* ============================================
   11. Dark Mode Override – immer helles CI
   ============================================ */

@media (prefers-color-scheme: dark) {

    html {
        color: var(--tcs-color-text) !important;
    }

    body {
        background-color: var(--tcs-color-bg-page) !important;
        background-size: cover !important;
        background-position: center center !important;
        background-repeat: no-repeat !important;
    }

    .wrap {
        background-color: var(--tcs-color-bg-card) !important;
        box-shadow: 0 2px 10px var(--tcs-color-shadow-card) !important;
    }

    h1 {
        color: var(--tcs-color-text) !important;
    }

    .wrap > p {
        color: var(--tcs-color-text-muted) !important;
    }

    .inp {
        background-color: #ffffff !important;
        color: var(--tcs-color-text) !important;
        border-color: var(--tcs-color-border) !important;
    }

    select.inp {
        background-color: #ffffff !important;
        color: var(--tcs-color-text) !important;
    }

    label.required::after {
        color: var(--tcs-color-text) !important;
    }

    .help-text {
        color: var(--tcs-color-help-text) !important;
    }

    .error {
        background-color: var(--tcs-color-error-bg) !important;
        border-color: var(--tcs-color-error-border) !important;
        color: var(--tcs-color-error-text) !important;
    }

    .ok {
        color: var(--tcs-color-ok) !important;
    }

    .wrap .ok {
        color: var(--tcs-color-ok) !important;
    }

    .wrap .error {
        color: var(--tcs-color-error-field-border) !important;
    }

    .btn {
        background-color: var(--tcs-color-primary) !important;
        color: #ffffff !important;
    }

    .btn:hover {
        background-color: var(--tcs-color-primary-dark) !important;
    }

    .terms-link {
        color: var(--tcs-color-primary) !important;
    }

    .terms-link:hover,
    .terms-link:focus {
        color: var(--tcs-color-primary-dark) !important;
    }

    .modal-content {
        background-color: #ffffff !important;
        color: var(--tcs-color-text) !important;
    }

    .modal-header {
        border-bottom-color: var(--tcs-color-border-light) !important;
    }

    .modal-body a {
        color: var(--tcs-color-primary) !important;
    }

    .modal-body a:hover {
        color: var(--tcs-color-primary-dark) !important;
    }
}