/* ------------------------------------------------------------- Goals slide ---
   Bead onfiremobile-0cb3r. Contract: docs/PRD/displays/CONTRACT-slide-settings.md
   §goals. Loaded after styles.css; every class here is .ns-gl*. The shell reuses
   .ns-root / .ns-head / .ns-title / .ns-count / .ns-more from styles.css.

   Sizes are clamp()/vmin, never a bare length: the same markup has to read on a
   1280x720 Raspberry Pi panel and on a 4K wall. The only media queries are the
   portrait collapse (a real device fact) and reduced motion. */

.ns-gl {
    --gl-ink: #0c1018;
    --gl-card: rgba(255, 255, 255, 0.06);
    --gl-card-edge: rgba(255, 255, 255, 0.12);
    --gl-track: rgba(255, 255, 255, 0.10);
    --gl-text: #fff;
    --gl-sub: rgba(255, 255, 255, 0.62);
    --gl-ok: #7fd1a8;
    --gl-soon: #FFCE54;
    --gl-over: #FF5A4D;
    --gl-done: #00A662;

    background: var(--gl-ink);
    position: relative;
    isolation: isolate;
    gap: clamp(12px, 2.2vmin, 32px);
}

/* A static glow — no animation: a display runs for days on a Pi. */
.ns-gl-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(60% 55% at 12% 0%, rgba(255, 107, 31, 0.22) 0%, rgba(255, 107, 31, 0) 70%),
        radial-gradient(55% 60% at 100% 100%, rgba(255, 206, 84, 0.12) 0%, rgba(255, 206, 84, 0) 70%);
}

.ns-gl .ns-head { border-bottom-color: rgba(255, 255, 255, 0.10); }

.ns-gl-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(var(--gl-cols, 3), minmax(0, 1fr));
    grid-template-rows: repeat(var(--gl-rows, 2), minmax(0, 1fr));
    gap: clamp(10px, 2vmin, 28px);
}

.ns-gl-card {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: clamp(12px, 2.4vmin, 36px);
    padding: clamp(12px, 2.4vmin, 36px);
    border-radius: clamp(14px, 2.4vmin, 32px);
    background: var(--gl-card);
    border: 1px solid var(--gl-card-edge);
    box-shadow: 0 clamp(4px, 1vmin, 14px) clamp(12px, 3vmin, 40px) rgba(0, 0, 0, 0.35);
}
/* Many cards: stack the ring over the text so titles keep their width. */
.ns-gl-grid[data-count="7"] .ns-gl-card,
.ns-gl-grid[data-count="8"] .ns-gl-card,
.ns-gl-grid[data-count="10"] .ns-gl-card,
.ns-gl-grid[data-count="11"] .ns-gl-card,
.ns-gl-grid[data-count="12"] .ns-gl-card {
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.ns-gl-ring-wrap {
    position: relative;
    flex: 0 0 auto;
    width: clamp(64px, 16vmin, 260px);
    aspect-ratio: 1 / 1;
    max-height: 100%;
}
.ns-gl-grid[data-count="1"] .ns-gl-card { justify-content: center; }
.ns-gl-grid[data-count="1"] .ns-gl-ring-wrap { width: clamp(120px, 38vmin, 560px); }
.ns-gl-grid[data-count="2"] .ns-gl-ring-wrap,
.ns-gl-grid[data-count="3"] .ns-gl-ring-wrap { width: clamp(90px, 22vmin, 360px); }

.ns-gl-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    display: block;
}
.ns-gl-ring circle {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
}
.ns-gl-ring-track { stroke: var(--gl-track); }
.ns-gl-ring-fill {
    /* Paints empty, then .ns-gl-lit moves it to its real offset (easeOutCubic per
       style.md). */
    stroke-dashoffset: var(--gl-full);
    transition: stroke-dashoffset 1100ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
.ns-gl-lit .ns-gl-ring-fill { stroke-dashoffset: var(--gl-off); }

.ns-gl-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(22px, 6vmin, 90px);
    line-height: 1;
}
.ns-gl-grid[data-count="1"] .ns-gl-icon { font-size: clamp(44px, 14vmin, 200px); }

