/*
 * Fraction Worksheets – V1.0
 * Aligned with worksheet-base.css design system.
 * Uses sheet-common.css for .sheet-header, .instruction-text and panel controls.
 * Printed paper colors are hardcoded (never theme-aware).
 */

/* =========================================
   1. PROBLEM GRID
   ========================================= */
.fw-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    gap: 2mm 5mm;
    padding: 3mm 4mm;
}

.fw-cols-1 { grid-template-columns: 1fr; }
.fw-cols-2 { grid-template-columns: repeat(2, 1fr); }
.fw-cols-3 { grid-template-columns: repeat(3, 1fr); }
.fw-cols-4 { grid-template-columns: repeat(4, 1fr); }

.fw-problem {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    min-height: 0;
    overflow: hidden;
    padding: 2mm;
    border-bottom: 1px dotted #e5e7eb;
    font-family: 'Nunito', sans-serif;
    font-size: 20px;
    color: #1f2937;
    break-inside: avoid;
}

.fw-problem-num {
    flex-shrink: 0;
    min-width: 22px;
    padding-top: 2px;
    font-size: 12px;
    color: #9ca3af;
    text-align: right;
}

.fw-body {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 2mm;
}

.fw-problem--visual .fw-body {
    align-items: center;
}

/* Shape and answer boxes side by side so shapes keep their size on dense pages */
.fw-problem--identify .fw-body {
    flex-direction: row;
    justify-content: center;
    gap: 5mm;
}

.fw-problem--identify .fw-visual {
    flex: 0 1 auto;
    width: auto;
    height: 100%;
}

.fw-prompt {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #6b7280;
}

.fw-prompt .fw-frac {
    font-size: 15px;
}

/* =========================================
   2. SHAPES (inline SVG)
   ========================================= */
.fw-visual {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fw-shape {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.fw-shape--circle {
    width: 34mm;
    height: 34mm;
}

.fw-shape--bar {
    width: 48mm;
    height: 16mm;
}

/* =========================================
   3. STACKED FRACTIONS & ANSWER SLOTS
   ========================================= */
.fw-expr {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-weight: 700;
}

.fw-frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.15;
    vertical-align: middle;
}

.fw-num,
.fw-den {
    min-width: 1.2em;
    padding: 0 3px;
    text-align: center;
}

.fw-bar {
    align-self: stretch;
    height: 2px;
    margin: 2px 0;
    background: #1f2937;
}

.fw-mixed {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.fw-whole {
    font-weight: 700;
}

.fw-op {
    color: #6b7280;
    font-weight: 600;
}

/* Empty box students write in */
.fw-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5em;
    min-height: 1.3em;
    border: 1.5px solid #9ca3af;
    border-radius: 4px;
    background: #fff;
}

.fw-frac > .fw-box {
    margin: 1px 0;
}

.fw-box--circle {
    width: 1.6em;
    height: 1.6em;
    min-width: 0;
    border-radius: 50%;
}

.fw-answer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.2em;
    min-height: 1.9em;
    border-bottom: 1.5px solid #9ca3af;
}

/* Answers shown (answer key / show answers) */
.fw-filled {
    color: #16a34a;
    border-color: #16a34a;
}

.fw-filled .fw-bar {
    background: #16a34a;
}

/* =========================================
   4. DENSITY (24+ problems per page)
   ========================================= */
.fw-dense {
    gap: 1mm 4mm;
}

.fw-dense .fw-problem {
    padding: 1mm 1.5mm;
    font-size: 16px;
}

.fw-dense .fw-prompt {
    font-size: 12px;
}

.fw-dense .fw-shape--circle {
    width: 24mm;
    height: 24mm;
}

.fw-dense .fw-shape--bar {
    width: 38mm;
    height: 12mm;
}

/* =========================================
   5. PRINT OVERRIDES
   ========================================= */
@media print {
    .fw-shape,
    .fw-shape * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .fw-problem {
        color: #1f2937 !important;
    }

    .fw-bar {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .fw-filled {
        color: #16a34a !important;
    }
}
