/* Cron Expression Builder (/cron-expression-builder): what is its own (the expression field, the field chips, the
   schedule in words, the builder's value grid and the runs table). Panels, fields, buttons, tables and colours come from
   the app kit (css/app-kit, docs/app-kit.md). Loaded only on this app's page (StylePaths in its demo catalog entry). */

/* On a phone the site's photo-app rule (seo-pages.css) sets align-items: start on every stage, which beats the kit's
   stretch: the panels would shrink to their own width. */
.ceb-landing-app > .ak-stage > * {
    align-self: stretch;
}

/* The script hides parts with the hidden attribute; the display rules below must not bring them back. */
.ceb-landing-app [hidden] {
    display: none !important;
}

/* --- The expression -------------------------------------------------------------------------------------------- */

.ceb-landing-app .ceb-expr-row {
    display: flex;
    gap: var(--ak-space-2);
    align-items: stretch;
}

/* The kit's input rule is (0,6,1); these beat it. */
.ceb-landing-app.ak-app .ceb-expr-panel .ceb-expr-row input.ak-field.ceb-expr[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--ak-font-mono);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.ceb-landing-app .ceb-expr-row .ak-btn {
    flex: 0 0 auto;
}

/* One chip per field, in the order of the expression (the expression is always written left to right). */
.ceb-landing-app .ceb-chips {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.4rem;
    margin-top: var(--ak-space-3);
    direction: ltr;
}

.ceb-landing-app .ceb-chips[data-count="6"] {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.ceb-landing-app .ceb-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    min-width: 0;
    padding: 0.4rem 0.3rem;
    border: 1px solid var(--ak-border);
    border-top: 3px solid var(--ceb-chip, var(--ak-accent));
    border-radius: var(--ak-radius-sm, 6px);
    background: var(--ak-field);
    color: var(--ak-text);
    font: inherit;
    cursor: pointer;
}

.ceb-landing-app .ceb-chip:nth-child(1) { --ceb-chip: var(--ak-series-1); }
.ceb-landing-app .ceb-chip:nth-child(2) { --ceb-chip: var(--ak-series-2); }
.ceb-landing-app .ceb-chip:nth-child(3) { --ceb-chip: var(--ak-series-3); }
.ceb-landing-app .ceb-chip:nth-child(4) { --ceb-chip: var(--ak-series-4); }
.ceb-landing-app .ceb-chip:nth-child(5) { --ceb-chip: var(--ak-series-5); }
.ceb-landing-app .ceb-chip:nth-child(6) { --ceb-chip: var(--ak-series-6); }

.ceb-landing-app .ceb-chip:hover {
    background: var(--ak-hover);
}

.ceb-landing-app .ceb-chip:focus-visible {
    outline: 2px solid var(--ak-accent);
    outline-offset: 2px;
}

.ceb-landing-app .ceb-chip[aria-pressed="true"] {
    border-color: var(--ceb-chip, var(--ak-accent));
    box-shadow: inset 0 0 0 1px var(--ceb-chip, var(--ak-accent));
}

.ceb-landing-app .ceb-chip.is-bad {
    --ceb-chip: var(--ak-danger);
    border-color: var(--ak-danger);
    background: color-mix(in srgb, var(--ak-danger) 10%, var(--ak-field));
}

.ceb-landing-app .ceb-chip-token {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--ak-font-mono);
    font-size: 1rem;
    font-weight: 700;
}

.ceb-landing-app .ceb-chip-label {
    max-width: 100%;
    font-size: var(--ak-fs-xs, 0.72rem);
    line-height: 1.2;
    color: var(--ak-muted);
    text-align: center;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* The chips' labels follow the page language and direction. */
[dir="rtl"] .ceb-landing-app .ceb-chip-label {
    direction: rtl;
}

/* The schedule in words. */
.ceb-landing-app .ceb-meaning {
    margin: var(--ak-space-3) 0 0;
    padding: 0.55rem 0.8rem;
    border-inline-start: 4px solid var(--ak-accent);
    border-radius: var(--ak-radius-sm, 6px);
    background: color-mix(in srgb, var(--ak-accent) 9%, transparent);
    font-size: 1.12rem;
    font-weight: 600;
    line-height: 1.4;
}

.ceb-landing-app .ceb-expr-panel .ak-message {
    margin-top: var(--ak-space-3);
}

/* --- The builder ----------------------------------------------------------------------------------------------- */

.ceb-landing-app .ceb-builder {
    display: flex;
    flex-direction: column;
    gap: var(--ak-space-3);
}

.ceb-landing-app .ceb-tabs,
.ceb-landing-app .ceb-modes {
    flex-wrap: wrap;
}

.ceb-landing-app .ceb-body {
    min-height: 2.6rem;
}

.ceb-landing-app .ceb-every {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ak-muted);
}

