/**
 * KabalaTech Biblical Dictionary UI.
 *
 * @author Shmuel Fortman Hapartzy
 */

.page-kabalatech-dict .dict-main {
    max-width: 44rem;
}

/* Same family as gematria search waiting state (flipping book). */
.dict-loader.gematria-loader {
    text-align: center;
    padding: 1.5rem 1rem;
    margin: 0.75rem 0 1rem;
    border-radius: 10px;
    background: var(--panel-soft, color-mix(in srgb, var(--card-bg, #f7f3ea) 88%, transparent));
    border: 1px solid var(--card-border, rgba(0, 0, 0, 0.08));
}

.dict-loader .gem-book {
    position: relative;
    width: 104px;
    height: 68px;
    margin: 0 auto 1.1rem;
    border: 3px solid color-mix(in srgb, var(--gold, #c9a227) 50%, transparent);
    border-radius: 2px 8px 8px 2px;
    background: linear-gradient(145deg, #5c4308 0%, var(--gold, #c9a227) 42%, #a67c0f 100%);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.dict-loader .gem-book__page {
    position: absolute;
    left: 50%;
    top: -3px;
    width: 52px;
    height: 68px;
    margin: 0 auto;
    border-top: 3px solid rgba(255, 252, 240, 0.9);
    border-bottom: 3px solid rgba(255, 252, 240, 0.9);
    border-right: 3px solid rgba(255, 252, 240, 0.9);
    border-radius: 0 5px 5px 0;
    background: linear-gradient(180deg, #fff9ee 0%, #f2e8d4 100%);
    color: #3d2f0a;
    font-family: "Frank Ruhl Libre", "Heebo", "Noto Sans Hebrew", serif;
    font-size: 0.62rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    direction: rtl;
    line-height: 1.15;
    transform-origin: 0% 50%;
    animation: dict-gem-book-flip 2.1s infinite linear;
    animation-fill-mode: forwards;
    box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.18);
}

.dict-loader .gem-book__page--1 {
    z-index: 3;
    animation-delay: 0s;
}

.dict-loader .gem-book__page--2 {
    z-index: 2;
    animation-delay: 0.7s;
}

.dict-loader .gem-book__page--3 {
    z-index: 1;
    animation-delay: 1.4s;
}

@keyframes dict-gem-book-flip {
    0% {
        transform: perspective(600px) rotateY(0deg);
        opacity: 1;
    }
    22% {
        background: linear-gradient(180deg, #fff3dc 0%, #e8dcc4 100%);
    }
    30% {
        transform: perspective(220px) rotateY(-92deg);
    }
    54.9% {
        opacity: 1;
    }
    55% {
        opacity: 0;
    }
    60% {
        transform: perspective(220px) rotateY(-180deg);
        opacity: 0;
    }
    100% {
        transform: perspective(220px) rotateY(-180deg);
        opacity: 0;
    }
}

.dict-loader .gematria-loader__tanakh {
    font-family: "Heebo", "Rubik", "Noto Sans Hebrew", serif;
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
    direction: rtl;
}

.dict-loader .gematria-loader__text {
    margin: 0;
    color: var(--muted, #6b6560);
}

.dict-submit.is-loading {
    opacity: 0.65;
    cursor: wait;
}

.dict-app.is-searching .dict-status {
    min-height: 0;
}

.dict-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.dict-app base {
    display: none;
}

.dict-form {
    display: grid;
    gap: 0.85rem;
    margin: 0 0 0.75rem;
}

@media (min-width: 640px) {
    .dict-form {
        grid-template-columns: 1fr minmax(10rem, 13rem) auto;
        align-items: end;
    }
}

.dict-field {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.dict-label {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.dict-input,
.dict-select {
    width: 100%;
    box-sizing: border-box;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text);
    font: inherit;
    line-height: 1.35;
}

.dict-input:focus,
.dict-select:focus {
    outline: 2px solid color-mix(in srgb, var(--gold) 55%, transparent);
    outline-offset: 1px;
}

.dict-input[dir="rtl"] {
    text-align: right;
}

.dict-submit {
    min-height: 2.7rem;
    white-space: nowrap;
}

.dict-suggest {
    position: absolute;
    z-index: 20;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    max-height: 16rem;
    overflow: auto;
}

.dict-suggest[hidden] {
    display: none !important;
}

.dict-suggest-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.15rem 0.75rem;
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.dict-suggest-item:hover,
.dict-suggest-item.is-active {
    background: color-mix(in srgb, var(--gold) 12%, transparent);
}

.dict-suggest-he {
    font-weight: 700;
    color: var(--gold);
}

.dict-suggest-meta {
    grid-column: 1 / -1;
    font-size: 0.9rem;
    color: var(--muted);
}

.dict-status {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.dict-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dict-card {
    padding: 1.1rem 1.15rem 1.25rem;
    border-radius: 14px;
    border: 1px solid var(--card-border);
    background: linear-gradient(155deg, var(--card-bg) 0%, var(--surface) 100%);
}

.dict-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.45rem 1rem;
    margin-bottom: 0.85rem;
}

.dict-lemma {
    margin: 0;
    font-size: clamp(1.45rem, 4vw, 1.9rem);
    font-weight: 700;
    color: var(--gold);
    line-height: 1.2;
}

.dict-meta {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.dict-chain-badge {
    display: inline-block;
    margin: 0 0 0.75rem;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.dict-lang-tabs-wrap {
    margin-top: 0.15rem;
}

.dict-lang-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0 0 0.85rem;
}

.dict-lang-tab {
    font: inherit;
    cursor: pointer;
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.04em;
    font-size: 0.85rem;
}

.dict-lang-tab:hover {
    border-color: color-mix(in srgb, var(--gold) 55%, var(--card-border));
    color: var(--ink);
}

.dict-lang-tab.is-active {
    border-color: var(--gold);
    color: var(--gold);
    background: color-mix(in srgb, var(--gold) 12%, transparent);
}

.dict-lang-panel[hidden] {
    display: none !important;
}

.dict-sense-block {
    margin-top: 0.15rem;
}

.dict-sense-h {
    margin: 0 0 0.55rem;
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.dict-sense-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.dict-sense-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.75rem;
}

.dict-sense-text {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.4;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.5rem;
    min-width: 0;
}

.dict-sense-word {
    font-weight: 600;
}

.dict-sense-count {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
}

.dict-sense-sources {
    position: relative;
}

.dict-sense-sources-sum {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    list-style: none;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: color-mix(in srgb, var(--gold) 8%, transparent);
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.2;
    user-select: none;
}

.dict-sense-sources-sum::-webkit-details-marker {
    display: none;
}

.dict-sense-sources-sum::before {
    content: '▸';
    font-size: 0.7rem;
    color: var(--gold);
}

.dict-sense-sources[open] > .dict-sense-sources-sum::before {
    content: '▾';
}

.dict-sense-sources-label {
    letter-spacing: 0.02em;
}

.dict-sense-sources-n {
    font-weight: 700;
    color: var(--gold);
}

.dict-sense-sources-body {
    flex-basis: 100%;
    width: 100%;
    margin-top: 0.45rem;
}

.dict-sense-sources[open] {
    flex-basis: 100%;
    width: 100%;
}

.dict-sources {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.dict-source--static {
    display: inline-block;
    font-size: 0.78rem;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    background: color-mix(in srgb, var(--gold) 10%, transparent);
    color: var(--muted);
}

.dict-source-detail {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface) 70%, var(--card-bg));
    overflow: hidden;
}

.dict-source-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
    cursor: pointer;
    list-style: none;
    padding: 0.45rem 0.7rem;
    font-size: 0.9rem;
}

.dict-source-summary::-webkit-details-marker {
    display: none;
}

.dict-source-cite {
    font-weight: 600;
    color: var(--gold);
}

.dict-source-hint {
    font-size: 0.75rem;
    color: var(--muted);
}

.dict-source-detail[open] .dict-source-hint {
    opacity: 0.55;
}

.dict-source-body {
    padding: 0 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    border-top: 1px solid color-mix(in srgb, var(--card-border) 80%, transparent);
}

.dict-source-lemma {
    margin: 0.55rem 0 0;
    font-weight: 700;
    color: var(--gold);
}

.dict-source-block {
    margin: 0;
}

.dict-source-lang {
    margin: 0 0 0.2rem;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.dict-source-he,
.dict-source-tr {
    margin: 0;
    line-height: 1.55;
    font-size: 0.98rem;
}

.dict-source-he {
    font-size: 1.05rem;
}

.dict-mark {
    background: color-mix(in srgb, var(--gold) 28%, transparent);
    color: inherit;
    border-radius: 3px;
    padding: 0.12em 0.12em 0.38em;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.dict-bridge-from {
    margin: 0 0 0.55rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.dict-how-lead {
    margin: 0;
    max-width: 40rem;
    color: var(--muted);
    line-height: 1.55;
}

.dict-empty {
    margin: 0;
    padding: 1rem 1.1rem;
    border-radius: 12px;
    border: 1px dashed var(--card-border);
    color: var(--muted);
}

.dict-suggest-fallback {
    margin: 0.75rem 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.dict-fallback-item {
    font: inherit;
    cursor: pointer;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--gold);
    font-weight: 700;
}

.dict-fallback-item:hover {
    border-color: var(--gold);
}

.dict-classics {
    margin-top: 1.1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--card-border);
}

.dict-classic-source {
    margin: 0.75rem 0 0;
}

.dict-classic-source-h {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
}

.dict-classic-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.4rem;
}

.dict-classic-detail {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: color-mix(in srgb, var(--card-bg) 92%, var(--gold) 8%);
    overflow: hidden;
    direction: rtl;
    text-align: right;
}

.dict-classic-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.75rem;
    cursor: pointer;
    padding: 0.55rem 0.75rem;
    list-style: none;
    direction: rtl;
    text-align: right;
}

.dict-classic-summary::-webkit-details-marker {
    display: none;
}

.dict-classic-key {
    font-weight: 700;
    font-size: 1.05rem;
}

.dict-classic-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.dict-classic-body {
    padding: 0 0.75rem 0.75rem;
}

.dict-classic-he {
    margin: 0;
    line-height: 1.65;
    white-space: pre-wrap;
}

.dict-classic-en {
    margin: 0.55rem 0 0;
    color: var(--muted);
    line-height: 1.5;
    white-space: pre-wrap;
}

.dict-classics-attr {
    margin: 0.85rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
}

.dict-classic-body--radak,
.dict-classic-body--mach {
    padding-top: 0.35rem;
    direction: rtl;
    text-align: right;
}

.mach-article {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    line-height: 1.7;
    font-size: 1.02rem;
    direction: rtl;
    text-align: right;
}

.mach-root {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gold);
}

.mach-preface {
    margin: 0;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--card-border) 85%, transparent);
    background: color-mix(in srgb, var(--card-bg) 90%, var(--gold) 10%);
}

.mach-sense {
    margin: 0;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--card-border) 85%, transparent);
    background: color-mix(in srgb, var(--card-bg) 94%, transparent);
}

.mach-sense + .mach-sense {
    margin-top: 0.15rem;
}

.mach-sense-h {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gold);
}

.mach-p {
    margin: 0;
}

.mach-quote {
    font-weight: 700;
    color: var(--ink);
}

.mach-cite {
    display: inline;
    margin: 0;
    padding: 0;
    unicode-bidi: isolate;
}

.mach-cite--static {
    color: var(--muted);
    font-size: 0.9em;
    white-space: nowrap;
}


.radak-article {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    line-height: 1.7;
    font-size: 1.02rem;
    direction: rtl;
    text-align: right;
}

.radak-root {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gold);
}

.radak-section {
    margin: 0;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--card-border) 85%, transparent);
    background: color-mix(in srgb, var(--card-bg) 88%, var(--gold) 12%);
}

