﻿/* -----------------------------------------------------------
   GLOBAL FOUNDATIONS
----------------------------------------------------------- */

/* Always reserve the scrollbar gutter — prevents layout shift / flicker
   when overlays or popovers cause the page to momentarily exceed viewport height.
   scrollbar-gutter:stable reserves the gutter on the right only, without
   forcing a visible scrollbar track or affecting the left-side layout. */
html {
    scrollbar-gutter: stable;
}

/* Background with subtle grain + vignette */
body {
    background: radial-gradient(circle at center, rgba(20, 20, 25, 0.6) 0%, rgba(10, 10, 14, 1) 80%), #0a0a0e;
    background-attachment: fixed;
    font-feature-settings: "liga" 1, "kern" 1;
}

    /* A faint texture */
    body::after {
        content: "";
        position: fixed;
        inset: 0;
        pointer-events: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Crect width='100%25' height='100%25' fill='none'/%3E%3Ccircle cx='2' cy='2' r='1' fill='rgba(255,255,255,0.03)'/%3E%3C/svg%3E");
        opacity: 0.4;
        mix-blend-mode: overlay;
        z-index: 0;
    }

/* Drawer width used by MudDrawer Style="width:250px" */
:root {
    --rpg-drawer-width: 250px;
    /* Fluid type scale — rem min/max respect user font settings; vw fills the middle. */
    --rpg-fluid-body: clamp(0.8rem, 1vw + 0.5rem, 1rem);
    --rpg-fluid-caption: clamp(0.7rem, 0.8vw + 0.45rem, 0.875rem);
    --rpg-fluid-subtitle: clamp(0.875rem, 1.2vw + 0.5rem, 1.25rem);
    --rpg-fluid-title: clamp(1rem, 2vw + 0.5rem, 2.125rem);
    --rpg-fluid-icon: clamp(1.2rem, 2.5vw + 0.5rem, 2rem);
}

.align-items-center {
    align-items: center !important;
}

/* -----------------------------------------------------------
   GENERAL UTILITY CLASSES
----------------------------------------------------------- */

.rpg-surface {
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(4px);
    border-radius: 8px;
}

.gray-paper {
    background: var(--mud-palette-background-gray);
}
/* -----------------------------------------------------------
   MAIN CONTENT
----------------------------------------------------------- */

.mud-main-content {
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 56px;
}

/* -----------------------------------------------------------
   APPBAR
----------------------------------------------------------- */

.mud-appbar {
    /* Use theme-driven background to respect dark/light mode */
    background: var(--mud-palette-appbar-background);
    border-bottom: 1px solid var(--mud-palette-primary);
    box-shadow: 0 0 6px rgba(255, 200, 68, 0.35), 0 4px 14px rgba(0,0,0,0.6);
}

.mud-appbar .mud-toolbar {
    /* Use appbar text color, fall back to general text if not set */
    color: var(--mud-palette-appbar-text, var(--mud-palette-text-primary));
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Appbar Buttons */
.mud-appbar .mud-button-root {
    /* Inherit to maintain contrast with appbar text color */
    color: inherit;
    transition: 0.25s ease-in-out;
}

.mud-appbar .mud-button-root:hover {
    color: var(--mud-palette-secondary);
    text-shadow: 0 0 6px var(--mud-palette-warning);
}

/* -----------------------------------------------------------
   NAVIGATION LINKS / DRAWER
----------------------------------------------------------- */

.mud-drawer {
    background: #141318;
    border-right: 1px solid rgba(255,200,68,0.2);
}

.mud-nav-link {
    padding: 12px 20px;
    border-left: 3px solid transparent;
    transition: 0.25s ease-in-out;
    font-weight: 500;
}

    .mud-nav-link:hover {
        background: rgba(255,200,68,0.06);
        border-left-color: var(--mud-palette-primary);
    }

    .mud-nav-link.active {
        background: rgba(255,200,68,0.12);
        border-left-color: var(--mud-palette-warning);
        color: var(--mud-palette-primary);
        font-weight: 600;
    }

/* -----------------------------------------------------------
   BUTTONS
----------------------------------------------------------- */

.mud-button-root {
    border-radius: 6px;
    font-weight: 600;
    letter-spacing: 0.4px;
    transition: all 0.25s ease;
}

.mud-button-filled {
    box-shadow: 0 0 6px rgba(255,200,68,0.25);
}

    .mud-button-filled:hover {
        box-shadow: 0 0 14px rgba(255,200,68,0.45);
        transform: translateY(-1px);
    }

.mud-button-outlined {
    border-color: var(--mud-palette-primary);
}

    .mud-button-outlined:hover {
        border-color: var(--mud-palette-secondary);
        box-shadow: 0 0 6px var(--mud-palette-secondary);
    }

/* -----------------------------------------------------------
   PAPERS
----------------------------------------------------------- */

.mud-paper {
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(4px);
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid rgba(255,200,68,0.15);
    box-shadow: 0 0 8px rgba(255,200,68,0.15), 0 0 20px rgba(0,0,0,0.5);
}

.mud-elevation-6,
.mud-elevation-8,
.mud-elevation-12 {
    transition: box-shadow 0.3s ease;
}

    .mud-elevation-8:hover {
        box-shadow: 0 0 20px rgba(255,200,68,0.3);
    }

/* -----------------------------------------------------------
   CARDS
----------------------------------------------------------- */

.mud-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,200,68,0.15);
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(255,200,68,0.12), 0 0 25px rgba(0,0,0,0.5);
}

    .mud-card:hover {
        box-shadow: 0 0 20px rgba(255,200,68,0.25), 0 0 30px rgba(0,0,0,0.7);
    }

