/*! Bento Cards · (c) 2026 Antichaos — antichaosdata.com. All rights reserved. Proprietary. */
:root {
    --bg: #f4f5f7;
    --card-bg: #ffffff;
    --card-border: rgba(15, 23, 42, 0.06);
    --title-color: #0f172a;
    --text-color: #475569;
    --meta-bg: rgba(15, 23, 42, 0.05);
    --meta-color: #334155;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-hover: 0 4px 8px rgba(15, 23, 42, 0.08), 0 16px 40px rgba(15, 23, 42, 0.12);
    --radius: 20px;
    --gap: 16px;
    /* Reorder/move animation duration. Overridden per-config via JS (Slow /
       Normal / Fast / Instant); 0.42s is the Normal default. */
    --anim-dur: 0.42s;
}

/* Dark palette, shared by auto (OS) and the forced-dark theme. */
@media (prefers-color-scheme: dark) {
    /* Auto: follow the OS only when no explicit theme is set in config. */
    :root:not([data-theme]) {
        --bg: #0b0f19;
        --card-bg: #151a27;
        --card-border: rgba(255, 255, 255, 0.06);
        --title-color: #f1f5f9;
        --text-color: #94a3b8;
        --meta-bg: rgba(255, 255, 255, 0.07);
        --meta-color: #cbd5e1;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
        --shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
    }
}

/* Forced dark (config Theme = Dark), regardless of OS. */
:root[data-theme="dark"] {
    --bg: #0b0f19;
    --card-bg: #151a27;
    --card-border: rgba(255, 255, 255, 0.06);
    --title-color: #f1f5f9;
    --text-color: #94a3b8;
    --meta-bg: rgba(255, 255, 255, 0.07);
    --meta-color: #cbd5e1;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
}
/* Forced light (Theme = Light) just uses the :root defaults above; setting
   data-theme also stops the auto media query from applying. */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
}

body {
    background: var(--bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--text-color);
}

/* Toolbar -------------------------------------------------------------- */
.toolbar {
    display: flex;
    justify-content: flex-end;
    padding: var(--gap) var(--gap) 0;
}

.toolbar[hidden] {
    display: none;
}

.randomize-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--title-color);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.randomize-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.randomize-btn:active {
    transform: scale(0.97);
}

.randomize-btn__icon {
    font-size: 15px;
    line-height: 1;
}

.bento-grid {
    position: relative; /* anchor for exiting tiles taken out of flow */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    /* Rows have a comfortable minimum but grow to fit content, so text
       is never sliced mid-line. */
    grid-auto-rows: minmax(150px, auto);
    grid-auto-flow: dense;
    gap: var(--gap);
    padding: var(--gap);
    min-height: 100%;
}

/* Outer tile = grid item + FLIP layer (transform/opacity animated in JS). */
.bento-card {
    transition: transform var(--anim-dur) cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}

/* Masonry: JS positions tiles absolutely; animate movement via top/left. */
.bento-grid.is-masonry {
    display: block;
    grid-auto-rows: initial;
}

.bento-grid.is-masonry .bento-card {
    position: absolute;
    transition: top var(--anim-dur) cubic-bezier(0.2, 0.8, 0.2, 1),
                left var(--anim-dur) cubic-bezier(0.2, 0.8, 0.2, 1),
                transform var(--anim-dur) cubic-bezier(0.2, 0.8, 0.2, 1),
                opacity 0.3s ease;
}

/* In masonry each tile is its natural height and text is never clamped. */
.bento-grid.is-masonry .bento-card__inner {
    height: auto;
}

.bento-grid.is-masonry .bento-card__text {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}

/* Entering and exiting tiles start/end faded and slightly scaled down. */
.bento-card.is-enter,
.bento-card.is-exit {
    opacity: 0;
    transform: scale(0.94);
}

/* Exiting tiles are frozen out of layout flow (position set inline by JS). */
.bento-card.is-exiting {
    position: absolute;
    z-index: 0;
    pointer-events: none;
}

/* Inner = the visual card: background, border, hover lift. */
.bento-card__inner {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

/* Padded text wrapper. Separated from __inner so a __media panel can bleed to the
   card edges (and so the side panel can sit full-height beside the text). */
.bento-card__content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 20px 22px;
}

.bento-card__inner:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

/* When a click-to-set-parameter target is configured, tiles act like buttons. */
.bento-grid.is-clickable .bento-card__inner {
    cursor: pointer;
}

.bento-grid.is-clickable .bento-card__inner:active {
    transform: translateY(-1px) scale(0.985);
}

/* Accent stripe driven by --accent set per card in JS */
.bento-card__inner::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent, transparent);
    opacity: 0.9;
}

.bento-card__title {
    margin: 0 0 8px;
    font-size: clamp(15px, 1.4vw, 19px);
    font-weight: 700;
    line-height: 1.25;
    color: var(--title-color);
    letter-spacing: -0.01em;
}

/* Header row: optional image beside the title. */
.bento-card__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

/* Image on the right of the title (DOM order is always image, then title). */
.bento-card__header--img-right {
    flex-direction: row-reverse;
}

.bento-card__header .bento-card__title {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0; /* let the title wrap instead of overflowing */
}