.radak-sense {
    margin: 0 0 0.55rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
}

.radak-block + .radak-block {
    margin-top: 0.7rem;
    padding-top: 0.65rem;
    border-top: 1px dashed color-mix(in srgb, var(--card-border) 70%, transparent);
}

.radak-h {
    margin: 0 0 0.35rem;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--gold);
}

.radak-h--inline {
    display: inline;
    margin: 0 0.25em 0 0;
}

.radak-p {
    margin: 0;
}

.radak-form {
    font-weight: 700;
    color: var(--ink);
}

.radak-binyan {
    display: inline-block;
    margin: 0 0.15em;
    padding: 0.05em 0.4em;
    border-radius: 6px;
    border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--card-border));
    background: color-mix(in srgb, var(--gold) 12%, transparent);
    font-size: 0.86em;
    font-weight: 700;
    color: var(--gold);
}

.radak-cite {
    display: inline;
    margin: 0;
    padding: 0;
    /* Keep the cite chip from forcing the following punctuation onto its own line. */
    unicode-bidi: isolate;
}

.radak-cite--static {
    color: var(--muted);
    font-size: 0.9em;
    white-space: nowrap;
}

.radak-cite-sum {
    display: inline;
    cursor: pointer;
    list-style: none;
    color: var(--gold);
    font-weight: 600;
    font-size: 0.92em;
    white-space: nowrap;
}

.radak-cite-sum::-webkit-details-marker {
    display: none;
}

.radak-cite-body {
    display: block;
    margin: 0.4rem 0 0.55rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    direction: rtl;
    text-align: right;
}

.radak-cite-he {
    margin: 0;
    line-height: 2.05;
    font-size: 1.02rem;
}

.radak-cite-tr {
    margin: 0.45rem 0 0;
    color: var(--muted);
    line-height: 1.5;
    font-size: 0.95rem;
    direction: ltr;
    unicode-bidi: plaintext;
}

.radak-cite-he .dict-mark,
.radak-cite-tr .dict-mark,
.dict-classic-body--mach .radak-cite-he .dict-mark,
.dict-classic-body--mach .radak-cite-tr .dict-mark {
    background: color-mix(in srgb, var(--gold) 28%, transparent);
    color: inherit;
    border-radius: 3px;
    padding: 0.12em 0.12em 0.38em;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}
