/* ============================================================
   mathrun — shared stylesheet
   Used by: index.html, record.html, test.html
   ============================================================ */

/* ---------- Reset / global ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans Hebrew", "Noto Sans", sans-serif;
  background: #0f1115;
  color: #e8e8e8;
  min-height: 100%;
  overflow-x: hidden;
}

:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #2a2e38;
  --text: #e8e8e8;
  --muted: #8a8f9c;
  --blue: #5ab0ff;
  --red: #ff5565;
  --green: #4ade80;
  --border: #2a2e38;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

h1, h2, h3, h4, h5, h6, p {
  margin: 0;
}

/* ---------- Utility ---------- */
.container {
  max-width: 720px;
  margin-inline: auto;
  padding: 16px;
}

.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

.hidden {
  display: none !important;
}

.stack {
  --gap: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.muted {
  color: var(--muted);
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #151821;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header h1 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.app-header a {
  color: var(--muted);
  font-size: 13px;
}

.app-header a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 80ms ease, background 150ms ease, opacity 150ms ease;
  text-align: center;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover {
  background: #6fbaff;
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover {
  background: #ff6a78;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--surface);
}

.btn-giant {
  min-height: 72px;
  font-size: 22px;
  width: 100%;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* ---------- Landing page cards ---------- */
.landing-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
  cursor: pointer;
}

.landing-card:hover {
  transform: translateY(-2px);
  background: #1e222b;
  border-color: #343945;
}

.landing-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
}

.landing-card p {
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Record page ---------- */
.record-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}

.record-tabs button {
  flex: 1;
  padding: 10px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  border: 0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.record-tabs button.active {
  background: var(--blue);
  color: #fff;
}

.record-card {
  padding: 24px;
  background: var(--surface);
  border-radius: 14px;
  margin-bottom: 16px;
  text-align: center;
}

.record-label {
  font-size: 56px;
  font-weight: 700;
  margin: 8px 0;
  min-height: 80px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.record-sublabel {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}

.ptt-btn {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  border: 0;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  box-shadow: 0 4px 16px rgba(255, 85, 101, 0.3);
  transition: transform 100ms ease;
}

.ptt-btn:active {
  transform: scale(0.96);
}

.ptt-btn.recording {
  animation: pulse 1.4s ease-out infinite;
}

.ptt-status {
  font-size: 14px;
  margin-top: 12px;
  color: var(--muted);
  min-height: 20px;
}

.chip-strip {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chip-strip::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  scroll-snap-align: start;
  border: 0;
  font-weight: 500;
  transition: background 150ms ease, color 150ms ease, outline-color 150ms ease;
}

.chip.uploaded {
  background: #1f3a2a;
  color: var(--green);
}

.chip.current {
  outline: 2px solid var(--blue);
  outline-offset: 0;
}

.chip.failed {
  background: #3a1f23;
  color: var(--red);
}

.nav-btns {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

.counter {
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Test page ---------- */
.settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.settings label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.settings input[type="number"] {
  width: 100%;
  padding: 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}

.settings .op-checks {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
}

.settings .op-checks label {
  display: inline-flex;
  flex-direction: row;
  gap: 6px;
  align-items: center;
  cursor: pointer;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 0;
}

.now-playing {
  min-height: 140px;
  padding: 24px;
  background: var(--surface);
  border-radius: 14px;
  text-align: center;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.now-playing .question {
  font-size: 40px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.now-playing .state {
  font-size: 16px;
  color: var(--muted);
  margin-top: 12px;
}

.test-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

.alert-error {
  background: #3a1f23;
  color: #ff9da8;
}

.alert-info {
  background: #1a2a3a;
  color: #9dc8ff;
}

/* ---------- Accessibility ---------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ---------- Animations ---------- */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 85, 101, 0.6),
                0 4px 16px rgba(255, 85, 101, 0.3);
  }
  70% {
    box-shadow: 0 0 0 20px rgba(255, 85, 101, 0),
                0 4px 16px rgba(255, 85, 101, 0.3);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 85, 101, 0),
                0 4px 16px rgba(255, 85, 101, 0.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .ptt-btn.recording {
    animation: none;
  }
}
