/* ============================================
   K-Map Solver - Minimal UI Design
   Neutral/Warm Color Palette - No Scroll Layout
   ============================================ */

:root {
    /* Neutral/Warm palette */
    --color-primary: #c9824e;
    --color-primary-dark: #b8704c;
    --color-accent: #d4a574;
    --color-success: #9caf88;
    --color-error: #d97706;
    --color-warning: #f59e0b;
    
    /* Background and text */
    --color-bg: #faf9f7;
    --color-bg-alt: #f5f3f0;
    --color-border: #e8e3de;
    --color-text: #3a3430;
    --color-text-light: #7a7268;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
    /* Warm dark palette with better contrast */
    --color-bg: #1f1d1a;
    --color-bg-alt: #2a2724;
    --color-border: #3d3935;
    --color-text: #ede8e3;
    --color-text-light: #a89f94;
    
    /* Adjusted colors for dark mode */
    --color-primary: #d4956a;
    --color-primary-dark: #c48559;
    --color-accent: #e0b896;
    --color-success: #a8bb94;
    --color-error: #e8923d;
    --color-warning: #f5a623;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Overline for complemented variables */
.overline {
    text-decoration: overline;
    text-decoration-thickness: 2px;
}

html, body {
    width: 100%;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    transition: background-color 0.2s, color 0.2s;
}

/* App container with full viewport height */
.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Compact header */
.app-header {
    background: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 1.5rem;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.theme-toggle {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--color-text);
}

.theme-toggle:hover {
    background: var(--color-border);
    border-color: var(--color-primary);
}

.sun-icon { display: block; }
.moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }

/* Main grid layout */
.main-grid {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 1rem;
    flex: 1;
    overflow: hidden;
    padding: 1rem;
}

/* Responsive for smaller screens */
@media (max-width: 1400px) {
    .main-grid {
        grid-template-columns: 240px 1fr 280px;
        gap: 0.75rem;
        padding: 0.75rem;
    }
}

/* Panel styling */
.panel {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
}

.panel h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Scrollbar styling */
.panel::-webkit-scrollbar {
    width: 6px;
}

.panel::-webkit-scrollbar-track {
    background: transparent;
}

.panel::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.panel::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Input panel */
.input-panel {
    grid-column: 1;
}

/* K-Map panel */
.kmap-panel {
    grid-column: 2;
    overflow: visible;
}

/* Results panel */
.results-panel {
    grid-column: 3;
}

/* Form elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    color: var(--color-text);
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(201, 130, 78, 0.1);
}

/* Buttons */
.btn {
    padding: 0.65rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-family: inherit;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--color-accent);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--color-primary);
}

.btn-outline {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-outline:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-sm {
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
}

.btn-mode {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.btn-mode.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.full-width {
    width: 100%;
}

/* Button groups */
.button-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.button-group.compact .btn {
    flex: 1;
    font-size: 0.75rem;
    padding: 0.5rem 0.6rem;
}

/* K-Map visualization */
.kmap-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    margin-bottom: 1rem;
    position: relative;
    overflow: visible;
}

#kmap {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
}

