/* Student quiz result - clone of demo-staging /onlinequizv2/quiz-result.
   Values were measured from the live page at 1440px: 55px header, 70px rail, #E9ECEF document well,
   white details card with a #F8F9FA header. Phone layouts are improvements on the original:
   portrait = document + bottom sheet, landscape = document and details side by side. */

:root {
  --sq-font: "Poppins", sans-serif;
  --sq-pill-font: "Montserrat", sans-serif;
  --sq-yellow: #fec53c;
  --sq-pattern: url("https://elb-onlinequiz.smartjen.com/images/bg-smartjen.png");
  --sq-band-pattern: url("https://cdn-staging.heyhi.sg/images/bg-smartjen-color.png");
  --sq-blue: #0fb0f8;
  --sq-blue-dark: #0d93cc;
  --sq-link-blue: #146ef5;
  --sq-green: #16d8a7;
  --sq-orange: #ffb300;
  --sq-red: #ff1744;
  --sq-dot-correct: #00e676;
  --sq-dot-partial: #ffc107;
  --sq-bg: #f6f8fa;
  --sq-text: #12263f;
  --sq-muted: #616161;
  --sq-soft: #95aac9;
  --sq-border: #dee2e6;
  --sq-field-border: #e0e0e0;
  --sq-well: #e9ecef;
  --sq-sheet-peek: 120px; /* keep in sync with the sheet stops in student.js */
  --sq-sheet-half: 48dvh;
  --sq-sheet-full: 88dvh;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--sq-font);
  font-size: 15px;
  color: var(--sq-text);
  background: var(--sq-bg);
  overflow: hidden;
}

button,
select {
  font-family: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

.sq-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- header ---------- */
.sq-header {
  flex-shrink: 0;
  height: 55px;
  background-color: var(--sq-yellow);
  background-image: var(--sq-pattern);
  background-repeat: repeat;
}

.sq-header-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 1320px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

.sq-title {
  margin: 0;
  max-width: calc(100% - 220px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
}

.sq-exit {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  border-radius: 16px;
  background: var(--sq-blue);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.sq-exit:hover {
  background: var(--sq-blue-dark);
}

/* ---------- status band ---------- */
/* Measured on staging (.info-result): white, tiled colour doodle pattern, soft shadow, 84px tall. */
.sq-band {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 13px;
  height: 84px;
  padding: 0 clamp(16px, 5vw, 75px) 0 24px;
  background-color: #fff;
  background-image: var(--sq-band-pattern);
  background-repeat: repeat;
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.05);
}

.sq-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 7px 16px;
  border: 2px solid;
  border-radius: 16px;
  background: #fff;
  font-family: var(--sq-pill-font);
  font-size: 16px;
  font-weight: 700;
  line-height: 24px;
  white-space: nowrap;
}

.sq-pill--marked {
  color: var(--sq-green);
  border-color: var(--sq-green);
}

.sq-pill--score {
  gap: 5px;
  min-height: 44px;
  color: var(--sq-blue);
  border-color: var(--sq-blue);
}

/* ---------- main: rail | document | details ---------- */
.sq-main {
  flex: 1;
  min-height: 0;
  display: flex;
}

.sq-rail {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 70px;
  padding: 20px 0 20px 15px;
  overflow-y: auto;
  background: #fff;
  box-shadow: 0 12px 24px rgba(18, 38, 63, 0.03);
  scrollbar-width: none;
}

.sq-dot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 37px;
  height: 37px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-family: var(--sq-font);
  font-size: 16px;
  cursor: pointer;
}

.sq-dot.is-correct {
  background: var(--sq-dot-correct);
}

.sq-dot.is-partial {
  background: var(--sq-dot-partial);
}

.sq-dot.is-wrong,
.sq-dot.is-blank {
  background: var(--sq-red);
}

.sq-dot[aria-current="true"] {
  font-weight: 700;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--sq-blue);
}

.sq-split {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 16px;
  padding: 16px;
}

.sq-doc {
  position: relative;
  flex: 3 1 0;
  min-width: 0;
  padding: 16px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--sq-well);
}

.sq-detail {
  flex: 2 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--sq-border);
  border-radius: 8px;
  background: #fff;
}

.sq-detail-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--sq-border);
  background: #f8f9fa;
}

.sq-detail-title h2 {
  margin: 0;
  color: var(--sq-link-blue);
  font-size: 15px;
  font-weight: 600;
}

.sq-head-meta {
  display: none;
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--sq-muted);
}

.sq-q-nav {
  display: flex;
  gap: 8px;
}

.sq-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--sq-border);
  border-radius: 50%;
  background: #fff;
  color: var(--sq-blue);
  cursor: pointer;
}

.sq-nav-btn:hover:not(:disabled) {
  border-color: var(--sq-blue);
}

.sq-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.sq-detail-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  scrollbar-width: thin;
}

/* ---------- details content ---------- */
.sq-stats {
  position: relative;
  margin-bottom: 24px;
}

.sq-stats-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 7px 0;
  border: 0;
  background: none;
  color: var(--sq-muted);
  font-size: 14px;
  cursor: pointer;
}

.sq-stats-toggle:hover {
  color: var(--sq-blue);
}

