/* Vocabulary hub — word grid, filters, popover.
   Every colour here is a project token; nothing is hardcoded. */

/* ── Toolbar ─────────────────────────────────────────────────────── */
.vh-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 24px;
}

.vh-search {
    flex: 1 1 220px;
    min-width: 180px;
    padding: 10px 14px;
    font-size: .92rem;
    font-family: var(--font-body);
    color: var(--fg);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.vh-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Pill trigger shared by both dropdowns and the view toggle. */
.vh-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: .88rem;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--fg);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color .2s ease, background .2s ease, color .2s ease;
}

.vh-pill:hover { border-color: var(--accent); }
.vh-pill[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.vh-pill .vh-caret { font-size: .65rem; opacity: .6; }

.vh-dropdown { position: relative; }

.vh-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 40;
    min-width: 190px;
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.vh-panel[hidden] { display: none; }

.vh-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    font-size: .88rem;
    font-family: var(--font-body);
    color: var(--fg);
    background: none;
    border: none;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    transition: background .2s ease;
}

.vh-option:hover { background: var(--bg-subtle); }
.vh-option[aria-checked="true"] { color: var(--accent); font-weight: 600; }

.vh-option input { accent-color: var(--accent); cursor: pointer; }

.vh-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: var(--border-strong);
}

.vh-dot.is-mastered { background: var(--green); }
.vh-dot.is-learning { background: var(--yellow); }
.vh-dot.is-weak     { background: var(--red); }
.vh-dot.is-neutral  { background: var(--border-strong); }

/* Dark pill call to action. */
.vh-start {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    padding: 11px 22px;
    font-size: .9rem;
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--bg-card);
    background: var(--fg);
    border: 1px solid var(--fg);
    border-radius: 999px;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}

.vh-start:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    opacity: .92;
}

/* ── Stats row ───────────────────────────────────────────────────── */
.vh-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.vh-stat {
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.vh-stat-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--fg-muted);
}

/* Plain numbers: inherits the body font deliberately — no display face, no tabular
   figures, no oversized weight. */
.vh-stat-value {
    margin-top: 6px;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--fg);
}

/* ── Word grid ───────────────────────────────────────────────────── */
.vh-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

@media (max-width: 1024px) { .vh-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .vh-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Cards are links to the word's own page — real navigation, so middle-click and
   open-in-new-tab work. */
.vh-card {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 90px;
    padding: 10px 12px;
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    color: var(--fg);
    text-decoration: none;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    overflow-wrap: anywhere;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;

    /* Staggered by JS; without it they simply fade in together. */
    animation: vh-fade-in .28s ease both;
}

.vh-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.vh-card:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.vh-card.is-mastered { border-color: var(--green); }
.vh-card.is-learning { border-color: var(--yellow); }
.vh-card.is-weak     { border-color: var(--red); }
.vh-card.is-neutral  { border-color: var(--border); }

.vh-card[hidden] { display: none; }

@keyframes vh-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .vh-card { animation: none; }
    .vh-card:hover { transform: none; }
    .vh-start:hover { transform: none; }
}

/* ── List view ───────────────────────────────────────────────────── */
.vh-grid.is-list { grid-template-columns: 1fr; gap: 8px; }

.vh-grid.is-list .vh-card {
    height: auto;
    min-height: 0;
    justify-content: flex-start;
    text-align: left;
    padding: 14px 18px;
    border-width: 1px;
    border-left-width: 3px;
}

.vh-grid.is-list .vh-card::after {
    content: attr(data-definition);
    margin-left: 14px;
    padding-left: 14px;
    border-left: 1px solid var(--border);
    font-size: .88rem;
    font-weight: 400;
    color: var(--fg-muted);
}

@media (max-width: 640px) {
    .vh-grid.is-list .vh-card { flex-direction: column; align-items: flex-start; gap: 6px; }
    .vh-grid.is-list .vh-card::after { margin-left: 0; padding-left: 0; border-left: none; }
}

/* ── Pager ───────────────────────────────────────────────────────── */
.vh-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.vh-page-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: .9rem;
    font-weight: 500;
    color: var(--fg);
    text-decoration: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.vh-page-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
}

.vh-page-btn.is-disabled {
    opacity: .4;
    pointer-events: none;
}

.vh-page-info {
    font-size: .85rem;
    color: var(--fg-muted);
    text-align: center;
    flex: 1 1 auto;
}

/* ── Word page ───────────────────────────────────────────────────── */
.vh-word-page {
    max-width: 560px;
    margin: 0 auto;
    padding: 40px 16px;
}

