/* theme.css */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700;800&display=swap');

:root,
:root[data-theme="dark"] {
    --bg-base: #100b1a; /* Deeper space purple */
    --bg-surface: #1d1330; /* Dark vibrant purple */
    --bg-surface-variant: #2c1b4d;
    --text-primary: #f9fafb;
    --text-secondary: #c4b5fd;

    --color-primary: #c084fc;
    --color-primary-hover: #a855f7;
    --color-secondary: #f472b6;
    --color-tertiary: #2dd4bf;
    --color-accent: #38bdf8;
    --color-success: #4ade80;
    --color-error: #f87171;


    --border-color: #4c1d95;
    --elevation-1: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --elevation-2: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --elevation-3: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

.log-entry.system { color: #facc15; }
.log-entry.error { color: #f87171; }
.log-entry.correct { color: #4ade80; }
.log-entry.wrong { color: #f87171; }
.log-entry.buzzer { color: #60a5fa; }

/* Custom View Transition for Tile Morphing */
::view-transition-group(active-tile) {
    animation-duration: 0.6s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Category Intro Slide Transitions */
::view-transition-old(category-intro) {
    animation: slideOutLeft 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}
::view-transition-new(category-intro) {
    animation: slideInRight 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes slideOutLeft {
    to { transform: translateX(-100vw); opacity: 0; }
}
@keyframes slideInRight {
    from { transform: translateX(100vw); opacity: 0; }
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Outfit', sans-serif;
    margin: 0;
    color: var(--text-primary);
}

/* Material Cards */
.md-card {
    background-color: var(--bg-surface);
    border-radius: 16px;
    box-shadow: var(--elevation-1);
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.md-card.interactive:hover {
    box-shadow: var(--elevation-3);
    transform: translateY(-4px);
    cursor: pointer;
    border-color: var(--color-primary);
}

.md-card-media {
    width: 100%;
    height: 160px;
    object-fit: cover;
    object-position: top center;
    background-color: var(--bg-surface-variant);
    border-bottom: 1px solid var(--border-color);
}

.md-card-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.md-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.md-card-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Buttons */
.md-btn {
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    box-shadow: var(--elevation-1);
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.md-btn:hover:not(:disabled) {
    background-color: var(--color-primary-hover);
    box-shadow: var(--elevation-2);
}

.md-btn:active:not(:disabled) {
    box-shadow: var(--elevation-1);
    transform: scale(0.98);
}

.md-btn:disabled {
    background-color: var(--bg-surface-variant) !important;
    color: var(--text-secondary) !important;
    cursor: not-allowed;
    box-shadow: none;
}

.md-btn-secondary {
    background-color: transparent;
    color: var(--color-primary);
    border: 1px solid var(--border-color);
    box-shadow: none;
}

.md-btn-secondary:hover:not(:disabled) {
    background-color: rgba(168, 85, 247, 0.1);
    border-color: var(--color-primary);
}

.md-btn-danger {
    background-color: var(--color-error);
}

.md-btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
}

.md-btn-success {
    background-color: var(--color-success);
    color: #121212;
}

/* Inputs */
.md-input {
    background-color: var(--bg-surface-variant);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 1rem;
    font-family: 'Roboto', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

.md-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

select.md-input {
    cursor: pointer;
    appearance: none;
}

/* FAB */
.md-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--color-secondary);
    color: white;
    border: none;
    box-shadow: var(--elevation-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 24px;
}

.md-fab:hover {
    transform: scale(1.05);
    box-shadow: var(--elevation-3);
}

/* Player Cards Details */
.player-card {
    position: relative;
    width: 220px;
}

.player-card.buzzed {
    border-color: var(--color-error);
    box-shadow: 0 0 15px rgba(248, 113, 113, 0.5);
}

.player-card.in-control {
    border-color: var(--color-tertiary);
    box-shadow: 0 0 15px rgba(45, 212, 191, 0.5);
}

.player-card.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.control-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--color-tertiary);
    color: #121212;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: bold;
    z-index: 10;
    box-shadow: var(--elevation-1);
    display: none;
}

.player-card.in-control .control-badge {
    display: block;
}

/* Grids */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    align-items: stretch;
}

.player-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

/* Active Question Pane Scaling */
#activeQuestionPane {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 3cqw;
    box-sizing: border-box;
    text-align: center;
}

#timerDisplay {
    font-size: 5cqh;
    color: var(--color-error);
    font-weight: 800;
    margin-bottom: 2cqh;
    font-family: 'Outfit', sans-serif;
}

#pointValueHeader {
    font-size: 6cqh;
    margin-bottom: 3cqh;
    color: var(--color-accent);
}

#questionText {
    font-size: 8cqh;
    margin-bottom: 4cqh;
    text-transform: uppercase;
    font-weight: 700;
    line-height: 1.2;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    width: 100%;
}

#answerText {
    font-size: 6cqh;
    color: var(--color-success);
    margin-bottom: 4cqh;
    font-weight: 600;
}

#buzzerStatus {
    margin-bottom: 2cqh;
    font-size: 4cqh;
    color: var(--text-secondary);
}

