/* ===========================
   General Styling
   =========================== */
:root {
    --line-height: 44px;
    --columns: 2;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Atkinson Hyperlegible Mono', sans-serif;
    font-size: 16px;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333333;
}

/* ===========================
   Navigation
   =========================== */
nav {
    background-color: #0056b3;
    padding: 10px 20px;
    text-align: left;
}

nav a {
    color: white;
    text-decoration: none;
    font-size: 16px;
    font-weight: bold;
    transition: color 0.3s ease;
}

nav a:hover {
    color: #ffeb3b;
}

/* ===========================
   Header
   =========================== */
header {
    background-color: #007bff;
    color: white;
    padding: 20px 0;
    text-align: center;
    width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    margin: 0;
    font-size: 32px;
    font-weight: bold;
}

header p {
    margin: 10px 0 0 0;
    font-size: 16px;
    font-style: italic;
}

/* ===========================
   Footer
   =========================== */
footer {
    font-size: 14px;
    color: #666666;
    margin: 20px 0;
    text-align: center;
}

/* ===========================
   Container
   =========================== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* ===========================
   Controls
   =========================== */
.controls-section {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group > label {
    font-weight: bold;
    font-size: 13px;
    color: #555;
}

.control-group select,
.control-group input[type="number"] {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #cccccc;
    border-radius: 5px;
    font-family: 'Atkinson Hyperlegible Mono', sans-serif;
    background-color: white;
}

.control-group input[type="number"] {
    width: 90px;
}

.control-group select:focus,
.control-group input[type="number"]:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Toggle mode buttons */
.toggle-group {
    display: flex;
    border: 1px solid #007bff;
    border-radius: 6px;
    overflow: hidden;
}

.toggle-btn {
    padding: 8px 18px;
    font-size: 14px;
    font-family: 'Atkinson Hyperlegible Mono', sans-serif;
    background: white;
    color: #007bff;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.toggle-btn:not(:last-child) {
    border-right: 1px solid #007bff;
}

.toggle-btn.active {
    background-color: #007bff;
    color: white;
}

/* Level buttons */
.level-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.level-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-family: 'Atkinson Hyperlegible Mono', sans-serif;
    border: 1px solid #aaa;
    border-radius: 20px;
    cursor: pointer;
    background: white;
    color: #555;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.level-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

/* Checkboxes */
.checkbox-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    cursor: pointer;
    font-weight: normal;
    color: #333;
}

.checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #007bff;
}

/* Action buttons */
.btn-primary {
    padding: 10px 28px;
    font-size: 15px;
    font-weight: bold;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Atkinson Hyperlegible Mono', sans-serif;
    transition: background-color 0.2s;
}

.btn-primary:hover { background-color: #0056b3; }
.btn-primary:disabled { background-color: #cccccc; cursor: not-allowed; }

.btn-secondary {
    padding: 10px 28px;
    font-size: 15px;
    font-weight: bold;
    background-color: white;
    color: #007bff;
    border: 2px solid #007bff;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Atkinson Hyperlegible Mono', sans-serif;
    transition: background-color 0.2s, color 0.2s;
}

.btn-secondary:hover {
    background-color: #007bff;
    color: white;
}

.hidden {
    display: none !important;
}

/* Print notice */
.print-notice {
    background-color: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    padding: 10px 16px;
    margin-bottom: 25px;
    font-size: 13px;
    color: #5d4037;
}

/* ===========================
   Dictation Sheet
   =========================== */
.dictee-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #007bff;
}

.dictee-title {
    font-size: 20px;
    font-weight: bold;
    color: #333;
}

.dictee-meta {
    font-size: 13px;
    color: #888;
}

/* Word entry: number + writing lines */
.dictee-words {
    display: grid;
    grid-template-columns: repeat(var(--columns), 1fr);
    gap: 4px 24px;
}

.dictee-entry {
    display: flex;
    gap: 12px;
    margin-bottom: 0;
    align-items: flex-start;
}

.entry-number {
    font-size: 14px;
    font-weight: bold;
    color: #007bff;
    width: 24px;
    flex-shrink: 0;
    padding-top: 4px;
    text-align: right;
}

.entry-word {
    font-size: 18px;
    padding: 4px 0 8px;
    color: #333;
}

.entry-lines {
    flex: 1;
    position: relative;
    counter-reset: none;
}

/* Single writing line — notebook style matching practice-list */
.dictee-line {
    height: var(--line-height);
    --gap: calc((var(--line-height) - 6px) / 3);
    background-image:
        repeating-linear-gradient(
            90deg,
            #8b7d6b 0px, #8b7d6b 4px,
            transparent 4px, transparent 8px
        ),
        linear-gradient(to bottom,
            transparent calc(2px + var(--gap)),
            #4a90e2     calc(2px + var(--gap)),
            #4a90e2     calc(4px + var(--gap)),
            transparent calc(4px + var(--gap))
        ),
        linear-gradient(to bottom,
            transparent calc(4px + 2 * var(--gap)),
            #4a90e2     calc(4px + 2 * var(--gap)),
            #4a90e2     calc(6px + 2 * var(--gap)),
            transparent calc(6px + 2 * var(--gap))
        );
    background-size: 100% 2px, 100% 100%, 100% 100%;
    background-position: 0 0, 0 0, 0 0;
    background-repeat: no-repeat, no-repeat, no-repeat;
}

/* Closing dotted line after each entry's lines */
.entry-lines::after {
    content: '';
    display: block;
    height: 2px;
    background-image: repeating-linear-gradient(
        90deg,
        #8b7d6b 0px, #8b7d6b 4px,
        transparent 4px, transparent 8px
    );
    background-repeat: no-repeat;
    background-size: 100% 2px;
    margin-bottom: var(--gap);
}

/* Answer key overlay */
.entry-answer {
    position: absolute;
    top: calc(var(--line-height) / 2 - 10px);
    left: 8px;
    font-size: 16px;
    font-weight: bold;
    color: #c0392b;
    pointer-events: none;
    background: transparent;
}

.answers-hidden .entry-answer {
    display: none;
}

/* Word tag shown in answer mode on the entry number */
.entry-lines.answer-visible .entry-answer {
    display: block;
}

/* ===========================
   Print Styles
   =========================== */
@media print {
    body { background-color: white; }

    .no-print { display: none !important; }

    header {
        padding: 12px 0;
    }

    header h1 { font-size: 22px; }

    header p {
        display: block;
    }

    header p::after {
        content: attr(data-info);
    }

    .container {
        max-width: 100%;
        padding: 0.4in;
        margin: 0;
    }

    .dictee-entry {
        page-break-inside: avoid;
    }

    .dictee-line {
        --line-height: 40px;
        height: var(--line-height);
    }

    @page {
        margin: 0.5in;
        size: A4;
    }
}