.sq-stats-menu {
  position: absolute;
  z-index: 3;
  top: 100%;
  left: 0;
  min-width: 300px;
  max-width: 100%;
  padding: 8px 16px;
  border: 1px solid var(--sq-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(18, 38, 63, 0.12);
}

.sq-stats-menu h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.sq-stats-menu .sq-stats-sub {
  display: block;
  margin-bottom: 8px;
  color: var(--sq-soft);
  font-size: 13px;
}

.sq-stats-menu hr {
  margin: 0 0 8px;
  border: 0;
  border-top: 1px solid var(--sq-border);
}

.sq-stats-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.sq-stats-row strong {
  font-weight: 600;
}

.sq-qtext {
  line-height: 1.6;
}

.sq-qtext img {
  max-width: 100%;
  height: auto;
}

.sq-answer {
  margin: 16px 0 0;
  font-weight: 700;
  white-space: pre-line;
}

.sq-answer p {
  margin: 0;
  line-height: 30px;
}

.sq-answer.is-pending {
  color: var(--sq-orange);
}

.sq-answer.is-correct {
  color: var(--sq-green);
}

.sq-answer.is-wrong {
  color: var(--sq-red);
}

.sq-correct {
  margin: 16px 0 0;
  color: var(--sq-green);
  font-weight: 700;
  line-height: 30px;
}

.sq-empty {
  margin: 16px 0 0;
  color: var(--sq-soft);
  font-style: italic;
}

.sq-remarks {
  margin-top: 12px;
}

.sq-remarks-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.sq-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.sq-select {
  width: 210px;
  max-width: 100%;
  height: 41px;
  padding: 8px 28px 8px 12px;
  border: 1px solid var(--sq-field-border);
  border-radius: 12px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2312263f' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
}

.sq-remark-text {
  line-height: 30px;
  white-space: pre-line;
}

.sq-marks {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 0;
  font-weight: 700;
}

/* ---------- toast ---------- */
.sq-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--sq-text);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.sq-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* =========================================================
   Narrow desktop / tablet landscape
   ========================================================= */
@media (max-width: 1100px) and (min-width: 821px) {
  .sq-select {
    width: 170px;
  }
}

/* =========================================================
   Portrait phones: document on top, details in a bottom sheet
   ========================================================= */
@media (max-width: 820px) and (orientation: portrait) {
  .sq-header {
    height: 48px;
  }

  .sq-title {
    max-width: calc(100% - 100px);
    font-size: 16px;
  }

  .sq-exit {
    right: 12px;
    padding: 3px 12px;
    font-size: 14px;
  }

  .sq-band {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    height: auto;
    padding: 10px 16px;
  }

  .sq-pill,
  .sq-pill--score {
    min-height: 0;
    padding: 4px 12px;
    font-size: 12px;
    line-height: 1.5;
  }

  .sq-main {
    flex-direction: column;
  }

  /* The original hides the question list on phones; here it becomes a horizontal strip. */
  .sq-rail {
    flex-direction: row;
    width: auto;
    gap: 10px;
    padding: 10px 16px;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: none;
    border-bottom: 1px solid var(--sq-border);
  }

  .sq-dot {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  .sq-dot[aria-current="true"] {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--sq-blue);
  }

  .sq-split {
    padding: 0;
  }

  .sq-doc {
    padding: 8px;
    border-radius: 0;
  }

  /* the document is the only scroller; bottom padding keeps its end clear of the sheet */
  .sq-doc .qr-doc-scroll {
    padding-bottom: calc(var(--sq-sheet-peek) + 24px + env(safe-area-inset-bottom));
  }

  .sq-doc .qr-zoom {
    display: flex;
    bottom: calc(var(--sq-sheet-peek) + 14px + env(safe-area-inset-bottom));
  }

  .sq-detail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    height: calc(var(--sq-sheet-peek) + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 24px rgba(18, 38, 63, 0.16);
    transition: height 0.22s ease;
  }

  .sq-detail[data-sheet="half"] {
    height: var(--sq-sheet-half);
  }

  .sq-detail[data-sheet="full"] {
    height: var(--sq-sheet-full);
  }

  .sq-detail.is-dragging {
    transition: none;
  }

  .sq-detail .qr-sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 100%;
    height: 26px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
  }

  /* peek shows the question number, chevrons and a one-line result */
  .sq-detail-head {
    padding: 0 16px 12px;
    border-bottom: 0;
    background: #fff;
  }

  .sq-head-meta {
    display: block;
  }

  .sq-detail-body {
    overflow: hidden;
    padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--sq-border);
  }

  .sq-detail[data-sheet="half"] .sq-detail-body,
  .sq-detail[data-sheet="full"] .sq-detail-body {
    overflow-y: auto;
  }

  .sq-select {
    flex: 1 1 140px;
    width: auto;
  }
}

/* =========================================================
   Landscape phones: document and details side by side
   ========================================================= */
@media (max-height: 500px) and (orientation: landscape) {
  .sq-header {
    height: 36px;
  }

  .sq-title {
    font-size: 14px;
  }

  .sq-exit {
    right: 12px;
    padding: 1px 12px;
    font-size: 13px;
  }

  .sq-band {
    height: auto;
    padding: 4px calc(12px + env(safe-area-inset-right)) 4px 12px;
  }

  .sq-pill,
  .sq-pill--score {
    min-height: 0;
    padding: 2px 12px;
    font-size: 11.5px;
    line-height: 1.5;
  }

  .sq-rail {
    width: 52px;
    gap: 8px;
    padding: 8px 0 8px 8px;
  }

  .sq-dot {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .sq-dot[aria-current="true"] {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--sq-blue);
  }

  .sq-split {
    gap: 10px;
    padding: 8px calc(10px + env(safe-area-inset-right)) 8px 10px;
  }

  .sq-doc {
    padding: 8px;
  }

  .sq-doc .qr-zoom {
    display: flex;
  }

  .sq-detail {
    flex: 0 0 clamp(240px, 38vw, 340px);
  }

  .sq-detail-head {
    padding: 8px 12px;
  }

  .sq-detail-body {
    padding: 10px 12px 20px;
    font-size: 14px;
  }

  .sq-stats {
    margin-bottom: 12px;
  }

  .sq-select {
    flex: 1 1 120px;
    width: auto;
    height: 36px;
    font-size: 13px;
  }
}