/* Card Container for Can I Buy */
#cib-container, #iab-container-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    width: 100%;
}

#cib-question-text {
    font-size: 6cqh;
    margin-bottom: 2cqh;
}

.card-container { 
    position: relative; 
    display: flex; 
    justify-content: center;
    flex: 1;
    min-height: 0;
    max-height: 100%;
    border-radius: 12px; 
    transform-style: preserve-3d; 
}
.card-container img { 
    max-height: 100%; 
    max-width: 100%; 
    object-fit: contain;
    border-radius: 12px; 
    display: block; 
}
.foil-effect { animation: foilTilt 4s infinite ease-in-out alternate; }
.foil-overlay { display: none; }
.foil-effect .foil-overlay { 
    display: block; 
    position: absolute; 
    top: 0; left: 0; right: 0; bottom: 0; 
    border-radius: 12px; 
    background: linear-gradient(125deg, rgba(255,0,0,0) 15%, rgba(255,0,0,0.5) 25%, rgba(255,165,0,0.5) 35%, rgba(255,255,0,0.5) 45%, rgba(0,128,0,0.5) 55%, rgba(0,0,255,0.5) 65%, rgba(128,0,128,0.5) 75%, rgba(128,0,128,0) 85%); 
    background-size: 300% 300%; 
    mix-blend-mode: overlay; 
    pointer-events: none; 
    animation: foilShine 4s infinite ease-in-out alternate; 
}
@keyframes foilTilt { 0% { transform: perspective(1000px) rotateY(-15deg) rotateX(5deg); } 100% { transform: perspective(1000px) rotateY(15deg) rotateX(-5deg); } }
@keyframes foilShine { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }

/* Overrides for Game Board */
.tv-container {
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
    background: #2e1065; /* Deep Purple Board Background */
    border-radius: 16px;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border: 4px solid var(--border-color);
    container-type: size;
}

.board {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    gap: 1.5%;
    padding: 2%;
    box-sizing: border-box;
}

.column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2%;
}

.category-header {
    background-color: #7c3aed; /* Vibrant purple */
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    text-align: center;
    padding: 5%;
    border-radius: 12px;
    font-size: 2cqw;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow: var(--elevation-1);
    height: 15%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    border: 2px solid #a78bfa;
}

.question-tile {
    background-color: #2563eb; /* Vibrant blue */
    color: #fcd34d; /* Yellow text */
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    text-align: center;
    padding: 5%;
    border-radius: 12px;
    font-size: 3.5cqw;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    box-shadow: var(--elevation-2);
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #60a5fa;
}

.question-tile:hover:not(.completed) {
    transform: scale(1.02);
    box-shadow: var(--elevation-2);
    border-color: var(--color-accent);
}

.question-tile.completed {
    opacity: 0.3;
    pointer-events: none;
    color: transparent;
}