.ns-gl-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(2px, 0.6vmin, 10px);
}
.ns-gl-title {
    color: var(--gl-text);
    font-size: clamp(16px, 3vmin, 44px);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.15;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.ns-gl-grid[data-count="1"] .ns-gl-title { font-size: clamp(26px, 6vmin, 90px); }
.ns-gl-pct {
    color: var(--gl-accent, #FF6B1F);
    font-size: clamp(20px, 4.4vmin, 64px);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.05;
}
.ns-gl-grid[data-count="1"] .ns-gl-pct { font-size: clamp(36px, 9vmin, 130px); }
.ns-gl-value,
.ns-gl-chat {
    color: var(--gl-sub);
    font-size: clamp(12px, 2vmin, 28px);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ns-gl-due {
    font-size: clamp(12px, 2vmin, 28px);
    font-weight: 600;
    white-space: nowrap;
}
.ns-gl-grid[data-count="1"] .ns-gl-value,
.ns-gl-grid[data-count="1"] .ns-gl-due,
.ns-gl-grid[data-count="1"] .ns-gl-chat { font-size: clamp(16px, 3.2vmin, 44px); }
.ns-gl-due-ok     { color: var(--gl-ok); }
.ns-gl-due-soon   { color: var(--gl-soon); }
.ns-gl-due-over   { color: var(--gl-over); }
.ns-gl-due-done   { color: var(--gl-done); }
.ns-gl-due-paused { color: var(--gl-sub); }

.ns-gl-status-paused { opacity: 0.6; }
.ns-gl-status-completed .ns-gl-pct { color: var(--gl-done); }

/* ------------------------------------------------------------ next items ---
   Bead onfiremobile-mgsjg. Up to three rows under the goal's text. A row is a
   pill (radius = half its height, style.md) whose height never drops under a
   44px touch target; on a big wall it scales up with vmin so a finger still
   finds it from arm's length. Motion is transform/opacity only and eases out
   (cubic-bezier(0.215, 0.61, 0.355, 1) = easeOutCubic, style.md). */

.ns-gl-body { flex: 1 1 0; }
/* The list is the card's last child and takes a full row of its own under the
   ring + text (flex-wrap); a card with a list trades ring size for rows. */
.ns-gl-card { flex-wrap: wrap; align-content: center; }
.ns-gl-items-wrap:empty { display: none; }
.ns-gl-items-wrap { flex: 1 0 100%; min-width: 0; }
.ns-gl-card:has(.ns-gl-items) .ns-gl-ring-wrap { width: clamp(56px, 11vmin, 190px); }
.ns-gl-card:has(.ns-gl-items) .ns-gl-title { -webkit-line-clamp: 1; }

.ns-gl-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(4px, 0.9vmin, 12px);
}
.ns-gl-item-li { margin: 0; padding: 0; overflow: hidden; }

.ns-gl-item {
    --gl-item-h: clamp(44px, 6.2vmin, 96px);
    width: 100%;
    min-height: var(--gl-item-h);
    display: flex;
    align-items: center;
    gap: clamp(8px, 1.4vmin, 20px);
    padding: 0 clamp(12px, 1.8vmin, 26px) 0 clamp(6px, 0.9vmin, 12px);
    border-radius: calc(var(--gl-item-h) / 2);
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.05);
    color: var(--gl-text);
    font: inherit;
    text-align: left;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 180ms ease-out, border-color 180ms ease-out,
                transform 160ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
/* .ns-root is pointer-events:none so the deck's swipe layer keeps working
   (styles.css); a control opts back in, as .ns-check does there. */
.ns-gl-item-btn { pointer-events: auto; cursor: pointer; touch-action: manipulation; }
.ns-gl-item-btn:active { transform: scale(0.97); background: rgba(255, 255, 255, 0.10); }
.ns-gl-item-btn:focus { outline: none; }
.ns-gl-item-btn:focus-visible {
    border-color: var(--gl-accent, #FF6B1F);
    box-shadow: 0 0 0 3px rgba(255, 107, 31, 0.35);
}

.ns-gl-check {
    flex: 0 0 auto;
    width: calc(var(--gl-item-h) * 0.62);
    height: calc(var(--gl-item-h) * 0.62);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transition: background-color 200ms ease-out, border-color 200ms ease-out,
                transform 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ns-gl-item-habit .ns-gl-check { border-style: dashed; }
.ns-gl-check-svg { width: 70%; height: 70%; display: block; }
.ns-gl-check-svg path {
    fill: none;
    stroke: #fff;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    transition: stroke-dashoffset 260ms cubic-bezier(0.215, 0.61, 0.355, 1) 60ms;
}

.ns-gl-item-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: clamp(13px, 2.1vmin, 30px);
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 200ms ease-out, opacity 200ms ease-out;
}
.ns-gl-item-due {
    flex: 0 0 auto;
    font-size: clamp(11px, 1.7vmin, 24px);
    font-weight: 600;
    white-space: nowrap;
}
.ns-gl-item-due-habit { color: var(--gl-sub); }
.ns-gl-item-due-ok    { color: var(--gl-sub); }
.ns-gl-item-due-soon  { color: var(--gl-soon); }
.ns-gl-item-due-over  { color: var(--gl-over); }

/* Checked (optimistic, then confirmed). */
.ns-gl-item-done .ns-gl-check {
    background: var(--gl-accent, #FF6B1F);
    border-color: var(--gl-accent, #FF6B1F);
    border-style: solid;
    transform: scale(1.08);
}
.ns-gl-item-done .ns-gl-check-svg path { stroke-dashoffset: 0; }
.ns-gl-item-done .ns-gl-item-title {
    color: var(--gl-sub);
    text-decoration: line-through;
    text-decoration-color: rgba(255, 255, 255, 0.45);
}

/* Refused: the check is already reverted; the row tints for a moment. */
.ns-gl-item-err {
    border-color: var(--gl-over);
    background: rgba(255, 90, 77, 0.14);
    animation: ns-gl-item-nudge 320ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
@keyframes ns-gl-item-nudge {
    0%, 100% { transform: translateX(0); }
    30%      { transform: translateX(-4px); }
    65%      { transform: translateX(3px); }
}

/* Done row folds away, then the next one slides in from below. */
.ns-gl-item-leave {
    animation: ns-gl-item-leave 280ms cubic-bezier(0.215, 0.61, 0.355, 1) forwards;
}
@keyframes ns-gl-item-leave {
    to { opacity: 0; transform: translateX(12%); }
}
.ns-gl-item-enter {
    animation: ns-gl-item-enter 380ms cubic-bezier(0.215, 0.61, 0.355, 1) both;
}
@keyframes ns-gl-item-enter {
    from { opacity: 0; transform: translateY(60%); }
    to   { opacity: 1; transform: translateY(0); }
}

.ns-gl-items-more {
    margin-top: clamp(2px, 0.6vmin, 8px);
    padding-left: clamp(8px, 1.2vmin, 16px);
    color: var(--gl-sub);
    font-size: clamp(11px, 1.6vmin, 22px);
}

/* A single goal owns the wall: bigger rows. */
.ns-gl-grid[data-count="1"] .ns-gl-card:has(.ns-gl-items) .ns-gl-ring-wrap { width: clamp(90px, 22vmin, 360px); }
.ns-gl-grid[data-count="1"] .ns-gl-items-wrap { flex-basis: 100%; max-width: min(80vw, 1200px); margin: 0 auto; }
.ns-gl-grid[data-count="1"] .ns-gl-item { --gl-item-h: clamp(52px, 8vmin, 120px); }
.ns-gl-grid[data-count="1"] .ns-gl-item-title { font-size: clamp(16px, 3vmin, 44px); }
/* Dense boards (7+ cards) and portrait panels stack the ring over the text.
   A card that carries a list goes back to ring-beside-text with the list in
   its own row underneath — stacking all three would push the rows out of the
   card. Without :has() (very old engines) the card keeps the stacked layout. */
.ns-gl-grid[data-count="7"] .ns-gl-card,
.ns-gl-grid[data-count="8"] .ns-gl-card,
.ns-gl-grid[data-count="10"] .ns-gl-card,
.ns-gl-grid[data-count="11"] .ns-gl-card,
.ns-gl-grid[data-count="12"] .ns-gl-card { flex-wrap: nowrap; }
.ns-gl-grid .ns-gl-card:has(.ns-gl-items) {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    text-align: left;
}
.ns-gl-grid[data-count="7"] .ns-gl-card:has(.ns-gl-items) .ns-gl-ring-wrap,
.ns-gl-grid[data-count="8"] .ns-gl-card:has(.ns-gl-items) .ns-gl-ring-wrap,
.ns-gl-grid[data-count="10"] .ns-gl-card:has(.ns-gl-items) .ns-gl-ring-wrap,
.ns-gl-grid[data-count="11"] .ns-gl-card:has(.ns-gl-items) .ns-gl-ring-wrap,
.ns-gl-grid[data-count="12"] .ns-gl-card:has(.ns-gl-items) .ns-gl-ring-wrap { width: clamp(40px, 7vmin, 110px); }

/* Portrait / narrow panel: at most two columns, rows size to content. */
@media (max-aspect-ratio: 4/5) {
    .ns-gl-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: none;
        grid-auto-rows: minmax(0, 1fr);
    }
    .ns-gl-grid[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
    .ns-gl-card { flex-direction: column; flex-wrap: nowrap; text-align: center; justify-content: center; }
    .ns-gl-grid .ns-gl-card:has(.ns-gl-items) { flex-direction: row; flex-wrap: wrap; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    .ns-gl-ring-fill { transition: none; }
    .ns-gl-item, .ns-gl-check, .ns-gl-check-svg path, .ns-gl-item-title { transition: none; }
    .ns-gl-item-err, .ns-gl-item-leave, .ns-gl-item-enter { animation: none; }
    .ns-gl-item-leave { opacity: 0; }
}
