/* Very Good Dice Roller - Main Styles */

:root {
    /* Logo background color - exact match for dark mode */
    --logo-dark-bg: #2c3e50;
    --logo-mustache: #8b4513;
    --logo-text: #ffffff;
    
    /* Dark mode colors - exact logo background match */
    --bg-primary: #2c3e50;
    --bg-secondary: #34495e;
    --bg-tertiary: #3c4f66;
    --text-primary: #ffffff;
    --text-secondary: #bdc3c7;
    --text-muted: #95a5a6;
    
    /* Accent colors */
    --accent-primary: #3498db;
    --accent-secondary: #2ecc71;
    --accent-danger: #e74c3c;
    --accent-warning: #f39c12;
    
    /* Interactive states */
    --hover-overlay: rgba(255, 255, 255, 0.1);
    --active-overlay: rgba(255, 255, 255, 0.2);
    --focus-outline: #3498db;
    
    /* Layout */
    --max-width: 1200px;
    --border-radius: 8px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    
    /* Borders */
    --border-color: rgba(255, 255, 255, 0.1);
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: #2c3e50;
    min-height: 100vh;
}

.app-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing-md);
    position: relative;
}

/* Compact Header */
.app-header {
    text-align: center;
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-sm) var(--spacing-md);
    background-color: #2c3e50;
}

.logo-container {
    margin-bottom: var(--spacing-sm);
}

.logo {
    height: 200px;
    width: auto;
}

.tagline {
    font-size: var(--font-size-xl);
    color: var(--text-secondary);
    font-weight: 400;
    margin: 0 auto;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90vw;
}

