/*
  ╔══════════════════════════════════════════════════════════════════════════╗
  ║                   dojoMathUtilityStyles.css                              ║
  ║            APCS Java Dojo — Math Utilities Page Styling                  ║
  ║                                                                          ║
  ║  Color Theme:  Green Chalkboard (from hero image)                       ║
  ║  Structure:    Back bar → Hero section → Intro → Driver → Utilities     ║
  ║  Component:    Terminal code display, copy buttons, accordion sections   ║
  ║  Responsive:   Mobile-first, tablet & desktop layouts                   ║
  ╚══════════════════════════════════════════════════════════════════════════╝
*/

/* ══════════════════════════════════════════════════════════════════════════
   ROOT / CSS CUSTOM PROPERTIES
   ══════════════════════════════════════════════════════════════════════════ */

:root {
    /* Primary & Accent Colors: Java Blue Theme (Mystic Shield Palette) */
    --dojo:               #5eb3d6;    /* Primary Java Blue */
    --dojo-mid:           #3a8fb5;    /* Mid blue for accents */
    --dojo-dark:          #1a5c8a;    /* Dark blue for text/borders */
    --dojo-dim:           rgba(94, 179, 214, 0.18);  /* Dim blue overlay */
    
    /* Math Utilities Green Theme - Custom Green Accent Colors */
    --math-primary:       #538458;    /* Primary dark green accent */
    --math-primary-light: #9ed895;    /* Light green for backgrounds/accents */
    --math-primary-dark:  #3d6342;    /* Darker green for hover/active states */
    --math-dim:           rgba(83, 132, 88, 0.18);   /* Dim green overlay */
    
    /* Neutral & Structural */
    --dojo-bg:            #ffffff;    /* Page background */
    --dojo-light:         #f8f8f8;    /* Light section bg */
    --dojo-text:          #333333;    /* Text color */
    --dojo-border:        #e0e0e0;    /* Border color */
    
    /* Mystic Shield Java Color Palette (Standard for Java code at TNT) */
    --java-row-a:         #f4f9ff;    /* Alternating row A (light blue) */
    --java-row-b:         #b8d5f0;    /* Alternating row B (medium blue) */
    --java-kw:            #000099;    /* Keywords (dark blue) */
    --java-str:           #990000;    /* Strings (dark red) */
    --java-cmt:           #005540;    /* Comments (dark green) */
    --java-num:           #003d80;    /* Numbers (blue) */
    --java-num-lit:       #660099;    /* Numeric literals (purple) */
    --java-text:          #001020;    /* Text (very dark blue) */
    
    /* Typography */
    --font-primary:       'Inter', sans-serif;
    --font-mono:          'Source Code Pro', monospace;
    --font-display:       'Boogaloo', cursive;
    
    /* Sizing & Spacing */
    --radius-sm:          0.25rem;
    --radius-md:          0.5rem;
    --radius-lg:          0.75rem;
    --transition:         0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ══════════════════════════════════════════════════════════════════════════
   RESET & BASE STYLES
   ══════════════════════════════════════════════════════════════════════════ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--dojo-bg);
    color: var(--dojo-dark);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: var(--math-primary);
    transition: color var(--transition);
}

a:hover {
    color: var(--math-primary-dark);
    text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════════════════════
   BACK BAR — Navigation
   ══════════════════════════════════════════════════════════════════════════ */

#mathUtilsBackBar {
    background: #030c16;
    padding: 0.55rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-bottom: 2px solid var(--math-primary);
    font-size: 0.88rem;
}

#mathUtilsBackBar .back-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
}

#mathUtilsBackBar a {
    color: var(--math-primary-light);
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s;
}

#mathUtilsBackBar a:hover {
    color: #fff;
}

#mathUtilsBackBar .back-label {
    color: rgba(255, 255, 255, 0.28);
    font-size: 0.80rem;
}

/* ══════════════════════════════════════════════════════════════════════════
   HERO SECTION
   ══════════════════════════════════════════════════════════════════════════ */

