/*
 * FamilyForge.Web integration layer
 * Bridges the static Guild Ledger design system to the actual Blazor/MudBlazor markup.
 * Loaded last so page structure and MudBlazor components share one layout contract.
 */

html,
body,
#app {
    min-height: 100%;
}

body {
    overflow-x: hidden;
}

body.app-page,
body.landing-page,
body.empty-page {
    color: var(--ink);
    background: var(--page-bg);
}

.app-shell,
.admin-shell {
    width: 100%;
}

.workspace,
.admin-workspace {
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.workspace-content,
.admin-workspace-content {
    width: min(100%, 1440px);
    min-width: 0;
    margin: 0 auto;
}

.workspace-content > :first-child,
.admin-workspace-content > :first-child {
    margin-top: 0;
}

.screen-title,
.admin-screen-title,
.layout-screen-title {
    margin: 0 0 1.25rem;
    color: var(--ink);
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: clamp(1.8rem, 3.2vw, 2.7rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -.035em;
}

.panel-title,
.admin-panel-title {
    margin: 0 0 1rem;
    color: var(--ink);
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 1.25rem;
    line-height: 1.25;
}

.stat-label,
.admin-stat-label {
    color: var(--muted);
    font-size: .8rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: .045em;
    text-transform: uppercase;
}

.stat-value,
.admin-stat-value {
    color: var(--ink);
    font-size: clamp(1.45rem, 2.5vw, 2rem);
    font-weight: 850;
    line-height: 1;
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums;
}

.workspace-content .panel,
.workspace-content .stat-card,
.workspace-content .chore-card,
.workspace-content .treasure-card,
.workspace-content .member-plaque,
.workspace-content .detail-panel,
.workspace-content .review-panel,
.workspace-content .form-panel,
.admin-workspace-content .admin-panel,
.admin-workspace-content .admin-stat-card,
.admin-workspace-content .admin-detail-panel {
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--ledger-line);
    box-shadow: none;
}

.workspace-content .panel,
.detail-panel,
.review-panel,
.form-panel,
.admin-detail-panel {
    padding: clamp(1rem, 2.2vw, 1.5rem);
    border-radius: var(--radius-lg);
}

.workspace-content .stat-grid {
    align-items: stretch;
}

.workspace-content .stat-card {
    min-width: 0;
    min-height: 128px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    gap: .45rem;
    padding: 1.1rem;
    border-radius: var(--radius-md);
}

.workspace-content .stat-card > .mud-icon-root {
    margin-bottom: .35rem;
}

.action-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    margin: 1.25rem 0;
}

.card-grid {
    display: grid;
    gap: 1rem;
    align-items: stretch;
}

