/* ==========================================================================
   Glance grid — shared by the wine page "At a glance" and Insights.
   Port of the app's components/v2/glance/GlanceGrid.tsx + GlancePasses (PassHead,
   GlancePassCard). Squares at rest, a pass when open, the other squares as a deck.
   Tokens below mirror the app's lib/theme/colors.ts; reuse them, never a raw hex.
   ========================================================================== */

:root {
    --gl-border: #d7dfdb;          /* app colors.border */
    --gl-border-soft: #c7d1cc;     /* app colors.borderSoft */
    --gl-border-light: #e4eae7;    /* app colors.borderLight */
    --gl-heading: #131a17;         /* app colors.textHeading */
    --gl-text-secondary: #42524a;  /* app colors.textSecondary */
    --gl-placeholder: #7a8b83;     /* app colors.placeholder */
    --gl-chart-muted: #8a93ab;     /* app colors.chartMuted */
    --gl-shadow: rgba(19, 26, 23, 0.08);
}

.gl { position: relative; }

/* ── At rest: two squares to a row, hairlines between ── */
.gl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.gl-cell {
    all: unset;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0.75rem 0 0.9rem;
    border-top: 1px solid var(--gl-border);
    cursor: pointer;
    border-radius: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}
.gl-cell--first { border-top-color: transparent; }
.gl-cell--left { padding-right: 0.9rem; }
.gl-cell--right {
    padding-left: 0.9rem;
    border-left: 1px solid var(--gl-border);
    /* keep the vertical hairline off the row's top/bottom edge, like the app */
    background-image: none;
}
.gl-cell--wide { grid-column: 1 / -1; }
.gl-cell:hover { opacity: 0.78; }
.gl-cell:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; border-radius: 6px; }

.gl-kicker-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.gl-kicker {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--color-muted);
}
.gl-expand { color: var(--gl-placeholder); display: inline-flex; }
.gl-title {
    margin-top: 3px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--gl-heading);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gl-symbol {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 4px 0;
}
.gl-symbol > svg, .gl-symbol-fit > svg { max-width: 100%; }
.gl-symbol-fit { display: block; margin: 0.75rem 0 0.6rem; }
.gl-sub {
    font-size: 0.75rem;
    color: var(--color-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Open: the pass, with the other squares as a deck under it ── */
.gl-open { animation: gl-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes gl-in {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
    to { opacity: 1; transform: none; }
}
.gl-pass {
    position: relative;
    z-index: 50;
    background: var(--color-card-bg);
    border: 1px solid var(--gl-border-light);
    border-radius: 16px;
    box-shadow: 0 4px 14px var(--gl-shadow);
}
.gl-pass-head {
    all: unset;
    box-sizing: border-box;
    display: block;
    width: 100%;
    cursor: pointer;
    border-radius: 16px 16px 0 0;
}
.gl-pass-head:hover { background: var(--color-primary-bg); }
.gl-pass-head:focus-visible { outline: 2px solid var(--color-brand); outline-offset: -2px; }
.gl-face { padding: 0.25rem 1rem 1.1rem; }

.gl-deck { position: relative; display: flex; flex-direction: column; }
/* base/reset.css gives every svg width:100%; inside the grid an svg keeps its own size
   unless a rule (a symbol class) asks for the full width. */
.gl svg { width: auto; }
.gl-deck-item {
    all: unset;
    box-sizing: border-box;
    display: block;
    position: relative;
    margin-top: -12px;
    padding-top: 12px;
    background: var(--color-card-bg);
    border: 1px solid var(--gl-border-light);
    border-top: 0;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 4px 8px var(--gl-shadow);
    cursor: pointer;
}
.gl-deck-item:hover { background: var(--color-primary-bg); }
.gl-deck-item:focus-visible { outline: 2px solid var(--color-brand); outline-offset: -2px; }

/* ── Pass header ── */
.gl-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem; }
.gl-head--compact { padding: 0.55rem 1rem; }
.gl-badge {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-brand-soft);
    color: var(--color-brand);
}
.gl-head--compact .gl-badge { width: 28px; height: 28px; }
.gl-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gl-head-label {
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--color-muted);
}
.gl-head-main {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gl-heading);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gl-head--compact .gl-head-main { font-size: 0.9rem; }
.gl-head-sub {
    font-size: 0.78rem;
    color: var(--color-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gl-head-mini { flex-shrink: 0; display: inline-flex; align-items: center; }
.gl-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-secondary-bg);
    color: var(--gl-text-secondary);
}

@media (max-width: 520px) {
    .gl-cell--left { padding-right: 0.6rem; }
    .gl-cell--right { padding-left: 0.6rem; }
    .gl-face { padding: 0.25rem 0.8rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .gl-open { animation: none; }
    .gl-cell { transition: none; }
}
