/**
 * White Rose Maths Styling
 * Shared CSS for White Rose Maths resources and web pages
 * 
 * Color Scheme:
 * - Primary: #1D3759 (Dark navy blue)
 * - Secondary: #0477BF (Vibrant blue)
 * - Accent: #91D2D9 (Light blue)
 * - Highlight: #F2AD85 (Light orange/peach)
 * - Background: #F2F2F2 (Light grey)
 * - Text: #1D3759 (Dark navy text)
 * 
 * Fonts:
 * - Fredoka (headings)
 * - Rockwell (body text)
 * - DIN Condensed Bold (titles)
 * - STIX Two Math (mathematical notation)
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --white-rose-primary: #1D3759;
    --white-rose-secondary: #0477BF;
    --white-rose-accent: #91D2D9;
    --white-rose-highlight: #F2AD85;
    --white-rose-background: #F2F2F2;
    --white-rose-text: #1D3759;
    --white-rose-red: #C90C0F;
    --white-rose-red-dark: #8B0000;
    --white-rose-yellow: #FAB719;
    --white-rose-yellow-dark: #F5A623;
}

/* ============================================
   FONT DEFINITIONS
   ============================================ */
@font-face {
    font-family: "Fredoka";
    src: url("/fonts/Fredoka-Regular.ttf") format("truetype");
    font-weight: 300 700;
    font-style: normal;
}

