/* Reusable components. Every page uses these; pages do not restyle them. */

/* Buttons */
.btn {
  display: inline-block; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  padding: 0.7rem 1.25rem; border-radius: var(--radius-md); border: 2px solid transparent;
}
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-strong); color: var(--on-accent); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--accent); color: var(--text); }
.btn--small { padding: 0.4rem 0.9rem; font-size: var(--text-sm); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem;
  background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-md); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
.icon--moon { display: none; }
:root[data-theme="dark"] .icon--sun { display: none; }
:root[data-theme="dark"] .icon--moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon--sun { display: none; }
  :root:not([data-theme="light"]) .icon--moon { display: block; }
}

.lang-switch { color: var(--text); text-decoration: none; padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); }
.lang-switch:hover { background: var(--surface-2); color: var(--text); }

/* Small labels */
.badge { font-size: var(--text-sm); background: var(--surface-2); color: var(--text-muted); padding: 0 var(--space-2); border-radius: var(--radius-sm); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; margin: 0; padding: 0; }
.chip { font-size: var(--text-sm); padding: 0 var(--space-2); background: var(--surface-2); border-radius: var(--radius-sm); white-space: nowrap; }

.muted { color: var(--text-muted); }
.note { color: var(--text-muted); font-size: var(--text-sm); }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }

/* Exam lists */
.exam-group { margin-bottom: var(--space-6); }
.exam-group__title { border-bottom: 2px solid var(--text); padding-bottom: var(--space-2); font-size: var(--text-xl); }
.exam-list { list-style: none; margin: 0; padding: 0; }
.exam-row { display: grid; gap: var(--space-2) var(--space-5); padding-block: var(--space-4); border-bottom: 1px solid var(--line); }
@media (min-width: 44rem) { .exam-row { grid-template-columns: 1fr auto; align-items: center; } }
.exam-row__title { font-size: var(--text-lg); font-weight: 700; color: var(--text); }
.exam-row__title:hover { color: var(--accent-strong); }
.exam-row__summary { margin: var(--space-1) 0 0; color: var(--text-muted); max-width: 40rem; }

/* Breadcrumbs */
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); list-style: none; margin: 0 0 var(--space-4); padding: 0; font-size: var(--text-sm); color: var(--text-muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: var(--space-2); color: var(--line); }
.breadcrumbs a { color: var(--text-muted); }

/* Rules table */
.rules-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); margin-bottom: var(--space-4); }
.rules-table th, .rules-table td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); vertical-align: top; }
.rules-table tr:last-child th, .rules-table tr:last-child td { border-bottom: 0; }
.rules-table th { width: 38%; font-weight: 700; color: var(--text-muted); }

.mock-list a { font-weight: 700; }

/* FAQ */
.faq details { border-bottom: 1px solid var(--line); padding-block: var(--space-3); }
.faq summary { font-weight: 700; }
.faq p { margin: var(--space-2) 0 0; color: var(--text-muted); }

/* Feature list on the home page */
.feature-list { display: grid; gap: var(--space-6) var(--space-7); margin: 0; }
@media (min-width: 44rem) { .feature-list { grid-template-columns: 1fr 1fr; } }
.feature dt { font-weight: 700; font-size: var(--text-lg); margin-bottom: var(--space-1); }
.feature dd { margin: 0; color: var(--text-muted); max-width: 30rem; }

/* Sample result slip: typed text with mistakes marked the way exams count them */
.slip {
  margin: 0; padding: var(--space-5); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-md); box-shadow: 0 1px 0 var(--line), 6px 6px 0 var(--surface-2);
}
.slip__head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.slip__title { font-weight: 700; }
.slip__text {
  font-size: var(--text-lg); line-height: 2.6; margin: 0 0 var(--space-4);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(2.6em - 1px), var(--line) calc(2.6em - 1px), var(--line) 2.6em);
}
html[lang="hi"] .slip__text { line-height: 2.8; }

.tok { display: inline-block; vertical-align: top; margin-right: 0.3em; line-height: 1.5; }
.tok small { display: block; font-size: 0.62em; line-height: 1.3; padding: 0 0.4em; border-radius: var(--radius-sm); width: fit-content; }
.tok--full { color: var(--danger); }
.tok--full .tok__word { text-decoration: underline wavy var(--danger); text-underline-offset: 0.25em; }
.tok--full small { background: var(--danger-bg); }
.tok--half { color: var(--warn); }
.tok--half .tok__word { text-decoration: underline dotted var(--warn) 2px; text-underline-offset: 0.25em; }
.tok--half small { background: var(--warn-bg); }
.tok--gap .tok__word { text-decoration: line-through; }