#mathUtilsHero {
    position: relative;
    min-height: 50vh;
    background-image: url('../images/sonnyMathProblems.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    overflow: hidden;
    padding: 4rem 1rem 3rem;
}

#mathUtilsHero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(94, 179, 214, 0.35), rgba(26, 92, 138, 0.35));
    z-index: 1;
}

#mathUtilsHero .hero-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

#mathUtilsHero .hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 600px;
    padding: 2rem;
}

#mathUtilsHero .hero-label {
    font-size: 0.75rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.50);
    margin-bottom: 0.6rem;
    display: block;
}

#mathUtilsHero .hero-title {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
}

#mathUtilsHero .hero-tagline {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.95;
    line-height: 1.5;
}

#mathUtilsHero .hero-cta {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.btn-math-primary {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--math-primary);
    color: #ffffff;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition);
    border: 2px solid var(--math-primary);
}

.btn-math-primary:hover {
    background-color: var(--math-primary-dark);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(83, 132, 88, 0.3);
    text-decoration: none;
}

@media (max-width: 768px) {
    #mathUtilsHero {
        height: 200px;
    }
    #mathUtilsHero .hero-title {
        font-size: 2rem;
    }
    #mathUtilsHero .hero-tagline {
        font-size: 0.95rem;
    }
}

/* ══════════════════════════════════════════════════════════════════════════
   MAIN CONTENT CONTAINER
   ══════════════════════════════════════════════════════════════════════════ */

#mathUtilsMain {
    padding: 3rem 1rem;
    background-color: var(--dojo-bg);
}

#mathUtilsMain .container {
    max-width: 900px;
    margin: 0 auto;
}

/* ══════════════════════════════════════════════════════════════════════════
   INTRO BOX
   ══════════════════════════════════════════════════════════════════════════ */

