/* legal-ref.css — TaxTami Legislation Reference Preview
 * Tooltip (desktop hover) + Modal overlay (click / tap)
 * Colours drawn from lessons.css :root variables where possible.
 * ---------------------------------------------------------------- */

/* ── Interactive state for .leg-ref spans ───────────────────────── */
.leg-ref[data-provision] {
    cursor: pointer;
    position: relative;
}

.leg-ref[data-provision]:focus {
    outline: 2px solid #2c724f;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── Desktop tooltip (hover preview) ───────────────────────────── */
.leg-tooltip {
    position: fixed;
    z-index: 9000;
    max-width: 360px;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid rgba(44, 114, 79, 0.30);
    border-left: 4px solid #2c724f;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 12px 15px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    font-size: 12.5px;
    line-height: 1.55;
    color: #2d3436;
}

.leg-tooltip.leg-tooltip--visible {
    opacity: 1;
    transform: translateY(0);
}

.leg-tooltip__act {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #2c724f;
    margin-bottom: 4px;
}

.leg-tooltip__section {
    font-size: 13px;
    font-weight: 700;
    color: #1a3a2a;
    margin-bottom: 6px;
}

.leg-tooltip__text {
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.leg-tooltip__hint {
    margin-top: 8px;
    font-size: 10px;
    color: #999;
    font-style: italic;
}

/* ── Modal overlay ──────────────────────────────────────────────── */
.leg-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9100;
    background: rgba(0, 0, 0, 0.50);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.22s ease;
    -webkit-overflow-scrolling: touch;
}

.leg-modal-backdrop.leg-modal--open {
    opacity: 1;
}

.leg-modal {
    position: relative;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.22s ease;
    outline: none;
}

.leg-modal-backdrop.leg-modal--open .leg-modal {
    transform: scale(1) translateY(0);
}

/* Modal header */
.leg-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 2px solid #e9f1ed;
    flex-shrink: 0;
}

.leg-modal__heading {
    flex: 1;
    min-width: 0;
}

.leg-modal__act-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #fff;
    background: #2c724f;
    border-radius: 4px;
    padding: 2px 7px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.leg-modal__title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #1a3a2a;
    line-height: 1.3;
}

.leg-modal__close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 18px;
    line-height: 1;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    padding: 0;
    margin-top: 2px;
}

.leg-modal__close:hover,
.leg-modal__close:focus {
    background: #e9f1ed;
    color: #2c724f;
    border-color: #2c724f;
    outline: none;
}

/* Modal body */
.leg-modal__body {
    padding: 16px 20px 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.leg-modal__text {
    font-size: 14px;
    line-height: 1.7;
    color: #2d3436;
    margin: 0;
}

/* Fallback state */
.leg-modal__fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
    text-align: center;
    color: #888;
}

.leg-modal__fallback-icon {
    font-size: 28px;
    margin-bottom: 8px;
    opacity: 0.5;
}

.leg-modal__fallback-msg {
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    max-width: 300px;
}

/* Modal footer */
.leg-modal__footer {
    padding: 10px 20px 14px;
    border-top: 1px solid #e9f1ed;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}

.leg-modal__chapter {
    font-size: 11px;
    color: #aaa;
    font-style: italic;
}

.leg-modal__disclaimer {
    font-size: 10.5px;
    color: #bbb;
    text-align: right;
    flex: 1;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .leg-modal {
        max-height: 90vh;
        border-radius: 12px;
    }

    .leg-modal__title {
        font-size: 14px;
    }

    .leg-modal__text {
        font-size: 13.5px;
    }

    /* No hover tooltip on touch devices — hidden via JS */
    .leg-tooltip {
        display: none !important;
    }
}

/* ── Reduced-motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .leg-tooltip,
    .leg-modal-backdrop,
    .leg-modal {
        transition: none;
    }
}
