/* Colori comuni: le personalizzazioni nei CSS di vista prevalgono. */
@layer foundation, palette, view-foundation;
@layer palette {
/* =========================================================
   FANTAINFINITY - PREMIUM NAVY & GOLD
   Shared surfaces and unified palette
   ========================================================= */

:root {
    /* Page */
    --fi-page-bg-top: #0B1F44;
    --fi-page-bg-bottom: #0B1F44;
    --fi-page-bg: #0B1F44;
    --fi-page-text: #FFFFFF;

    /* Cards */
    --fi-card-bg: #F8F5E9;
    --fi-card-inset: #FFFFFF;
    --fi-card-border: #D4AF37;

    /* Global typography */
    --fi-text: #FFFFFF;
    --fi-muted: #C7D5E8;
    --fi-accent: #D4AF37;

    /* Shared content surfaces */
    --fi-surface: #F8F5E9;
    --fi-surface-soft: #EAE5D8;
    --fi-surface-text: #0B1F44;
    --fi-surface-muted: #59677E;
    --fi-surface-accent: #A67C16;

    /* Supporting palette */
    --fi-royal-blue: #1D4ED8;
    --fi-gold: #D4AF37;
    --fi-gold-light: #F4DE98;
    --fi-pitch-green: #16A34A;
    --fi-border-soft: #DCD6C7;
    --fi-navy-soft: #132E59;
    --fi-focus: #D4AF37;

    /* Shadows */
    --fi-card-shadow: 0 5px 18px rgba(0, 9, 31, .24);
}

/* =========================================================
   PAGE BACKGROUND
   ========================================================= */

html:has(body.fi-unified-palette.fi-unified-palette),
html[data-theme]:has(body.fi-unified-palette.fi-unified-palette) {
    background: var(--fi-page-bg) ;
}

html body.fi-unified-palette.fi-unified-palette.fi-unified-palette.fi-unified-palette.fi-unified-palette.fi-unified-palette {
    background: var(--fi-page-bg) ;
}

html body.fi-unified-palette::before,
html body.fi-unified-palette::after {
    background: none ;
}

html body.fi-unified-palette.fi-unified-palette,
html[data-theme] body.fi-unified-palette:not(.auth-page) {
    background: var(--fi-page-bg) ;
    color: var(--fi-page-text) ;
    min-height: 100dvh;
    background-repeat: no-repeat ;
    -webkit-tap-highlight-color: rgba(212, 175, 55, .15);
}

/* Keep main containers transparent */
html body.fi-unified-palette.fi-unified-palette:is(
  main.page,
  main.dashboard-shell,
  .staff-page,
  .kind-shell,
  .var-shell,
  .guru-shell,
  .live-shell,
  .round-recap-shell,
  .fi-account-shell,
  .market-shell,
  .competition-shell
) {
    background-color: transparent ;
    background-image: none ;
}

/* =========================================================
   SHARED CARDS - IVORY
   ========================================================= */

html body.fi-unified-palette.fi-unified-palette:is(
  .panel,
  .dashboard-panel,
  .gent-panel,
  .kind-panel,
  .var-panel,
  .zazu-panel,
  .fi-account-card,
  .tool-card,
  .player-card,
  .team-card,
  .match-card,
  .mobile-standing-card,
  .staff-copy,
  .club-overview-card,
  .fan-change-panel,
  .card-body,
  .news-card,
  .news-card-body,
  .club-card,
  .csv-panel,
  .login-audit-card,
  .leaders-panel,
  .bench-panel,
  .staff-heading,
  .table-panel,
  .news-empty
):not(:has(.pitch)) {
    background: var(--fi-surface) ;
    color: var(--fi-surface-text) ;
    border-color: var(--fi-card-border) ;
    box-shadow: var(--fi-card-shadow) ;
}

/* Preserve individual illustrated card backgrounds */
html body.fi-unified-palette.fi-unified-palette:is(.market-card, .competition-card, .staff-card) {
    border-color: var(--fi-card-border) ;
}

/* =========================================================
   TEXT INSIDE LIGHT SURFACES
   ========================================================= */

html body.fi-unified-palette.fi-unified-palette:is(
  .panel,
  .dashboard-panel,
  .gent-panel,
  .kind-panel,
  .var-panel,
  .zazu-panel,
  .fi-account-card,
  .tool-card,
  .player-card,
  .team-card,
  .match-card,
  .mobile-standing-card,
  .staff-copy,
  .club-overview-card,
  .fan-change-panel,
  .news-card-body,
  .club-card,
  .csv-panel,
  .login-audit-card,
  .staff-heading,
  .table-panel,
  .news-empty
):not(:has(.pitch)):is(h1, h2, h3, h4, p, label, td, th) {
    color: var(--fi-surface-text) ;
    -webkit-text-fill-color: var(--fi-surface-text) ;
    text-shadow: none ;
}

/* Secondary text - muted slate */
html body.fi-unified-palette.fi-unified-palette:is(
  .staff-copy,
  .panel-header,
  .player-body,
  .player-meta,
  .gent-panel,
  .kind-panel,
  .var-panel,
  .zazu-panel,
  .staff-heading,
  .news-card-body,
  .news-empty
):is(small, .subtitle, .description) {
    color: var(--fi-surface-muted) ;
    -webkit-text-fill-color: var(--fi-surface-muted) ;
    text-shadow: none ;
}

/* Premium gold accents on light backgrounds */
html body.fi-unified-palette.fi-unified-palette:is(
  .staff-copy > small,
  .staff-copy > b,
  .section-heading > div > span,
  .panel-header .kicker,
  .staff-heading > small
) {
    color: var(--fi-surface-accent) ;
    -webkit-text-fill-color: var(--fi-surface-accent) ;
}

/* =========================================================
   INPUTS - WHITE, NAVY TEXT, GOLD FOCUS
   ========================================================= */

html body.fi-unified-palette.fi-unified-palette:is(
  .panel,
  .gent-panel,
  .kind-panel,
  .var-panel,
  .zazu-panel,
  .fi-account-card,
  .table-panel,
  .advanced-filters,
  .search-box
):is(
  input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]):not([type=submit]),
  select,
  textarea
) {
    background: #FFFFFF ;
    color: var(--fi-surface-text) ;
    -webkit-text-fill-color: var(--fi-surface-text) ;
    border-color: #B8B1A1 ;
    color-scheme: light;
}