.card-grid.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-grid.three-col {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filter-bar {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--ledger-line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.filter-bar > .mud-tabs {
    min-width: 0;
}

.filter-bar .mud-tabs-panels {
    padding: .75rem;
    background: transparent;
}

.filter-bar .mud-tabs-tabbar {
    border-bottom: 1px solid var(--ledger-line);
    background: var(--surface-raised);
}

.treasure-card {
    min-width: 0;
    min-height: 190px;
    display: flex;
    flex-direction: column;
    padding: 1.15rem;
    border-radius: var(--radius-lg);
    box-shadow: inset 0 3px 0 var(--gold) !important;
}

.treasure-card > :last-child {
    margin-top: auto !important;
}

.form-panel {
    width: min(100%, 700px);
    margin-top: 1rem;
    border-top: 4px solid var(--forest) !important;
}

.form-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 1400;
    width: min(560px, calc(100vw - 2rem));
    max-height: min(84vh, 760px);
    margin: 0;
    overflow-y: auto;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 100vmax rgba(16, 26, 22, .52), var(--shadow) !important;
}

.detail-panel,
.review-panel {
    width: min(100%, 900px);
}

.detail-header {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.detail-header > div {
    min-width: 0;
    padding: .85rem;
    border: 1px solid var(--ledger-line);
    border-radius: var(--radius-md);
    background: var(--surface-raised);
}

.member-grid {
    align-items: stretch;
}

.member-plaque {
    min-width: 0;
    padding: 1rem;
    border: 1px solid var(--ledger-line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: inset 0 3px 0 var(--river);
}

.leaderboard-list {
    display: grid;
    gap: .75rem;
}

.leaderboard-entry {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--ledger-line);
    border-radius: var(--radius-md);
    background: var(--surface-raised);
}

/* The child summary uses hero-card markup but needs a compact in-app banner. */
.workspace-content > .hero-card {
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    padding: 1.35rem;
    border-radius: var(--radius-lg);
}

.workspace-content > .hero-card::after {
    display: none;
}

/* MudBlazor alignment with the Guild Ledger component language. */
.mud-button-root,
.mud-icon-button,
.mud-chip,
.mud-input-control .mud-input-root,
.mud-picker,
.mud-pagination-item,
.mud-menu-item,
.mud-tabs-tabbar .mud-tab {
    border-radius: var(--radius-md) !important;
}

.mud-button-root {
    min-height: 40px;
    font-weight: 750;
    text-transform: none;
}

.mud-button-filled-primary,
.mud-button-filled-secondary,
.mud-button-filled-tertiary {
    box-shadow: none !important;
}

.mud-button-filled-primary:hover,
.mud-button-filled-secondary:hover,
.mud-button-filled-tertiary:hover {
    box-shadow: 0 3px 0 var(--ledger-rule) !important;
    transform: translateY(-1px);
}

.mud-chip {
    min-height: 26px;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .045em;
}

.mud-paper,
.mud-table-container,
.mud-tabs {
    color: var(--ink);
}

.mud-table-container {
    max-width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    background: transparent !important;
    box-shadow: none !important;
}

.mud-table,
.mud-table-head,
.mud-table-body,
.mud-table-row,
.mud-table-cell {
    background: transparent !important;
}

.mud-table-cell {
    border-bottom-color: var(--ledger-line) !important;
}

.mud-table-head .mud-table-cell {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .065em;
    text-transform: uppercase;
}

.mud-input-control {
    min-width: 0;
}

.mud-input-outlined-border {
    border-color: var(--ledger-line) !important;
    border-radius: 7px !important;
}

.mud-dialog {
    border: 1px solid var(--ledger-line);
    border-top: 4px solid var(--forest);
    border-radius: var(--radius-lg) !important;
    background: var(--surface) !important;
}

.mud-popover,
.mud-menu-list {
    color: var(--ink);
    background: var(--surface-raised) !important;
}

.topbar-actions .mud-icon-button {
    width: 44px;
    height: 44px;
    border: 1px solid var(--ledger-line);
    background: var(--surface);
}

/* Landing page styles are now fully handled by design-system.css. */

/* Auth, onboarding, and other pages outside the authenticated shell. */
.empty-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
}

.empty-layout-content {
    width: min(100%, 960px);
}

.empty-theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 20;
}

.auth-card {
    width: min(100%, 470px);
    margin: 0 auto;
    border: 1px solid var(--ledger-line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-card-inner {
    padding: clamp(1.5rem, 5vw, 2.5rem);
}

.onboarding-wizard {
    width: min(100%, 820px);
    margin: 0 auto;
}

/* Admin pages use MudBlazor controls inside the Forgekeeper shell. */
.admin-workspace-content {
    display: grid;
    gap: 1.1rem;
}

.admin-screen-title {
    display: flex;
    align-items: center;
    gap: .65rem;
}

.admin-screen-title-icon {
    color: var(--river);
}

.admin-workspace-content .admin-hero {
    min-height: 0;
    grid-template-columns: auto minmax(0, 1fr);
    padding: clamp(1.25rem, 3vw, 2rem);
}

.admin-hero-orb {
    width: 76px;
    height: 82px;
    display: grid;
    place-items: center;
    border: 1px solid var(--ledger-line);
    border-radius: 12px 12px 20px 20px;
    background: var(--surface-raised);
}

.admin-orb-indicator {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--river);
    box-shadow: 0 0 0 7px rgba(111, 156, 175, .14);
}

.admin-orb-indicator.orb-healthy {
    background: var(--moss);
    box-shadow: 0 0 0 7px rgba(113, 139, 90, .16);
}

.admin-hero-headline,
.admin-hero-description {
    margin: 0;
}

.admin-hero-description,
.admin-panel-empty {
    margin-top: .35rem;
    color: var(--muted);
}

.admin-workspace-content .admin-stat-card {
    min-width: 0;
    min-height: 145px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    gap: .5rem;
}

.admin-filter-bar > * {
    min-width: 0;
}

.admin-action-button {
    align-self: center;
}

.admin-workspace-content .admin-panel {
    min-width: 0;
    overflow: hidden;
}

.admin-panel-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 1rem;
}

.admin-pagination-select {
    width: 120px;
}

.admin-detail-panel {
    display: grid;
    gap: 1rem;
}

.admin-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-back-button {
    margin-bottom: .5rem;
}

.admin-pill.pill-active {
    color: #38502d;
    background: rgba(113, 139, 90, .18);
}

