/* static/style.css */

/* General body styling */
body {
    background-color: #0e1318;
    color: white;
    background-image:
        linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255,255,255,0.014) 1px, transparent 1px);
    background-size: 44px 44px, 44px 44px;
    background-position: center;
    background-attachment: fixed;
    margin: 0;
    height: 100%;
    z-index: 98;
    font-family: Arial, sans-serif;
}

/* Background image for non-logged-in users */
body.logged-out {
    background-image: none;
}

/* Full height */
html {
    height: 100%;
}

/* Top Navbar */
.navbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(12, 18, 24, 0.96);
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: 1px solid #26333f;
    z-index: 1001;
    margin: 0;
}

.navbar-top a {
    float: left;
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

.navbar-top a:hover {
    background-color: #172431;
}

.navbar-top .brand-link {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 4px 14px;
}

.navbar-top .brand-link:hover {
    background-color: #172431;
}

.brand-logo {
    display: block;
    width: 172px;
    height: auto;
}

.navbar-right {
    display: flex;
    align-items: center;
}

.nav-form {
    display: inline;
    margin: 0;
}

.nav-link-button {
    display: block;
    color: white;
    background: transparent;
    border: 0;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}

.nav-link-button:hover {
    background-color: #172431;
}

.email-verify-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 56px auto 0;
    max-width: 980px;
    padding: 10px 16px;
    background: #2a2114;
    border: 1px solid #6f5523;
    border-radius: 8px;
    color: #ffd27a;
    position: relative;
    z-index: 2;
}

.email-verify-banner form {
    margin: 0;
}

.email-verify-banner button {
    border: 0;
    border-radius: 8px;
    background: #00bfff;
    color: #0b0b0b;
    cursor: pointer;
    font-weight: 800;
    padding: 8px 10px;
}

.email-verify-banner button:hover {
    filter: brightness(1.06);
}

/* Bottom Navbar */
.navbar-bottom {
    background-color: #333;
    overflow: hidden;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    border-top: 2px solid #333;
    z-index: 1002;
    display: flex;
    justify-content: flex-start;
    padding: 5px;
}

/* Menu Button */
.menu-button {
    border: 2px solid white;
    background-color: #333;
    color: white;
    padding: 10px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 8px;
    height: 40px;
}

/* Hamburger Icon */
.menu-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-left: 10px;
}

.menu-icon .line {
    width: 35px;
    height: 3px;
    background-color: white;
    margin: 2px 0;
}

