/* ============================================
   INFINITE CANVAS - STYLES
   Minimal, clean, intentional design
   ============================================ */

/* CSS Variables */
:root {
  /* Colors - Pure and minimal (Light Mode) */
  --bg: #ffffff;
  --bg-secondary: #fafafa;
  --text: #262626;
  --text-secondary: #737373;
  --border: #e5e5e5;
  --canvas-bg: #ffffff;
  --post-bg: #fafafa;
  --post-border: #e5e5e5;
  --post-text: #262626;

  --white: #ffffff;
  --black: #0a0a0a;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-300: #d4d4d4;
  --gray-400: #a3a3a3;
  --gray-500: #737373;
  --gray-600: #525252;
  --gray-700: #404040;
  --gray-800: #262626;
  --gray-900: #171717;

  /* Accent - Subtle blue for interactions */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #dbeafe;

  /* Semantic */
  --error: #dc2626;
  --success: #16a34a;
  --warning: #ca8a04;

  /* Typography */
  --font-mono: 'IBM Plex Mono', 'SF Mono', 'Consolas', monospace;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 15px;
  --font-size-lg: 18px;
  --font-size-xl: 24px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --blur-amount: 4px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* Dark Mode */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-secondary: #171717;
  --text: #f5f5f5;
  --text-secondary: #a3a3a3;
  --border: #404040;
  --canvas-bg: #0a0a0a;
  --post-bg: #171717;
  --post-border: #404040;
  --post-text: #f5f5f5;

  --white: #0a0a0a;
  --black: #ffffff;
  --gray-50: #171717;
  --gray-100: #262626;
  --gray-200: #404040;
  --gray-300: #525252;
  --gray-400: #737373;
  --gray-500: #a3a3a3;
  --gray-600: #d4d4d4;
  --gray-700: #e5e5e5;
  --gray-800: #f5f5f5;
  --gray-900: #fafafa;

  --accent-light: #1e3a5f;
}

/* Theme toggle button */
#theme-toggle {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 18px;
  transition: all var(--transition-fast);
}

#theme-toggle:hover {
  background: var(--gray-200);
}

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

/* Body & Canvas */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  color: var(--gray-800);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#canvas:active {
  cursor: grabbing;
}

/* ============================================
   UI OVERLAY
   ============================================ */

#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 100;
}

#ui-overlay > * {
  pointer-events: auto;
}

/* Coordinates display */
#coords {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--gray-400);
  letter-spacing: 0.5px;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

#coords:hover {
  opacity: 1;
}

/* Hint message */
#hint {
  position: absolute;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  background: var(--white);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  opacity: 1;
  transition: opacity var(--transition-slow);
  white-space: nowrap;
}

#hint.faded {
  opacity: 0;
  pointer-events: none;
}

/* Post button */
#post-btn {
  position: absolute;
  bottom: var(--space-6);
  right: var(--space-6);
}

/* Zoom controls */
#zoom-controls {
  position: absolute;
  bottom: var(--space-6);
  left: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--white);
  padding: var(--space-1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.zoom-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--gray-700);
  font-size: var(--font-size-lg);
  font-family: var(--font-mono);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.zoom-btn:hover {
  background: var(--gray-100);
}

.zoom-btn:active {
  background: var(--gray-200);
}

.zoom-btn.small {
  font-size: var(--font-size-xs);
  font-weight: 500;
}

/* ============================================
   BUTTONS
   ============================================ */

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
  background: var(--gray-800);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.primary-btn:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
  transform: none;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--white);
  color: var(--gray-800);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.secondary-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.secondary-btn:active {
  background: var(--gray-100);
}

/* ============================================
   MODALS
   ============================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  animation: modalIn var(--transition-base) ease-out;
}

.modal-content.small {
  max-width: 360px;
  text-align: center;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.modal-header h2 {
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--gray-900);
}

.close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--gray-500);
  font-size: 24px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.close-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

/* Status box */
.status-box {
  padding: var(--space-3) var(--space-4);
  background: var(--gray-50);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--gray-600);
  margin-bottom: var(--space-5);
  line-height: 1.5;
}

.status-box.success {
  background: #f0fdf4;
  color: var(--success);
}

.status-box.warning {
  background: #fefce8;
  color: var(--warning);
}

.status-box.error {
  background: #fef2f2;
  color: var(--error);
}

/* Post form */
#post-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.input-wrapper {
  position: relative;
}

#post-text {
  width: 100%;
  padding: var(--space-4);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  color: var(--gray-800);
  resize: none;
  transition: border-color var(--transition-fast);
  line-height: 1.5;
}

#post-text:focus {
  outline: none;
  border-color: var(--gray-500);
}

#post-text:disabled {
  background: var(--gray-50);
  color: var(--gray-400);
  cursor: not-allowed;
}

#post-text::placeholder {
  color: var(--gray-400);
}

#char-count {
  position: absolute;
  bottom: var(--space-2);
  right: var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--gray-400);
}

#char-count.near-limit {
  color: var(--warning);
}

#char-count.at-limit {
  color: var(--error);
}

.form-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.disclaimer {
  font-size: var(--font-size-xs);
  color: var(--gray-500);
  line-height: 1.6;
  text-align: center;
}

/* Payment section */
#payment-section {
  margin-top: var(--space-4);
}

.divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

.divider span {
  font-size: var(--font-size-xs);
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#pay-btn {
  width: 100%;
}

.payment-note {
  font-size: var(--font-size-xs);
  color: var(--gray-400);
  text-align: center;
  margin-top: var(--space-2);
}

/* Cooldown section */
#cooldown-section {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--gray-200);
}

.cooldown-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.cooldown-label {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
}

.cooldown-time {
  font-size: var(--font-size-xl);
  font-weight: 500;
  color: var(--gray-800);
  font-variant-numeric: tabular-nums;
}

/* Confirmation modal */
.confirm-buttons {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
  justify-content: center;
}

#confirm-modal h3 {
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--gray-900);
  margin-bottom: var(--space-3);
}

#confirm-modal p {
  font-size: var(--font-size-sm);
  color: var(--gray-600);
  line-height: 1.6;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

#toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  padding: var(--space-3) var(--space-5);
  background: var(--gray-900);
  color: var(--white);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--transition-base) ease-out;
  max-width: 320px;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--error);
}

.toast.exit {
  animation: toastOut var(--transition-base) ease-in forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ============================================
   LOADING INDICATOR
   ============================================ */

#loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1500;
}

#loading.hidden {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--gray-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   CANVAS POST STYLES (rendered on canvas, but
   these are reference styles for text blocks)
   ============================================ */

/* Blurred word indicator - used in canvas rendering logic */
.blurred-word {
  filter: blur(var(--blur-amount));
  cursor: pointer;
  transition: filter var(--transition-fast);
}

.blurred-word.revealed {
  filter: none;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 600px) {
  #hint {
    font-size: var(--font-size-xs);
    padding: var(--space-2) var(--space-3);
  }
  
  #post-btn {
    bottom: var(--space-4);
    right: var(--space-4);
  }
  
  #zoom-controls {
    bottom: var(--space-4);
    left: var(--space-4);
  }
  
  .modal-content {
    padding: var(--space-5);
  }
  
  #toast-container {
    top: auto;
    bottom: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
  }
  
  .toast {
    max-width: none;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
  display: none !important;
}

.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;
}