.bento-card__image {
    flex: 0 0 auto;
    object-fit: cover;
    border-radius: 10px;
    display: block;
}

.bento-card__emoji {
    flex: 0 0 auto;
    line-height: 1;
}

.bento-card__header--small  .bento-card__image { width: 28px; height: 28px; }
.bento-card__header--small  .bento-card__emoji { font-size: 24px; }
.bento-card__header--medium .bento-card__image { width: 44px; height: 44px; }
.bento-card__header--medium .bento-card__emoji { font-size: 36px; }
.bento-card__header--large  .bento-card__image { width: 64px; height: 64px; }
.bento-card__header--large  .bento-card__emoji { font-size: 52px; }

/* ── Larger image displays: side panel / cover banner / full-bleed background ──
   The image becomes a __media panel (a sibling of __content) instead of a header
   thumbnail. __inner already clips to the rounded corners (overflow:hidden). */
.bento-card__media {
    position: relative;
    overflow: hidden;
    flex: 0 0 auto;
    background: var(--media-bg, rgba(120, 130, 150, 0.12));
    display: flex;
    align-items: center;
    justify-content: center;
}
.bento-card__media-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.bento-card__media-emoji { font-size: 56px; line-height: 1; }

/* SIDE — text and a full-height image panel side by side (image left by default,
   right when --img-right is set). The panel stretches to the tile's height. */
.bento-card--img-side .bento-card__inner { flex-direction: row; align-items: stretch; }
.bento-card--img-side.bento-card--img-right .bento-card__inner { flex-direction: row-reverse; }
.bento-card--img-side .bento-card__media {
    flex: 0 0 40%;
    align-self: stretch;
    min-height: 120px;
}
.bento-card--img-side .bento-card__content { flex: 1 1 auto; }

/* BANNER — image across the top, text below. Aspect-ratio keeps it sensible in
   both fixed-height (grid) and natural-height (masonry) tiles. */
.bento-card--img-banner .bento-card__inner { flex-direction: column; }
.bento-card--img-banner .bento-card__media {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 55%;
}
.bento-grid.is-masonry .bento-card--img-banner .bento-card__media { max-height: none; }

/* BACKGROUND — image fills the whole tile; text is overlaid at the bottom over a
   darkening gradient so it stays legible regardless of theme. */
.bento-card--img-background .bento-card__inner { position: relative; }
.bento-card--img-background .bento-card__media { position: absolute; inset: 0; z-index: 0; }
.bento-card--img-background .bento-card__media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(8, 12, 20, 0.10) 0%, rgba(8, 12, 20, 0.30) 45%, rgba(8, 12, 20, 0.82) 100%);
}
.bento-card--img-background .bento-card__content {
    position: relative;
    z-index: 1;
    justify-content: flex-end;
    min-height: 150px;
}
.bento-card--img-background .bento-card__title,
.bento-card--img-background .bento-card__text { color: #fff; }
/* Don't let the text grow — keep the title/text/meta clustered at the bottom. */
.bento-card--img-background .bento-card__text { flex: 0 1 auto; }
.bento-card--img-background .bento-card__chip {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    backdrop-filter: blur(2px);
}

.bento-card__text {
    margin: 0;
    font-size: clamp(13px, 1.1vw, 15px);
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color);
    flex: 1 1 auto;
    /* Clamp very long text to whole lines (with ellipsis) instead of
       cutting it off mid-line. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6;
    overflow: hidden;
}

.bento-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}

.bento-card__chip {
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--meta-bg);
    color: var(--meta-color);
    white-space: nowrap;
}

/* Bento size variants */
.bento-card--feature { grid-column: span 2; grid-row: span 2; }
.bento-card--wide    { grid-column: span 2; }
.bento-card--tall    { grid-row: span 2; }

.bento-card--feature .bento-card__title { font-size: clamp(20px, 2vw, 28px); }
.bento-card--feature .bento-card__text  { font-size: clamp(14px, 1.2vw, 17px); }

@media (max-width: 480px) {
    .bento-card--feature,
    .bento-card--wide { grid-column: span 1; }
    .bento-card--feature { grid-row: span 2; }
}

/* Empty state */
.empty-state {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* Beat the display:flex above so the hidden attribute actually hides it. */
.empty-state[hidden] {
    display: none;
}

.empty-state__card {
    max-width: 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 30px 28px 24px;
    border-radius: var(--radius);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
}

.empty-state__icon {
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    background: color-mix(in srgb, #5b8def 14%, transparent);
    color: #5b8def;
    margin-bottom: 2px;
}

.empty-state__title {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--title-color);
}

.empty-state__text {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-color);
}

.empty-state__brand { margin-top: 8px; }

/* ── Free-tier badge ──────────────────────────────────────────────────────
   Small, unobtrusive "Made with BentoCards" pill floating bottom-right of the
   viz. Removed when a valid license is applied (bentocards.js toggles [hidden]).
   Links to the buy/pricing page. */
.bento-badge {
    position: fixed;
    right: 10px;
    bottom: 10px;
    z-index: 50;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font: 500 11px/1 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--text-color);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
    text-decoration: none;
    opacity: 0.78;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.bento-badge:hover { opacity: 1; transform: translateY(-1px); }
.bento-badge b { font-weight: 700; }
.bento-badge[hidden] { display: none; }