/* Card headers */
.mud-card-header {
    border-bottom: 1px solid rgba(255,200,68,0.15);
    padding-bottom: 0.5rem;
}

/* -----------------------------------------------------------
   TEXT / TYPOGRAPHY
----------------------------------------------------------- */

.mud-typography-h3,
.mud-typography-h4 {
    text-shadow: 0 0 6px rgba(255,200,68,0.25);
    letter-spacing: 0.5px;
}

.mud-typography-h6 {
    text-shadow: 0 0 4px rgba(255,200,68,0.2);
}

/* -----------------------------------------------------------
   INPUTS, FIELDS, FORMS
----------------------------------------------------------- */

.mud-input-root,
.mud-select-root {
    border-radius: 6px;
}

    .mud-input-root:hover fieldset,
    .mud-select-root:hover fieldset {
        border-color: var(--mud-palette-primary) !important;
    }

    .mud-input-root input,
    .mud-select-root input,
    .mud-select-root .mud-input-slot {
        color: var(--mud-palette-text-primary);
    }

/* -----------------------------------------------------------
   TABLES
----------------------------------------------------------- */

.mud-table {
    background: rgba(20, 15, 10, 0.4);
    border-radius: 10px;
    border: 1px solid rgba(255,200,68,0.12);
}

    .mud-table thead {
        background: rgba(255,200,68,0.07);
    }

.mud-table-row:hover {
    background: rgba(255,200,68,0.08);
}

/* -----------------------------------------------------------
   TOOLTIP
----------------------------------------------------------- */

.mud-tooltip {
    background: #1a1a1f !important;
    border: 1px solid var(--mud-palette-primary);
    box-shadow: 0 0 10px rgba(255,200,68,0.4);
}

/* -----------------------------------------------------------
   DIALOGS
----------------------------------------------------------- */

.mud-dialog {
    background: rgba(15, 10, 5, 0.95);
    border: 1px solid rgba(255,200,68,0.2);
    box-shadow: 0 0 20px rgba(255,200,68,0.25), 0 0 30px rgba(0,0,0,0.8);
    border-radius: 12px;
}

/* MudAutocomplete applies MaxHeight + overflow-y:auto on the popover, while
   .mud-list also uses max-height:inherit + overflow-y:auto. That nesting leaves
   an outer scrollbar that only moves a few pixels. Keep scroll on the list only. */
.mud-popover.npc-catalog-picker {
    overflow-y: hidden !important;
}

.mud-popover.npc-catalog-picker .mud-list {
    max-height: inherit;
    overflow-y: auto;
}

/* -----------------------------------------------------------
   MISC UX TOUCHES
----------------------------------------------------------- */

/* Fancy horizontal divider */
hr,
.mud-divider {
    border-color: rgba(255,200,68,0.25) !important;
    margin: 1rem 0;
    position: relative;
}

    hr::after,
    .mud-divider::after {
        content: "✦";
        font-size: 0.9rem;
        color: var(--mud-palette-primary);
        position: absolute;
        left: 50%;
        top: -0.6rem;
        transform: translateX(-50%);
        background: #0b0b0e;
        padding: 0 0.3rem;
    }

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--mud-palette-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

/* -----------------------------------------------------------
   LOADING PROGRESS (Blazor boot)
----------------------------------------------------------- */

#app {
    position: relative;
    min-height: 100vh;
}

/* Centered spinner */
.loading-progress {
    position: fixed;
    left: 50%;
    top: 50%;
    width: 96px;
    height: 96px;
    transform: translate(-50%, -50%);
    z-index: 2; /* above the body overlay */
}

