/* GrammarRuleWidget: a rule in coloured pills and example sentences in the same colours.
   A role keeps one colour through the whole course. */

.grammar-rule {
    --gr-n: var(--text-primary);
    --gr-aux: #1d4ed8;
    --gr-mod: #b45309;
    --gr-v3: #15803d;
    --gr-base: #8a6a00;
    --gr-ing: #be185d;
    --gr-v2: #6d28d9;
    --gr-adj: #0f766e;
    --gr-on-pill: #fff;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(14px, 3.4vw, 22px);
    margin: 42px 0 30px;
    overflow-x: clip;
    font-family: "Google Sans", sans-serif;
}

[data-theme="dark"] .grammar-rule {
    --gr-aux: #5aa9f0;
    --gr-mod: #f59e42;
    --gr-v3: #5bc489;
    --gr-base: #f5d547;
    --gr-ing: #e879b9;
    --gr-v2: #b79cf7;
    --gr-adj: #4fd1c5;
    --gr-on-pill: #14151a;
}

.grammar-rule__formula {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 10px 8px;
}

.grammar-rule__group {
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
}

.grammar-rule__pills {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 12px;
    margin: 0 -8px;
    /* The bracket that makes the pills above it one part of the rule. */
    background:
        linear-gradient(var(--text-muted), var(--text-muted)) left 16px bottom 0 / calc(100% - 32px) 1.5px no-repeat,
        linear-gradient(var(--text-muted), var(--text-muted)) left 16px bottom 0 / 1.5px 6px no-repeat,
        linear-gradient(var(--text-muted), var(--text-muted)) right 16px bottom 0 / 1.5px 6px no-repeat;
}

.grammar-rule.grammar-rule .grammar-rule__label {
    margin-top: 5px;
    font-size: clamp(11px, 2.8vw, 14px);
    letter-spacing: .08em;
    text-align: center;
    text-transform: uppercase;
    color: var(--text-muted);
}

.grammar-rule.grammar-rule .grammar-rule__pill {
    display: inline-flex;
    align-items: center;
    height: clamp(32px, 8vw, 40px);
    padding: 0 clamp(11px, 3vw, 16px);
    border-radius: 999px;
    font-size: clamp(15px, 3.8vw, 20px);
    font-weight: 700;
    white-space: nowrap;
    color: var(--gr-on-pill);
    background: var(--gr-n);
}

.grammar-rule.grammar-rule .grammar-rule__pill--aux { background: var(--gr-aux); }
.grammar-rule.grammar-rule .grammar-rule__pill--mod { background: var(--gr-mod); }
.grammar-rule.grammar-rule .grammar-rule__pill--v3 { background: var(--gr-v3); }
.grammar-rule.grammar-rule .grammar-rule__pill--base { background: var(--gr-base); }
.grammar-rule.grammar-rule .grammar-rule__pill--ing { background: var(--gr-ing); }
.grammar-rule.grammar-rule .grammar-rule__pill--v2 { background: var(--gr-v2); }
.grammar-rule.grammar-rule .grammar-rule__pill--adj { background: var(--gr-adj); }

.grammar-rule.grammar-rule .grammar-rule__comma {
    align-self: flex-start;
    margin: 0 0 0 -5px;
    font-size: clamp(18px, 4.4vw, 24px);
    font-weight: 700;
    line-height: clamp(32px, 8vw, 40px);
    color: var(--text-primary);
}

.grammar-rule__slides { width: 100%; }

.grammar-rule__slide {
    display: flex;
    /* The icon starts level with the top of the English sentence (user, 14.11.2026). */
    align-items: flex-start;
    justify-content: center;
    gap: clamp(14px, 3.6vw, 26px);
}

.grammar-rule .grammar-rule__icon {
    flex: none;
    width: auto;
    height: calc(clamp(46px, 12vw, 70px) * var(--gr-icon-scale, 1));
    max-width: 30%;
    /* Down to the top of the capitals of the first line. */
    margin: clamp(5px, 1.3vw, 8px) 0 0;
    object-fit: contain;
}

.grammar-rule__line {
    margin: 0;
    font-size: clamp(21px, 5.4vw, 32px);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    /* A sentence breaks only when it does not fit, and then into lines of like length. */
    text-wrap: balance;
}

.grammar-rule.grammar-rule .grammar-rule__w { font-weight: 600; color: var(--gr-n); }
.grammar-rule.grammar-rule .grammar-rule__w--aux { color: var(--gr-aux); }
.grammar-rule.grammar-rule .grammar-rule__w--mod { color: var(--gr-mod); }
.grammar-rule.grammar-rule .grammar-rule__w--v3 { color: var(--gr-v3); }
.grammar-rule.grammar-rule .grammar-rule__w--base { color: var(--gr-base); }
.grammar-rule.grammar-rule .grammar-rule__w--ing { color: var(--gr-ing); }
.grammar-rule.grammar-rule .grammar-rule__w--v2 { color: var(--gr-v2); }
.grammar-rule.grammar-rule .grammar-rule__w--adj { color: var(--gr-adj); }

.grammar-rule__tr {
    margin: clamp(8px, 2vw, 14px) 0 0;
    font-size: clamp(15px, 3.6vw, 20px);
    font-weight: 400;
    line-height: 1.35;
    color: var(--text-muted);
    text-wrap: pretty;
}

.grammar-rule .slide-nav { margin-top: -4px; }
