@import 'tailwindcss';
@import './themes.css';

@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
@source '../../storage/framework/views/*.php';

/*
 * Token -> utility bridge. `@theme inline` makes each utility reference the
 * runtime CSS variable (not a build-time copy), so bg-surface, text-fg-2,
 * border-line, bg-brand/15 ... all follow whichever theme is active.
 * The tokens themselves are documented in themes.css and docs/design-system.md.
 */
@theme inline {
    --font-sans: var(--mm-font-active);

    --color-app: var(--mm-bg);
    --color-sidebar: var(--mm-sidebar);
    --color-surface: var(--mm-surface);
    --color-surface-2: var(--mm-surface-2);
    --color-surface-3: var(--mm-surface-3);
    --color-line: var(--mm-border);
    --color-line-strong: var(--mm-border-strong);

    --color-fg: var(--mm-fg);
    --color-fg-2: var(--mm-fg-2);
    --color-fg-3: var(--mm-fg-3);

    --color-brand: var(--mm-brand);
    --color-brand-hover: var(--mm-brand-hover);
    --color-brand-pressed: var(--mm-brand-pressed);
    --color-brand-soft: var(--mm-brand-soft);
    --color-brand-text: var(--mm-brand-text);
    --color-on-brand: var(--mm-on-brand);

    --color-success: var(--mm-success);
    --color-success-soft: var(--mm-success-soft);
    --color-warning: var(--mm-warning);
    --color-warning-soft: var(--mm-warning-soft);
    --color-danger: var(--mm-danger);
    --color-danger-soft: var(--mm-danger-soft);
    --color-danger-solid: var(--mm-danger-solid);
    --color-danger-solid-hover: var(--mm-danger-solid-hover);
    --color-on-danger: var(--mm-on-danger);
    --color-info: var(--mm-info);
    --color-info-soft: var(--mm-info-soft);

    --color-float: var(--mm-float);

    --shadow-float: var(--mm-shadow-float);
    --shadow-card: var(--mm-shadow-card);
}

@layer base {
    html {
        font-family: var(--mm-font-active);
        -webkit-text-size-adjust: 100%;
    }

    body {
        background-color: var(--mm-bg);
        color: var(--mm-fg);
        font-size: 0.875rem;
        line-height: 1.375rem;
        -webkit-font-smoothing: antialiased;
    }

    /* One consistent, always-visible keyboard focus indicator. */
    :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
        outline: 2px solid var(--mm-ring);
        outline-offset: 2px;
    }

    ::selection {
        background-color: color-mix(in oklab, var(--mm-brand) 45%, transparent);
    }

    /* Dark, low-contrast scrollbars so overflow regions don't flash white. */
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--mm-border-strong) transparent;
    }

    [x-cloak] {
        display: none !important;
    }
}