/* Base track circle */
.loading-progress circle:first-child {
    stroke: var(--mud-palette-primary, #d4af37);
    opacity: 0.18;
    fill: none;
    stroke-width: 6;
}

/* Animated arc */
.loading-progress circle:last-child {
    stroke: var(--mud-palette-primary, #d4af37);
    fill: none;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 1, 200;
    stroke-dashoffset: 0;
    animation: loading-dash 1.4s ease-in-out infinite;
}

/* Optional progress text below spinner */
.loading-progress-text {
    position: fixed;
    left: 50%;
    top: calc(50% + 72px);
    transform: translateX(-50%);
    color: var(--mud-palette-text-primary, #fdf7e3);
    font-weight: 600;
    letter-spacing: 0.4px;
    z-index: 2; /* above the body overlay */
    text-shadow: 0 0 6px rgba(0,0,0,0.4);
}

@keyframes loading-dash {
    0% {
        stroke-dasharray: 1, 200;
        stroke-dashoffset: 0;
    }

    50% {
        stroke-dasharray: 90, 200;
        stroke-dashoffset: -35;
    }

    100% {
        stroke-dasharray: 90, 200;
        stroke-dashoffset: -124;
    }
}

/* -----------------------------------------------------------
   Sticky Page Title Bar
----------------------------------------------------------- */


.sticky-title-bar {
    position: sticky;
    z-index: 1099;
    background: var(--mud-palette-background);
    border-bottom: 1px solid var(--mud-palette-primary);
    padding: 0.75rem 1.5rem;
    box-shadow: 0 2px 8px rgba(63,81,181,0.08);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sticky-title-icon {
    font-size: var(--rpg-fluid-icon);
    margin-right: 12px;
    color: var(--mud-palette-primary);
}

.sticky-title-text {
    font-weight: 600;
    font-size: var(--rpg-fluid-title) !important;
}

.sticky-title-bar .sticky-subtitle-text {
    font-size: var(--rpg-fluid-caption) !important;
}

@media (max-width: 600px) {
    .sticky-title-icon {
        margin-right: 6px;
    }

    .sticky-title-bar {
        padding: 0.4rem 0.75rem;
        gap: 0.4rem;
    }
}

@media (min-width: 601px) and (max-width: 1024px) {
    .sticky-title-icon {
        margin-right: 8px;
    }

    .sticky-title-bar {
        padding: 0.5rem 1rem;
    }
}

/* Desktop and large screens: clamp caps at MudBlazor h4 (2.125rem) */

/* -----------------------------------------------------------
   Encounter runner — mobile participant action sheet
----------------------------------------------------------- */
.encounter-mobile-sheet-host {
    position: fixed;
    inset: 0;
    z-index: 1500;
}

.encounter-mobile-sheet-scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.encounter-mobile-sheet {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 1;
    background: var(--mud-palette-surface);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.encounter-participant-row {
    flex-wrap: wrap;
}

.encounter-participant-name {
    flex: 1 1 120px;
    min-width: 0;
}

.encounter-participant-action-btn {
    min-height: 44px;
}

.encounter-header-btn {
    min-height: 44px;
    text-transform: none;
}

.npc-vitals-adjust-btn {
    flex: 0 0 auto;
    min-width: auto;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.npc-vitals-adjust-panel {
    width: fit-content;
    max-width: 100%;
}

.npc-vitals-adjust-field {
    width: 88px;
    flex: 0 0 auto;
}

.npc-vitals-adjust-field .mud-input-root {
    width: 88px;
}

.encounter-rank-field {
    width: 64px;
    flex-shrink: 0;
}

.encounter-rank-label {
    min-width: 28px;
    flex-shrink: 0;
}

.encounter-bank-display {
    min-width: 40px;
    font-weight: 600;
}

.encounter-round-chip {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.encounter-round-chip-appbar {
    vertical-align: middle;
    font-weight: 600;
}

.encounter-rank-field .mud-input-root {
    width: 64px;
}

/* -----------------------------------------------------------
   Footer Bar
----------------------------------------------------------- */
.footer-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    background: var(--mud-palette-surface);
    padding: 4px 8px;
    min-height: 56px;
    height: auto;
    flex-wrap: wrap;
    align-items: center;
    box-sizing: border-box;
}

/* Prevent content from being hidden behind the fixed footer bar.
   Footer height is auto (buttons can wrap on mobile), so use a generous buffer. */
.layout-main-content {
    padding-bottom: 140px; /* covers footer wrapping to 2 rows (~112px) + buffer */
}

/* -----------------------------------------------------------
   Player Game
----------------------------------------------------------- */

/* Outer wrapper div for the PlayerGame page content area */
.playergame-content {
    /* structural wrapper — no visual override needed */
}

/* Tab container inside PlayerCharacterRolls */
.player-character-rolls-tabs {
    /* structural wrapper — no visual override needed */
}

/* -----------------------------------------------------------
   Attribute Lists
----------------------------------------------------------- */

.rpg-skill-listitem {
    border: 1px solid var(--mud-palette-divider);
    border-radius: 7px;
    margin-bottom: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: rgba(255,255,255,0.01);
}

/* Selected state: uses MudBlazor's .mud-selected class */
.rpg-skill-listitem.mud-selected {
    border: 2px solid var(--mud-palette-primary);
    box-shadow: 0 0 8px var(--mud-palette-primary);
    background: rgba(255,202,68,0.08);
}

.rpg-skill-description {
    color: var(--mud-palette-info);
}

/* -----------------------------------------------------------
   Player Game Stats
----------------------------------------------------------- */

/* Typography / inline layout */
.rpg-stat-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
}

.rpg-stat-name {
    color: var(--mud-palette-primary);
    font-weight: 600;
}

.rpg-stat-base-inline {
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

/* Numeric editor sizing + contrast */
.rpg-stat-current-field {
    width: 6.0ch; /* ~3 digits + padding */
    min-width: 6.0ch;
}

.rpg-stat-current-field .mud-input-root {
    background: rgba(255, 255, 255, 0.03);
}

.rpg-stat-current-field .mud-input-root:hover fieldset {
    border-color: var(--mud-palette-secondary) !important;
    box-shadow: 0 0 6px rgba(255, 200, 68, 0.25);
}

/* Desktop/tablet: right-align current column only (wide layout uses MudTd align="right") */
.rpg-stat-current-cell {
    display: flex;
    justify-content: flex-end;
}

/* Wide layout (MdAndUp ≥960px): force table to fit its grid column exactly */
@media (min-width: 960px) {
    /* Fixed-layout makes the table respect the container width instead of sizing to content */
    .rpg-stat-table .mud-table-root {
        table-layout: fixed;
        width: 100%;
        min-width: 0;
    }
    /* Clip any residual overflow inside the panel — prevents page-level horizontal scrollbar */
    .rpg-stat-table .mud-table-container {
        overflow-x: hidden;
    }
}

/* Mobile: single-cell row with left content + right editor */
/* Matches MudBlazor SmAndDown breakpoint (MudHidden Breakpoint="MdAndUp" is visible below 960px) */
@media (max-width: 959.98px) {
    /* Force the td content back to left; MudBlazor responsive table mode may right-align */
    .rpg-stat-table .mud-table-row .mud-table-cell {
        text-align: left !important;
    }

    /* Header is redundant on small/medium screens; content is self-describing */
    .rpg-stat-table thead {
        display: none;
    }

    .rpg-stat-mobile-row {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.75rem;
    }

    .rpg-stat-mobile-row .rpg-stat-line {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Only the editor sticks to the right edge */
    .rpg-stat-mobile-row .rpg-stat-current-cell {
        margin-left: auto;
        flex: 0 0 auto;
        justify-content: flex-end;
        text-align: right;
    }

    .rpg-stat-table .rpg-stat-name,
    .rpg-stat-table .rpg-stat-base-inline {
        font-size: var(--rpg-fluid-body);
    }

    .rpg-stat-table .rpg-stat-current-field .mud-input-root input {
        font-size: var(--rpg-fluid-body);
    }
}

/* -----------------------------------------------------------
   Fluid typography (mobile / tablet)
   Scoped to main content so app bar + drawer keep Mud defaults.
----------------------------------------------------------- */
@media (max-width: 1024px) {
    .mud-main-content .mud-typography-body1,
    .mud-main-content .mud-typography-body2,
    .mud-main-content .mud-table .mud-table-cell,
    .mud-main-content .mud-list-item-text,
    .mud-main-content .mud-input-root input,
    .mud-main-content .mud-input-root textarea,
    .mud-main-content .mud-select .mud-input-slot {
        font-size: var(--rpg-fluid-body);
    }

    .mud-main-content .mud-typography-caption,
    .mud-main-content .mud-typography-overline {
        font-size: var(--rpg-fluid-caption);
    }

    .mud-main-content .mud-typography-subtitle1,
    .mud-main-content .mud-typography-subtitle2,
    .mud-main-content .mud-expansion-panel .mud-expansion-panel-header {
        font-size: var(--rpg-fluid-subtitle);
    }

    .mud-main-content .mud-typography-h6 {
        font-size: clamp(0.95rem, 1.5vw + 0.5rem, 1.25rem);
    }

    .mud-main-content .rpg-skill-listitem .mud-typography-body2 {
        font-size: var(--rpg-fluid-body);
    }
}

/* -----------------------------------------------------------
   Mobile Bottom Panel
----------------------------------------------------------- */

/* The inline panel replaces the rolls view — no special overrides needed */