.ceb-landing-app .ceb-star {
    font-family: var(--ak-font-mono);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ak-accent);
}

.ceb-landing-app .ceb-step {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ak-space-3);
    align-items: center;
}

.ceb-landing-app .ceb-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
}

.ceb-landing-app.ak-app .ceb-builder .ceb-inline input.ak-field.ceb-n[type="number"] {
    width: 5.5rem;
}

.ceb-landing-app.ak-app .ceb-inline select.ceb-sel {
    width: auto;
    min-width: 6rem;
}

/* The values of a field as toggle buttons: ten per row for seconds and minutes, fewer and wider for the rest. */
.ceb-landing-app .ceb-grid {
    display: grid;
    grid-template-columns: repeat(15, minmax(0, 1fr));
    gap: 0.3rem;
}

.ceb-landing-app .ceb-grid--hour { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.ceb-landing-app .ceb-grid--dom { grid-template-columns: repeat(16, minmax(0, 1fr)); }
.ceb-landing-app .ceb-grid--month { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.ceb-landing-app .ceb-grid--dow { grid-template-columns: repeat(7, minmax(0, 1fr)); }

/* Narrower stages (a laptop with the side panel): fewer, wider buttons. */
@media (max-width: 1200px) {
    .ceb-landing-app .ceb-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
    .ceb-landing-app .ceb-grid--hour { grid-template-columns: repeat(12, minmax(0, 1fr)); }
    .ceb-landing-app .ceb-grid--dom { grid-template-columns: repeat(8, minmax(0, 1fr)); }
    .ceb-landing-app .ceb-grid--month { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.ceb-landing-app .ceb-val {
    min-width: 0;
    min-height: 2rem;
    padding: 0.2rem 0.1rem;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm, 6px);
    background: var(--ak-field);
    color: var(--ak-text);
    font: inherit;
    font-size: var(--ak-fs-sm, 0.85rem);
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.ceb-landing-app .ceb-val:hover {
    background: var(--ak-hover);
}

.ceb-landing-app .ceb-val:focus-visible {
    outline: 2px solid var(--ak-accent);
    outline-offset: 1px;
}

.ceb-landing-app .ceb-val[aria-pressed="true"] {
    border-color: var(--ak-accent);
    background: var(--ak-accent);
    color: var(--ak-on-accent);
    font-weight: 700;
}

.ceb-landing-app .ceb-val:disabled {
    cursor: default;
}

/* --- The runs -------------------------------------------------------------------------------------------------- */

.ceb-landing-app .ceb-runs td {
    font-variant-numeric: tabular-nums;
}

.ceb-landing-app .ceb-runs .ceb-idx {
    width: 2.5rem;
    color: var(--ak-muted);
}

.ceb-landing-app .ceb-runs-panel .ak-message {
    margin-top: var(--ak-space-3);
}

@media (max-width: 640px) {
    .ceb-landing-app.ak-app .ceb-expr-panel .ceb-expr-row input.ak-field.ceb-expr[type="text"] {
        font-size: 1.1rem;
    }

    .ceb-landing-app .ceb-chips {
        gap: 0.25rem;
    }

    .ceb-landing-app .ceb-chip {
        padding: 0.35rem 0.15rem;
    }

    .ceb-landing-app .ceb-chip-token {
        font-size: 0.9rem;
    }

    .ceb-landing-app .ceb-chip-label {
        font-size: 0.66rem;
    }

    .ceb-landing-app .ceb-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .ceb-landing-app .ceb-grid--hour { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .ceb-landing-app .ceb-grid--dom { grid-template-columns: repeat(7, minmax(0, 1fr)); }
    .ceb-landing-app .ceb-grid--month { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ceb-landing-app .ceb-grid--dow { grid-template-columns: repeat(4, minmax(0, 1fr)); }

    .ceb-landing-app .ceb-runs .ceb-rel {
        white-space: nowrap;
    }
}
