/**
 * Context Clues - Responsive Styles
 * Mobile-first design with soft, rounded aesthetic
 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Prevent flash of unstyled content - simplified */
.container {
  opacity: 1;
}

:root {
  --text-color: #13171d; /* Dark gray text - 19.5:1 contrast ratio */
  --bg-color: #ffffff; /* White background */
  --border-color: #13171d; /* Dark gray borders */

  --pastel-blue: #cee5fc;

  --bg-incorrect: #f8d7da; /* Light red background for incorrect guesses */
  --bg-correct: #d4edda; /* Light green background for correct guesses */

  --button-bg: #13171d; /* Dark gray button background */
  --button-text: #ffffff; /* White text on buttons - 19.5:1 contrast ratio */
  --button-height: 48px;
  --button-width: 100%;
  --button-max-width: 350px;
  --button-text-size: 1rem;

  --error-red: #e53e3e;

  /* Disabled state - improved contrast */
  --disabled-gray: #6b7280; /* Darker gray for better contrast - 4.5:1 ratio */

  --text-primary: var(--text-color);
  --bg-primary: var(--bg-color);

  --font-family:
    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-title: 3.25rem;

  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);

  --transition: all 200ms ease;
}

body {
  font-family: var(--font-family);
  background: var(--pastel-blue) !important;
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-md);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Opacity animation already defined above */
}

.header {
  position: relative;
  text-align: center;
  padding: var(--space-sm);
  padding-top: 0;
  display: flex;
  justify-content: center;
}

.header-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: fit-content;
}

.title {
  font-size: var(--font-size-title);
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: var(--space-xs);
}

.subtitle {
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: var(--font-size-sm);
  color: var(--text-color);
  font-weight: 400;
  font-style: italic;
}

.input-container {
  position: relative;
  background: transparent;
  transition: var(--transition);
  width: 100%;
  max-width: 350px;
  margin-left: auto;
  margin-right: auto;
}

.guess-section {
  margin-top: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.results-section {
  margin-bottom: var(--space-md);
}

.results-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.results-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-color);
}

.guess-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.letter-boxes {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  width: 100%;
}

.letter-box {
  width: 100%;
  max-width: 60px;
  height: auto;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xl);
  font-weight: 600;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  background: var(--bg-color);
  color: var(--text-color);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  padding: 0;
  box-sizing: border-box;
}

.letter-box:focus {
  outline: none;
  border-color: var(--border-color);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.letter-box.active {
  border-color: var(--border-color);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
}

.letter-box.filled {
  background: var(--bg-color);
  border-color: var(--border-color);
}

.letter-box.disabled {
  background: var(--bg-color);
  border-color: var(--border-color);
  color: var(--text-color);
  opacity: 0.6;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--button-bg);
  font-family: inherit;
  font-size: var(--button-text-size);
  color: var(--button-text);
  height: var(--button-height);
  width: var(--button-width);
  max-width: var(--button-max-width);
  cursor: pointer;
  transition: var(--transition);
}

.button:disabled {
  background: var(--disabled-gray);
  border-color: var(--border-color);
  color: var(--text-color);
  opacity: 0.8;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

/* Share button copied state styling */
#share-button {
  transition: all 0.3s ease;
}

#share-button:disabled {
  background: var(--text-color);
  border-color: var(--text-color);
  color: var(--button-text);
  opacity: 1;
  transform: scale(0.98);
  pointer-events: none;
}

/* Definition button pointer highlight */
.pointer-highlight {
  position: absolute;
  left: 45%;
  font-size: 48px;
  color: var(--text-color);
  pointer-events: none;
  animation: bounceFloat 3s ease-in-out;
  margin-bottom: var(--space-sm);
  rotate: 135deg;
}

@keyframes bounceFloat {
  0%,
  100% {
    opacity: 0;
    transform: translateY(60px);
  }
  15%,
  85% {
    opacity: 1;
    transform: translateY(60px);
  }
  50% {
    opacity: 1;
    transform: translateY(30px);
  }
}

/* Game Content Layout - Two Columns */
.game-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.guesses-column,
.context-column {
  min-height: 200px;
}

.column-header {
  text-align: center;
  margin-bottom: var(--space-md);
}

.guesses-column h3,
.context-column h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-color);
  margin: 0 0 var(--space-xs) 0;
}

.remaining-counter {
  font-size: 12px;
  color: var(--text-color);
  font-weight: 400;
  display: block;
  margin-top: -12px;
}