.kmap-container {
    position: relative;
    display: inline-block;
    overflow: visible;
    animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.kmap-wrapper table {
    border-collapse: collapse;
    background: transparent;
    overflow: visible;
    position: relative;
    z-index: 1;
}

.kmap-wrapper td {
    width: 100px;
    height: 100px;
    text-align: center;
    vertical-align: middle;
    border: 2px solid var(--color-text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    color: var(--color-text);
    font-size: 1.4rem;
    background: #faf9f7 !important;
}

[data-theme="dark"] .kmap-wrapper td {
    background: #faf9f7 !important;
    color: #1a1816;
    border-color: #1a1816;
}

[data-theme="dark"] .kmap-wrapper td.labeled {
    background: #2a2724 !important;
    color: #ede8e3;
    border: none;
}

.kmap-wrapper td:hover {
    background: var(--color-accent);
    color: #fff;
}

.kmap-wrapper td.labeled {
    background: var(--color-bg-alt);
    font-size: 1rem;
    cursor: default;
    color: var(--color-text);
    font-weight: 600;
}

.kmap-wrapper td.labeled:hover {
    background: var(--color-bg-alt);
    color: var(--color-text);
}

.kmap-wrapper td.selected {
    background: var(--color-primary) !important;
    color: #fff !important;
    font-weight: 700;
}

.kmap-wrapper td.cell-one {
    background: #faf9f7 !important;
    color: var(--color-text);
}

.kmap-wrapper td.cell-one:hover {
    background: var(--color-accent) !important;
    color: #fff;
}

.kmap-wrapper td.cell-zero {
    background: #faf9f7 !important;
    color: var(--color-text-light);
}

.kmap-wrapper td.cell-zero:hover {
    background: var(--color-accent) !important;
    color: #fff;
}

.kmap-wrapper td.cell-dontcare {
    background: #faf9f7 !important;
    color: var(--color-text-light);
    font-style: italic;
}

.kmap-wrapper td.cell-dontcare:hover {
    background: var(--color-accent) !important;
    color: #fff;
}

.kmap-wrapper td.value-1 {
    background: #faf9f7 !important;
    color: var(--color-text);
}

.kmap-wrapper td.value-1:hover {
    background: var(--color-accent) !important;
    color: #fff;
}

[data-theme="dark"] .kmap-wrapper td.value-1 {
    background: #faf9f7 !important;
    color: #1a1816;
}

.kmap-wrapper td.value-X {
    background: #faf9f7 !important;
    color: var(--color-text-light);
    font-style: italic;
}

.kmap-wrapper td.value-X:hover {
    background: var(--color-accent) !important;
    color: #fff;
}

[data-theme="dark"] .kmap-wrapper td.value-X {
    background: #faf9f7 !important;
    color: #4a4540;
}

.kmap-wrapper th {
    padding: 14px;
    font-size: 1.1rem;
    color: var(--color-text);
    font-weight: 600;
    background: transparent !important;
    border: none;
}

.kmap-wrapper thead th:first-child {
    border: none;
    background: transparent !important;
}

.kmap-wrapper tbody th {
    border: none;
}

/* Interactive K-Map Table (Setup panel) */
.interactive-kmap-table {
    border-collapse: collapse;
    background: var(--color-bg);
    margin: 0.5rem 0;
}

.interactive-kmap-table th,
.interactive-kmap-table td {
    border: 2px solid var(--color-text);
    padding: 0.5rem;
    text-align: center;
    vertical-align: middle;
    font-size: 0.9rem;
}

.interactive-kmap-table thead th:first-child {
    border: none;
    background: transparent;
}

.interactive-kmap-table tbody th {
    border-left: none;
    font-weight: 600;
    background: var(--color-bg);
}

.interactive-kmap-table thead th {
    font-weight: 600;
    background: var(--color-bg);
}

.interactive-kmap-table td {
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-weight: 600;
    background: var(--color-bg);
    transition: all 0.15s;
}

.interactive-kmap-table td:hover {
    background: var(--color-accent);
    color: #fff;
}

.interactive-cell-0 {
    color: var(--color-text-light);
}

.interactive-cell-1 {
    color: var(--color-text);
    background: rgba(156, 175, 136, 0.2) !important;
}

.interactive-cell-X {
    color: var(--color-text-light);
    font-style: italic;
    background: rgba(201, 130, 78, 0.1) !important;
}

/* Loop overlay styling */
.loop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    overflow: visible;
}

.loop-overlay svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.loop-rect {
    pointer-events: auto;
    stroke-width: 4;
}

.loop-tooltip {
    position: absolute;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    max-width: 200px;
}

.loop-tooltip code {
    background: var(--color-bg);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Courier New', monospace;
}

/* Prime implicants list */
.prime-implicants-list {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.prime-implicants-list h3 {
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
}

.prime-implicant-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.85rem;
}

.color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Expression box */
.expression-box {
    background: var(--color-bg);
    padding: 1rem;
    border-radius: 5px;
    border: 1px solid var(--color-border);
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.95rem;
    color: var(--color-primary);
    word-break: break-all;
}

/* Empty state */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--color-text-light);
    font-style: italic;
}

