/**
 * DF Handstilstränare v1.0.0
 * CSS - pergament/papper-tema med riktig handstilsrendering
 */

/* ============================================================
   WRAPPER OCH GRUNDLAYOUT
   ============================================================ */

.dfh-wrapper {
    font-family: inherit;
    max-width: 100%;
    margin: 1.5em 0;
    background: #f5ede0;
    border: 1px solid #c4a682;
    border-radius: 8px;
    overflow: hidden;
}

.dfh-header {
    padding: 1.5em 1.5em 1em;
    background: linear-gradient(135deg, #e8d4b0 0%, #d4ba8c 100%);
    border-bottom: 1px solid #a88555;
}

.dfh-title {
    margin: 0 0 0.3em 0;
    font-size: 1.4em;
    color: #2c1810;
}

.dfh-intro {
    margin: 0;
    color: #4a3424;
    font-size: 0.95em;
    line-height: 1.5;
}

/* ============================================================
   TABS
   ============================================================ */

.dfh-tabs {
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    border-bottom: 2px solid #a88555;
    padding: 0;
    margin: 0;
}

.dfh-tab {
    flex: 1 1 auto;
    white-space: nowrap;
    padding: 0.9em 1em;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95em;
    font-family: inherit;
    color: #5a4530;
    border-right: 1px solid #efe3cc;
    transition: background-color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.5em;
    justify-content: center;
}

.dfh-tab:hover {
    background: #f8efdb;
    color: #2c1810;
}

.dfh-tab-active {
    background: #a88555;
    color: #fff;
    font-weight: 600;
    border-bottom: 2px solid #7a5d3a;
    margin-bottom: -2px;
}

.dfh-tab-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    background: rgba(122, 93, 58, 0.15);
    border-radius: 50%;
    font-size: 0.85em;
    font-weight: 600;
}

.dfh-tab-active .dfh-tab-num {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================
   PANELS
   ============================================================ */

.dfh-panel {
    display: none;
    padding: 1.5em;
    background: #fff;
}

.dfh-panel-active {
    display: block;
}

.dfh-panel h3 {
    margin: 0 0 0.5em 0;
    color: #2c1810;
    font-size: 1.2em;
}

.dfh-panel h4 {
    margin: 1.5em 0 0.5em;
    color: #2c1810;
    font-size: 1.05em;
}

.dfh-panel-intro {
    margin: 0 0 1em;
    color: #4a3424;
    line-height: 1.6;
}

.dfh-panel ul, .dfh-panel ol {
    color: #4a3424;
    line-height: 1.6;
}

/* ============================================================
   FORM
   ============================================================ */

.dfh-form-row {
    margin-bottom: 1em;
}

.dfh-form-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1em;
    min-width: 0;
}

.dfh-form-row-grid > div {
    min-width: 0;
}

.dfh-label {
    display: block;
    margin-bottom: 0.3em;
    font-weight: 600;
    color: #2c1810;
    font-size: 0.9em;
}

.dfh-input,
.dfh-select {
    width: 100%;
    padding: 0.55em 0.7em;
    font-size: 1em;
    font-family: inherit;
    background: #fff;
    border: 1px solid #c4a682;
    border-radius: 4px;
    color: #2c1810;
    box-sizing: border-box;
}

.dfh-input:focus,
.dfh-select:focus {
    outline: 2px solid #a88555;
    outline-offset: -1px;
    border-color: #a88555;
}

.dfh-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a88555' stroke-width='2.5'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.6em center;
    background-size: 14px;
    padding-right: 2.2em;
}

/* ============================================================
   HANDSTIL-RENDERING
   ============================================================ */

/* Pappersbakgrund */
.dfh-papper {
    position: relative;
    padding: 2.5em 2em;
    margin: 1em auto;
    max-width: 600px;
    background:
        linear-gradient(135deg, #f9f1e0 0%, #f5ead4 100%);
    background-size: cover;
    border: 1px solid #c4a682;
    border-radius: 4px;
    box-shadow:
        0 2px 8px rgba(122, 93, 58, 0.15),
        inset 0 0 60px rgba(122, 93, 58, 0.08);
    text-align: center;
}

/* Pappersfläckar och åldrat utseende via pseudo-element */
.dfh-papper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(180, 130, 70, 0.08) 0%, transparent 40%),
        radial-gradient(ellipse at 80% 70%, rgba(180, 130, 70, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 60% 20%, rgba(160, 110, 50, 0.05) 0%, transparent 30%);
    pointer-events: none;
    border-radius: 4px;
}

.dfh-papper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2em,
            rgba(122, 93, 58, 0.03) 2em,
            rgba(122, 93, 58, 0.03) calc(2em + 1px)
        );
    pointer-events: none;
    border-radius: 4px;
}