.context-buttons-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.guesses-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-height: 2rem; /* Prevent layout shift */
}

.guess-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-lg);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-color);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-color);
  cursor: default;
  transition: var(--transition);
  height: 48px;
  width: 100%;
}

.guess-item.incorrect {
  background: var(--bg-incorrect);
}

.guess-item.correct {
  background: var(--bg-correct);
}

.guess-item.empty {
  background: var(--bg-color);
  opacity: 0.6;
}

.word-reveal {
  margin-top: var(--space-xs);
  margin-bottom: var(--space-md);
}

.word-result {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
  letter-spacing: 3px;
  padding: var(--space-md);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  display: inline-block;
  border: 2px solid var(--border-color);
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  max-width: 400px;
  width: 100%;
  text-align: left;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 200ms ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  position: relative;
  margin-bottom: var(--space-md);
}

.modal-header h2 {
  font-size: var(--font-size-2xl);
  color: var(--text-color);
  margin: 0;
}

.modal-header .close-button {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  font-size: var(--font-size-2xl);
  color: var(--text-color);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.modal-header .close-button:hover {
  background: var(--bg-color);
  color: var(--text-color);
}

.modal-body {
  margin-bottom: var(--space-lg);
}

.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 200ms ease;
}

.loading.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Skeleton loader for letter boxes */
.letter-boxes-skeleton {
  width: 100%;
  max-width: var(--button-max-width);
  height: 60px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
  margin: 0 auto;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--text-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 319px) {
  .title {
    font-size: 1.5rem;
  }
}

@media (max-width: 340px) {
  .game-content {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .guesses-column {
    order: 2;
  }

  .context-column {
    order: 1;
  }
}

@media (max-width: 400px) {
  .title {
    font-size: 2.5rem;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 700px;
  }
}

.error-display,
.success-display {
  position: fixed;
  top: 20px;
  right: 20px;
  max-width: 300px;
  z-index: 1001;
  animation: slideInRight 300ms ease;
}

.error-content,
.success-content {
  background: var(--bg-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.error-content {
  border-left: 4px solid var(--bg-incorrect);
}

.success-content {
  border-left: 4px solid var(--bg-correct);
}

.error-close,
.success-close {
  background: none;
  border: none;
  font-size: var(--font-size-lg);
  cursor: pointer;
  color: var(--text-color);
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.error-close:hover,
.success-close:hover {
  background: var(--bg-color);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.error-display.sliding-out,
.success-display.sliding-out {
  animation: slideOutRight 200ms ease forwards;
}

/* Wrong Guess Animation - Big X Flash */
.wrong-guess-flash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1002;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.1);
  animation: flashBackground 800ms ease;
}

.wrong-guess-x {
  font-size: 12rem;
  font-weight: 900;
  color: var(--error-red);
  text-shadow: 0 0 20px rgba(229, 62, 62, 0.6);
  animation: xFlashIn 800ms ease;
  font-family: 'Arial', sans-serif;
}

@keyframes flashBackground {
  0% {
    opacity: 0;
    background: rgba(0, 0, 0, 0);
  }
  20% {
    opacity: 1;
    background: rgba(0, 0, 0, 0.15);
  }
  80% {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
  }
  100% {
    opacity: 0;
    background: rgba(0, 0, 0, 0);
  }
}

@keyframes xFlashIn {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-15deg);
  }
  20% {
    opacity: 1;
    transform: scale(1.2) rotate(5deg);
  }
  40% {
    transform: scale(0.95) rotate(-2deg);
  }
  60% {
    transform: scale(1.05) rotate(1deg);
  }
  80% {
    transform: scale(0.98) rotate(0deg);
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1) rotate(0deg);
  }
}

/* Mobile adjustments for wrong guess flash */
@media (max-width: 480px) {
  .wrong-guess-x {
    font-size: 8rem;
  }
}

@media (max-width: 320px) {
  .wrong-guess-x {
    font-size: 6rem;
  }
}

/* Footer */
.footer {
  padding: 1rem 0;
  text-align: center;
  border-top: 1px solid var(--color-border);
}

.footer-text {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin: 0;
  opacity: 0.8;
}

@media (max-width: 480px) {
  .footer {
    margin-top: 1.5rem;
    padding: 0.75rem 0;
  }

  .footer-text {
    font-size: 0.8rem;
  }
}