.slip__stats { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); margin: 0 0 var(--space-4); padding-top: var(--space-4); border-top: 1px dashed var(--line); }
.slip__stats dt { font-size: var(--text-sm); color: var(--text-muted); }
.slip__stats dd { margin: 0; font-size: var(--text-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.slip__legend { display: flex; flex-wrap: wrap; gap: var(--space-4); margin: 0 0 var(--space-2); font-size: var(--text-sm); }
.legend { display: inline-flex; align-items: center; gap: var(--space-2); }
.legend::before { content: ""; width: 1.4rem; height: 0; border-top: 3px solid; }
.legend--full { color: var(--danger); } .legend--full::before { border-top-style: double; }
.legend--half { color: var(--warn); } .legend--half::before { border-top-style: dotted; }
.slip__note { margin: 0; color: var(--text-muted); font-size: var(--text-sm); }

.prose { max-width: 42rem; }
.error-page pre { white-space: pre-wrap; }

/* Forms and messages */
.auth { max-width: 30rem; padding-block: var(--space-7); }
.auth--wide { max-width: 40rem; }
.auth h1 { font-size: var(--text-2xl); }
.form { display: grid; gap: var(--space-4); margin-block: var(--space-5); }
.field label { display: block; font-weight: 700; margin-bottom: var(--space-1); }
.field input {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--line); border-radius: var(--radius-md); padding: 0.7rem 0.9rem;
}
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.field__hint { margin: var(--space-1) 0 0; color: var(--text-muted); font-size: var(--text-sm); }
.btn--block { display: block; width: 100%; text-align: center; }
.alert { margin: var(--space-4) 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border-left: 4px solid; }
.alert--error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.alert--success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.flash { padding-top: var(--space-4); }
.divider { display: flex; align-items: center; gap: var(--space-3); color: var(--text-muted); margin: var(--space-5) 0 var(--space-4); }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.provider-list { display: grid; gap: var(--space-3); margin-bottom: var(--space-5); }
.auth__links { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.inline-form { display: inline; margin: 0; }
.link-button { font: inherit; background: none; border: 0; padding: 0; color: var(--accent-strong); text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }
.user-link { color: var(--text); font-weight: 700; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-5); margin-bottom: var(--space-5); }
.panel h2 { font-size: var(--text-xl); }
.check { display: flex; gap: var(--space-3); align-items: flex-start; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: 0.3rem; accent-color: var(--accent); }
.check small { display: block; color: var(--text-muted); }

/* Developer playground (not used in production) */
.playground { display: grid; gap: var(--space-4); }
.playground__grid { display: grid; gap: var(--space-4); }
@media (min-width: 48rem) { .playground__grid { grid-template-columns: 1fr 1fr; } }
.field textarea, .select { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-md); padding: 0.6rem 0.8rem; }
.field textarea { resize: vertical; }
.field textarea#rules { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--text-sm); }

