/**
 * Calculator Styles - Modular & Mobile-First
 * 
 * This file contains all styles for calculators and form tools.
 * Designed to be mobile-first and reusable across different calculators.
 * 
 * Usage: Include in any page with a calculator or form tool.
 * <link rel="stylesheet" href="<?= Path::asset('css/calculator.css') ?>">
 * 
 * Structure:
 * 1. Calculator Container & Header
 * 2. Form Elements (inputs, selects, buttons)
 * 3. Results Container & Cards
 * 4. Zone & Status Indicators
 * 5. Data Grids (dose, time, scenarios)
 * 6. Special Cards (ARS, Cancer, Survival)
 * 7. Tables
 * 8. Responsive Breakpoints (Mobile-First)
 */

/* ============================================================================
   1. CALCULATOR CONTAINER & HEADER
   ============================================================================ */

.calculator-container {
    background: linear-gradient(135deg, #1e2d42 0%, #16213e 100%);
    border-radius: 12px;
    padding: 1rem;
    margin: 1.5rem 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.calculator-header {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #fff;
}

.calculator-header h2 {
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    line-height: 1.3;
}

.calculator-header p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.5;
}

.calculator-header p a {
    color: var(--accent-primary);
}

/* ============================================================================
   2. FORM ELEMENTS
   ============================================================================ */

.calculator-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.calc-input-group {
    display: flex;
    flex-direction: column;
}

.calc-input-group label {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: var(--text-sm);
    line-height: 1.4;
}

.calc-select, .calc-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-medium);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 16px; /* Prevents iOS zoom on focus */
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.calc-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

.calc-select:focus, .calc-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.distance-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.distance-input-wrapper .calc-input {
    flex: 1;
    min-width: 0; /* Allow input to shrink */
}

.input-unit {
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
    font-size: var(--text-sm);
}

.calc-button {
    grid-column: 1 / -1;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-hover) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
}

.calc-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.4);
}

.calc-button:active {
    transform: translateY(0);
}

/* ============================================================================
   3. RESULTS CONTAINER & CARDS
   ============================================================================ */

.calculator-results {
    margin-top: 1.5rem;
    animation: calcFadeIn 0.5s ease-in;
}

@keyframes calcFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-card {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    overflow-x: auto; /* Allow horizontal scroll for tables if needed */
}

.result-card h3, .result-card h4 {
    color: var(--accent-primary);
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    line-height: 1.3;
}

.result-content {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.result-content strong {
    color: #fff;
}

.result-content p {
    margin: 0.5rem 0;
}

.result-content ul, .result-content ol {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

.result-content li {
    margin-bottom: 0.25rem;
}

/* Result Grid - Mobile First */
.result-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.result-grid.three-col {
    grid-template-columns: 1fr;
}

.result-card.full-width {
    grid-column: 1 / -1;
}

/* ============================================================================
   4. ZONE & STATUS INDICATORS
   ============================================================================ */

.zone-card {
    text-align: center;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1) 0%, rgba(0, 153, 204, 0.1) 100%);
    border-color: var(--accent-primary);
}

.zone-indicator {
    font-size: 2rem;
    margin: 0.75rem 0;
    font-weight: 700;
    word-break: break-word;
}

.zone-description {
    font-size: 0.95rem;
    color: #fff;
    font-weight: 600;
    line-height: 1.5;
}