/* Compact Control Panel */
.control-panel {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.control-panel select,
.control-panel input[type="number"] {
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    min-width: 80px;
    height: 32px;
    box-sizing: border-box;
}

.modifier-mode {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

.modifier-mode input[type="checkbox"] {
    margin: 0;
    transform: scale(1.1);
    cursor: pointer;
}

.control-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    cursor: pointer;
    height: 32px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background-color: var(--hover-overlay);
    border-color: var(--text-muted);
}

/* Unified input focus - white outline with fade, no double outline */
select:focus,
input:focus,
textarea:focus {
    outline: 2px solid var(--text-muted);
    outline-offset: 2px;
    animation: focusFadeOut 3.5s ease-out forwards;
    /* Remove browser default outline and border highlighting */
    border-color: var(--text-muted);
    box-shadow: none;
}

/* Buttons */
button {
    font-family: inherit;
    font-size: var(--font-size-base);
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
}

.primary-btn {
    background-color: var(--accent-primary);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    background-color: #2980b9;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.primary-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.secondary-btn {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--bg-tertiary);
}

.secondary-btn:hover {
    background-color: var(--hover-overlay);
    border-color: var(--text-muted);
}

.danger-btn {
    background-color: var(--accent-danger);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
}

.danger-btn:hover {
    background-color: #c0392b;
}

/* Two Column Layout */
.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.dice-column {
    background-color: var(--bg-secondary);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.results-column {
    background-color: var(--bg-secondary);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.dice-column h3,
.results-column h3 {
    margin: 0 0 var(--spacing-md) 0;
    color: var(--text-primary);
    font-size: var(--font-size-lg);
    font-weight: 600;
}

/* Action Buttons Row */
.action-buttons-row {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.action-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    max-width: 180px;
    height: 32px;
    box-sizing: border-box;
}

.action-btn:hover {
    background-color: var(--hover-overlay);
    border-color: var(--text-muted);
}

/* Custom Roll Section */
.custom-roll-section {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.custom-roll-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    flex-wrap: wrap;
}

.custom-roll-controls .roll-btn {
    margin-left: auto;
}

.custom-roll-controls .roll-btn:first-of-type {
    margin-left: var(--spacing-lg);
}

.custom-roll-controls .roll-btn + .roll-btn {
    margin-left: var(--spacing-xs);
}

.custom-label {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    min-width: 100px;
    margin-right: var(--spacing-md);
}

.custom-roll-controls select,
.custom-roll-controls input[type="number"] {
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    min-width: 40px;
    max-width: 60px;
    font-size: var(--font-size-sm);
}

.roll-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    cursor: pointer;
    height: 32px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.roll-btn:hover {
    background-color: var(--hover-overlay);
    border-color: var(--text-muted);
}

.custom-roll-controls span {
    font-weight: 500;
    color: var(--text-secondary);
}

.expression-input {
    margin-top: var(--spacing-sm);
}

.expression-input input[type="text"] {
    width: 100%;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: monospace;
    font-size: var(--font-size-sm);
    box-sizing: border-box;
}


.roll-results {
    min-height: 200px;
    max-height: 400px;
    padding: 4px;
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.no-results {
    color: var(--text-muted);
    text-align: center;
    padding: var(--spacing-lg);
    font-style: italic;
}

.roll-result {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 4px 6px;
    border: 1px solid var(--border-color);
    font-family: var(--font-family);
    transition: all 0.2s ease;
}

.roll-result:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.roll-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
    font-weight: 600;
}

.roll-notation {
    color: var(--text-primary);
    font-size: var(--font-size-base);
}

.roll-total {
    color: var(--accent-secondary);
    font-size: var(--font-size-base);
    font-weight: 600;
}

.roll-details {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.2;
    margin-top: 2px;
    font-family: var(--font-mono);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.roll-dice-display {
    font-family: var(--font-mono);
    margin-top: var(--spacing-xs);
}

.expand-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: var(--font-size-xs);
    cursor: pointer;
    margin-left: var(--spacing-xs);
    transition: all 0.2s ease;
}

.expand-btn:hover {
    background-color: var(--hover-overlay);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.roll-expanded {
    max-height: 120px;
    overflow-y: auto;
    background-color: var(--bg-tertiary);
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
    margin-top: var(--spacing-xs);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    line-height: 1.3;
    border: 1px solid var(--border-color);
}

.dice-summary {
    color: var(--text-muted);
    font-style: italic;
}


/* Character Creation */
.character-creation-section {
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.character-creation-section h3 {
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    font-size: var(--font-size-xl);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm);
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.stats-total {
    text-align: center;
    padding: var(--spacing-md);
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    font-size: var(--font-size-lg);
}

/* Statistics Section */
.statistics-section {
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}


.stats-filters {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    align-items: center;
}

.stats-filters select {
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.stats-content {
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    min-height: 200px;
}

/* History Panel */
.history-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background-color: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.history-panel.open {
    right: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--bg-tertiary);
}

.history-header h3 {
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--text-primary);
    background-color: var(--hover-overlay);
    border-radius: 50%;
}

.close-modal {
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    color: var(--text-primary);
    background-color: var(--hover-overlay);
    border-radius: 50%;
}

.history-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.history-actions {
    padding: var(--spacing-md);
    border-top: 1px solid var(--bg-tertiary);
    display: flex;
    gap: var(--spacing-xs);
}

.history-actions button {
    flex: 1;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

.clear-history-confirm {
    background-color: var(--accent-danger) !important;
    color: white !important;
    animation: button-flash 150ms ease-out;
}

.clear-history-confirm:hover {
    background-color: #c0392b !important;
}

.history-toggle {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 999;
    background-color: var(--accent-primary);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.no-history {
    color: var(--text-muted);
    text-align: center;
    padding: var(--spacing-lg);
    font-style: italic;
}

.history-item {
    padding: var(--spacing-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-family: monospace;
    font-size: var(--font-size-sm);
}

.history-item:last-child {
    border-bottom: none;
}

.history-roll-result {
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.history-roll-result:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.history-roll-result:last-child {
    margin-bottom: 0;
}

.history-timestamp {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    text-align: right;
    margin-top: var(--spacing-xs);
    padding-top: var(--spacing-xs);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-family: var(--font-mono);
}


/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--bg-tertiary);
}

.modal-header h3 {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-md);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-family: inherit;
}

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

.form-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    margin-top: var(--spacing-lg);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        padding: var(--spacing-sm);
    }
    
    .logo {
        height: 80px;
    }
    
    .tagline {
        font-size: var(--font-size-lg);
    }
    
    .control-panel {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .two-column-layout {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .action-buttons-row {
        flex-wrap: wrap;
    }
    
    .action-btn {
        flex: 1 1 45%;
        max-width: none;
    }
    
    .custom-roll-controls {
        justify-content: center;
    }
    
    .history-panel {
        width: 100vw;
        right: -100vw;
    }
    
    .history-toggle {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        margin: var(--spacing-md) 0;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons button {
        min-width: auto;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .logo {
        max-width: 200px;
    }
    
    .tagline {
        font-size: var(--font-size-sm);
    }
    
    .custom-roll-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .expression-input {
        flex-direction: column;
    }
    
    .expression-input input[type="text"] {
        min-width: auto;
    }
}

/* Unified focus system - white outline that fades after 3 seconds */
button:focus,
button:focus-visible,
.dice-btn:focus,
.dice-btn:focus-visible,
.control-btn:focus,
.control-btn:focus-visible,
.action-btn:focus,
.action-btn:focus-visible,
.roll-btn:focus,
.roll-btn:focus-visible,
.mode-btn:focus,
.mode-btn:focus-visible,
.toggle-btn:focus,
.toggle-btn:focus-visible,
.filter-btn:focus,
.filter-btn:focus-visible,
.secondary-btn:focus,
.secondary-btn:focus-visible,
.primary-btn:focus,
.primary-btn:focus-visible,
.close-btn:focus,
.close-btn:focus-visible,
.close-modal:focus,
.close-modal:focus-visible,
.expand-btn:focus,
.expand-btn:focus-visible {
    outline: 2px solid var(--text-muted);
    outline-offset: 1px;
    animation: focusFadeOut 3.5s ease-out forwards;
}

@keyframes focusFadeOut {
    0%, 85.7% {  /* 3 seconds of 3.5s = 85.7% */
        outline-color: var(--text-muted);
    }
    100% {
        outline-color: transparent;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast support */
/* Methodology Section in Randomness Test Modal */
.methodology-section {
    background-color: var(--bg-tertiary);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin: var(--spacing-md) 0;
}

.methodology-section h4 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-md);
}

.methodology-section p {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-sm);
}

.methodology-section p:last-child {
    margin-bottom: 0;
}

/* Progression Chart Styling */
.progression-chart {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    line-height: 1.2;
    background-color: var(--bg-primary);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    overflow-x: hidden;
    white-space: pre;
    border: 1px solid var(--bg-tertiary);
}

@media (prefers-contrast: high) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1a1a1a;
        --bg-tertiary: #333333;
        --text-primary: #ffffff;
        --text-secondary: #ffffff;
        --text-muted: #cccccc;
    }
}