/*
 * Flux office · navigation: the floating header, "Mai mult", the phone dock and its sheet, the logo (the account menu: fx-account.css).
 * Markup: resources/views/filament/header.blade.php and menu-tile.blade.php. Behaviour: Alpine in the markup, plus
 * public/js/fx-nav.js (focus, Back, swipe, the gliding marker). Tokens come from fx-tokens.css; nothing here is a raw
 * colour, radius, shadow, duration or z-index except values derived locally from tokens.
 *
 *   computer (>= 1280)        floating graphite glass header: logo, places with icons, "Mai mult" (a short list and the Setări row), account
 *   tablet on its side (1024) the same, places without icons
 *   phone, upright tablet     the header keeps the logo and the account; a floating glass dock at the bottom holds
 *   (< 1024)                  up to five places, "Mai mult" opens a sheet that slides up
 */

/* ---------- The logo (also on the login page, through the panel's brandLogo) ---------- */
.fx-brand { display: inline-flex; align-items: center; }
.fx-brand img { height: 1.75rem; width: auto; display: block; }
.fx-brand-name { font-weight: var(--fx-fw-bold); font-size: var(--fx-fs-18); letter-spacing: -0.01em; }
.fx-logo-dark { display: none !important; }

/* ---------- Local values, derived from the tokens ---------- */
.fx-nav {
    display: contents;                                                   /* the shell stays a direct child of <body> for sticky */
    --fx-nav-link-h: 40px;                                               /* header links; 44 with a touch screen */
    --fx-nav-pill-bg: var(--fx-on-dark-active);
    --fx-dock-item-w: 84px;
    --fx-dock-pad: 6px;
    --fx-dock-pill-bg: color-mix(in oklab, var(--fx-brand) 16%, transparent); /* see-through, so icons show while it glides */
    --fx-tile-hover: var(--fx-line-soft);
    --fx-pop-gap: 10px;
}
@media (pointer: coarse) { .fx-nav { --fx-nav-link-h: var(--fx-tap); } }
.fx-ico { width: 1.25rem; height: 1.25rem; flex: none; }

/* ---------- Skip to the page (the first stop for the keyboard) ---------- */
.fx-skip {
    position: fixed;
    top: calc(var(--fx-safe-t) + var(--fx-s-2));
    left: calc(var(--fx-safe-l) + var(--fx-s-2));
    z-index: var(--fx-z-top);
    padding: var(--fx-s-3) var(--fx-s-4);
    border-radius: var(--fx-r-ctl);
    background: var(--fx-surface);
    color: var(--fx-ink);
    font-weight: var(--fx-fw-semibold);
    box-shadow: var(--fx-shadow-3);
    transform: translateY(calc(-100% - var(--fx-s-6)));
}
.fx-skip:focus-visible { transform: none; outline: var(--fx-focus-width) solid var(--fx-focus-color); outline-offset: var(--fx-focus-offset); }

/* ---------- The shell: sticky at the top, the page shows through the gaps around the header ---------- */
.fx-shell {
    position: sticky;
    top: 0;
    z-index: var(--fx-z-header);
    padding: calc(var(--fx-safe-t) + var(--fx-hdr-gap)) max(var(--fx-gutter), var(--fx-safe-r)) 0 max(var(--fx-gutter), var(--fx-safe-l));
    pointer-events: none;                                                /* the gaps let clicks through to the page */
}
/* The strip above the header: the page scrolls away under a fade of the canvas, so nothing peeks out above it
   (not glass: a plain gradient, behind the header's own glass). */
.fx-shell::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: calc(var(--fx-safe-t) + var(--fx-hdr-gap) + var(--fx-hdr-h) * 0.6);
    pointer-events: none;
    background: linear-gradient(180deg, var(--fx-canvas) calc(var(--fx-safe-t) + var(--fx-hdr-gap)), color-mix(in oklab, var(--fx-canvas) 0%, transparent));
}

/* ---------- The header: graphite glass, a light along the top, the factory's colour along the bottom ---------- */
.fx-hdr {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    gap: var(--fx-s-2);
    max-width: var(--fx-content-max);
    height: var(--fx-hdr-h);
    margin: 0 auto;
    padding: 0 var(--fx-s-2) 0 var(--fx-s-4);
    border-radius: var(--fx-r-float);
    background: transparent;
    color: var(--fx-on-dark);
    box-shadow: var(--fx-shadow-dark);
    pointer-events: auto;
}
.fx-hdr::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    pointer-events: none;
    background: var(--fx-glass-sheen), var(--fx-glass-dark);
    -webkit-backdrop-filter: var(--fx-glass-dark-filter);
    backdrop-filter: var(--fx-glass-dark-filter);
    box-shadow: var(--fx-glass-edge-dark);
}
.fx-hdr::after {
    content: '';
    position: absolute;
    left: var(--fx-r-float);
    right: var(--fx-r-float);
    bottom: 0;
    z-index: -1;
    height: 2px;
    border-radius: 2px;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--fx-brand) 10%, var(--fx-brand) 90%, transparent);
}