/* Mock test page */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.start { max-width: 46rem; }
.choice { border: 0; padding: 0; margin: 0 0 var(--space-5); display: grid; gap: var(--space-3); }
.choice legend { font-weight: 700; margin-bottom: var(--space-2); padding: 0; }
.start .field, .start .check { margin-bottom: var(--space-4); }
.search { width: 100%; max-width: 16rem; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-md); padding: 0.6rem 0.8rem; margin: var(--space-2) 0 var(--space-3); }
.passage-grid { display: flex; flex-wrap: wrap; gap: var(--space-2); min-height: 3rem; margin-bottom: var(--space-3); }
.passage-btn { font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); cursor: pointer; text-align: left; min-width: 5.5rem; }
.passage-btn:hover { border-color: var(--accent); }
.passage-btn[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.passage-btn strong { display: block; font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.passage-btn small { color: var(--text-muted); }
.pager { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
button:disabled, .btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Typing screen: nothing but the passage, the timer and the typing box */
.exam { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.exam__bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-2) var(--space-5); padding: var(--space-3) var(--space-5); background: var(--surface); border-bottom: 1px solid var(--line); }
.exam__bar p { margin: 0; }
.exam__title span { margin-left: var(--space-3); color: var(--text-muted); }
.exam__timer { font-size: var(--text-lg); }
.exam__timer span { color: var(--text-muted); font-size: var(--text-sm); }
.exam__timer output { font-family: var(--font-numbers); font-weight: 700; font-size: var(--text-2xl); font-variant-numeric: tabular-nums; margin-left: var(--space-2); }
.exam__work { flex: 1; display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) var(--space-5) var(--space-5); width: min(100%, 64rem); margin-inline: auto; }
.passage {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4) var(--space-5);
  font-size: 1.3rem; line-height: 1.9; max-height: 42vh; overflow-y: auto; white-space: pre-wrap;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.passage--print { font-size: var(--text-xl); font-weight: 700; }
.field textarea.typing {
  width: 100%; flex: 1; min-height: 11rem; font: inherit; font-size: 1.3rem; line-height: 1.8; color: var(--text); background: var(--surface);
  border: 2px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); resize: none;
}
.field textarea.typing:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.field textarea.typing:disabled { background: var(--surface-2); }
.dialog { width: min(100% - 2rem, 40rem); max-height: calc(100dvh - 2rem); overflow-y: auto; padding: var(--space-6); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.dialog::backdrop { background: rgb(5 12 20 / 0.72); }
.dialog h1 { font-size: var(--text-2xl); }
.dialog h2 { font-size: var(--text-lg); margin-top: var(--space-5); }
.dialog__sub { color: var(--text-muted); }
.dialog__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5); }
.dialog h1:focus-visible { outline: none; }
/* The confirm box and Start button stay in view however long the rules are. */
.dialog__footer { position: sticky; bottom: calc(var(--space-6) * -1); margin: 0 calc(var(--space-6) * -1) calc(var(--space-6) * -1); padding: var(--space-4) var(--space-6) var(--space-5); background: var(--surface); border-top: 1px solid var(--line); }
.dialog__footer .dialog__actions { margin-top: var(--space-4); }
.instructions { padding-left: 1.2rem; display: grid; gap: var(--space-2); margin: 0 0 var(--space-5); }
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: var(--space-4); background: rgb(5 12 20 / 0.82); }
.overlay[hidden] { display: none; }
.overlay__box { width: min(100%, 32rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-6); }

/* Result page */
.result__meta { color: var(--text-muted); margin-bottom: var(--space-2); }
.result__verdict { font-size: var(--text-hero); }
.result__verdict--pass { color: var(--success); }
.result__verdict--fail { color: var(--danger); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--space-4) var(--space-5); margin: var(--space-5) 0 var(--space-6); padding: var(--space-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.stat-grid dt { font-size: var(--text-sm); color: var(--text-muted); }
.stat-grid dd { margin: 0; font-family: var(--font-numbers); font-size: var(--text-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.checks { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: grid; gap: var(--space-2); }
.check-line { display: flex; gap: var(--space-3); align-items: baseline; padding: var(--space-2) var(--space-3); border-left: 4px solid var(--line); background: var(--surface); }
.check-line__status { flex: none; font-weight: 700; font-size: var(--text-sm); padding: 0 var(--space-2); border-radius: var(--radius-sm); }
.check-line--pass .check-line__status { background: var(--success-bg); color: var(--success); }
.check-line--fail .check-line__status { background: var(--danger-bg); color: var(--danger); }
.check-line--pass { border-color: var(--success); }
.check-line--fail { border-color: var(--danger); }
.compare { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); background-image: none; line-height: 2.8; font-size: var(--text-base); }
.tok--muted { color: var(--text-muted); }

/* Phones: leave room for the on-screen keyboard */
@media (max-width: 40rem) {
  .exam__bar { padding: var(--space-2) var(--space-4); }
  .exam__timer output { font-size: var(--text-xl); }
  .exam__work { padding: var(--space-3) var(--space-3) var(--space-4); gap: var(--space-3); }
  .passage { font-size: 1.1rem; line-height: 1.7; max-height: 30vh; max-height: 30dvh; padding: var(--space-3) var(--space-4); }
  .field textarea.typing { font-size: 1.1rem; min-height: 6rem; padding: var(--space-3) var(--space-4); }
}

/* Hindi typing */
.layout-details { margin: 0 0 var(--space-4); }
.layout-details summary { cursor: pointer; font-weight: 700; }
.layout-chart { overflow-x: auto; padding: var(--space-3) 0; }
.layout-row { display: flex; gap: 0.3rem; margin-bottom: 0.3rem; white-space: nowrap; }
.layout-key { position: relative; width: 2.6rem; height: 2.9rem; flex: none; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.layout-key__main { font-size: 1.2rem; line-height: 1; margin-top: 0.6rem; }
.layout-key__shift { position: absolute; top: 0.15rem; left: 0.3rem; font-size: 0.75rem; color: var(--text-muted); }