html body.fi-unified-palette:is(input, textarea)::placeholder {
    color: #68768B;
    opacity: 1;
}

html body.fi-unified-palette:is(a, button, input, select, textarea, summary):focus-visible {
    outline: 3px solid var(--fi-focus) ;
    outline-offset: 3px ;
}

/* =========================================================
   GENERAL INTERACTION AND SPACING
   ========================================================= */

html:has(body.fi-unified-palette) {
    scroll-padding-top: 84px;
    scroll-padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

html body.fi-unified-palette:is(a, button, summary) {
    touch-action: manipulation;
}

html body.fi-unified-palette:is(.staff-copy, .market-card, .section-heading):is(h2, p) {
    overflow-wrap: anywhere;
}

html body.fi-unified-palette:is(
  .staff-card,
  .market-card,
  .mobile-duo-card,
  .mobile-lineup-cta
) {
    transition: filter .15s ease;
}

html body.fi-unified-palette:is(
  .staff-card,
  .market-card,
  .mobile-duo-card,
  .mobile-lineup-cta
):active {
    filter: brightness(.94);
}

/* =========================================================
   TABLES - IVORY / WHITE
   ========================================================= */

html body.fi-unified-palette.fi-unified-palette:is(.table-wrapper, .table-panel) {
    min-width: 0;
    max-width: 100%;
}

html body.fi-unified-palette.fi-unified-palette.table-wrapper {
    overflow-x: auto ;
}

html body.fi-unified-palette.fi-unified-palette.table-panel :is(thead, th, .table-header) {
    background: var(--fi-navy-soft) ;
    color: #FFFFFF ;
    -webkit-text-fill-color: #FFFFFF ;
}

html body.fi-unified-palette.fi-unified-palette.table-panel tbody tr {
    background: var(--fi-surface) ;
    border-color: var(--fi-border-soft) ;
}

html body.fi-unified-palette.fi-unified-palette.table-panel tbody tr:nth-child(even) {
    background: #FFFFFF ;
}

html body.fi-unified-palette.fi-unified-palette.table-panel tbody tr:hover {
    background: #F1E8D3 ;
}

/* =========================================================
   MISCELLANEOUS TEXT
   ========================================================= */

html body.fi-unified-palette.fi-unified-palette:is(.staff-club-link, .fi-account-back) {
    color: var(--fi-page-text) ;
}

html body.fi-unified-palette.fi-unified-palette:is(
  .fi-account-card dt,
  .fi-account-card dd,
  .staff-heading > span,
  .player-meta span,
  .player-meta b,
  .news-card-time
) {
    color: var(--fi-surface-text) ;
    -webkit-text-fill-color: var(--fi-surface-text) ;
    text-shadow: none ;
}

/* Header text on navy table headers */
html body.fi-unified-palette.fi-unified-palette.table-header strong {
    color: #FFFFFF ;
    -webkit-text-fill-color: #FFFFFF ;
    text-shadow: none ;
}

html body.fi-unified-palette.fi-unified-palette.player-body {
    background: var(--fi-surface) ;
}

/* =========================================================
   RESPONSIVE SHARED ELEMENTS
   ========================================================= */

@media (max-width: 760px) {
    html body.fi-unified-palette    :is(
    .advanced-filters input,
    .advanced-filters select,
    .search-box input,
    .fi-account-card input
  ) {
        font-size: 16px ;
        min-height: 44px;
    }

    html body.fi-unified-palette    :is(.filter-button, .apply-filters, .reset-filters) {
        min-height: 44px;
    }

    html body.fi-unified-palette    :is(.staff-heading, .news-empty) {
        padding: 16px ;
    }

    html body.fi-unified-palette .staff-copy {
        gap: 8px ;
    }
}

@media (prefers-reduced-motion: reduce) {
    html body.fi-unified-palette {
        scroll-behavior: auto ;
    }

    html body.fi-unified-palette    :is(
    .staff-card,
    .market-card,
    .competition-card,
    .club-action,
    .mobile-duo-card,
    .mobile-lineup-cta
  ) {
        transition: none ;
    }
}

/* =========================================================
   NATURAL DOCUMENT FLOW
   ========================================================= */

html body.fi-unified-palette:is(
  .dashboard-page,
  .market-page,
  .assistenti-page
) {
    height: auto ;
    min-height: calc(100dvh + 24px) ;
    overflow-y: auto ;
}

/* =========================================================
   MARKET PAGE
   ========================================================= */

html body.fi-unified-palette.market-page main.market-shell {
    display: flex ;
    flex-direction: column ;
    height: auto ;
    min-height: 0 ;
    gap: 18px ;
    overflow: visible ;
    padding: 8px 0 calc(112px + env(safe-area-inset-bottom)) ;
}

html body.fi-unified-palette.market-page main.market-shell .merenda-market-entry {
    margin: 0 ;
    flex-shrink: 0 ;
}

html body.fi-unified-palette.market-page main.market-shell .market-actions {
    display: grid ;
    grid-template-columns: repeat(3, minmax(0, 1fr)) ;
    grid-template-rows: none ;
    grid-auto-rows: auto ;
    gap: 16px ;
    margin: 0 ;
    align-items: start ;
}

html body.fi-unified-palette.market-page main.market-shell .market-actions > a.market-card {
    height: 260px ;
    min-height: 0 ;
    margin: 0 ;
    transform: none ;
    border-width: 1px ;
    box-shadow: var(--fi-card-shadow) ;
}

/* =========================================================
   ASSISTENTI PAGE
   ========================================================= */

html body.fi-unified-palette.assistenti-page main.staff-page {
    padding: 8px 12px calc(112px + env(safe-area-inset-bottom)) ;
}

html body.fi-unified-palette.assistenti-page.staff-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) ;
    gap: 16px ;
}