.fx-hdr-logo {
    display: inline-flex;
    align-items: center;
    flex: none;
    min-height: var(--fx-tap);
    padding: 0 var(--fx-s-2);
    margin-right: var(--fx-s-2);
    border-radius: var(--fx-r-ctl);
    color: var(--fx-on-dark);
    text-decoration: none;
}
.fx-hdr .fx-logo-light { display: none !important; }
.fx-hdr .fx-logo-dark { display: block !important; }
.fx-hdr .fx-brand img { height: 2rem; }
.fx-hdr .fx-brand-name { color: var(--fx-on-dark); }

/* ---------- The places in the header ---------- */
.fx-hdr-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--fx-s-1);
    flex: 1;
    min-width: 0;
}
.fx-hdr-link {
    position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    gap: var(--fx-s-2);
    height: var(--fx-nav-link-h);
    padding: 0 clamp(var(--fx-s-3), calc(2.5vw - 20px), var(--fx-s-4));  /* 12 at 1280, 16 from 1440 */
    border-radius: var(--fx-r-pill);
    color: var(--fx-on-dark-2);
    font-size: var(--fx-fs-14);
    font-weight: var(--fx-fw-medium);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    -webkit-user-select: none;
    user-select: none;
    transition: color var(--fx-dur-2) var(--fx-ease-out), background-color var(--fx-dur-2) var(--fx-ease-out), transform var(--fx-dur-1) var(--fx-ease-out);
}
.fx-hdr-link .fx-ico { width: 1.125rem; height: 1.125rem; opacity: 0.9; }
.fx-hdr-link.is-on { color: var(--fx-on-dark); font-weight: var(--fx-fw-semibold); }
.fx-hdr-link.is-on .fx-ico { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
    .fx-hdr-link:hover { background-color: var(--fx-on-dark-hover); color: var(--fx-on-dark); }
    .fx-hdr-link.is-on:hover { background-color: transparent; }
}

/* The current place: a lighter pill with a short line in the factory's colour under the word (never brand text on graphite). */
.fx-nav-pill {
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: var(--fx-nav-pill-bg);
    box-shadow: inset 0 1px 0 var(--fx-on-dark-line);
    pointer-events: none;
}
.fx-nav-pill::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 4px;
    width: 16px;
    height: 3px;
    margin-left: -8px;
    border-radius: 3px;
    background: var(--fx-brand);
}

.fx-chev { width: 1rem; height: 1rem; transition: transform var(--fx-dur-3) var(--fx-ease-move); }
[aria-expanded="true"] > .fx-chev { transform: rotate(180deg); }
.fx-hdr-more-btn[aria-expanded="true"] { background-color: var(--fx-on-dark-hover); color: var(--fx-on-dark); }
.fx-hdr-more-btn .fx-chev { margin-right: calc(-1 * var(--fx-s-1)); opacity: 0.8; }

/* Focus on the dark header: white rings. */
.fx-hdr-logo:focus-visible,
.fx-hdr-link:focus-visible {
    outline: var(--fx-focus-width) solid var(--fx-focus-color-dark);
    outline-offset: var(--fx-focus-offset);
}

/* ---------- The account (the menu itself: partials/fx-account.blade.php and fx-account.css) ---------- */
.fx-hdr-account { position: relative; flex: none; margin-left: auto; display: flex; align-items: center; }