@layer components {
    /*
     * Glass. Static panels are translucent only (a hairline border and a faint
     * top highlight), so a page of cards stays cheap to paint. Layers that
     * overlap content — menus, dialogs, toasts, the header and sticky action
     * bars — also blur what is behind them. Opacity and blur come from the
     * --mm-glass-* tokens, which the fallbacks at the end of this file drop to
     * solid surfaces.
     */
    .mm-panel {
        background-color: color-mix(in oklab, var(--mm-surface) var(--mm-glass-opacity), transparent);
        border: 1px solid var(--mm-border);
        box-shadow: var(--mm-shadow-card);
    }

    /* Floating layers: menus, dialogs, toasts, tooltips. */
    .mm-float {
        background-color: color-mix(in oklab, var(--mm-float) var(--mm-glass-float-opacity), transparent);
        -webkit-backdrop-filter: var(--mm-glass-filter);
        backdrop-filter: var(--mm-glass-filter);
        box-shadow: var(--mm-shadow-float);
    }

    /*
     * Bars that stay put while the page scrolls under them (header, sticky
     * action bars, the sidebar). The colour and blur sit on a pseudo-element:
     * a blurred element becomes the backdrop root for its descendants, which
     * would stop the menus inside the header from seeing the page behind them.
     */
    .mm-glass-bar {
        position: relative;
        isolation: isolate;
    }

    .mm-glass-bar::before {
        content: '';
        position: absolute;
        inset: 0;
        z-index: -1;
        pointer-events: none;
        background-color: color-mix(in oklab, var(--mm-bar-color, var(--mm-header)) var(--mm-glass-float-opacity), transparent);
        -webkit-backdrop-filter: var(--mm-glass-filter);
        backdrop-filter: var(--mm-glass-filter);
    }

    .mm-glass-bar--sidebar {
        --mm-bar-color: var(--mm-sidebar);
    }

    /*
     * A quiet brand-tinted glow behind the whole workspace; it is the only thing
     * the glass has to show. Browsers without color-mix() get no glow at all
     * rather than a full-strength one.
     */
    .mm-ambient {
        position: relative;
        isolation: isolate;
    }

    @supports (color: color-mix(in oklab, red 50%, transparent)) {
        .mm-ambient::before {
            content: '';
            position: fixed;
            inset: 0;
            z-index: -1;
            pointer-events: none;
            background:
                radial-gradient(60rem 34rem at 78% -10%, color-mix(in oklab, var(--mm-brand) var(--mm-glow-strength), transparent), transparent 72%),
                radial-gradient(46rem 30rem at 6% 100%, color-mix(in oklab, var(--mm-brand) var(--mm-glow-strength-2), transparent), transparent 72%);
        }
    }

    /*
     * One definition for every text-like control (input, select, textarea) so
     * heights, borders, focus and error states cannot drift between pages.
     * Used by <x-ui.input|select|textarea>.
     */
    .mm-control {
        @apply block h-9 w-full rounded-lg border border-line-strong bg-surface-2 px-3 text-sm text-fg transition-colors;
        @apply placeholder:text-fg-3 hover:border-fg-3/50;
        @apply focus:border-brand focus:outline-none focus:ring-2 focus:ring-brand/30;
        @apply disabled:cursor-not-allowed disabled:opacity-60;
        @apply aria-[invalid=true]:border-danger aria-[invalid=true]:focus:ring-danger/30;
    }

    textarea.mm-control {
        @apply h-auto min-h-24 py-2 leading-relaxed;
    }

    select.mm-control {
        @apply appearance-none bg-no-repeat pr-9;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239b93a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
        background-position: right 0.65rem center;
        background-size: 1rem;
    }

    input[type='file'].mm-control {
        @apply h-auto cursor-pointer py-1.5 text-fg-2 file:mr-3 file:cursor-pointer file:rounded-md file:border-0 file:bg-surface-3 file:px-3 file:py-1 file:text-xs file:font-medium file:text-fg;
    }

    /*
     * Data tables. Cell padding, header style, row dividers and hover live
     * here once; pages only supply content. Used by <x-ui.table>.
     */
    .mm-table {
        @apply w-full border-collapse text-left text-sm;
    }

    .mm-table th {
        @apply whitespace-nowrap bg-surface-2 px-4 py-2.5 text-xs font-medium uppercase tracking-wide text-fg-3;
    }

    .mm-table td {
        @apply px-4 py-3 align-middle text-fg-2;
    }

    .mm-table tbody tr {
        @apply border-t border-line transition-colors;
    }

    .mm-table tbody tr:hover {
        background-color: color-mix(in oklab, var(--mm-surface-2) 55%, transparent);
    }

    .mm-table td.mm-cell-primary {
        @apply font-medium text-fg;
    }

    .mm-spinner {
        @apply inline-block size-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent;
    }

    /*
     * Glass surface: a translucent charcoal panel with a hairline border and a
     * soft blur. Falls back to the plain surface wherever backdrop-filter is
     * unavailable, so text never sits on an unpredictable backdrop.
     */
    .mm-glass {
        background-color: color-mix(in oklab, var(--mm-surface) var(--mm-glass-hero-opacity), transparent);
        border: 1px solid var(--mm-border);
        border-top-color: color-mix(in oklab, var(--mm-brand) 24%, var(--mm-border));
        box-shadow: var(--mm-glass-shadow);
        -webkit-backdrop-filter: var(--mm-glass-filter);
        backdrop-filter: var(--mm-glass-filter);
    }

    /*
     * Portal sign-in pages. The Admin and Staff portals share one brand and one
     * set of tokens; each only nudges the neutral surfaces — Admin deeper and
     * more austere, Staff a step lighter — and never the brand colour, so
     * contrast and the purple-as-accent rule hold in both. By day Staff uses
     * the plain day surfaces and Admin a cooler canvas.
     */
    :root:not([data-mode='light']) .mm-portal--admin {
        --mm-bg: #0a0810;
        --mm-sidebar: #0e0b14;
        --mm-surface: #130f1a;
        --mm-surface-2: #1a1423;
        --mm-surface-3: #221a2d;
        --mm-border: #2d2338;
        --mm-border-strong: #40324f;
    }

    :root:not([data-mode='light']) .mm-portal--staff {
        --mm-bg: #17131f;
        --mm-sidebar: #1b1624;
        --mm-surface: #211b2b;
        --mm-surface-2: #272031;
        --mm-surface-3: #2d2538;
        --mm-border: #3c3149;
        --mm-border-strong: #50425f;
    }

    [data-mode='light'] .mm-portal--admin {
        --mm-bg: #f1f4f9;
        --mm-surface-2: #eef2f7;
        --mm-border: #dde3ec;
        --mm-border-strong: #c5cedb;
    }

    /*
     * Day/Night toggle (header and sign-in pages). Both glyphs are stacked and
     * the inactive one turns and fades away, so switching never moves layout;
     * which glyph shows comes from data-mode on <html>, so it is right from the
     * first paint.
     */
    .mm-mode-toggle {
        position: relative;
        display: inline-grid;
        place-items: center;
    }

    .mm-mode-toggle > svg {
        grid-area: 1 / 1;
        transition:
            opacity 0.25s ease,
            transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
    }

    :root:not([data-mode='light']) .mm-mode-toggle__sun,
    [data-mode='light'] .mm-mode-toggle__moon {
        opacity: 0;
        transform: rotate(-90deg) scale(0.6);
    }

    .mm-eyebrow {
        @apply text-xs font-semibold uppercase tracking-[0.22em] text-brand-text;
    }

    /* Entrance: a short rise-and-fade, staggered with --mm-delay. */
    .mm-rise {
        animation: mm-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
        animation-delay: var(--mm-delay, 0ms);
    }

    .mm-drift {
        animation: mm-drift 28s ease-in-out infinite alternate;
    }
}

