/* ============================================================
 * SciCirc Teach Widget — 共通モーダル UI
 *
 * 各セクションに <button class="scicirc-teach-btn" ...>💬 AIに教える</button>
 * を置くと、このCSS+widget.jsでモーダルが起動して3サイクル対話。
 * ============================================================ */

.scicirc-teach-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 999px;
    border: 1px solid rgba(57, 255, 20, 0.45);
    background: linear-gradient(135deg, rgba(57, 255, 20, 0.18), rgba(0, 204, 255, 0.10));
    color: #fff;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    text-decoration: none;
    font-family: inherit;
}

.scicirc-teach-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(57, 255, 20, 0.25);
    background: linear-gradient(135deg, rgba(57, 255, 20, 0.28), rgba(0, 204, 255, 0.18));
}

.scicirc-teach-btn__icon { font-size: 1.1rem; line-height: 1; }
.scicirc-teach-btn__sub { font-size: 0.72rem; opacity: 0.75; font-weight: 500; }

/* オーバーレイ */
.sc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 16, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.sc-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* モーダル本体 */
.sc-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: min(640px, 92vw);
    max-height: 86vh;
    background: linear-gradient(180deg, #0e1320 0%, #0a0e18 100%);
    border: 1px solid rgba(57, 255, 20, 0.35);
    border-radius: 18px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(57, 255, 20, 0.08);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #eaeaf0;
    font-family: inherit;
}

.sc-overlay.is-open + .sc-modal,
.sc-modal.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.sc-modal__header {
    padding: 18px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sc-modal__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sc-modal__cycle {
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(57, 255, 20, 0.15);
    color: #39ff14;
    font-family: 'Share Tech Mono', monospace;
    letter-spacing: 0.05em;
}

.sc-modal__close {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 1.6rem;
    line-height: 1;
    padding: 0 6px;
    transition: color 0.18s ease;
}

.sc-modal__close:hover { color: #fff; }

.sc-modal__body {
    padding: 22px 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sc-question {
    padding: 14px 18px;
    border-radius: 14px;
    background: rgba(57, 255, 20, 0.08);
    border-left: 3px solid #39ff14;
    color: #d9ffd0;
    line-height: 1.65;
    font-size: 0.95rem;
}

.sc-question::before {
    content: "🤖 ";
    margin-right: 4px;
}

.sc-answer {
    padding: 14px 18px;
    border-radius: 14px;
    background: rgba(0, 204, 255, 0.08);
    border-left: 3px solid #00ccff;
    color: #e0f4ff;
    line-height: 1.65;
    font-size: 0.95rem;
    align-self: flex-end;
    max-width: 92%;
}

.sc-answer::before {
    content: "👤 ";
    margin-right: 4px;
}

.sc-feedback {
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 193, 7, 0.08);
    border-left: 3px solid #ffc107;
    color: #ffe69a;
    line-height: 1.55;
    font-size: 0.85rem;
}

.sc-feedback::before { content: "💡 "; }

.sc-modal__input-area {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.sc-textarea {
    width: 100%;
    min-height: 80px;
    max-height: 200px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.95rem;
    line-height: 1.5;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.18s ease;
    box-sizing: border-box;
}

.sc-textarea:focus { border-color: rgba(57, 255, 20, 0.55); }
.sc-textarea:disabled { opacity: 0.5; cursor: not-allowed; }

.sc-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 12px;
}

.sc-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.sc-btn {
    padding: 10px 22px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #39ff14, #00ccff);
    color: #000;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    font-family: inherit;
}

.sc-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(57, 255, 20, 0.35);
}

.sc-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.sc-btn--secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* 完走画面 */
.sc-result {
    padding: 24px;
    text-align: center;
}

.sc-result__score {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #39ff14, #00ccff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-family: 'Share Tech Mono', monospace;
    line-height: 1;
    margin: 12px 0;
}

.sc-result__label {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.sc-result__rubric {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.sc-result__rubric-item {
    padding: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sc-result__rubric-item-label {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 4px;
}

.sc-result__rubric-item-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #39ff14;
    font-family: 'Share Tech Mono', monospace;
}

.sc-result__praise {
    margin: 16px 0;
    color: #d9ffd0;
    line-height: 1.7;
}

/* ローディング */
.sc-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

.sc-loading::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid rgba(57, 255, 20, 0.3);
    border-top-color: #39ff14;
    border-radius: 50%;
    animation: sc-spin 0.8s linear infinite;
}

@keyframes sc-spin {
    to { transform: rotate(360deg); }
}

.sc-error {
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(255, 80, 80, 0.1);
    border-left: 3px solid #ff5050;
    color: #ffb0b0;
    font-size: 0.88rem;
}

/* レスポンシブ */
@media (max-width: 480px) {
    .sc-modal { width: 96vw; max-height: 92vh; }
    .sc-modal__header { padding: 14px 16px; }
    .sc-modal__body { padding: 16px; }
    .sc-modal__input-area { padding: 12px 16px; }
}