/* ---------- "Mai mult" on a computer: a short list from its button, then the Setări row ---------- */
.fx-hdr-more { position: relative; flex: none; }
.fx-more-pop {
    position: absolute;
    z-index: var(--fx-z-raised);
    top: calc(100% + (var(--fx-hdr-h) - var(--fx-nav-link-h)) / 2 + var(--fx-pop-gap));
    right: calc(-1 * var(--fx-s-2));
    width: min(20rem, calc(100vw - 2 * var(--fx-gutter)));
    overflow: hidden;
    color: var(--fx-ink);
    background: color-mix(in srgb, var(--fx-surface) 96%, transparent);  /* the page's main button must not glow through */
    -webkit-backdrop-filter: var(--fx-glass-filter);
    backdrop-filter: var(--fx-glass-filter);
    box-shadow: var(--fx-glass-edge), var(--fx-shadow-3);
    border-radius: var(--fx-r-float);
    transform-origin: calc(100% - 56px) 0;
}
/* Four places or more: two columns, so the list stays short. */
.fx-more-pop:has(.fx-more-list > :nth-child(4)) { width: min(35rem, calc(100vw - 2 * var(--fx-gutter))); }
.fx-more-pop:has(.fx-more-list > :nth-child(4)) .fx-more-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fx-more-body {
    max-height: calc(100dvh - var(--fx-top-stack) - var(--fx-s-6));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--fx-s-2);
    scrollbar-width: thin;
}
.fx-more-list { display: grid; gap: 2px var(--fx-s-1); }
/* More below: the last row fades out until the list is scrolled to its end. */
.fx-more-body.is-fx-nav-cut,
.fx-sheet-body.is-fx-nav-cut {
    -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - var(--fx-s-8)), transparent);
    mask-image: linear-gradient(180deg, #000 calc(100% - var(--fx-s-8)), transparent);
}

/* ---------- Tiles (both "Mai mult" surfaces): an icon and a name, nothing more ---------- */
.fx-tile {
    display: flex;
    align-items: center;
    gap: var(--fx-s-3);
    min-height: 48px;
    padding: var(--fx-s-1) var(--fx-s-3) var(--fx-s-1) var(--fx-s-1);
    border-radius: calc(var(--fx-r-float) - var(--fx-s-2));
    color: var(--fx-ink);
    text-decoration: none;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    transition: background-color var(--fx-dur-2) var(--fx-ease-out), transform var(--fx-dur-1) var(--fx-ease-out);
}
.fx-tile:active { transform: scale(0.97); background-color: var(--fx-tile-hover); }
@media (hover: hover) and (pointer: fine) {
    .fx-tile:hover { background-color: var(--fx-tile-hover); }
    .fx-tile:hover .fx-tile-ico { background: var(--fx-surface); box-shadow: inset 0 0 0 1px var(--fx-line-2); }
}
.fx-tile:focus-visible { outline: var(--fx-focus-width) solid var(--fx-focus-color); outline-offset: calc(-1 * var(--fx-focus-width)); }
.fx-tile-ico {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: var(--fx-r-ctl);
    background: var(--fx-sunk);
    color: var(--fx-graphite);
    box-shadow: inset 0 0 0 1px var(--fx-line);
    transition: background-color var(--fx-dur-2) var(--fx-ease-out), box-shadow var(--fx-dur-2) var(--fx-ease-out);
}
.fx-tile-label { min-width: 0; font-size: var(--fx-fs-14); font-weight: var(--fx-fw-semibold); line-height: var(--fx-lh-snug); }
/* The current place: the same tint as the dock's pill; the factory's colour in the icon, the words stay dark. */
.fx-tile.is-on { background-color: var(--fx-brand-tint); }
.fx-tile.is-on .fx-tile-ico { background: var(--fx-surface); color: var(--fx-brand-text); box-shadow: inset 0 0 0 1px var(--fx-brand-line); }
.fx-tile.is-on .fx-tile-label { font-weight: var(--fx-fw-strong); }

/* The Setări row: under a hairline, full width, a grey line naming what is inside, a chevron. */
.fx-tile-row { position: relative; min-height: 56px; margin-top: var(--fx-s-3); }
.fx-tile-row::before {
    content: '';
    position: absolute;
    left: var(--fx-s-2);
    right: var(--fx-s-2);
    top: calc(-1 * var(--fx-s-2) / 2 - 3px);
    height: 1px;
    background: var(--fx-line);
    pointer-events: none;
}
.fx-tile-text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.fx-tile-hint { overflow: hidden; color: var(--fx-ink-3); font-size: var(--fx-fs-12); line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.fx-tile-chev { margin-left: auto; color: var(--fx-ink-3); }

/* ---------- The dock: phones and upright tablets ---------- */
.fx-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--fx-bottom-gap);
    z-index: var(--fx-z-dock);
    display: flex;
    align-items: stretch;
    width: min(calc(var(--fx-dock-n, 5) * var(--fx-dock-item-w) + 2 * var(--fx-dock-pad)), calc(100% - 24px - var(--fx-safe-l) - var(--fx-safe-r)), 480px);
    height: var(--fx-dock-h);
    margin: 0 auto;
    padding: var(--fx-dock-pad);
    border-radius: var(--fx-r-float);
    background: var(--fx-glass);
    -webkit-backdrop-filter: var(--fx-glass-filter);
    backdrop-filter: var(--fx-glass-filter);
    box-shadow: var(--fx-glass-edge), var(--fx-shadow-3);
}
/* A floating bar (price, save) sits on the dock as one slab: while one shows (fx-nav.js reads --fx-bar-h), the dock
   takes the bar's width and its top corners square off under it. */