html body.fi-unified-palette.assistenti-page.staff-card {
    display: grid ;
    grid-template-columns: 116px minmax(0, 1fr) ;
    min-height: 158px ;
    border-width: 1px ;
    border-radius: 18px ;
    box-shadow: var(--fi-card-shadow) ;
}

html body.fi-unified-palette.assistenti-page.staff-art {
    height: 100% ;
    min-height: 158px ;
}

html body.fi-unified-palette.assistenti-page.staff-art img {
    position: absolute;
    inset: 24px 0 0;
    height: calc(100% - 24px) ;
}

html body.fi-unified-palette.assistenti-page.staff-copy {
    padding: 14px ;
    min-width: 0;
    justify-content: center;
    box-shadow: none ;
}

html body.fi-unified-palette.assistenti-page.staff-copy h2 {
    font: 800 20px/1.15 Arial, sans-serif ;
}

html body.fi-unified-palette.assistenti-page.staff-copy p {
    font: 400 13px/1.4 Arial, sans-serif ;
}

/* =========================================================
   MOBILE LAYOUT
   ========================================================= */

@media (max-width: 760px) {
    html body.fi-unified-palette.market-page    main.market-shell .market-actions,
    html body.fi-unified-palette.assistenti-page.staff-grid {
        grid-template-columns: minmax(0, 1fr) ;
    }

    html body.fi-unified-palette.market-page main.market-shell .market-actions > a.market-card {
        height: 190px ;
    }

    html body.fi-unified-palette.assistenti-page .staff-card {
        grid-template-columns: 100px minmax(0, 1fr) ;
    }
}

}