@font-face {
    font-family: "DINCondensedBold";
    src: url("/fonts/DINCondensedBold.ttf") format("truetype");
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: "Rockwell";
    src: url("/fonts/Rockwell.ttc") format("truetype");
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: "STIXTwoMath";
    src: url("/fonts/STIXTwoMath-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}

/* PDF Font Definitions (for WeasyPrint) */
@font-face {
    font-family: "Fredoka-PDF";
    src: url("file:///var/www/mathsvault.uk/fonts/Fredoka-Regular.ttf") format("truetype");
    font-weight: 300 700;
    font-style: normal;
}

@font-face {
    font-family: "DINCondensedBold-PDF";
    src: url("file:///var/www/mathsvault.uk/fonts/DINCondensedBold.ttf") format("truetype");
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: "Rockwell-PDF";
    src: url("file:///var/www/mathsvault.uk/fonts/Rockwell.ttc") format("truetype");
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: "STIXTwoMath-PDF";
    src: url("file:///var/www/mathsvault.uk/fonts/STIXTwoMath-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}

/* ============================================
   BASE STYLES
   ============================================ */
.white-rose-body {
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    background-color: #f5f7fa;
    color: #1D1D1B;
}

.white-rose-container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

.white-rose-container-wide {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 20px;
}

/* ============================================
   HEADERS & TITLES
   ============================================ */
.white-rose-header {
    background: linear-gradient(135deg, var(--white-rose-primary) 0%, var(--white-rose-secondary) 100%);
    color: white;
    padding: 0.5cm 1cm;
    margin: 0 0 0.8cm 0;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 15px rgba(29, 55, 89, 0.2);
}

.white-rose-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
}

.white-rose-text-content {
    flex: 1;
}

.white-rose-header-content img {
    height: 1.8cm;
    width: auto;
    filter: drop-shadow(3px 3px 6px rgba(0,0,0,0.4));
    margin-left: 1cm;
    align-self: center;
}

.white-rose-title {
    font-family: "Fredoka", "DINCondensedBold", Arial, sans-serif;
    font-size: 1.8em;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    letter-spacing: 0.05em;
    font-weight: 600;
    text-align: left;
}

.white-rose-subtitle {
    font-size: 0.9em;
    text-align: left;
    margin-top: 0.1cm;
    opacity: 0.9;
    font-weight: 300;
}

/* Web page headers */
.white-rose-page-header {
    text-align: center;
    margin-bottom: 40px;
}

.white-rose-page-header h1 {
    font-size: 42px;
    color: var(--white-rose-red);
    margin-bottom: 15px;
}

.white-rose-page-header p {
    font-size: 18px;
    color: #666;
}

.topic-header {
    background: linear-gradient(135deg, var(--white-rose-primary) 0%, var(--white-rose-secondary) 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(29, 55, 89, 0.2);
}

.topic-header h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

/* ============================================
   BUTTONS
   ============================================ */
.white-rose-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-family: inherit;
}

.white-rose-btn-primary {
    background: var(--white-rose-secondary);
    color: white;
}

.white-rose-btn-primary:hover {
    background: var(--white-rose-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(4, 119, 191, 0.3);
    color: white;
}

.white-rose-btn-red {
    background: linear-gradient(135deg, var(--white-rose-red) 0%, var(--white-rose-red-dark) 100%);
    color: white;
}

.white-rose-btn-red:hover {
    background: var(--white-rose-red-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(201, 12, 15, 0.3);
    color: white;
}

.white-rose-btn-yellow {
    background: linear-gradient(135deg, var(--white-rose-yellow) 0%, var(--white-rose-yellow-dark) 100%);
    color: #1D1D1B;
}

.white-rose-btn-yellow:hover {
    background: var(--white-rose-yellow-dark);
    transform: translateY(-2px);
    color: #1D1D1B;
}

.white-rose-btn-secondary {
    background: linear-gradient(135deg, #607D8B 0%, #455A64 100%);
    color: white;
}

.white-rose-btn-secondary:hover {
    background: #455A64;
    transform: translateY(-2px);
    color: white;
}

.white-rose-btn-success {
    background: #28a745;
    color: white;
}

.white-rose-btn-success:hover {
    background: #1e7e34;
    transform: translateY(-2px);
    color: white;
}

/* Year/Term selector buttons */
.year-btn {
    padding: 20px 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 3px solid #e0e0e0;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    color: #1D1D1B;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.year-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.year-btn.active {
    background: linear-gradient(135deg, var(--white-rose-red) 0%, var(--white-rose-red-dark) 100%);
    border-color: var(--white-rose-red);
    color: white;
}

.year-btn.active small {
    color: var(--white-rose-yellow);
    opacity: 1;
    font-weight: bold;
}

.term-btn {
    padding: 15px 35px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #1D1D1B;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.term-btn:hover {
    transform: translateY(-2px);
}

.term-btn.active {
    background: linear-gradient(135deg, var(--white-rose-yellow) 0%, var(--white-rose-yellow-dark) 100%);
    border-color: var(--white-rose-yellow);
    color: #1D1D1B;
}

/* ============================================
   CARDS & SECTIONS
   ============================================ */
.white-rose-card {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s;
    border: 3px solid transparent;
}

.white-rose-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(201, 12, 15, 0.2);
    border-color: var(--white-rose-red);
}

.block-card {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s;
    border: 3px solid transparent;
    color: inherit;
    display: block;
    text-decoration: none;
}

.block-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(201, 12, 15, 0.2);
    border-color: var(--white-rose-red);
}

.form-section {
    background: white;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.form-section h2 {
    color: var(--white-rose-primary);
    margin-bottom: 20px;
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.selector-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 40px;
}

.section {
    margin-bottom: 0.3cm;
    background: white;
    padding: 0.5cm 0.6cm;
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

/* ============================================
   WORKSHEET COMPONENTS (PDF)
   ============================================ */
.worksheet-meta {
    background: white;
    padding: 1cm;
    border-radius: 10px;
    margin-bottom: 1.5cm;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-left: 5px solid var(--white-rose-primary);
}

.meta-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5cm;
    font-size: 1.1em;
}

.meta-label {
    font-family: "Fredoka", "DINCondensedBold", Arial, sans-serif;
    color: var(--white-rose-primary);
    font-weight: 600;
}

.meta-value {
    color: var(--white-rose-text);
}

.worksheet-instruction {
    background: var(--white-rose-highlight);
    color: var(--white-rose-text);
    padding: 0.3cm 0.6cm;
    border-radius: 8px;
    text-align: center;
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 0.5cm;
    box-shadow: 0 2px 8px rgba(242, 173, 133, 0.3);
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.2cm;
    page-break-after: avoid;
    break-after: avoid;
}

.section-title {
    font-family: "Fredoka", "DINCondensedBold", Arial, sans-serif;
    color: var(--white-rose-primary);
    font-size: 1.25em;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin: 0;
}

.section-title-line {
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--white-rose-primary) 0%, var(--white-rose-secondary) 100%);
    border: none;
    margin-bottom: 1.5em;
    border-radius: 2px;
    page-break-after: avoid;
    break-after: avoid;
}

.section-title-line + .questions-grid,
.section-title-line + .questions-grid-single {
    page-break-before: avoid;
    break-before: avoid;
}

.section-logo {
    height: 2.5em;
    margin-left: 0.8em;
}

/* ============================================
   QUESTIONS & ANSWERS
   ============================================ */
.questions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6em 0.8em;
    margin-bottom: 0.6em;
    width: 100%;
    max-width: 100%;
    align-items: start;
    box-sizing: border-box;
}

.questions-grid-single {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8em 0;
    margin-bottom: 0.8em;
}

.questions-grid-compact {
    gap: 0.4em 0.6em;
}

.questions-grid-spacious {
    gap: 0.8em 1em;
}

.question {
    font-family: "Rockwell", "STIXTwoMath", Arial, sans-serif;
    font-size: 0.9em;
    display: flex;
    align-items: flex-start;
    box-sizing: border-box;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 0.6em;
    margin: 0;
    transition: all 0.2s;
    overflow-wrap: break-word;
    word-wrap: break-word;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: auto;
    page-break-inside: avoid;
    break-inside: avoid;
}

.question:hover {
    border-color: var(--white-rose-secondary);
    background: #fff;
}

.question-number {
    font-family: "Fredoka", "DINCondensedBold", Arial, sans-serif;
    font-weight: 600;
    color: var(--white-rose-text);
    font-size: 1.2em;
    margin-right: 1em;
    min-width: 2.5em;
    flex-shrink: 0;
    align-self: flex-start;
    line-height: 1.6;
    background: var(--white-rose-accent);
    border-radius: 50%;
    width: 2.5em;
    height: 2.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    page-break-after: avoid;
    break-after: avoid;
}

.question-text {
    flex: 1;
    line-height: 1.7;
    font-family: "Fredoka", "Rockwell", "STIXTwoMath", Arial, sans-serif;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    font-size: 1em;
}

.answer-space {
    min-height: 2em;
    border-bottom: 2px solid #ddd;
    margin: 0.8em 0;
    padding: 0.3em 0;
}

.answer-space-lined {
    background-image: repeating-linear-gradient(
        transparent,
        transparent 1.4em,
        #e0e0e0 1.4em,
        #e0e0e0 1.5em
    );
    border-bottom: none;
    padding: 0.2em 0.5em;
}

.answer-space-grid {
    background-image: 
        repeating-linear-gradient(
            transparent,
            transparent 0.7em,
            #e0e0e0 0.7em,
            #e0e0e0 0.71em
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 0.7em,
            #e0e0e0 0.7em,
            #e0e0e0 0.71em
        );
    border-bottom: none;
    padding: 0.2em 0.5em;
}

.answer {
    color: #27ae60;
    margin-top: 0.8em;
    padding: 0.8em;
    border-left: 4px solid #27ae60;
    background: #f0f9f0;
    border-radius: 0 8px 8px 0;
    font-size: 1em;
}

/* ============================================
   VISUAL MODELS
   ============================================ */
.visual-model-container {
    background: #f9f9f9;
    padding: 12px;
    border-radius: 8px;
    margin: 12px 0;
    text-align: center;
    border: 1px solid #e0e0e0;
    page-break-inside: avoid;
    break-inside: avoid;
}

.visual-model-container svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.question:has(.visual-model-container) {
    flex-direction: column;
    padding: 0.8em;
}

.question:has(.visual-model-container) .question-text {
    width: 100%;
    margin-bottom: 0.5em;
}

/* ============================================
   FOOTER & SMALL STEPS
   ============================================ */
.white-rose-footer {
    text-align: center;
    font-size: 0.85em;
    color: var(--white-rose-text);
    font-family: "Fredoka", Arial, sans-serif;
    padding: 0.3cm 0;
    margin-top: 0.3cm;
    border-top: 1px solid #E0E0E0;
}

.small-steps-info {
    background: var(--white-rose-accent);
    color: var(--white-rose-text);
    padding: 0.3cm 0.5cm;
    border-radius: 8px;
    margin-bottom: 1cm;
    font-size: 0.9em;
    text-align: left;
}

.small-steps-title {
    font-family: "Fredoka", "DINCondensedBold", Arial, sans-serif;
    font-size: 1em;
    margin: 0;
    font-weight: 600;
    display: inline;
}

.small-steps-list {
    display: inline;
}

.small-step {
    font-size: 0.9em;
    font-weight: 500;
}

.copyright {
    position: fixed;
    bottom: 10mm;
    right: 10mm;
    font-family: "Rockwell", Arial, sans-serif;
    font-size: 10pt;
    color: var(--white-rose-primary);
    background: white;
    padding: 0.3cm 0.6cm;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ============================================
   COVERAGE STATUS
   ============================================ */
.coverage-status {
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

.coverage-exact {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.coverage-partial {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.coverage-none {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* ============================================
   BLOCK COMPONENTS
   ============================================ */
.block-header {
    margin-bottom: 20px;
}

.block-number {
    display: inline-block;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--white-rose-red) 0%, var(--white-rose-red-dark) 100%);
    color: white;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.block-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--white-rose-red);
    margin-bottom: 10px;
}

.block-meta {
    font-size: 14px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.small-steps-preview {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--white-rose-red);
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    line-height: 1.4;
}

.step-number {
    background: var(--white-rose-red);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.step-item.more-steps .step-number {
    background: #666;
}

.step-name {
    color: #333;
    flex: 1;
}

.block-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
    margin: 20px 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--white-rose-secondary);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 14px;
}

.description-examples {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-top: 10px;
    border-left: 4px solid var(--white-rose-secondary);
}

.description-examples h4 {
    margin-bottom: 10px;
    color: var(--white-rose-primary);
}

.description-examples ul {
    margin-left: 20px;
    color: #666;
}

.description-examples li {
    margin: 5px 0;
}

.visual-model-section {
    background: #f0f9ff;
    border: 2px dashed var(--white-rose-secondary);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.visual-model-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.visual-model-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.visual-model-options {
    display: none;
    margin-top: 15px;
}

.visual-model-options.active {
    display: block;
}

.visual-model-type {
    margin: 15px 0;
    padding: 15px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.visual-model-type h4 {
    color: var(--white-rose-primary);
    margin-bottom: 10px;
}

/* ============================================
   GRID LAYOUTS
   ============================================ */
.blocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.year-selector {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 30px;
}

.term-selector {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #666;
}

.empty-state i {
    font-size: 64px;
    color: var(--white-rose-red);
    margin-bottom: 20px;
    opacity: 0.3;
}

.toggle-view {
    text-align: center;
    margin-bottom: 20px;
}

.toggle-view a {
    color: #2196F3;
    text-decoration: none;
    font-weight: 600;
    padding: 10px 20px;
    background: #e3f2fd;
    border-radius: 5px;
    transition: all 0.2s;
}

.toggle-view a:hover {
    background: #bbdefb;
}

.selector-label {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    display: block;
}

/* ============================================
   PRINT/PDF SPECIFIC STYLES
   ============================================ */
@media print {
    .question {
        background: white;
        border: 1px solid #e0e0e0;
    }
    
    .visual-model-container {
        background: white;
        border: 1px solid #ddd;
    }
    
    .question-number {
        background: var(--white-rose-accent);
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .questions-grid {
        gap: 0.5em 0.7em;
    }
    
    .questions-grid-single {
        gap: 0.6em 0;
    }
}

/* PDF Page Setup */
@page {
    margin: 0.3cm;
    size: A4;
}

.main-container {
    margin: 0.3cm;
    max-width: 100%;
    padding: 0.3cm 0.3cm 0.5cm 0.3cm;
    background: white;
}

.content-wrapper {
    flex: 1;
}

/* Prevent orphaned elements */
.questions-grid > .question:last-child,
.questions-grid-single > .question:last-child {
    page-break-after: auto;
}
