/* Inline SVG diagrams inside grammar articles (html_block). The frame, the
   caption and the play-on-scroll classes come from article-illustrations.css
   and its script; each diagram carries only its own keyframes. Role colours
   appear only where the diagram is about those roles. */

.topic-material-block .grammar-diagram {
    margin: 22px 0 28px;

    /* The accent is the same blue as the place. */
    --gd-acc-ink: var(--gd-where-ink);
    --gd-who-ink: #b45309;
    --gd-verb-ink: #8a6a00;
    --gd-what-ink: #15803d;
    --gd-where-ink: #1d4ed8;
    --gd-when-ink: #be185d;
    /* A word that is wrong before the diagram corrects it. */
    --gd-err-ink: #dc2626;
}

[data-theme="dark"] .topic-material-block .grammar-diagram {
    --gd-who-ink: #f59e42;
    --gd-verb-ink: #f5d547;
    --gd-what-ink: #5bc489;
    --gd-where-ink: #5aa9f0;
    --gd-when-ink: #e879b9;
    --gd-err-ink: #f87171;
}

.grammar-diagram text {
    font-family: "Google Sans", sans-serif;
    fill: var(--illustration-text);
}

.grammar-diagram .gd-w { font-weight: 600; }
.grammar-diagram .gd-l { fill: var(--illustration-text); }
.grammar-diagram .gd-m { fill: var(--illustration-muted); }
.grammar-diagram .gd-acc,
.grammar-diagram tspan.gd-acc { fill: var(--gd-acc-ink); font-weight: 800; }

.grammar-diagram .gd-ink-acc { fill: var(--gd-acc-ink); }
.grammar-diagram .gd-ink-who { fill: var(--gd-who-ink); }
.grammar-diagram .gd-ink-verb { fill: var(--gd-verb-ink); }
.grammar-diagram .gd-ink-what { fill: var(--gd-what-ink); }
.grammar-diagram .gd-ink-where { fill: var(--gd-where-ink); }
.grammar-diagram .gd-ink-when { fill: var(--gd-when-ink); }
.grammar-diagram .gd-ink-err { fill: var(--gd-err-ink); }

.grammar-diagram .gd-strike { stroke: var(--illustration-muted); }
.grammar-diagram .gd-strike-err { stroke: var(--gd-err-ink); }
/* The cross beside a line that lacks a word. */
.grammar-diagram .gd-cross-err { stroke: var(--gd-err-ink); }
.grammar-diagram .gd-slot { stroke: var(--illustration-muted); stroke-width: 1.5; opacity: 0.7; }
.grammar-diagram .gd-arrow path { stroke: var(--gd-acc-ink); }
.grammar-diagram .gd-bracket { stroke: var(--illustration-text); }
.grammar-diagram .gd-scale,
.grammar-diagram .gd-dot { stroke: var(--illustration-grid); fill: var(--illustration-grid); }
.grammar-diagram .gd-scale { stroke-width: 4; }
.grammar-diagram .gd-marker { fill: var(--illustration-text); }

/* Wait until the reader gets there; the script adds both classes. */
.grammar-diagram.is-animated:not(.is-visible) svg * {
    animation-play-state: paused !important;
}

@media (prefers-reduced-motion: reduce) {
    .grammar-diagram svg * {
        animation: none !important;
    }
}

/* No card behind the diagram; it sits straight on the page. */
.grammar-diagram .article-illustration__svg {
    background: transparent;
    border: 0;
    border-radius: 0;
}

/* A ring before the text of a table cell whose rows are levels of one scale. The fuller the ring, the more of
   that quality. Two kinds: "sure" runs from green (yes) to red (no) and is only for the confidence of the speaker;
   "amount" keeps one colour, for formality, readiness and the like, where red would read as bad. */
.level-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.level-ring {
    --level-track: #e6e6ea;
    flex: none;
    display: block;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: conic-gradient(var(--level-ink) calc(var(--level-part) * 1%), var(--level-track) 0);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4.5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4.5px));
}

[data-theme="dark"] .level-ring { --level-track: #2a2a2e; }

.level-ring--95 { --level-part: 95; }
.level-ring--75 { --level-part: 75; }
.level-ring--60 { --level-part: 60; }
.level-ring--50 { --level-part: 50; }
.level-ring--35 { --level-part: 35; }
.level-ring--20 { --level-part: 20; }
.level-ring--6 { --level-part: 6; }

.level-ring--amount { --level-ink: #1d4ed8; }
.level-ring--sure.level-ring--95 { --level-ink: #15803d; }
.level-ring--sure.level-ring--75,
.level-ring--sure.level-ring--60 { --level-ink: #a16207; }
.level-ring--sure.level-ring--50,
.level-ring--sure.level-ring--35 { --level-ink: #c2410c; }
.level-ring--sure.level-ring--20,
.level-ring--sure.level-ring--6 { --level-ink: #dc2626; }

[data-theme="dark"] .level-ring--amount { --level-ink: #5aa9f0; }
[data-theme="dark"] .level-ring--sure.level-ring--95 { --level-ink: #5bc489; }
[data-theme="dark"] .level-ring--sure.level-ring--75,
[data-theme="dark"] .level-ring--sure.level-ring--60 { --level-ink: #f5d547; }
[data-theme="dark"] .level-ring--sure.level-ring--50,
[data-theme="dark"] .level-ring--sure.level-ring--35 { --level-ink: #f59e42; }
[data-theme="dark"] .level-ring--sure.level-ring--20,
[data-theme="dark"] .level-ring--sure.level-ring--6 { --level-ink: #f87171; }
