/* TheAzureAI: small layer on top of Bootstrap 5.3 */
:root, [data-bs-theme=light] {
  --app-bg: #f5f7fb;
  --app-card: #ffffff;
  --app-border: rgba(15, 23, 42, .09);
  --app-ok: #16a34a; --app-ok-bg: rgba(22, 163, 74, .10);
  --app-no: #dc2626; --app-no-bg: rgba(220, 38, 38, .09);
  --app-sel-bg: rgba(59, 130, 246, .10);
  --app-shadow: 0 10px 30px -12px rgba(15, 23, 42, .18);
}
[data-bs-theme=dark] {
  --bs-body-bg: #0b1220;
  --bs-body-bg-rgb: 11, 18, 32;
  --bs-tertiary-bg: #131c2e;
  --app-bg: #0b1220;
  --app-card: #131c2e;
  --app-border: #26324a;
  --app-ok: #22c55e; --app-ok-bg: rgba(34, 197, 94, .14);
  --app-no: #ef4444; --app-no-bg: rgba(239, 68, 68, .14);
  --app-sel-bg: rgba(59, 130, 246, .14);
  --app-shadow: 0 16px 40px -16px rgba(0, 0, 0, .6);
  --bs-border-color: #26324a;
}
:root { --bs-primary: #3b82f6; --bs-primary-rgb: 59, 130, 246; --ease: cubic-bezier(.2, .8, .2, 1); }

body { background: var(--app-bg); transition: background-color .25s ease, color .25s ease; }
.app-nav { background: color-mix(in srgb, var(--app-bg) 85%, transparent); backdrop-filter: saturate(160%) blur(10px); border-color: var(--app-border) !important; }
.btn-primary { --bs-btn-bg: #3b82f6; --bs-btn-border-color: #3b82f6; --bs-btn-hover-bg: #2563eb; --bs-btn-hover-border-color: #2563eb; --bs-btn-active-bg: #1d4ed8; }
.btn { transition: transform .12s var(--ease), background-color .15s ease, border-color .15s ease, box-shadow .15s ease; }
.btn:active:not(:disabled) { transform: scale(.97); }

.card-app { background: var(--app-card); border: 1px solid var(--app-border); border-radius: 1rem; box-shadow: var(--app-shadow); }
.text-gradient { background: linear-gradient(90deg, #3b82f6, #8b5cf6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pre-line { white-space: pre-line; }
code { background: rgba(127, 127, 127, .14); color: inherit; padding: .1rem .35rem; border-radius: .35rem; font-size: .9em; }

/* theme toggle label */
[data-bs-theme=dark] .when-light, [data-bs-theme=light] .when-dark { display: none; }

/* page + element transitions */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-8px); } }
.page-enter { animation: fadeUp .45s var(--ease) both; }
.fade-in { animation: fadeUp .35s var(--ease) both; }
.stage.leaving { animation: fadeOut .18s ease forwards; }
.stage.entering { animation: fadeUp .32s var(--ease) both; }

/* start page */
.exam-choice { display: flex; gap: .85rem; align-items: flex-start; padding: .9rem 1rem; border: 1px solid var(--app-border); border-radius: .75rem; cursor: pointer; transition: border-color .15s, background-color .15s; }
.exam-choice:hover { border-color: rgba(59, 130, 246, .6); }
.exam-choice:has(input:checked) { border-color: #3b82f6; background: var(--app-sel-bg); }
.exam-choice .form-check-input { margin-top: .2rem; flex-shrink: 0; }
.feature-icon { font-size: 1.4rem; margin-bottom: .25rem; }

/* quiz */
.progress-thin { height: .45rem; background: rgba(127, 127, 127, .18); }
.progress-bar { background: linear-gradient(90deg, #3b82f6, #8b5cf6); transition: width .5s var(--ease); width: 0; }
.opt {
  display: flex; gap: .85rem; align-items: flex-start; width: 100%; text-align: left;
  padding: .9rem 1rem; border-radius: .75rem; border: 1px solid var(--app-border);
  background: transparent; color: var(--bs-body-color);
  transition: border-color .15s, background-color .2s, transform .12s var(--ease);
  animation: fadeUp .3s var(--ease) both;
}
.opt:nth-child(2) { animation-delay: .04s; } .opt:nth-child(3) { animation-delay: .08s; }
.opt:nth-child(4) { animation-delay: .12s; } .opt:nth-child(5) { animation-delay: .16s; } .opt:nth-child(6) { animation-delay: .2s; }
.opt:hover:not(:disabled) { border-color: rgba(59, 130, 246, .7); transform: translateY(-1px); }
.opt:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.opt.sel { border-color: #3b82f6; background: var(--app-sel-bg); }
.opt:disabled { cursor: default; opacity: 1; }
.opt.ok, .opt-review.ok { border-color: var(--app-ok); background: var(--app-ok-bg); }
.opt.no, .opt-review.no { border-color: var(--app-no); background: var(--app-no-bg); }
.opt.dim { opacity: .6; }
.opt-key {
  flex-shrink: 0; width: 1.9rem; height: 1.9rem; border-radius: .5rem; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; border: 1px solid var(--app-border); background: rgba(127, 127, 127, .08);
}
.opt.sel .opt-key { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.opt.ok .opt-key, .opt-review.ok .opt-key { background: var(--app-ok); border-color: var(--app-ok); color: #fff; }
.opt.no .opt-key, .opt-review.no .opt-key { background: var(--app-no); border-color: var(--app-no); color: #fff; }
.opt-text { padding-top: .15rem; }
.opt.multi .opt-key { border-radius: .35rem; }

.explain { padding: 1rem 1.1rem; border-radius: .75rem; border-left: 4px solid; animation: fadeUp .35s var(--ease) both; }
.explain.ok { border-color: var(--app-ok); background: var(--app-ok-bg); }
.explain.no { border-color: var(--app-no); background: var(--app-no-bg); }
.explain p:last-child { margin-bottom: 0; }

@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.025); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.opt.ok.just { animation: pop .35s var(--ease); }
.opt.no.just { animation: shake .3s ease; }
@keyframes bump { 50% { transform: scale(1.35); color: var(--app-ok); } }
.bump { display: inline-block; animation: bump .4s var(--ease); }

/* results */
.score-ring { --p: 0; width: 11rem; height: 11rem; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), rgba(127, 127, 127, .15) 0); transition: --p 1s var(--ease); }
.score-ring::before { content: ""; position: absolute; inset: .7rem; border-radius: 50%; background: var(--app-card); }
.score-ring > div { position: relative; }
.score-ring.pass { --ring: var(--app-ok); } .score-ring.fail { --ring: #f59e0b; }
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }
.review .accordion-item { background: var(--app-card); border-color: var(--app-border); }
.review .accordion-button { background: var(--app-card); }
.review .accordion-button:not(.collapsed) { background: var(--app-sel-bg); color: inherit; box-shadow: none; }
.review-dot { width: .7rem; height: .7rem; border-radius: 50%; flex-shrink: 0; background: rgba(127, 127, 127, .5); }
.review-dot.ok { background: var(--app-ok); } .review-dot.no { background: var(--app-no); }
.opt-review { display: flex; gap: .75rem; align-items: flex-start; padding: .65rem .8rem; border-radius: .6rem; border: 1px solid var(--app-border); }

/* leaderboard */
.leaderboard { --bs-table-bg: transparent; }
.leaderboard tr.me td { color: #3b82f6; font-weight: 700; }
.exam-tabs .nav-link { padding: .3rem .8rem; }

@media (max-width: 575.98px) {
  .display-5 { font-size: 2rem; }
  .opt { padding: .8rem .85rem; }
  .score-ring { width: 9.5rem; height: 9.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* accounts + progress */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6); color: #fff; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
#userMenu { text-decoration: none; display: inline-flex; align-items: center; gap: .45rem; }
.signed-in-as { display: flex; gap: .75rem; align-items: center; padding: .85rem 1rem; border-radius: .75rem; background: var(--app-sel-bg); border: 1px solid var(--app-border); }
.dropdown-menu { --bs-dropdown-bg: var(--app-card); --bs-dropdown-border-color: var(--app-border); }
.score-chart { width: 100%; height: auto; display: block; }
.score-chart .grid { stroke: rgba(127, 127, 127, .18); stroke-width: 1; }
.score-chart .axis { fill: var(--bs-secondary-color); font-size: 11px; }
.score-chart .pass { stroke: #f59e0b; stroke-width: 1.5; stroke-dasharray: 5 4; }
.score-chart .pass-label { fill: #f59e0b; }
.score-chart .line { fill: none; stroke: #3b82f6; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round;
  stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: draw 1.1s var(--ease) .1s forwards; }
.score-chart .area { fill: rgba(59, 130, 246, .12); }
.score-chart .dot { fill: var(--app-card); stroke: #3b82f6; stroke-width: 2.5; transition: r .15s; }
.score-chart .dot.ok { stroke: var(--app-ok); }
.score-chart a:hover .dot { r: 7; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.progress-bar.good { background: var(--app-ok); } .progress-bar.weak { background: #f59e0b; }
.weak-q { display: flex; gap: .75rem; align-items: flex-start; padding: .6rem .7rem; border: 1px solid var(--app-border); border-radius: .6rem; }
.weak-pct { flex-shrink: 0; min-width: 3rem; text-align: center; font-weight: 700; border-radius: .4rem; padding: .1rem .3rem; }
.weak-pct.no { background: var(--app-no-bg); color: var(--app-no); } .weak-pct.ok { background: var(--app-ok-bg); color: var(--app-ok); }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Admin ---------- */
.admin-tabs .nav-link { padding: .3rem .8rem; }
.admin-table { --bs-table-bg: transparent; }
.admin-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--bs-secondary-color); font-weight: 600; }
.admin-table td, .admin-table th { border-color: var(--app-border); }
.col-check { width: 2.25rem; }
.status-chips .btn { border-radius: 2rem; }
.admin-opt { display: flex; gap: .75rem; align-items: flex-start; padding: .7rem .9rem; border: 1px solid var(--app-border); border-radius: .75rem; }
.review-stem { font-size: 1.1rem; font-weight: 500; white-space: pre-line; }
.review-actions kbd, .review-nav kbd { font-size: .7rem; padding: .05rem .3rem; opacity: .8; }
.opt-label-input { width: 4rem; }
.history-list li + li { border-top: 1px dashed var(--app-border); padding-top: .5rem; }
.admin-meta dt { font-weight: 500; color: var(--bs-secondary-color); }
.admin-meta dd { margin-bottom: .35rem; word-break: break-word; }

/* ---------- References ---------- */
.learn-more { border-top: 1px dashed var(--app-border); padding-top: .6rem; }
.learn-more ul { padding-left: 1.1rem; }
.learn-more a { word-break: break-word; }
.ref-row .ref-url { min-width: 0; }
.ref-list li + li { margin-top: .35rem; }

/* ---------- Feedback ---------- */
.report-btn { text-decoration: none; }
.report-btn:hover { text-decoration: underline; }
.feedback-list li + li { border-top: 1px dashed var(--app-border); padding-top: .6rem; margin-top: .6rem; }
.feedback-comment { white-space: pre-line; word-break: break-word; }
.fb-note { min-width: 12rem; }

/* ---------- Quiz layout: stacked below lg; two columns (question 7/12 | feedback 5/12) at lg+ after answering ---------- */
.quiz-layout { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "side" "nav"; }
.quiz-main { grid-area: main; min-width: 0; }
.quiz-side { grid-area: side; min-width: 0; }
.quiz-layout.answered .quiz-side { margin-top: 1rem; }
.quiz-nav { grid-area: nav; margin-top: 1.5rem; }
.quiz-col { max-width: 72rem; }
@media (max-width: 991.98px) { .quiz-col { max-width: 50rem; } }
@media (min-width: 992px) {
  .quiz-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "main side" "nav side";
    column-gap: 0;
    transition: grid-template-columns .5s var(--ease), column-gap .5s var(--ease);
  }
  /* Before answering: the question is centred at a comfortable reading width. */
  .quiz-main, .quiz-nav { width: 100%; max-width: 46rem; justify-self: center; transition: max-width .5s var(--ease); }
  .quiz-nav { align-self: start; }
  .quiz-side {
    margin-top: 0 !important; align-self: start;
    position: sticky; top: 5rem; max-height: calc(100vh - 6rem); overflow-y: auto; overscroll-behavior: contain;
    opacity: 0; visibility: hidden; transform: translateX(2rem);
    transition: opacity .3s ease, transform .45s var(--ease), visibility 0s linear .45s;
  }
  .quiz-side .explain { animation: none; }
  .quiz-layout.answered { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); column-gap: 2.5rem; }
  .quiz-layout.answered .quiz-main, .quiz-layout.answered .quiz-nav { max-width: 100%; }
  .quiz-layout.answered .quiz-side {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity .4s ease .15s, transform .5s var(--ease) .1s, visibility 0s;
  }
}
@media (prefers-reduced-motion: reduce) {
  .quiz-layout, .quiz-main, .quiz-nav, .quiz-side, .quiz-layout.answered .quiz-side { transition: none !important; }
  .quiz-side { transform: none !important; }
}

/* ---- Ads (Google Ad Manager; only rendered when Ads:Enabled and the unit is configured) ---- */
.ad-slot { position: relative; display: block; width: 100%; margin: 1rem auto 0; padding-top: 1.1rem; text-align: center; contain: layout; }
.ad-slot::before { content: "Advertisement"; position: absolute; top: 0; left: 0; right: 0; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; color: var(--bs-secondary-color); }
.ad-gpt { display: flex; align-items: center; justify-content: center; margin: 0 auto; max-width: 100%; overflow: hidden; }
.ad-gpt:not(.ad-rendered) { background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(127,127,127,.06) 10px 20px); border: 1px dashed var(--bs-border-color); border-radius: .5rem; }
/* Space is reserved up front for the size each breakpoint serves (no layout shift when the ad arrives). */
.ad-panel { margin-top: 1rem; }
.ad-panel .ad-gpt { width: 320px; min-height: 100px; }
@media (min-width: 992px) { .ad-panel .ad-gpt { width: 300px; min-height: 250px; } }
.ad-slot.ad-empty { display: none; }
/* The quiz-panel unit appears only after answering, below the explanation; never in the question area. */
.quiz-layout:not(.answered) .ad-panel { display: none; }
.prose h2 { margin-top: 1.75rem; }
.prose li { margin-bottom: .35rem; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
