/* ==========================================================================
   Internet IQ Test — Stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design Tokens
   -------------------------------------------------------------------------- */
:root {
  --bg: #050505;
  --surface: rgba(255,255,255,0.03);
  --border: rgba(255,255,255,0.08);
  --text: #f0f0f0;
  --muted: rgba(255,255,255,0.38);
  --accent: #fff;
  --danger: #e55;
  --warning: #f5a623;
  --success: #4a9;
  --font-mono: 'JetBrains Mono','Fira Code','Courier New',monospace;
  --font-sans: -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

a {
  color: inherit;
}

/* --------------------------------------------------------------------------
   Root container
   -------------------------------------------------------------------------- */
#iq-root {
  max-width: 620px;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 1.25rem;
}

/* --------------------------------------------------------------------------
   Utility
   -------------------------------------------------------------------------- */
.mono {
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Screens
   -------------------------------------------------------------------------- */
.iq-screen {
  display: flex;
  flex-direction: column;
  animation: screenIn 0.4s ease both;
}

/* --------------------------------------------------------------------------
   Intro Screen
   -------------------------------------------------------------------------- */
.iq-title {
  font-size: clamp(5rem, 20vw, 9rem);
  font-weight: 900;
  font-family: var(--font-mono);
  letter-spacing: -0.04em;
  line-height: 1;
  color: #fff;
  margin-bottom: 0.5rem;
}

.iq-subtitle {
  font-size: clamp(1rem, 3vw, 1.2rem);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.25rem;
  letter-spacing: -0.01em;
}

.iq-desc {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.55);
  line-height: 1.7;
  max-width: 44ch;
  margin-bottom: 1.25rem;
}

.iq-warning {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  letter-spacing: 0.02em;
}

.iq-taken {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.iq-begin-btn {
  align-self: flex-start;
  margin-bottom: 1.25rem;
}

.iq-fine-print {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.55;
  max-width: 40ch;
}

/* --------------------------------------------------------------------------
   Quiz Screen — Header
   -------------------------------------------------------------------------- */
.iq-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.iq-progress-text {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.iq-score-live {
  font-size: 0.7rem;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Timer bar
   -------------------------------------------------------------------------- */
.iq-timer-wrap {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 1.75rem;
}

.iq-timer-bar {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  transition: width linear;
  width: 100%;
}

.iq-timer-bar.warning {
  background: var(--warning);
}

.iq-timer-bar.danger {
  background: var(--danger);
}

/* --------------------------------------------------------------------------
   Quiz Body
   -------------------------------------------------------------------------- */
.iq-body {
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   Category tag
   -------------------------------------------------------------------------- */
.iq-category {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.5rem;
}

/* --------------------------------------------------------------------------
   Question
   -------------------------------------------------------------------------- */
.iq-question {
  font-size: clamp(1.15rem, 3.5vw, 1.4rem);
  font-weight: 500;
  line-height: 1.55;
  margin: 1.25rem 0;
  white-space: pre-wrap;
}

/* --------------------------------------------------------------------------
   Options
   -------------------------------------------------------------------------- */
.iq-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.iq-option {
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
  text-align: left;
  font-family: var(--font-sans);
  animation: optionIn 0.3s ease both;
}

.iq-option:nth-child(1) { animation-delay: 0.05s; }
.iq-option:nth-child(2) { animation-delay: 0.1s; }
.iq-option:nth-child(3) { animation-delay: 0.15s; }
.iq-option:nth-child(4) { animation-delay: 0.2s; }

.iq-option:hover {
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
}

.iq-option.correct {
  border-color: var(--success);
  background: rgba(74,153,100,0.12);
  color: var(--success);
}

.iq-option.wrong {
  border-color: var(--danger);
  background: rgba(229,85,85,0.1);
  color: rgba(255,255,255,0.5);
}

.iq-option.disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* --------------------------------------------------------------------------
   Calc Screen
   -------------------------------------------------------------------------- */
.calc-spinner {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1.5rem;
}

.calc-label {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 1.25rem;
  letter-spacing: 0.02em;
}

.calc-track {
  width: 100%;
  height: 2px;
  background: rgba(255,255,255,0.07);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.calc-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  width: 0%;
  transition: width 0.45s ease;
}

.calc-sub {
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

/* --------------------------------------------------------------------------
   Result Screen
   -------------------------------------------------------------------------- */
.iq-result-label {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 0.35rem;
}

.iq-score-reveal {
  font-size: clamp(5rem, 18vw, 8rem);
  font-weight: 900;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
  line-height: 1;
  color: #fff;
  animation: revealScore 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
}

.iq-percentile {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.iq-divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

.iq-category-label {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 0.4rem;
}

.iq-result-desc {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.7;
  max-width: 50ch;
}

/* --------------------------------------------------------------------------
   Breakdown grid
   -------------------------------------------------------------------------- */
.iq-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.breakdown-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.75rem 1rem;
}

.breakdown-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: block;
}

.breakdown-value {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0.25rem;
  display: block;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Retake notice
   -------------------------------------------------------------------------- */
.iq-retake-notice {
  font-size: 0.7rem;
  color: var(--muted);
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 1rem;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.iq-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.iq-btn-primary {
  background: #fff;
  color: #050505;
  border: none;
}

.iq-btn-primary:hover {
  background: #ddd;
}

.iq-btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
}

.iq-btn-outline:hover {
  border-color: rgba(255,255,255,0.45);
}

.iq-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

/* --------------------------------------------------------------------------
   Back link
   -------------------------------------------------------------------------- */
.iq-back {
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
  margin-top: 1.5rem;
  display: inline-block;
  transition: color 0.15s;
}

.iq-back:hover {
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes revealScore {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes screenIn {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes optionIn {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   Mobile
   -------------------------------------------------------------------------- */
@media (max-width: 520px) {
  .iq-options {
    grid-template-columns: 1fr;
  }

  .iq-actions {
    flex-direction: column;
  }

  .iq-actions .iq-btn {
    width: 100%;
    text-align: center;
  }

  .iq-breakdown {
    grid-template-columns: 1fr 1fr;
  }
}
