:root {
  --bg: #fbfbfc;
  --fg: #0b0b0c;
  --muted: #8c8c91;
  --border: #dcdcdf;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --fg: #f3f3f5;
    --muted: #7c7c80;
    --border: #262629;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "ss01", "cv11", "kern";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6vh 6vw;
  gap: 1rem;
  text-align: center;
}

/* Fixed vertical slots so the regen button stays anchored regardless
 * of quote/attribution line count. Each slot owns its own font-size
 * so em-based min-height scales correctly across viewports. */
.slot {
  display: grid;
  place-items: center;
  width: 100%;
}

.slot--quote {
  font-size: clamp(1.5rem, 4vw, 3.25rem);
  min-height: 5em; /* ~4.3 lines at line-height 1.15 */
}

.slot--attr {
  font-size: clamp(0.85rem, 1.1vw, 1rem);
  min-height: 3.2em; /* ~2 lines */
  margin-bottom: 0.75rem;
}

.quote {
  margin: 0;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
  max-width: 30ch;
  text-wrap: balance;
  will-change: opacity, transform;
}

.attribution {
  margin: 0;
  font-style: italic;
  color: var(--muted);
  letter-spacing: 0.01em;
  max-width: 40ch;
  text-wrap: balance;
  will-change: opacity, transform;
}

.regen {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 0.5rem 0.2rem;
  margin-top: 0.5rem;
  cursor: pointer;
  position: relative;
  transition:
    color 260ms ease,
    transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.regen::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 0;
  height: 1px;
  background: currentColor;
  transform: translateX(-50%);
  transition: width 320ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.regen:hover,
.regen:focus-visible {
  color: var(--fg);
  outline: none;
}

.regen:hover::after,
.regen:focus-visible::after { width: 85%; }

.regen:active { transform: scale(0.96); }

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.share {
  font: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: color 200ms ease;
}

.share:hover { color: var(--fg); }

.credit {
  color: inherit;
  text-decoration: none;
  transition: color 200ms ease;
}

.credit:hover { color: var(--fg); }

.toast {
  margin-left: 0.35rem;
  color: var(--fg);
  opacity: 0;
  transition: opacity 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.toast:not([hidden]) { opacity: 1; }

/* Hidden by default — the body.load animation below reveals them once
 * JS has finished painting the first random quote, so there's no flash
 * of the placeholder HTML between parse and script-run. */
.quote,
.attribution,
.regen {
  opacity: 0;
}

/* Initial load — gentle stagger */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

body.load .quote       { animation: fadeUp 560ms 0ms   both cubic-bezier(0.2, 0.7, 0.2, 1); }
body.load .attribution { animation: fadeUp 560ms 140ms both cubic-bezier(0.2, 0.7, 0.2, 1); }
body.load .regen       { animation: fadeUp 560ms 260ms both cubic-bezier(0.2, 0.7, 0.2, 1); }

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