/* Huvud-handstil: stor och dramatisk */
.dfh-handstil {
    position: relative;
    z-index: 1;
    font-family: 'Tangerine', 'Cormorant Garamond', 'Brush Script MT', cursive;
    font-style: italic;
    font-weight: 700;
    font-size: 3.5em;
    line-height: 1.2;
    color: #2c1810;
    text-shadow: 1px 1px 0 rgba(74, 52, 36, 0.05);
    letter-spacing: 0.02em;
    transform: rotate(-1deg);
    filter: contrast(1.05);
}

/* Medium handstil för fraser */
.dfh-handstil-medium {
    font-family: 'Tangerine', 'Cormorant Garamond', 'Brush Script MT', cursive;
    font-style: italic;
    font-weight: 700;
    font-size: 2.2em;
    line-height: 1.3;
    color: #2c1810;
    letter-spacing: 0.02em;
}

/* Liten handstil för alfabetstabell */
.dfh-handstil-litet {
    font-family: 'Tangerine', 'Cormorant Garamond', 'Brush Script MT', cursive;
    font-style: italic;
    font-weight: 700;
    font-size: 1.8em;
    line-height: 1.2;
    color: #2c1810;
}

/* ============================================================
   PROV
   ============================================================ */

.dfh-trana-controls {
    margin-bottom: 1em;
    padding: 1em;
    background: #fcf7ed;
    border-radius: 6px;
    border: 1px solid #e0c9a4;
}

.dfh-prov {
    margin: 1.5em 0;
}

.dfh-ordvisning {
    text-align: center;
    margin-bottom: 1.5em;
}

.dfh-meta {
    margin: 0.5em 0 1em;
    color: #5a4530;
    font-size: 0.95em;
    font-style: italic;
}

/* ============================================================
   FLERVAL-KNAPPAR
   ============================================================ */

.dfh-flerval {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8em;
    margin: 1em 0;
}

.dfh-svar-knapp {
    display: flex;
    align-items: flex-start;
    gap: 0.6em;
    padding: 1em 1.2em;
    background: #fff;
    border: 2px solid #c4a682;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-family: inherit;
    color: #2c1810;
    text-align: left;
    transition: all 0.15s ease;
    line-height: 1.4;
}

.dfh-svar-knapp:hover:not(:disabled) {
    background: #fcf7ed;
    border-color: #a88555;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(122, 93, 58, 0.15);
}

.dfh-svar-knapp:disabled {
    cursor: default;
    opacity: 0.7;
}

.dfh-svar-knapp.dfh-svar-ratt {
    background: #e8f4dd;
    border-color: #5a8a3a;
    color: #2a4a14;
    opacity: 1;
}

.dfh-svar-knapp.dfh-svar-fel {
    background: #fdeded;
    border-color: #b73a3a;
    color: #5a1a1a;
    opacity: 1;
}

.dfh-svar-bokstav {
    font-weight: 700;
    color: #a88555;
    flex-shrink: 0;
}

.dfh-svar-text {
    flex: 1;
}

/* ============================================================
   SKRIVLAEN
   ============================================================ */

.dfh-skriva {
    margin: 1em 0;
}

.dfh-skriva input {
    margin-bottom: 0.8em;
}

/* ============================================================
   FEEDBACK
   ============================================================ */

.dfh-feedback {
    margin-top: 1.2em;
}

.dfh-feedback-ratt,
.dfh-feedback-fel {
    padding: 1em 1.3em;
    border-radius: 6px;
    border-left: 4px solid;
    margin-bottom: 0.5em;
}

.dfh-feedback-ratt {
    background: #e8f4dd;
    border-left-color: #5a8a3a;
    color: #2a4a14;
}

.dfh-feedback-fel {
    background: #fdeded;
    border-left-color: #b73a3a;
    color: #5a1a1a;
}

.dfh-feedback p {
    margin: 0.3em 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.dfh-btn {
    padding: 0.65em 1.3em;
    font-size: 1em;
    font-family: inherit;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    margin-right: 0.5em;
    margin-top: 0.5em;
}

.dfh-btn-primary {
    background: #a88555;
    color: #fff;
    font-weight: 600;
}

.dfh-btn-primary:hover {
    background: #7a5d3a;
}

.dfh-btn-secondary {
    background: #e0c9a4;
    color: #2c1810;
}

.dfh-btn-secondary:hover {
    background: #c4a682;
}

/* ============================================================
   ALFABET-GRID
   ============================================================ */

.dfh-alfabet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.8em;
    min-width: 0;
}

.dfh-alfabet-kort {
    display: flex;
    gap: 0.8em;
    align-items: center;
    padding: 0.8em;
    background: #fcf7ed;
    border: 1px solid #e0c9a4;
    border-radius: 4px;
    min-width: 0;
}

.dfh-alfabet-historisk {
    flex-shrink: 0;
    width: 3em;
    height: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #c4a682;
    border-radius: 4px;
}

.dfh-alfabet-info {
    flex: 1;
    min-width: 0;
}

.dfh-alfabet-modern {
    font-size: 1.2em;
    font-weight: 700;
    color: #2c1810;
    margin-bottom: 0.2em;
}

