/* Calibre System 03: the rulebook library, the native builder, and the own-rulebook parts of a case. Uses the tokens in s3.css. */

/* A calm card that explains a locked action. Brass, never red. */
.upgrade { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid color-mix(in oklch, var(--brass) 35%, var(--line)); border-radius: var(--r-card); background: var(--brass-soft); }
.upgrade-mark { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--surface); color: var(--brass-ink); }
.upgrade-side { align-items: flex-end; flex: none; }
.upgrade p { color: var(--ink-2); }
@media (max-width: 640px) { .upgrade { flex-wrap: wrap; } .upgrade-side { flex-direction: row; align-items: center; } }

/* On and off, as a real button. The state is also written out in words. */
.switch { display: inline-flex; align-items: center; gap: 10px; padding: 4px 6px 4px 2px; border: 0; background: transparent; color: var(--ink); text-align: left; border-radius: var(--r-control); }
.switch-track { position: relative; flex: none; width: 34px; height: 20px; border-radius: 999px; background: var(--line-2); transition: background-color var(--t-hover) var(--ease-out); }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px oklch(0.2 0.02 158 / 0.3); transition: transform var(--t-hover) var(--ease-out); }
.switch[aria-checked="true"] .switch-track { background: var(--pine); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(14px); background: var(--on-pine); }
.switch:disabled { opacity: 0.55; }
.switch-text { display: flex; flex-direction: column; min-width: 86px; }
@media (prefers-reduced-motion: reduce) { .switch-track, .switch-thumb { transition: none; } }

/* Library */
.rb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.rb-card { display: flex; flex-direction: column; gap: 12px; }
.rb-card[data-status="archived"] { background: var(--surface-2); }   /* not dimmed with opacity: that failed the AA contrast ratio */
.rb-card-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.rb-open { font: inherit; font-weight: 600; color: var(--ink); text-align: left; text-decoration: none; }
.rb-open:hover { text-decoration: underline; }
.rb-builtin { list-style: none; margin: 0; padding: 0; }
.rb-builtin li { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--line); }
.rb-builtin li:first-child { border-top: 0; }
.rb-builtin li[data-scope="out"] .rb-name { color: var(--ink-2); }
.rb-builtin li[data-scope="out"] { background: color-mix(in oklch, var(--surface-2) 55%, var(--surface)); }
.rb-name { font-weight: 500; }

/* Builder */
.rb-progress { display: flex; align-items: center; gap: 12px; margin: -8px 0 20px; flex-wrap: wrap; }
.rb-progress .progress { width: 180px; }
.rb-layout { display: grid; grid-template-columns: 264px minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
@media (max-width: 1240px) { .rb-layout { grid-template-columns: 240px minmax(0, 1fr); } .rb-source { grid-column: 1 / -1; position: static; max-height: 280px; } }
@media (max-width: 760px) { .rb-layout { grid-template-columns: minmax(0, 1fr); } }
.rb-list, .rb-source { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.rb-list { display: flex; flex-direction: column; gap: 12px; }
.rb-list ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rb-section { margin: 12px 8px 4px; }
.rb-item { display: flex; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; color: var(--ink-2); transition: background-color var(--t-hover) var(--ease-out); }
.rb-item:hover { background: var(--surface-2); }
.rb-item[aria-current="true"] { background: var(--pine-soft); color: var(--ink); }
.rb-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rb-glyph { flex: none; display: grid; place-items: center; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; color: var(--ink-3); }
.rb-glyph[data-state="done"] { background: var(--pine); color: var(--on-pine); }
.rb-glyph[data-state="error"] { color: var(--danger); }
.rb-main { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.clause-text { margin: 0; padding: 4px 0 4px 16px; border-left: 2px solid var(--brass); font: 18px/1.55 var(--font-display); white-space: pre-wrap; user-select: text; }
.rb-check { padding: 16px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); }
.rb-check .ev { margin: 6px 0 8px; }
.rb-issues { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); }
.rb-issues li { margin: 2px 0; }
.rb-source { padding: 16px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface-2); }
.rb-source-text { margin: 0; font: 13px/1.6 var(--font-ui); white-space: pre-wrap; word-break: break-word; color: var(--ink-2); }
.rb-source-text mark { background: color-mix(in oklch, var(--brass) 28%, transparent); color: var(--ink); border-radius: 3px; padding: 1px 0; }

/* A case */
.applies-strip { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.strip-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); font-size: 13px; color: var(--ink); transition: border-color var(--t-hover) var(--ease-out); }
.strip-chip:hover { border-color: var(--v-applies); }
.book-group { margin-top: 4px; }
.out-scope > div { margin-top: 12px; }
.from-person { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: var(--r-control); background: var(--surface-2); border-left: 2px solid var(--pine); }
.own-card .card-head { flex-wrap: wrap; }
.field-inline { display: inline-flex; }
.rb-panel { margin-top: 20px; outline: none; }