.intro-box {
    background: linear-gradient(135deg, #f0f7f1, #f5f5f5);
    border-left: 4px solid var(--math-primary);
    border-radius: 8px;
    padding: 1.75rem;
    margin-bottom: 2.5rem;
}

.intro-box h2 {
    font-family: var(--font-display);
    color: var(--math-primary);
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.intro-box p {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    color: var(--dojo-dark);
}

.quick-tips {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.tip {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: rgba(158, 216, 149, 0.08);
    border-radius: 6px;
    border-left: 3px solid var(--math-primary);
}

.tip i {
    color: var(--math-primary);
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.tip strong {
    color: var(--math-primary);
    display: inline;
}

@media (max-width: 768px) {
    .intro-box {
        padding: 1.5rem;
    }
    .intro-box h2 {
        font-size: 1.3rem;
    }
}

/* ══════════════════════════════════════════════════════════════════════════
   UTILITY SECTION CONTAINERS
   ══════════════════════════════════════════════════════════════════════════ */

.utility-section {
    margin-bottom: 3rem;
}

.section-title {
    font-family: var(--font-display);
    color: var(--math-primary);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title i {
    color: var(--math-primary);
}

.section-desc {
    color: #666666;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════════════════════
   UTILITY CARD & CODE DISPLAY
   ══════════════════════════════════════════════════════════════════════════ */

.utility-card {
    background-color: #ffffff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

/* Terminal Header */
.code-terminal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.2rem;
    background-color: #001428;
    border-bottom: 2px solid #3380cc;
    flex-wrap: wrap;
}

.terminal-dots {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.td {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.td-red {
    background-color: #ff5f56;
}

.td-yellow {
    background-color: #ffbd2e;
}

.td-green {
    background-color: #27c93f;
}

.terminal-filename {
    font-family: var(--font-mono);
    color: #64b5f6;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.terminal-tag {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.70);
    white-space: nowrap;
}

/* Copy Button */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 1rem;
    background: rgba(94, 179, 214, 0.12);
    border: 1px solid rgba(94, 179, 214, 0.40);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--dojo);
    cursor: pointer;
    transition: background 0.18s, color 0.18s, transform 0.1s;
    white-space: nowrap;
    margin-left: auto;
}

.copy-btn:hover {
    background: rgba(94, 179, 214, 0.25);
    color: #fff;
}

.copy-btn:active {
    transform: scale(0.98);
}

.copy-btn-label {
    white-space: nowrap;
}

/* Code Paper / Listing - Vintage Banded Java Look (Mystic Shield style) */
.code-paper {
    background: var(--java-row-a);
    overflow-x: auto;
    counter-reset: code-line;
    font-family: var(--font-mono);
    font-size: 0.83rem;
    line-height: 1.65;
    padding: 0.6rem 0;
}

.code-paper ol {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: code-line;
}

.code-paper li {
    padding: 1px 0;
    white-space: pre;
    display: flex;
    counter-increment: code-line;
    color: var(--java-text);
}

.code-paper li:nth-child(odd)  { background: var(--java-row-a); }
.code-paper li:nth-child(even) { background: var(--java-row-b); }

.code-paper li::before {
    content: counter(code-line);
    display: inline-block;
    min-width: 36px;
    padding: 0 12px 0 10px;
    color: var(--java-num);
    user-select: none;
    text-align: right;
    border-right: 1px solid rgba(51, 128, 204, 0.18);
    margin-right: 12px;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.code-paper code {
    white-space: pre;
    color: var(--java-text);
    flex: 1;
}

.code-paper .kw { color: var(--java-kw); font-weight: 700; }
.code-paper .cm { color: var(--java-cmt); font-style: italic; }
.code-paper .st { color: var(--java-str); }
.code-paper .nm { color: var(--java-num-lit); }

/* Attribute Strip (Difficulty, Category, etc.) */
.attr-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.2rem;
    background: #001428;
    border-top: 1px solid rgba(51, 128, 204, 0.40);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
}

.attr-label {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
}

.attr-value {
    color: #64b5f6;
    font-weight: 700;
}

@media (max-width: 768px) {
    .code-terminal-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .terminal-filename {
        order: 3;
        flex-basis: 100%;
        margin-top: 0.25rem;
    }
    .code-paper li {
        font-size: 0.8rem;
    }
}

/* ══════════════════════════════════════════════════════════════════════════
   ACCORDION SECTIONS
   ══════════════════════════════════════════════════════════════════════════ */

.utility-accordion {
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: var(--dojo-mid);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Featured Utility Accordion - Change container background */
.utility-accordion:has(.accordion-header.featured-utility) {
    background-color: white;
}

.accordion-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background-color: rgba(158, 216, 149, 0.08);
    border: 1px solid var(--math-dim);
    border-bottom: none;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--math-primary);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.accordion-header:hover {
    background-color: rgba(158, 216, 149, 0.15);
    border-color: var(--math-primary);
}

.accordion-header.active {
    background-color: rgba(158, 216, 149, 0.12);
    border-color: var(--math-primary);
    border-bottom-color: var(--math-primary);
}

.accordion-header i {
    transition: transform var(--transition);
    color: var(--math-primary);
}

.accordion-header.active i {
    transform: rotate(90deg);
}

/* Featured/Primary Utility Styling */
.accordion-header.featured-utility {
    background-color: var(--math-primary-light);
    border-color: var(--math-primary);
    color: var(--math-primary-dark);
}

.accordion-header.featured-utility:hover {
    background-color: var(--math-primary-light);
    border-color: var(--math-primary);
}

.accordion-header.featured-utility.active {
    background-color: var(--math-primary-light);
    border-color: var(--math-primary);
    border-bottom-color: var(--math-primary);
}

.accordion-header.featured-utility i {
    color: var(--math-primary-dark);
}

.utility-category {
    display: inline-block;
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--math-primary);
    background-color: rgba(198, 240, 203, 0.2);
    border: 1px solid rgba(83, 132, 88, 0.4);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Ensure strong tags in accordion headers left-align and don't wrap awkwardly */
.accordion-header strong {
    flex-shrink: 0;
    text-align: left;
}

/* Accordion Content (Collapsed by default) */
.accordion-content {
    display: none;
    padding: 0;
    overflow: hidden;
}

.accordion-content.show {
    display: block;
}

.utility-info {
    padding: 1.5rem;
    background-color: var(--dojo-bg);
    border-top: 1px solid var(--dojo-border);
    color: var(--dojo-text);
    line-height: 1.7;
}

.utility-info p {
    margin-bottom: 0.75rem;
}

.utility-info p:last-child {
    margin-bottom: 0;
}

.utility-info code {
    background-color: rgba(158, 216, 149, 0.08);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    color: var(--math-primary);
}

.utility-notes {
    padding: 1.5rem;
    background-color: rgba(158, 216, 149, 0.05);
    border-top: 1px solid var(--math-dim);
    color: var(--dojo-text);
    line-height: 1.6;
}

.utility-notes strong {
    color: var(--math-primary);
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.utility-notes strong:first-child {
    margin-top: 0;
}

.utility-notes ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1rem;
}

.utility-notes li {
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
    position: relative;
}

.utility-notes li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--math-primary);
    font-weight: bold;
}

/* Featured Utility Notes (How It Works section) */
.utility-notes.featured-utility-notes {
    background: rgba(158, 216, 149, 0.08) !important;
    border-top: 2px solid var(--math-primary) !important;
}

.utility-accordion .accordion-content .utility-notes.featured-utility-notes {
    background: rgba(158, 216, 149, 0.08) !important;
    border-top: 2px solid var(--math-primary) !important;
}

.utility-notes.featured-utility-notes strong {
    color: var(--math-primary);
}

.utility-notes.featured-utility-notes li::before {
    color: var(--math-primary);
}

@media (max-width: 768px) {
    .accordion-header {
        padding: 1rem;
        font-size: 0.95rem;
    }
    .utility-category {
        display: block;
        margin-left: 0;
        margin-top: 0.5rem;
    }
    .utility-info,
    .utility-notes {
        padding: 1rem;
    }
}

/* ══════════════════════════════════════════════════════════════════════════
   HOW-TO BOX
   ══════════════════════════════════════════════════════════════════════════ */

.how-to-box {
    background: rgba(158, 216, 149, 0.08);
    border: 1.5px solid var(--math-dim);
    border-radius: 10px;
    padding: 2rem 1.75rem;
    margin: 3rem 0 2.5rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.5rem;
    align-items: start;
}

.how-to-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.how-to-content {
    flex: 1;
}

.how-to-content h3 {
    font-family: 'Boogaloo', cursive;
    font-size: 1.3rem;
    color: var(--math-primary);
    margin: 0 0 0.75rem 0;
}

.how-to-content ol {
    margin: 0;
    padding-left: 1.5rem;
    color: #2a2a3a;
}

.how-to-content li {
    margin-bottom: 0.5rem;
    line-height: 1.65;
    font-size: 0.95rem;
}

.how-to-content strong {
    color: var(--math-primary);
}

.how-to-content code {
    background: rgba(158, 216, 149, 0.12);
    color: var(--math-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
}

.how-to-content a {
    color: var(--math-primary);
    font-weight: 600;
}

.how-to-content a:hover {
    color: var(--math-primary-dark);
}

@media (max-width: 768px) {
    .how-to-box {
        flex-direction: column;
        gap: 1rem;
        padding: 1.5rem;
    }
    .how-to-icon {
        font-size: 2rem;
    }
}

/* ══════════════════════════════════════════════════════════════════════════
   BACK SECTION
   ══════════════════════════════════════════════════════════════════════════ */

.back-section {
    text-align: center;
    padding: 2rem 0;
    margin-top: 2rem;
    border-top: 2px solid var(--dojo-border);
}

.back-link {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--math-primary);
    color: #ffffff;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.back-link:hover {
    background-color: var(--math-primary-dark);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(45, 127, 63, 0.3);
    text-decoration: none;
    transform: translateX(-0.25rem);
}

/* ══════════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════════════════════════════════════════ */

@media print {
    #mathUtilsBackBar,
    .hero-cta,
    .back-section,
    .copy-btn {
        display: none;
    }
    
    .utility-accordion .accordion-content {
        display: block !important;
    }
    
    .code-paper {
        page-break-inside: avoid;
    }
}