.fx-dock.is-fx-nav-slab,
html:has(.fi-sc-actions.fi-sticky) .fx-dock {                             /* Filament's floating save bar (office.css) */
    width: min(calc(100% - 24px - var(--fx-safe-l) - var(--fx-safe-r)), 480px);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}
.fx-dock-item {
    position: relative;
    isolation: isolate;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0;
    border-radius: calc(var(--fx-r-float) - var(--fx-dock-pad));
    color: var(--fx-ink-2);
    font-size: var(--fx-fs-12);
    font-weight: var(--fx-fw-semibold);
    line-height: 1;
    text-decoration: none;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    transition: transform var(--fx-dur-1) var(--fx-ease-out), color var(--fx-dur-2) var(--fx-ease-out);
}
.fx-dock-item:active { transform: scale(0.92); }
.fx-dock-item:focus-visible { outline: var(--fx-focus-width) solid var(--fx-focus-color); outline-offset: calc(-1 * var(--fx-focus-width)); }
.fx-dock-ico { display: grid; place-items: center; height: 24px; }
.fx-dock-ico .fx-ico { width: 24px; height: 24px; }
.fx-dock-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 16px;
    font-stretch: var(--fx-wdth-num);                                    /* narrow, so "Configurator" fits five to a 360px phone */
    letter-spacing: -0.01em;
}
.fx-dock-item.is-on { color: var(--fx-ink); font-weight: var(--fx-fw-strong); }
.fx-dock-item.is-on .fx-dock-ico { color: var(--fx-brand-text); }
.fx-dock-more[aria-expanded="true"] { color: var(--fx-ink); }
.fx-dock-pill {
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: var(--fx-dock-pill-bg);
    pointer-events: none;
}

/* ---------- "Mai mult" on phones and upright tablets: a sheet that slides up ---------- */
.fx-scrim {
    position: fixed;
    inset: 0;
    z-index: var(--fx-z-scrim);
    background: var(--fx-scrim);
    touch-action: none;                                                  /* the page behind does not scroll */
}
.fx-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--fx-z-sheet);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 640px;
    max-height: 85dvh;
    margin: 0 auto;
    padding: 0 var(--fx-safe-r) var(--fx-safe-b) var(--fx-safe-l);
    border-radius: var(--fx-r-sheet) var(--fx-r-sheet) 0 0;
    color: var(--fx-ink);
    background: var(--fx-glass-strong);
    -webkit-backdrop-filter: var(--fx-glass-filter);
    backdrop-filter: var(--fx-glass-filter);
    box-shadow: var(--fx-glass-edge), var(--fx-shadow-4);
    overscroll-behavior: contain;
}
.fx-sheet-top {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--fx-s-3);
    padding: var(--fx-s-5) var(--fx-s-3) var(--fx-s-1) var(--fx-s-5);
    touch-action: none;                                                  /* the finger drags the sheet, not the page */
    cursor: grab;
}
.fx-sheet-handle {
    position: absolute;
    top: var(--fx-s-2);
    left: 50%;
    width: 36px;
    height: 5px;
    margin-left: -18px;
    border-radius: var(--fx-r-pill);
    background: var(--fx-line-2);
}
.fx-sheet-title {
    margin: 0;
    font-size: var(--fx-fs-20);
    font-weight: var(--fx-fw-strong);
    font-stretch: var(--fx-wdth-head);
    letter-spacing: var(--fx-track-head);
    line-height: var(--fx-lh-snug);
}
.fx-sheet-close {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: var(--fx-tap);
    height: var(--fx-tap);
    border-radius: 50%;
    background: var(--fx-line-soft);
    color: var(--fx-ink-2);
    cursor: pointer;
}
.fx-sheet-close:focus-visible { outline: var(--fx-focus-width) solid var(--fx-focus-color); outline-offset: var(--fx-focus-offset); }
.fx-sheet-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 var(--fx-s-3) var(--fx-s-5);
}
/* The places as tiles, icon above the name: three to a row on a phone, four on an upright tablet. */
.fx-sheet-tiles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--fx-s-2);
    padding-top: var(--fx-s-2);
}
.fx-sheet-tiles .fx-tile {
    flex-direction: column;
    justify-content: center;
    gap: var(--fx-s-2);
    min-height: 84px;
    padding: var(--fx-s-3) var(--fx-s-1) var(--fx-s-2);
    border-radius: var(--fx-r-card);
    background: var(--fx-surface);
    box-shadow: var(--fx-shadow-1);
    text-align: center;
}
.fx-sheet-tiles .fx-tile:active { background: var(--fx-surface); box-shadow: var(--fx-shadow-0); }
.fx-sheet-tiles .fx-tile-ico { width: 40px; height: 40px; }
.fx-sheet-tiles .fx-tile-ico .fx-ico { width: 22px; height: 22px; }
.fx-sheet-tiles .fx-tile-label { font-size: var(--fx-fs-13); line-height: 1.2; overflow-wrap: anywhere; hyphens: auto; }
.fx-sheet-tiles .fx-tile.is-on { background: var(--fx-brand-tint); box-shadow: inset 0 0 0 1px var(--fx-brand-line); }
/* The Setări row in the sheet: a card of its own, full width, under the tiles. */
.fx-sheet .fx-tile-row {
    min-height: 64px;
    margin-top: var(--fx-s-3);
    padding: var(--fx-s-2) var(--fx-s-4) var(--fx-s-2) var(--fx-s-2);
    border-radius: var(--fx-r-card);
    background: var(--fx-surface);
    box-shadow: var(--fx-shadow-1);
}
.fx-sheet .fx-tile-row::before { display: none; }
.fx-sheet .fx-tile-row .fx-tile-ico { width: 44px; height: 44px; }
.fx-sheet .fx-tile-row:active { background: var(--fx-surface); box-shadow: var(--fx-shadow-0); }
.fx-sheet .fx-tile-row.is-on { background: var(--fx-brand-tint); box-shadow: inset 0 0 0 1px var(--fx-brand-line); }