.dfh-alfabet-kommentar {
    font-size: 0.85em;
    color: #5a4530;
    line-height: 1.35;
}

/* ============================================================
   FRASER-GRID
   ============================================================ */

.dfh-fraser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1em;
    min-width: 0;
}

.dfh-fras-kort {
    padding: 1em;
    background: #fcf7ed;
    border: 1px solid #e0c9a4;
    border-radius: 6px;
    min-width: 0;
}

.dfh-fras-original {
    padding: 0.8em;
    background: #fff;
    border: 1px solid #c4a682;
    border-radius: 4px;
    margin-bottom: 0.6em;
    text-align: center;
    min-height: 4em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dfh-fras-tolkning {
    color: #2c1810;
    line-height: 1.5;
    font-size: 0.95em;
}

/* ============================================================
   STATISTIK
   ============================================================ */

.dfh-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.8em;
    margin: 1em 0 1.5em;
    min-width: 0;
}

.dfh-stat-kort {
    padding: 1em;
    background: #fcf7ed;
    border: 1px solid #e0c9a4;
    border-radius: 6px;
    text-align: center;
    min-width: 0;
}

.dfh-stat-tal {
    display: block;
    font-size: 2em;
    font-weight: 700;
    color: #2c1810;
    line-height: 1.1;
    margin-bottom: 0.2em;
}

.dfh-stat-tal.dfh-stat-ratt {
    color: #2a4a14;
}

.dfh-stat-tal.dfh-stat-fel {
    color: #5a1a1a;
}

.dfh-stat-etikett {
    font-size: 0.85em;
    color: #5a4530;
    font-weight: 600;
}

.dfh-stat-tabell {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.dfh-stat-tabell th {
    background: #4a3424;
    color: #fff;
    padding: 0.5em 0.8em;
    text-align: left;
    font-size: 0.92em;
}

.dfh-stat-tabell td {
    padding: 0.5em 0.8em;
    border-top: 1px solid #efe3cc;
    color: #2c1810;
}

.dfh-stat-tabell tr:nth-child(even) td {
    background: #fcf7ed;
}

/* ============================================================
   INFO-BOX
   ============================================================ */

.dfh-info-box {
    padding: 0.9em 1.1em;
    background: #f4ebd9;
    border-left: 4px solid #d4b483;
    border-radius: 4px;
    margin: 1em 0;
    font-size: 0.93em;
    color: #4a3424;
    line-height: 1.5;
}

.dfh-info-tip {
    background: #eef5f8;
    border-left-color: #5a8aaa;
}

.dfh-info-warning {
    background: #fef5e1;
    border-left-color: #e6a500;
}

.dfh-info-rubrik {
    margin: 0 0 0.5em;
    font-weight: 600;
}

.dfh-info-box ul {
    margin: 0.4em 0 0 1.2em;
    padding-left: 0;
}

.dfh-info-box li {
    margin-bottom: 0.3em;
}

/* ============================================================
   ERROR
   ============================================================ */

.dfh-error {
    padding: 0.8em 1em;
    background: #fdeded;
    border: 1px solid #d68080;
    border-left: 4px solid #b73a3a;
    border-radius: 4px;
    color: #5a1a1a;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .dfh-form-row-grid {
        grid-template-columns: 1fr;
    }

    .dfh-flerval {
        grid-template-columns: 1fr;
    }

    .dfh-tab {
        flex: 1 1 calc(50% - 2px);
        font-size: 0.85em;
        padding: 0.7em 0.6em;
    }

    .dfh-tab-text {
        font-size: 0.92em;
    }

    .dfh-tab-num {
        width: 1.3em;
        height: 1.3em;
        font-size: 0.78em;
    }

    .dfh-handstil {
        font-size: 2.8em;
    }

    .dfh-handstil-medium {
        font-size: 1.8em;
    }

    .dfh-papper {
        padding: 1.5em 1em;
    }
}

@media (max-width: 600px) {
    .dfh-header {
        padding: 1em;
    }

    .dfh-panel {
        padding: 1em;
    }

    .dfh-title {
        font-size: 1.2em;
    }

    .dfh-handstil {
        font-size: 2.4em;
    }

    /* Statistik-tabell blir kort på mobil */
    .dfh-stat-tabell thead {
        display: none;
    }

    .dfh-stat-tabell tbody,
    .dfh-stat-tabell tr,
    .dfh-stat-tabell td {
        display: block;
        width: 100%;
    }

    .dfh-stat-tabell tr {
        margin-bottom: 0.6em;
        border: 1px solid #efe3cc;
        border-radius: 4px;
        background: #fff;
        padding: 0.5em;
    }

    .dfh-stat-tabell tr:nth-child(even) {
        background: #fcf7ed;
    }

    .dfh-stat-tabell td {
        padding: 0.3em 0;
        border: none;
    }

    .dfh-stat-tabell td::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #a88555;
        display: inline;
    }
}