/*
 * Switching day/night: colors ease across instead of snapping. Applied to
 * <html> for the length of the switch only, so ordinary hovers keep their own
 * timing, and never when the visitor asks for reduced motion.
 */
@media (prefers-reduced-motion: no-preference) {
    .mm-mode-switching,
    .mm-mode-switching *,
    .mm-mode-switching *::before,
    .mm-mode-switching *::after {
        transition-property: background-color, border-color, color, fill, stroke, box-shadow, outline-color !important;
        transition-duration: 0.3s !important;
        transition-timing-function: ease !important;
    }

    .mm-mode-switching .mm-mode-toggle > svg {
        transition-property: opacity, transform !important;
        transition-duration: 0.35s !important;
    }
}

@keyframes mm-rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes mm-drift {
    from {
        transform: translate3d(0, 0, 0) scale(1);
    }
    to {
        transform: translate3d(-1.5%, 1.5%, 0) scale(1.03);
    }
}

/*
 * Glass fallbacks. Where the browser cannot blur, text must not depend on what
 * happens to be behind a half-transparent surface, so every glass layer becomes
 * a solid surface; the same when the visitor asks for reduced transparency or
 * more contrast, and the background glow goes with it.
 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :root {
        --mm-glass-opacity: 100%;
        --mm-glass-float-opacity: 100%;
        --mm-glass-hero-opacity: 100%;
        --mm-glass-filter: none;
    }
}

@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
    :root {
        --mm-glass-opacity: 100%;
        --mm-glass-float-opacity: 100%;
        --mm-glass-hero-opacity: 100%;
        --mm-glass-filter: none;
        --mm-glow-strength: 0%;
        --mm-glow-strength-2: 0%;
    }
}

@media (forced-colors: active) {
    .mm-panel,
    .mm-float,
    .mm-glass {
        background-color: Canvas;
        border-color: CanvasText;
    }

    .mm-glass-bar::before {
        background-color: Canvas;
    }

    .mm-ambient::before {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    ::before,
    ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