/* ---------- Windows high contrast: tints vanish, so the current place gets a real outline ---------- */
@media (forced-colors: active) {
    .fx-nav-pill, .fx-dock-pill { outline: 2px solid CanvasText; outline-offset: -2px; }
    .fx-tile.is-on { outline: 2px solid CanvasText; outline-offset: -2px; }
    .fx-hdr::before, .fx-dock, .fx-sheet, .fx-more-pop { border: 1px solid CanvasText; }
}

/* ---------- Bands ---------- */
@media (min-width: 1024px) {
    .fx-dock, .fx-scrim, .fx-sheet { display: none !important; }
}
@media (max-width: 1023.98px) {
    .fx-hdr-nav { display: none; }
    .fx-hdr { padding: 0 var(--fx-s-1) 0 var(--fx-s-3); }
    .fx-hdr .fx-brand img { height: 1.75rem; }
}
@media (min-width: 640px) and (max-width: 1023.98px) {
    .fx-nav { --fx-dock-item-w: 96px; }
    .fx-dock { width: min(calc(var(--fx-dock-n, 5) * var(--fx-dock-item-w) + 2 * var(--fx-dock-pad)), calc(100% - 24px - var(--fx-safe-l) - var(--fx-safe-r)), 560px); }
    .fx-dock.is-fx-nav-slab,
    html:has(.fi-sc-actions.fi-sticky) .fx-dock { width: min(calc(100% - 24px - var(--fx-safe-l) - var(--fx-safe-r)), 560px); }
    .fx-sheet-body { padding-inline: var(--fx-s-5); }
    .fx-sheet-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--fx-s-3); }
}
@media (min-width: 1024px) and (max-width: 1279.98px) {
    .fx-hdr-link { padding: 0 var(--fx-s-3); }
    .fx-hdr-link > .fx-ico:not(.fx-chev) { display: none; }
}
/* A phone on its side: the dock shows icons only (the words stay for screen readers). */
@media (max-height: 480px) and (max-width: 1023.98px) {
    .fx-nav { --fx-dock-pad: 4px; }                                     /* 52px dock, 44px targets */
    .fx-dock-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .fx-dock { width: min(calc(var(--fx-dock-n, 5) * 64px + 2 * var(--fx-dock-pad)), calc(100% - 24px - var(--fx-safe-l) - var(--fx-safe-r))); }
    .fx-sheet { max-height: calc(100dvh - var(--fx-safe-t) - var(--fx-s-4)); }
    .fx-sheet-tiles { grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); }
    .fx-sheet-tiles .fx-tile { min-height: 72px; }
}