.fema-zone-label {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Zone Colors */
.zone-critical { color: #dc2626; }
.zone-severe { color: #ea580c; }
.zone-moderate { color: #eab308; }
.zone-light { color: #22c55e; }
.zone-minimal { color: #3b82f6; }

/* ============================================================================
   5. DATA GRIDS (DOSE, TIME, SCENARIOS)
   ============================================================================ */

/* Dose Breakdown Grid */
.dose-breakdown {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.dose-item {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
}

.dose-item .dose-label {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.dose-item .dose-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.dose-item .dose-unit {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Time-Dose Grid */
.time-dose-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.time-item {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
}

.time-item .time-label {
    display: block;
    font-size: var(--text-xs);
    color: var(--accent-primary);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.time-item .time-value {
    display: block;
    font-size: 1.125rem;
    font-weight: 700;
    color: #fff;
}

.time-item .time-percent {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

/* Scenario & Cancer Grids */
.cancer-scenarios {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.cancer-scenario {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
}

.cancer-scenario h5 {
    color: #d8b4fe;
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.cancer-scenario .risk-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    display: block;
    margin-bottom: 0.25rem;
}

.cancer-scenario .risk-context {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Fallout Scenarios */
.fallout-scenarios {
    margin-bottom: 1rem;
}

.scenario-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem;
}

.scenario-box h5 {
    color: #fdba74;
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
}

.fallout-note {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.scenario-note {
    font-style: italic;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-size: 1rem;
}

/* Decontamination Steps */
.decon-steps {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.decon-step {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
}

.decon-step h5 {
    color: #6ee7b7;
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
}

.decon-step p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.decon-step .effectiveness {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(16, 185, 129, 0.3);
    font-size: 0.8rem;
    color: #6ee7b7;
}

/* Risk Factors Grid */
.risk-factors-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.risk-factor {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.risk-factor strong {
    color: #c4b5fd;
}

/* ============================================================================
   6. SPECIAL CARDS (ARS, CANCER, SURVIVAL, ETC.)
   ============================================================================ */

/* Fallout Card */
.result-card.fallout-card {
    background: rgba(234, 88, 12, 0.1);
    border-color: #ea580c;
}

.result-card.fallout-card h4 {
    color: #fdba74;
}

/* Cancer Card */
.result-card.cancer-card {
    background: rgba(168, 85, 247, 0.1);
    border-color: #a855f7;
}

.result-card.cancer-card h4 {
    color: #d8b4fe;
}

.cancer-disclaimer {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.cancer-disclaimer p {
    margin: 0;
}

/* Survival Card */
.result-card.survival-card {
    background: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
}

.result-card.survival-card h4 {
    color: #86efac;
}

.survival-content {
    line-height: 1.6;
}

.survival-content h5 {
    color: #86efac;
    margin: 0.75rem 0 0.5rem 0;
    font-size: 1rem;
}

.survival-content h5:first-child {
    margin-top: 0;
}

/* Action Card */
.result-card.action-card {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

.result-card.action-card h4 {
    color: #93c5fd;
}

/* Detailed Info Card */
.result-card.detailed-info {
    background: rgba(220, 38, 38, 0.1);
    border-color: #dc2626;
}

.result-card.detailed-info h4 {
    color: #fca5a5;
}

/* Time-Dose Card */
.result-card.time-dose-card {
    background: rgba(6, 182, 212, 0.1);
    border-color: #06b6d4;
}

.result-card.time-dose-card h4 {
    color: var(--accent-primary);
}

.decay-explanation {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.75rem;
}

.decay-explanation h5 {
    color: var(--accent-primary);
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
}

.decay-explanation p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Decon Card */
.result-card.decon-card {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
}

.result-card.decon-card h4 {
    color: #6ee7b7;
}

/* Risk Factors Card */
.result-card.risk-factors-card {
    background: rgba(139, 92, 246, 0.1);
    border-color: #8b5cf6;
}

.result-card.risk-factors-card h4 {
    color: #c4b5fd;
}

/* ARS Warning Styles */
.ars-warning {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.2) 0%, rgba(234, 88, 12, 0.2) 100%);
    border: 1px solid #dc2626;
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.75rem;
}

.ars-warning h5 {
    color: #fca5a5;
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
}

.ars-warning p {
    margin: 0;
    font-size: 1rem;
    color: #fecaca;
    line-height: 1.5;
}

.ars-critical {
    background: rgba(220, 38, 38, 0.3);
    border-color: #ef4444;
}

.ars-critical h5 {
    color: #fef2f2;
}

/* Uncertainty Warning */
.uncertainty-warning {
    background: rgba(234, 179, 8, 0.2);
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 0.75rem;
    font-size: 1rem;
    color: #fef3c7;
    line-height: 1.5;
}

/* Card Intro Text */
.card-intro {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

/* ============================================================================
   7. TABLES
   ============================================================================ */

.ars-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
    font-size: 0.8rem;
}

.ars-table th, .ars-table td {
    padding: 0.5rem 0.375rem;
    text-align: left;
    border-bottom: 1px solid rgba(220, 38, 38, 0.3);
    word-wrap: break-word;
}

.ars-table th {
    color: #fca5a5;
    font-weight: 600;
    font-size: var(--text-xs);
}

.ars-table td {
    color: var(--text-primary);
}

/* Matrix Table (Scenario Matrix) */
.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
}

.matrix-table th, .matrix-table td {
    padding: 0.375rem 0.25rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    word-wrap: break-word;
}

.matrix-table th {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    font-weight: 600;
}

.matrix-table td {
    color: var(--text-primary);
}

/* ============================================================================
   8. WARNINGS & NOTICES
   ============================================================================ */

.calculator-warning {
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid #eab308;
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 1rem;
    font-size: 1rem;
    color: #fef3c7;
    line-height: 1.5;
}

/* ============================================================================
   9. SHARE SECTION
   ============================================================================ */

.calculator-share-section {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1.5rem;
}

.share-cta {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.share-cta-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.share-cta h4 {
    margin: 0 0 0.25rem 0;
    color: #93c5fd;
    font-size: 1rem;
}

.share-cta p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-secondary);
}

.share-buttons-calc {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.share-btn-calc {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    color: white;
}

.share-btn-calc svg {
    width: 16px;
    height: 16px;
}

/* Brand colors picked for white-text contrast (WCAG AA 4.5:1 for normal
   text). Original Twitter/Facebook brand blues failed at roughly 2.7:1
   and 3.6:1, producing the washed-out "X (Twitter)" text the user
   reported. Workbench render comparison verified at
   C:/STORAGE/OSINT_Output/share-buttons-contrast-test.png. */
.share-twitter { background: #000000; }       /* X rebrand (black), 21:1 */
.share-twitter:hover { background: #1a1a1a; }

.share-facebook { background: #0a4ca6; }      /* darker than 2014 brand, 7.6:1 */
.share-facebook:hover { background: #073677; }

.share-reddit { background: #d83a00; }        /* darker than #FF4500, 4.6:1 */
.share-reddit:hover { background: #b13000; }

.share-whatsapp { background: #1f8c4a; }      /* darker than #25D366, 4.7:1 */
.share-whatsapp:hover { background: #166637; }

.share-copy {
    background: #475569;
    cursor: pointer;
    border: none;
    font-family: inherit;
}
.share-copy:hover { background: #334155; }

/* Cascade override: global .prose a:hover / .content a:hover (specificity 0,2,1)
   in core.css + typography-polish.css were forcing text color to accent-blue
   and re-adding underline on hover, making button text near-invisible against
   brand-colored backgrounds (Twitter blue text on Twitter blue button = blank).
   Compound selector (0,3,0) wins specificity and locks white text + no decoration
   across :link, :visited, :hover, :focus, :active states. */
.share-buttons-calc .share-btn-calc:link,
.share-buttons-calc .share-btn-calc:visited,
.share-buttons-calc .share-btn-calc:hover,
.share-buttons-calc .share-btn-calc:focus,
.share-buttons-calc .share-btn-calc:active {
    color: #ffffff;
    text-decoration: none;
    border-bottom: none;
}

/* ============================================================================
   10. RESPONSIVE BREAKPOINTS - TABLET (600px+)
   ============================================================================ */

@media (min-width: 600px) {
    .calculator-container {
        padding: 1.5rem;
    }
    
    .calculator-header h2 {
        font-size: 1.5rem;
    }
    
    .calculator-form {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    .result-card {
        padding: 1.25rem;
    }
    
    .result-card h3, .result-card h4 {
        font-size: 1.125rem;
    }
    
    .zone-indicator {
        font-size: 2.5rem;
    }
    
    .dose-breakdown {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .dose-item .dose-value {
        font-size: 1.5rem;
    }
    
    .time-dose-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .cancer-scenarios {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .decon-steps {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .risk-factors-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================================
   11. RESPONSIVE BREAKPOINTS - DESKTOP (900px+)
   ============================================================================ */

@media (min-width: 900px) {
    .calculator-container {
        padding: 2rem;
    }
    
    .calculator-header h2 {
        font-size: 1.75rem;
    }
    
    .calculator-header p {
        font-size: 1rem;
    }
    
    .calculator-form {
        gap: 1.5rem;
    }
    
    .result-card {
        padding: 1.5rem;
    }
    
    .result-grid.three-col {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .zone-indicator {
        font-size: 3rem;
    }
    
    .matrix-table {
        font-size: 1rem;
    }
    
    .matrix-table th, .matrix-table td {
        padding: 0.5rem;
    }
}

/* ============================================================================
   12. ACCESSIBILITY & PRINT
   ============================================================================ */

/* Focus visible for keyboard navigation */
.calc-select:focus-visible,
.calc-input:focus-visible,
.calc-button:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .calculator-results {
        animation: none;
    }
    
    .calc-button:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .calculator-container {
        background: white;
        color: black;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .calc-button,
    .calculator-share-section {
        display: none;
    }
    
    .result-card {
        break-inside: avoid;
    }
}