.vh-word-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.vh-back-link {
    font-size: .88rem;
    color: var(--fg-muted);
    text-decoration: none;
    transition: color .2s ease;
}

.vh-back-link:hover { color: var(--fg); }

.vh-position {
    font-size: .82rem;
    color: var(--fg-faint);
}

/* Live status totals above the card. */
.vh-counts {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    font-size: .78rem;
    color: var(--fg-muted);
}

.vh-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.vh-count b {
    color: var(--fg);
    font-weight: 600;
    /* Counts change in place; a fixed minimum stops the row jittering as digits are
       added or removed. */
    min-width: 1.4em;
    display: inline-block;
    transition: color .2s ease;
}

/* Both faces take the word's status colour, so the border reads the same either way. */
.vh-flip.is-mastered .vh-face { border-color: var(--green); }
.vh-flip.is-learning .vh-face { border-color: var(--yellow); }
.vh-flip.is-weak     .vh-face { border-color: var(--red); }
.vh-flip.is-neutral  .vh-face { border-color: var(--border); }

.vh-flip .vh-face { transition: border-color .2s ease; }

/* ── Flip card ───────────────────────────────────────────────────── */
.vh-flip {
    perspective: 1400px;
    min-height: 340px;
    cursor: pointer;
}

.vh-flip-inner {
    position: relative;
    width: 100%;
    min-height: 340px;
    transform-style: preserve-3d;
    transition: transform .4s ease;
}

.vh-flip.is-flipped .vh-flip-inner { transform: rotateY(180deg); }

.vh-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 32px 28px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.vh-face-back { transform: rotateY(180deg); }

.vh-modal-word {
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--fg);
    text-align: center;
    overflow-wrap: anywhere;
}

.vh-modal-type {
    margin-top: 4px;
    font-size: .9rem;
    font-style: italic;
    color: var(--fg-muted);
    text-align: center;
}

.vh-label {
    margin-top: 22px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--fg-muted);
    text-align: center;
}

.vh-modal-def {
    margin-top: 8px;
    font-size: 1.02rem;
    line-height: 1.55;
    color: var(--fg);
    text-align: center;
}

.vh-modal-example {
    margin-top: 8px;
    font-size: .94rem;
    line-height: 1.6;
    font-style: italic;
    color: var(--fg-muted);
    text-align: center;
}

.vh-flip-hint {
    margin-top: auto;
    padding-top: 20px;
    font-size: .78rem;
    color: var(--fg-faint);
    text-align: center;
}

/* Status badge, top right of the back face. */
.vh-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--fg-muted);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.vh-badge.is-mastered { color: var(--green); border-color: var(--green); }
.vh-badge.is-learning { color: var(--yellow); border-color: var(--yellow); }
.vh-badge.is-weak     { color: var(--red);    border-color: var(--red); }

/* ── Strong / Weak ───────────────────────────────────────────────── */
.vh-marks {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.vh-mark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 24px;
    font-size: .92rem;
    font-family: var(--font-body);
    font-weight: 600;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, transform .2s ease;
}

.vh-mark-strong { color: var(--green); border-color: var(--green); }
.vh-mark-weak   { color: var(--red);   border-color: var(--red); }

.vh-mark-strong:hover { background: var(--green-light); transform: translateY(-2px); }
.vh-mark-weak:hover   { background: var(--red-light);   transform: translateY(-2px); }

.vh-mark[disabled] { opacity: .55; cursor: default; transform: none; }

/* ── Modal navigation ────────────────────────────────────────────── */
.vh-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

/* Links now, not buttons — Previous/Next are real navigation. */
.vh-nav a,
.vh-nav span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: .85rem;
    color: var(--fg-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: color .2s ease, background .2s ease;
}

.vh-nav a:hover { color: var(--fg); background: var(--bg-subtle); }
.vh-nav .is-disabled { opacity: .4; pointer-events: none; }

@media (max-width: 480px) {
    .vh-face { padding: 26px 18px; }
    .vh-modal-word { font-size: 1.6rem; }
    .vh-marks { flex-direction: column; }
    .vh-nav a, .vh-nav span { padding: 8px 10px; font-size: .8rem; }
    .vh-pager { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .vh-flip-inner { transition: none; }
    .vh-mark:hover { transform: none; }
}

.vh-empty {
    padding: 48px 16px;
    text-align: center;
    color: var(--fg-muted);
    font-size: .95rem;
}

.vh-empty[hidden] { display: none; }
