/* History Tutor — hub + Ancient Rome chat/widget UI. Uses the site's edu-theme
   design tokens (static/css/edu-theme.css) rather than a bespoke palette. */

.ht-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px 80px;
}

.ht-header {
    position: relative;
    text-align: center;
    margin-bottom: 32px;
}

.ht-back {
    position: absolute;
    left: 0;
    top: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.ht-back:hover {
    color: var(--accent-blue);
}

.ht-header h1 {
    font-size: 2.2rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.ht-header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 640px;
    margin: 0 auto;
}

/* ---------- Hub page: agent cards ---------- */

.ht-agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.ht-agent-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    padding: 22px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

a.ht-agent-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--glass-shadow);
    border-color: var(--accent-blue);
}

.ht-agent-card--soon {
    opacity: 0.6;
}

.ht-agent-subject {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent-green);
    font-weight: 600;
}

.ht-agent-card h2 {
    font-size: 1.3rem;
    margin: 0;
    color: var(--text-primary);
}

.ht-agent-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    flex: 1;
}

.ht-agent-cta {
    font-weight: 600;
    color: var(--accent-deep);
    font-size: 0.9rem;
}

/* ---------- Ancient Rome chat page ---------- */

.ht-starters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}

.ht-starter-chip {
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.ht-starter-chip:hover {
    border-color: var(--accent-blue);
    color: var(--accent-deep);
}

.ht-starter-chip-suggested {
    border-color: var(--accent-blue);
    color: var(--accent-deep);
    box-shadow: 0 0 0 1px var(--accent-blue);
}

.ht-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 24px;
    align-items: start;
}

@media (max-width: 860px) {
    .ht-layout {
        grid-template-columns: 1fr;
    }
}

.ht-chat-col {
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    height: 70vh;
    min-height: 420px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.message-avatar {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--tertiary-dark);
    color: var(--text-secondary);
}

.message.user .message-avatar {
    background: var(--accent-blue);
    color: #fff;
}

.message-content {
    background: var(--tertiary-dark);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
    max-width: 85%;
    white-space: pre-wrap;
}

.message.user .message-content {
    background: var(--accent-blue);
    color: #fff;
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: ht-typing 1.1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ht-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--hairline);
}

.chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--primary-dark);
    color: var(--text-primary);
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.send-btn {
    background: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 20px;
    font-weight: 600;
    cursor: pointer;
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.alert {
    background: #fbe6e6;
    color: #8a2a2a;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.9rem;
}

/* ---------- Widget stage ---------- */

.ht-stage-col {
    min-height: 420px;
}

.ht-stage {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 2px;
}

.ht-stage-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 40px 20px;
    border: 1px dashed var(--hairline);
    border-radius: 14px;
}

.ht-widget {
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    padding: 16px;
    animation: ht-widget-in 0.25s ease;
}

@keyframes ht-widget-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.ht-widget h3 {
    margin: 0 0 10px;
    font-size: 1rem;
    color: var(--text-primary);
}

/* Map widget */

.ht-map-el {
    width: 100%;
    height: 320px;
    border-radius: 10px;
    background: var(--tertiary-dark);
}

.ht-map-era-label {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Timeline widget */

.ht-timeline-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.ht-timeline-event {
    flex-shrink: 0;
    width: 150px;
    background: var(--primary-dark);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    padding: 10px;
    font-size: 0.82rem;
    cursor: pointer;
}

.ht-timeline-event:hover,
.ht-timeline-event.ht-highlight {
    border-color: var(--accent-purple);
}

.ht-timeline-event .ht-timeline-date {
    font-weight: 700;
    color: var(--accent-deep);
    display: block;
    margin-bottom: 4px;
}

.ht-timeline-event .ht-timeline-name {
    display: block;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.ht-timeline-detail {
    margin-top: 12px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--hairline);
    padding-top: 10px;
}

/* Figure (biography) widget */

.ht-figure-body {
    display: flex;
    gap: 14px;
}

.ht-figure-portrait {
    width: 84px;
    height: 84px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--tertiary-dark);
}

.ht-figure-portrait-fallback {
    width: 84px;
    height: 84px;
    border-radius: 10px;
    flex-shrink: 0;
    background: var(--tertiary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-muted);
}

.ht-figure-name {
    font-weight: 700;
    color: var(--text-primary);
}

.ht-figure-meta {
    font-size: 0.8rem;
    color: var(--accent-green);
    margin-bottom: 6px;
}

.ht-figure-summary {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* Quiz widget */

.ht-quiz-question {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.ht-quiz-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ht-quiz-choice {
    text-align: left;
    background: var(--primary-dark);
    border: 1px solid var(--hairline);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text-primary);
}

.ht-quiz-choice:hover:not(:disabled) {
    border-color: var(--accent-blue);
}

.ht-quiz-choice:disabled {
    cursor: default;
}

.ht-quiz-choice.ht-correct {
    border-color: var(--accent-green);
    background: rgba(47, 122, 107, 0.12);
}

.ht-quiz-choice.ht-incorrect {
    border-color: #b23a3a;
    background: rgba(178, 58, 58, 0.1);
}

.ht-quiz-feedback {
    margin-top: 12px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--hairline);
    padding-top: 10px;
}
