/* ------------------------------------------------------------------
 * phrasaurus — styles
 * ----------------------------------------------------------------
 * Colour, type, and layout for a single-purpose single-page app.
 * No framework — the previous version pulled in Bootstrap, Popper,
 * and jQuery purely to use a handful of utility classes and a
 * spinner. We replaced those with ~30 lines of plain CSS.
 * ------------------------------------------------------------------ */

:root {
  --color-bg: #77dd77;
  --color-fg: #ffffff;
  --color-surface: #48bf31;
  --color-accent: #ff964f;
  --color-accent-hover: #ee9070;
  --color-accent-active: #e47a50;
  --radius: 5px;
  --transition-fast: 0.3s ease;
  --font-display: 'Dosis', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  background-color: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-display);
}

/* --- layout ----------------------------------------------------- */

.app {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.stack {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
}

.query {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  align-items: flex-start;
}

/* --- input ------------------------------------------------------ */

.phrase-input {
  flex: 1 1 auto;
  min-height: 75px;
  padding: 0.5rem 1rem;
  background-color: var(--color-surface);
  color: var(--color-fg);
  font-family: inherit;
  font-size: clamp(1.25rem, 4vw, 3rem);
  font-weight: bold;
  border: none;
  border-radius: var(--radius);
  resize: none;
  word-wrap: break-word;
}

.phrase-input:focus {
  outline: 2px solid var(--color-fg);
  outline-offset: 2px;
}

.phrase-input::placeholder {
  color: var(--color-fg);
  opacity: 1;
}

/* Applied after the input receives focus for the first time so the
 * placeholder hint fades rather than vanishing abruptly. */
.phrase-input.placeholder-dimmed::placeholder {
  opacity: 0.5;
}

/* --- button ----------------------------------------------------- */

.button {
  background-color: var(--color-accent);
  color: var(--color-fg);
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1.2em;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  min-width: 60px;
}

.button:hover:not(:disabled) {
  background-color: var(--color-accent-hover);
}

.button:active:not(:disabled) {
  background-color: var(--color-accent-active);
}

.button:disabled {
  cursor: progress;
  opacity: 0.8;
}

/* --- output ----------------------------------------------------- */

.output-phrase {
  display: inline-block;
  max-width: 100%;
  padding: 0.75rem 1rem;
  margin: 0;
  background-color: var(--color-surface);
  border-radius: var(--radius);
  font-size: clamp(1rem, 2vw, 2em);
  cursor: pointer;
  white-space: normal;
  overflow-wrap: break-word;
}

.output-phrase:focus-visible {
  outline: 2px solid var(--color-fg);
  outline-offset: 2px;
}

/* --- spinner (replaces Bootstrap's .spinner-grow) --------------- */

.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background-color: var(--color-fg);
  animation: spinner-pulse 0.9s ease-in-out infinite;
}

@keyframes spinner-pulse {
  0%,
  100% {
    transform: scale(0);
    opacity: 1;
  }
  50% {
    transform: scale(1);
    opacity: 0.3;
  }
}

/* --- utilities -------------------------------------------------- */

.hidden {
  display: none !important;
}

/* Accessible-only content — visually hidden but reachable by
 * screen readers. Standard recipe. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- small screens --------------------------------------------- */

@media (max-width: 576px) {
  .query {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }
}