.admin-pill.pill-disabled {
    color: var(--muted);
    background: var(--surface-subtle);
}

body[data-theme="dark"] .admin-pill.pill-active {
    color: #d9edc7;
}

@media (max-width: 1120px) {
    .card-grid.three-col {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .workspace,
    .admin-workspace {
        padding: 1rem;
    }

    .topbar,
    .admin-topbar {
        align-items: flex-start;
    }

    .screen-title,
    .admin-screen-title {
        font-size: 1.8rem;
    }

    .card-grid.two-col,
    .card-grid.three-col,
    .detail-header {
        grid-template-columns: 1fr;
    }

    .landing-page .landing-nav {
        display: none;
    }

    .landing-page .landing-nav.is-open {
        display: grid;
    }

    .admin-panel-footer {
        align-items: stretch;
        flex-direction: column;
    }
}

/* Live Blazor page compositions ported from the Guild Ledger prototype. */
.page-intro h1,
.hero-card h1,
.focus-card h2,
.section-heading h2,
.guild-journey-copy h2,
.reward-card h2,
.podium-card h2 {
    margin: 0;
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    color: var(--ink);
}

.page-intro h1 {
    max-width: 820px;
    font-size: clamp(2rem, 4.5vw, 3.75rem);
    line-height: 1.02;
    letter-spacing: -.045em;
}

.page-intro-copy {
    max-width: 720px;
    margin: .75rem 0 0;
    color: var(--muted);
    line-height: 1.65;
}

.hero-card h1 {
    max-width: 690px;
    font-size: clamp(2rem, 4.2vw, 3.7rem);
    line-height: 1;
    letter-spacing: -.045em;
}

.focus-card h2,
.section-heading h2,
.guild-journey-copy h2,
.reward-card h2,
.podium-card h2 {
    font-size: 1.35rem;
}

.empty-guild-panel {
    width: min(100%, 620px);
    margin: clamp(2rem, 8vw, 6rem) auto;
    padding: clamp(2rem, 6vw, 4rem);
    text-align: center;
}

.empty-guild-panel h1 {
    margin: .25rem 0 .75rem;
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
}

.empty-guild-panel p:not(.eyebrow) {
    max-width: 480px;
    margin: 0 auto 1.5rem;
    color: var(--muted);
}

.empty-guild-emblem {
    width: 70px;
    height: 78px;
    display: grid;
    place-items: center;
    margin: 0 auto 1rem;
    border: 1px solid var(--ledger-line);
    border-radius: 10px 10px 22px 22px;
    color: var(--guild-gold-ink);
    background: var(--guild-gold-soft);
    font-size: 1.75rem;
}

.ledger-empty-state {
    padding: 1.25rem;
    border: 1px dashed var(--ledger-line);
    color: var(--muted);
    background: var(--surface-subtle);
}

.ledger-empty-state strong {
    color: var(--ink);
}

.ledger-empty-state p {
    margin: .3rem 0 0;
}

.quest-review-ledger,
.hero-roll-panel,
.guild-chronicle-panel {
    margin-top: 1rem;
}

.treasure-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: -4px 0 14px;
}

.reward-card {
    min-width: 0;
}

.reward-card.is-inactive {
    opacity: .66;
}

.reward-card-actions,
.dialog-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .65rem;
    margin-top: auto;
}

.dialog-actions {
    justify-content: flex-end;
}

.reward-card .ember-action {
    color: var(--ember);
}

.wishlist-action.is-active,
.treasure-toolbar .is-active {
    border-color: var(--guild-gold);
    color: var(--guild-gold-ink);
    background: var(--guild-gold-soft);
}

.hero-roll-panel + .guild-chronicle-panel {
    margin-top: 1rem;
}

@media (max-width: 640px) {
    .page-intro {
        align-items: stretch;
    }

    .page-intro > .primary-button,
    .page-intro > button.primary-button {
        width: 100%;
    }

    .reward-card-actions > *,
    .dialog-actions > * {
        flex: 1;
    }
}

@media (max-width: 520px) {
    .topbar,
    .admin-topbar {
        flex-wrap: wrap;
    }

    .topbar-actions,
    .admin-topbar-actions {
        width: 100%;
        align-items: stretch;
    }

    .role-switcher {
        width: 100%;
    }

    .role-option {
        flex: 1;
    }

    .action-bar > .mud-button-root,
    .hero-actions > a {
        width: 100%;
    }

    .form-dialog {
        width: calc(100vw - 1rem);
    }

    .leaderboard-entry {
        grid-template-columns: auto minmax(0, 1fr);
    }
}