/* Sliding Menu */
.sliding-menu {
    position: fixed;
    bottom: 50px;
    left: 0;
    width: 100%;
    height: 93%;
    max-height: 0;
    overflow: hidden;
    box-sizing: border-box;
    background-color: #222;
    color: white;
    transition: max-height 0.3s ease-in-out;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.sliding-menu.active {
    max-height: 100%;
}

.sliding-menu ul {
    list-style: none;
    padding: 20px;
    width: 80%;
    text-align: center;
}

.sliding-menu ul li {
    border-bottom: 2px solid white;
    margin-bottom: 10px;
    position: relative;
}

.sliding-menu ul li a {
    display: block;
    padding: 10px;
    text-decoration: none;
    color: white;
}

.menu-form {
    margin: 0;
}

.menu-link-button {
    display: block;
    width: 100%;
    padding: 10px;
    border: 0;
    background: transparent;
    color: white;
    font: inherit;
    cursor: pointer;
}

.menu-link-button:hover,
.sliding-menu ul li a:hover {
    background-color: #333;
}

.sliding-menu ul li::after {
    content: '';
    display: block;
    height: 2px;
    background: linear-gradient(to right, transparent, white, transparent);
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
}

@media (max-width: 720px) {
    .navbar-top {
        min-height: 50px;
        overflow: visible;
    }

    .navbar-top > a {
        padding-right: 96px;
    }

    .brand-logo {
        width: 146px;
    }

    .navbar-right {
        display: none;
    }

    .navbar-bottom {
        top: 4px;
        right: 8px;
        bottom: auto;
        left: auto;
        width: auto;
        padding: 0;
        background: transparent;
        border: 0;
        border-radius: 0;
        z-index: 1003;
    }

    .menu-button {
        min-width: 82px;
        height: 42px;
        justify-content: center;
        padding: 8px 10px;
        background-color: #333;
        border-color: #777;
    }

    .menu-icon .line {
        width: 24px;
    }

    .sliding-menu {
        top: 50px;
        bottom: auto;
        height: calc(100dvh - 50px);
        justify-content: flex-start;
        padding-top: 0;
        padding-bottom: 0;
        pointer-events: none;
        z-index: 1000;
    }

    .sliding-menu.active {
        max-height: calc(100dvh - 50px);
        padding-top: 24px;
        padding-bottom: 24px;
        pointer-events: auto;
        overflow-y: auto;
    }
}

/* Login/Signup Section */
.choose-dashboard {
    max-width: 400px;
    margin: 100px auto;
    padding: 20px;
    background:
        linear-gradient(90deg, #24384a 0 8px, #19222b 8px 100%),
        #19222b;
    border: 1px solid #2d3b47;
    border-radius: 8px;
    box-shadow: 0 12px 0 -8px rgba(0,0,0,.65);
    color: white;
}

.choose-dashboard form {
    display: flex;
    flex-direction: column;
}

.choose-dashboard input,
.choose-dashboard button {
    margin-bottom: 12px;
    padding: 10px;
    font-size: 16px;
    border-radius: 4px;
    border: none;
}

.choose-dashboard input {
    background-color: #2a2a2a;
    color: white;
}

.choose-dashboard button {
    background-color: #00bfff;
    color: white;
    cursor: pointer;
}

.choose-dashboard button:hover {
    background-color: #009acd;
}

.separator {
    margin: 20px 0;
    height: 1px;
    background-color: #999;
}

/* Dashboard when logged in */
.logged-in-dashboard {
    padding: 80px 20px;
    color: white;
    text-align: center;
}

.dashboard-card {
    background:
        linear-gradient(90deg, rgba(71,192,255,.18) 0 8px, transparent 8px),
        linear-gradient(180deg, #1a222a, #141a20);
    border: 1px solid #273641;
    border-radius: 8px;
    padding: 20px;
    max-width: 600px;
    margin: auto;
    box-shadow: 0 12px 0 -8px rgba(0,0,0,.62);
}

/* Flash messages */
.flash {
    padding: 10px;
    margin: 10px auto;
    max-width: 500px;
    text-align: center;
    border-radius: 5px;
}

.flash-success {
    background-color: #4CAF50;
    color: white;
}

.flash-danger {
    background-color: #f44336;
    color: white;
}

.flash-warning {
    background-color: #6f5523;
    color: #fff3c4;
}

.auth-help-text {
    color: #cfcfcf;
    font-size: .9rem;
    line-height: 1.35;
    margin: 0 0 12px;
}


/* ======================================================================
   ADD-ON: Vertical scrolling Courses/Units cards for .stack-* (no overlap)
   ====================================================================== */

.main-content .stack-page { max-width: 1200px; margin: 0 auto; }

/* Welcome spacing */
.main-content .stack-header {
    max-width: 900px;
    margin: 64px auto 8px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}
.main-content .stack-header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: .2px;
}
.main-content .stack-header h1 span { color: #33cfff; }

.main-content .grade-history-panel {
    max-width: 1100px;
    margin: 12px auto;
    padding: 14px 16px;
    background: linear-gradient(180deg, #18212a, #121a21);
    border: 1px solid #263641;
    border-radius: 8px;
    box-shadow: 0 12px 0 -8px rgba(0,0,0,.55);
}
.main-content .grade-history-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.main-content .grade-history-head h2 {
    margin: 0 0 2px;
    font-size: 1.05rem;
}
.main-content .grade-history-head p {
    margin: 0;
    color: #bbb;
    font-size: .9rem;
}
.main-content .grade-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}
.main-content .grade-history-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    background:
        linear-gradient(90deg, #7357ff 0 5px, #202b35 5px 100%);
    border: 1px solid #334552;
    border-radius: 6px;
    padding: 10px 12px 10px 16px;
}
.main-content .grade-history-copy {
    min-width: 0;
}
.main-content .grade-history-copy strong {
    display: block;
    color: #fff;
    font-size: .95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.main-content .grade-history-copy span,
.main-content .grade-history-score span {
    display: block;
    color: #bbb;
    font-size: .82rem;
}
.main-content .grade-history-score {
    flex: 0 0 auto;
    text-align: right;
}
.main-content .grade-history-score strong {
    display: block;
    color: #8fdcff;
    font-size: 1.05rem;
}
.main-content .grade-history-empty {
    color: #bbb;
    background: #17212a;
    border: 1px dashed #3a4b58;
    border-radius: 6px;
    padding: 12px;
}
@media (max-width: 560px) {
    .main-content .grade-history-item {
        align-items: flex-start;
    }
    .main-content .grade-history-copy strong {
        white-space: normal;
    }
}

/* Section panel */
.main-content .stack-panel {
    max-width: 1100px;
    margin: 12px auto 90px;
    background: linear-gradient(180deg, #17212a, #11181f);
    border-radius: 8px;
    box-shadow: 0 12px 0 -8px rgba(0,0,0,.65);
    border: 1px solid #263641;
    display: flex;
    flex-direction: column;
    min-height: 260px;
    max-height: calc(100vh - 220px);
}

/* Sticky head */
.main-content .stack-panel .stack-head {
    position: sticky;
    top: 0;
    background: rgba(18, 26, 33, .96);
    padding: 12px 16px;
    border-bottom: 1px solid #2b3c48;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    z-index: 1;
}
.main-content .stack-panel .stack-head.split .row {
    display: flex;
    gap: 12px;
    align-items: baseline;
    flex-wrap: wrap;
}
.main-content .stack-panel .stack-head h2 { margin: 0; font-size: 1.12rem; }
.main-content .stack-panel .muted { color: #bbb; font-size: .92rem; }
.main-content .stack-panel .backlink {
    color: #8ecbff; text-decoration: none; font-weight: 700;
    border-bottom: 1px dashed rgba(127,221,255,.25);
}
.main-content .stack-panel .backlink:hover { border-bottom-color: #bfe2ff; }

/* Scrollable viewport */
.main-content .stack-panel .stack-viewport {
    overflow-y: auto;
    padding: 18px 16px 120px;
}

/* Centering logic (flex) */
.main-content .stack-panel .stack-list {
    list-style: none;
    margin: 0 auto;
    padding: 0;

    display: flex;
    flex-wrap: wrap;
    gap: 18px 14px;
    justify-content: center;
    align-items: flex-end;

    max-width: 1100px;
    width: 100%;
}

/* Card sizing & container */
.main-content .stack-panel .stack-card {
    position: relative;
    margin: 0;
    flex: 0 1 clamp(260px, 28vw, 340px);
}

/* Card body */
.main-content .stack-panel .stack-card-body {
    position: relative;
    z-index: 0;
    min-height: 142px;
    padding: 18px 16px 16px 32px;
    background:
        linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, transparent 1px 12px, rgba(0,0,0,.13) 12px 16px, transparent 16px),
        linear-gradient(180deg, #263441, #1d2832);
    border: 1px solid #344653;
    border-radius: 6px;
    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,.025),
        0 11px 0 -7px rgba(0,0,0,.72);
    transition: transform .12s ease, box-shadow .2s ease, border-color .12s ease;
}
.main-content .stack-panel .stack-card-body:hover {
    transform: translateY(-3px);
    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,.04),
        0 15px 0 -8px rgba(0,0,0,.78);
    border-color: #49606f;
}

/* Click overlay above the body */
.main-content .stack-panel .stack-card-hit {
    position: absolute;
    inset: 0;
    display: block;
    opacity: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-decoration: none;
    z-index: 2;
}

/* Accent strip */
.main-content .stack-panel .stack-strip {
    position: absolute;
    left: 10px; top: 10px; bottom: 10px;
    width: 8px; border-radius: 5px;
    background: linear-gradient(180deg, #47c0ff, #1b8bb8);
    box-shadow: 0 0 0 1px rgba(255,255,255,.06) inset;
}
.main-content .stack-panel .stack-card:nth-child(4n+2) .stack-strip {
    background: linear-gradient(180deg, #fbbf24, #b97812);
}
.main-content .stack-panel .stack-card:nth-child(4n+3) .stack-strip {
    background: linear-gradient(180deg, #9b8cff, #5f46c7);
}
.main-content .stack-panel .stack-card:nth-child(4n+4) .stack-strip {
    background: linear-gradient(180deg, #6ee7b7, #239a74);
}

/* Titles */
.main-content .stack-panel .stack-card-title {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: 700;
}
.main-content .stack-panel .stack-card-sub { color: #bbb; font-size: .9rem; }

/* Empty state */
.main-content .stack-panel .empty-box {
    text-align: center;
    padding: 32px 16px;
    color: #ddd;
    border: 1px dashed #334552;
    border-radius: 8px;
    background: rgba(18, 26, 33, .72);
}
.main-content .stack-panel .empty-box h3 {
    font-size: 1.1rem; font-weight: 700; margin-bottom: 6px;
}
.main-content .stack-panel .empty-box .muted {
    color: #bbb; margin-bottom: 12px;
}
.main-content .stack-panel .btn {
    display: inline-block; padding: 10px 14px; border-radius: 12px; text-decoration: none; font-weight: 800;
    background: #00bfff; color: #111; border: 1px solid #36d3ff;
}
.main-content .stack-panel .btn:hover { filter: brightness(1.05); }

/* Hide fades */
.main-content .stack-panel .stack-fade,
.main-content .stack-panel .stack-fade-top,
.main-content .stack-panel .stack-fade-bottom { display: none; }

/* ======================================================================
   MATH RENDERING ADDITIONS
   ====================================================================== */

.katex-display { 
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.katex, .katex .mord, .katex .text, .katex .mrel, .katex .mbin, .katex .mopen, .katex .mclose {
    color: inherit;
}

.katex-display > .katex {
    margin: 0.25rem 0;
}

.katex-error {
    color: #ff6b6b;
    background: transparent;
    border: none;
}

.math-inline { white-space: normal; }
.math-block  { margin: 8px 0; }

.quiz-wrap .katex-display { margin: 6px 0; }
.quiz-wrap .explain .katex-display { 
    background: #181818; 
    border-radius: 8px; 
    padding: 6px 8px; 
}

/* Ensures the .q-math title block spacing if used outside quiz.scss */
.q-math { display:block; margin-top:6px; }

/* === Quiz inline styles moved to global stylesheet (optional) === */
.quiz-wrap{max-width:920px;margin:90px auto 100px;padding:0 16px 140px}
@media (max-width: 520px){ .quiz-wrap{padding-bottom:170px} }
.quiz-header, .q-card { scroll-margin-top: 90px; }

.q-card{
  position:relative;
  background:
    linear-gradient(90deg, #2f4354 0 8px, transparent 8px),
    linear-gradient(180deg, #1a232c, #141b22);
  border:1px solid #2d3c48;
  border-radius:8px;
  padding:16px 16px 16px 22px;margin:14px 0;overflow:hidden;
  box-shadow:0 12px 0 -8px rgba(0,0,0,.6)
}
.q-title{
  font-weight:700;margin:0 0 12px;line-height:1.35;
  display:flex;flex-wrap:wrap;gap:8px;align-items:flex-start
}
.q-title-text{flex:1 1 100%; word-wrap:break-word; overflow-wrap:anywhere}
.chip{
  display:inline-block;font-size:.8rem;padding:2px 8px;border-radius:999px;
  background:#2a2a2a;border:1px solid #3a3a3a;color:#bbb
}

.explain{
  display:none;margin:8px 0 12px;padding:12px 14px;border-radius:8px;
  background:#202b34;border:1px solid #344653;color:#ddd
}
.explain-title{
  font-weight:800;margin:0 0 6px;color:#cfcfcf;display:flex;align-items:center;gap:10px;flex-wrap:wrap
}
.status-pill{
  font-weight:800;border-radius:999px;padding:2px 10px;
  background:#2a2a2a;border:1px solid #3a3a3a
}
.status-ok{color:#4CAF50;border-color:#2f8f46}
.status-bad{color:#ff4d4d;border-color:#8f2f2f}
.explain-body{white-space:pre-wrap}

.answers{display:grid;grid-template-columns:1fr;gap:10px;margin-bottom:10px}
.ans-card{
  display:flex;align-items:center;gap:10px;
  background:linear-gradient(90deg, rgba(251,191,36,.25) 0 4px, #202a33 4px 100%);
  border:1px solid #334552;
  border-radius:8px;padding:12px 12px 12px 14px;cursor:pointer;transition:transform .06s ease,border-color .1s ease,background .1s ease
}
.ans-card:hover{transform:translateY(-1px);border-color:#486171;background:linear-gradient(90deg, rgba(251,191,36,.32) 0 4px, #24313b 4px 100%)}
.ans-card input{transform:scale(1.2)}
.ans-label{flex:1}
.ans-correct{border-color:#2f8f46;background:linear-gradient(90deg, #43d978 0 5px, #17331f 5px 100%)}
.ans-wrong{border-color:#8f2f2f;background:linear-gradient(90deg, #ff6b6b 0 5px, #331717 5px 100%)}

/* Matching & Sequencing shared UI */
.chip-row{
  display:none; /* reveal after first selection */
  flex-wrap:wrap;gap:8px;background:#1d1d1d;border:1px solid #2f2f2f;
  border-radius:12px;padding:10px;min-height:46px;margin:8px 0;
}
.chip-badge{
  display:inline-flex;align-items:center;gap:8px;padding:8px 10px;border-radius:10px;
  background:#2b2b2b;border:1px solid #3e3e3e;cursor:pointer
}
.chip-badge .x{opacity:.8}
.chip-badge:hover .x{opacity:1}

.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
@media (max-width: 720px){ .grid-2{grid-template-columns:1fr} }

.pool{background:#1d1d1d;border:1px solid #2f2f2f;border-radius:12px;padding:12px}
.pool-grid{display:grid;grid-template-columns:1fr;gap:8px}

.btn-pill{
  width:100%;text-align:center;padding:10px;border-radius:10px;border:1px solid #383838;
  background:#252525;color:#eee;cursor:pointer;user-select:none;
  transition:box-shadow .12s ease, background .12s ease, border-color .12s ease, transform .06s ease
}
.btn-pill.active{
  background:#203745;border-color:#00bfff;
  box-shadow:0 0 0 2px rgba(0,191,255,0.35) inset, 0 2px 0 rgba(0,0,0,0.2);
  transform:translateY(-1px);
}

/* Sequencing chip order number */
.chip-badge .order{
  display:inline-flex;align-items:center;justify-content:center;
  width:18px;height:18px;border-radius:999px;background:#00bfff;color:#0b0b0b;
  font-size:.75rem;font-weight:800;
}

/* Done box */
.done{margin-top:18px;background:linear-gradient(180deg,#1a232c,#141b22);border:1px solid #2d3c48;border-radius:8px;padding:16px}
