@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=block");

:root {
  --theme-background: #232936;
  --theme-foreground: #e6e9f0;
  --theme-highlight: #9db2d8;
  --theme-font: "Plus Jakarta Sans";

  --ui-font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Soft, theme-derived surfaces (adapt to any light/dark palette). */
  --tint-1: color-mix(in srgb, var(--theme-highlight) 9%, transparent);
  --tint-2: color-mix(in srgb, var(--theme-highlight) 16%, transparent);
  --tint-3: color-mix(in srgb, var(--theme-highlight) 26%, transparent);
  --line: color-mix(in srgb, var(--theme-foreground) 14%, transparent);
  --muted: color-mix(in srgb, var(--theme-foreground) 55%, transparent);
}

* {
  box-sizing: border-box;
}

html.font-resizing {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-width: 320px;
  background-color: var(--theme-background);
  background-image: linear-gradient(
    180deg,
    color-mix(in srgb, var(--theme-highlight) 4%, transparent),
    transparent 40%
  );
  color: var(--theme-foreground);
  font-family: var(--ui-font);
  font-size: 1.1rem;
  -webkit-font-smoothing: antialiased;
}

body.themed {
  transition: background-color 0.5s ease, color 0.5s ease;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ------------------------------------------------------------- header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
}

.brand {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.theme-button {
  width: auto;
  height: auto;
  flex-shrink: 0;
  min-width: max-content;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  gap: 0.45rem;
  white-space: nowrap;
}
.theme-button svg,
.theme-name { flex-shrink: 0; }

.theme-name {
  font-size: 0.85rem;
  font-weight: 600;
}

/* --------------------------------------------------------------- main */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding: 1.5rem 0;
  text-align: center;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.counter {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

h2#question-display {
  margin: 0;
  max-width: 20ch;
  padding: 0.25rem;
  font-family: var(--theme-font), -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", sans-serif;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
  font-display: swap;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(0.6rem); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-down {
  from { opacity: 0; transform: translateY(-0.6rem); }
  to { opacity: 1; transform: translateY(0); }
}
h2#question-display.slide-next { animation: fade-up 0.32s var(--ease); }
h2#question-display.slide-prev { animation: fade-down 0.32s var(--ease); }

html.font-resizing h2#question-display {
  position: absolute;
  visibility: hidden;
}

.credit {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.credit a {
  color: var(--theme-foreground);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.credit a:hover {
  color: var(--theme-highlight);
  border-color: var(--theme-highlight);
}

/* ----------------------------------------- ghost buttons (icons/arrows) */
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.85rem;
  height: 2.85rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--theme-foreground);
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease,
    color 0.18s ease, transform 0.1s ease;
}
.ghost-button svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: currentColor;
  transition: transform 0.18s var(--ease);
}
.ghost-button:hover {
  background: var(--tint-1);
  border-color: var(--tint-3);
  color: var(--theme-highlight);
}
.ghost-button:hover svg { transform: scale(1.08); }
.ghost-button:active { transform: translateY(1px); }

.question-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.25rem;
}

#favorite-button.is-active {
  background: var(--tint-2);
  border-color: var(--tint-3);
  color: var(--theme-highlight);
}
#favorite-button.is-active svg { animation: pop 0.3s var(--ease); }
@keyframes pop {
  0% { transform: scale(0.7); }
  55% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Emoji confetti burst (spawned + removed by JS). */
.confetti {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  transform: translate(-50%, -50%);
  animation: confetti-fly 0.9s var(--ease) forwards;
  will-change: transform, opacity;
}
@keyframes confetti-fly {
  0% { transform: translate(-50%, -50%) scale(0.4) rotate(0deg); opacity: 0; }
  15% { opacity: 1; }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)))
      scale(1) rotate(var(--rot));
    opacity: 0;
  }
}

.copy-feedback {
  margin: 0;
  min-height: 1.2rem;
  font-size: 0.85rem;
  color: var(--theme-highlight);
  opacity: 0;
  transform: translateY(-0.2rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.copy-feedback.is-visible { opacity: 1; transform: translateY(0); }

/* ------------------------------------------------------- navigation */
.navbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

button#reload-button {
  border: 1px solid var(--tint-3);
  border-radius: 999px;
  background: var(--tint-2);
  color: var(--theme-foreground);
  cursor: pointer;
  font-family: var(--ui-font);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.85rem 1.75rem;
  transition: background-color 0.18s ease, transform 0.1s ease;
}
button#reload-button:hover { background: var(--tint-3); }
button#reload-button:active { transform: translateY(1px); }

.nav-arrow svg { width: 1.45rem; height: 1.45rem; }

.swipe-hint {
  display: none;
  margin: 0 0 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}
.swipe-hint::before { content: "← "; }
.swipe-hint::after { content: " →"; }

/* ----------------------------------------------------------- footer */
.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding: 1.25rem 0 1.75rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

select,
#search-input {
  appearance: none;
  background: var(--tint-1);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  color: var(--theme-foreground);
  font-family: var(--ui-font);
  font-size: 0.9rem;
  padding: 0.55rem 0.8rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
select {
  cursor: pointer;
  max-width: 13rem;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 1rem center, right 0.75rem center;
  background-size: 0.34rem 0.34rem, 0.34rem 0.34rem;
  background-repeat: no-repeat;
}
select option,
select optgroup {
  background: var(--theme-background);
  color: var(--theme-foreground);
}
#search-input { min-width: 13rem; }
#search-input::placeholder { color: var(--muted); }

select:hover,
#search-input:hover { border-color: var(--tint-3); }
select:focus-visible,
#search-input:focus-visible {
  outline: 2px solid var(--theme-highlight);
  outline-offset: 1px;
  border-color: var(--theme-highlight);
}

.config-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.link-button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--ui-font);
  font-size: inherit;
  padding: 0.2rem 0.1rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.link-button:hover { color: var(--theme-highlight); }
.config-feedback { color: var(--theme-highlight); }

a {
  color: var(--theme-highlight);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

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

/* ------------------------------------------------------ touch / sizes */
@media (hover: none) and (pointer: coarse) {
  .swipe-hint { display: block; opacity: 0.6; }
  .nav-arrow { display: none; }
  button#reload-button { flex: 1; max-width: 22rem; }
}

@media (min-width: 640px) {
  h2#question-display { font-size: 2.9rem; max-width: 16ch; }
  body { font-size: 1.15rem; }
}

@media (min-width: 1024px) {
  h2#question-display { font-size: 3.6rem; max-width: 15ch; }
}

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