/* Circuit container */
.circuit-container {
    min-height: 150px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

/* Saved K-Maps Section */
.saved-section {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.saved-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-light);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.saved-list {
    max-height: 150px;
    overflow-y: auto;
}

.saved-list:empty::after {
    content: 'No saved K-Maps yet';
    color: var(--color-text-light);
    font-size: 0.8rem;
    font-style: italic;
}

.saved-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.saved-item:hover {
    border-color: var(--color-primary);
    background: rgba(201, 130, 78, 0.05);
}

.saved-item-expr {
    font-weight: 600;
    color: var(--color-text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saved-item-meta {
    font-size: 0.7rem;
    color: var(--color-text-light);
}

.saved-item-delete {
    background: none;
    border: none;
    color: var(--color-error);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.9rem;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.saved-item-delete:hover {
    opacity: 1;
}

.circuit-container-mermaid {
    width: 100%;
    display: flex;
    justify-content: center;
}

.circuit-container-mermaid .mermaid {
    font-size: 0.9rem;
}

/* Mermaid styling */
.mermaid text {
    font-size: 12px !important;
    fill: var(--color-text) !important;
}

.mermaid .node rect,
.mermaid .node polygon,
.mermaid .node ellipse {
    stroke: var(--color-primary) !important;
    stroke-width: 1.5px !important;
    fill: var(--color-bg) !important;
}

.mermaid .edgePath path {
    stroke: var(--color-primary) !important;
}

[data-theme="dark"] .mermaid text {
    fill: #ede8e3 !important;
}

[data-theme="dark"] .mermaid .node rect,
[data-theme="dark"] .mermaid .node polygon,
[data-theme="dark"] .mermaid .node ellipse {
    fill: #2a2724 !important;
    stroke: #d4956a !important;
}

[data-theme="dark"] .mermaid .edgePath path {
    stroke: #d4956a !important;
}

[data-theme="dark"] .mermaid .nodeLabel {
    color: #ede8e3 !important;
    fill: #ede8e3 !important;
}

[data-theme="dark"] .mermaid .label {
    color: #ede8e3 !important;
    fill: #ede8e3 !important;
}

/* Prime implicants list */
.prime-implicants-list {
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
}

.prime-implicant-item {
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: var(--color-bg);
    border-left: 3px solid var(--color-accent);
    border-radius: 3px;
    font-family: 'Monaco', monospace;
}

/* Quick actions */
.quick-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.quick-actions .btn {
    flex: 1;
    font-size: 1.2rem;
    padding: 0.6rem;
}

/* Interactive K-map */
#interactiveKmapContainer table {
    width: 100%;
    margin-bottom: 0.5rem;
}

#interactiveKmapContainer td {
    cursor: pointer;
}

/* Batch and saved lists */
.batch-list,
.saved-list {
    font-size: 0.85rem;
    max-height: 120px;
    overflow-y: auto;
}

.list-item {
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: var(--color-bg);
    border-radius: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-item small {
    color: var(--color-text-light);
}

/* Utility classes */
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.text-muted { color: var(--color-text-light); }

/* ============================================
   Popup Modal with Blur Effect
   ============================================ */

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: popupFadeIn 0.15s ease-out;
}

.popup-modal {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.5rem 2.5rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: popupScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.popup-icon {
    width: 50px;
    height: 50px;
    background: var(--color-success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 0.75rem;
}

.popup-icon.success { background: var(--color-success); }
.popup-icon.error { background: var(--color-error); }
.popup-icon.warning { background: var(--color-warning); }
.popup-icon.info { background: var(--color-primary); }

.popup-message {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
}

.popup-fade-out {
    animation: popupFadeOut 0.3s ease-out forwards;
}

.popup-fade-out .popup-modal {
    animation: popupScaleOut 0.3s ease-out forwards;
}

@keyframes popupFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popupFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes popupScaleIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes popupScaleOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
}

@keyframes popupBounce {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* ============================================
   Animations - GitHub Pages Compatible
   ============================================ */

/* Keyframe Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-15px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(15px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Panel Animations */
.panel {
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-panel {
    animation: slideInLeft 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.kmap-panel {
    animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    animation-delay: 0.1s;
    animation-fill-mode: backwards;
}

.results-panel {
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    animation-delay: 0.15s;
    animation-fill-mode: backwards;
}

/* K-Map Table Cell Animations */
.kmap-wrapper td {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.kmap-wrapper td:hover {
    transform: scale(1.05);
    z-index: 5;
}

/* Result Expression Animation */
.expression-box {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.expression-box:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Button Animations */
.btn {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

/* Loop Animations */
.loop-rect {
    transition: opacity 0.25s ease, stroke-width 0.25s ease, filter 0.25s ease;
}

.loop-rect:hover {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

/* Prime Implicant List Items */
.prime-implicant-item {
    animation: fadeIn 0.3s ease;
    animation-fill-mode: backwards;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.prime-implicant-item:nth-child(1) { animation-delay: 0.1s; }
.prime-implicant-item:nth-child(2) { animation-delay: 0.15s; }
.prime-implicant-item:nth-child(3) { animation-delay: 0.2s; }
.prime-implicant-item:nth-child(4) { animation-delay: 0.25s; }
.prime-implicant-item:nth-child(5) { animation-delay: 0.3s; }
.prime-implicant-item:nth-child(6) { animation-delay: 0.35s; }

.prime-implicant-item:hover {
    transform: translateX(4px);
    background: rgba(201, 130, 78, 0.08);
}

/* Color Indicator Pulse on Hover */
.color-indicator {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.prime-implicant-item:hover .color-indicator {
    transform: scale(1.2);
    box-shadow: 0 0 8px currentColor;
}

/* Input Field Focus Animation */
input[type="text"],
input[type="number"],
select {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(201, 130, 78, 0.15);
}

/* Header Animation */
.app-header {
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Theme Toggle Animation */
.theme-toggle {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-toggle:hover {
    transform: rotate(15deg) scale(1.1);
}

.theme-toggle:active {
    transform: rotate(0deg) scale(0.95);
}

/* Tab Animations */
.tab-btn {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-btn:hover:not(.active) {
    transform: translateY(-1px);
}

.tab-btn.active {
    animation: pulse 0.3s ease;
}

/* Interactive Grid Cell Animation */
.interactive-kmap-table td {
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.interactive-kmap-table td:hover {
    transform: scale(1.08);
    z-index: 5;
}

.interactive-kmap-table td:active {
    transform: scale(0.95);
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Disable animations during URL load */
.no-animate *,
.no-animate *::before,
.no-animate *::after {
    animation: none !important;
    transition: none !important;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
