/* ===========================
   CSS Variables & Theming
   =========================== */
:root {
  --bg-color: #111;
  --fg-color: #fff;
  --btn-bg: #333;
  --btn-hover: #444;
}

body.light {
  --bg-color: #f5f5f5;
  --fg-color: #111;
  --btn-bg: #ddd;
  --btn-hover: #ccc;
}

/* ===========================
   Base Styles
   =========================== */
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-color);
  color: var(--fg-color);
  font-family: 'Merriweather Sans', sans-serif;
  overflow: hidden;
  position: relative;
  z-index: 0;
}

body.fullscreen-inactive {
  cursor: none;
}

/* ===========================
   Header
   =========================== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--bg-color);
  position: relative;
  z-index: 200;
}

.title {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 10px;
}

.title h1 {
    margin: 0;
    font-size: 1.5rem;
}

.title span {
  font-family: 'Rouge Script', cursive;
  font-size: 1.4rem;
  color: var(--fg-color);
  opacity: 0.7;
}

.header-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Buy Me a Coffee button styling */
.header-buttons a[href*="buymeacoffee"] {
  display: flex !important;
  align-items: center !important;
  height: 48px !important;
  margin: 0 !important;
}

.header-buttons a[href*="buymeacoffee"] img {
  height: auto !important;
  max-height: 40px !important;
}

/* ===========================
   Buttons
   =========================== */
button {
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 22px;
  border: none;
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--fg-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Merriweather Sans', sans-serif;
  flex-shrink: 0;
}

button:hover {
  background: var(--btn-hover);
}

button svg {
  width: 26px;
  height: 26px;
}

/* ===========================
   Arrow
   =========================== */
#arrow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 85vmin;
  height: 85vmin;
  --dx: 0px;
  --dy: -20px;
  --rot: 0deg;
  z-index: 1;
  transition: filter 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

#arrow svg {
  pointer-events: none;
  cursor: default;
}

/* Only the arrow elements themselves are grabbable */
#arrow svg .arrow-grab-area,
#arrow svg polyline,
#arrow svg line {
  pointer-events: auto;
  cursor: grab;
}

#arrow svg .arrow-grab-area:active,
#arrow svg polyline:active,
#arrow svg line:active {
  cursor: grabbing;
}

#arrow.dragging svg {
  filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.3));
}

#arrow svg {
  width: 100%;
  height: 100%;
  transform-origin: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Arrow animation */
.animate svg {
  animation: jump 0.5s infinite ease-in-out;
}

@keyframes jump {
  0% { transform: translate(0, 0) rotate(var(--rot)); }
  50% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
  100% { transform: translate(0, 0) rotate(var(--rot)); }
}

/* ===========================
   Control Buttons
   =========================== */
.bottom-controls {
  position: fixed;
  bottom: 24px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 20px;
  transition: opacity 0.3s ease;
  z-index: 100;
  pointer-events: none;
}

.bottom-controls > * {
  pointer-events: auto;
}

.buttons,
.right-buttons {
  display: flex;
  gap: 20px;
  align-items: baseline;
}

.right-buttons span{
    font-size: 0.9rem;
    color: var(--fg-color);
    opacity: 0.7;
}

.right-buttons span:hover {
    opacity: 1;
}

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

/* ===========================
   Floating Text Element
   =========================== */
.floating-text {
  position: absolute;
  top: 20%;
  left: 30%;
  width: auto;
  height: auto;
  max-width: 80vw;
  /* background: var(--bg-color); */
  backdrop-filter: blur(10px);
  border: 2px solid var(--fg-color);
  border-radius: 8px;
  padding: 30px 15px 15px 15px;
  z-index: 50;
  cursor: default;
  opacity: 1;
  transition: opacity 0.3s ease, border-color 0.5s ease;
  display: inline-block;
}

.floating-text.idle {
  border-color: transparent;
  background: transparent;
  backdrop-filter: none;
}

.floating-text.idle .text-drag-handle,
.floating-text.idle .text-resize-handle {
  opacity: 0;
  pointer-events: none;
}

.text-drag-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: move;
  color: var(--fg-color);
  font-size: 16px;
  opacity: 0.5;
  user-select: none;
  letter-spacing: 2px;
  transition: opacity 0.5s ease, background 0.2s ease;
}

.text-drag-handle:hover {
  opacity: 0.8;
  background: rgba(var(--fg-color), 0.1);
}

.text-input {
  width: auto;
  min-width: 50px;
  max-width: 75vw;
  height: auto;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg-color);
  font-family: 'Merriweather Sans', sans-serif;
  font-size: 24px;
  font-weight: 700;
  resize: none;
  padding: 0;
  line-height: 1.2;
  cursor: text;
  overflow: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.text-input::placeholder {
  color: var(--fg-color);
  opacity: 0.4;
  font-weight: 400;
}

.text-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  color: var(--fg-color);
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  user-select: none;
  transition: opacity 0.5s ease;
}

.text-resize-handle:hover {
  opacity: 0.8;
}

/* ===========================
   Contact Button & Modal
   =========================== */
.about-trigger,
.contact-trigger {
  background: transparent;
  color: var(--fg-color);
  border: none;
  cursor: pointer;
  padding: 0;
  width: 48px;
  height: 48px;
  opacity: 0.6;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.about-trigger:hover,
.contact-trigger:hover {
  opacity: 1;
  background: transparent;
}

.about-trigger.hidden,
.contact-trigger.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--bg-color);
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  position: relative;
  z-index: 10000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  font-size: 32px;
  color: var(--fg-color);
  cursor: pointer;
  width: 40px;
  height: 40px;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
}

.modal-close:hover {
  opacity: 1;
  background: transparent;
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.5rem;
  color: var(--fg-color);
}

.modal-content h3 {
  margin-top: 20px;
  margin-bottom: 12px;
  font-size: 1.1rem;
  color: var(--fg-color);
}

.modal-content p {
  line-height: 1.6;
  color: var(--fg-color);
  margin: 10px 0;
}

.controls-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.controls-list li {
  color: var(--fg-color);
  line-height: 1.5;
  font-size: 0.8rem;
  opacity: 0.75;
}

.controls-list li strong {
  color: var(--fg-color);
}

/* Form Styles */
#contactForm {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#contactForm label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: -10px;
  color: var(--fg-color);
}

#contactForm input,
#contactForm textarea {
  padding: 12px;
  border: 1px solid var(--btn-bg);
  border-radius: 8px;
  background: var(--bg-color);
  color: var(--fg-color);
  font-family: 'Merriweather Sans', sans-serif;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

#contactForm input:focus,
#contactForm textarea:focus {
  outline: none;
  border-color: var(--fg-color);
}

#contactForm button[type="submit"] {
  background: var(--btn-bg);
  color: var(--fg-color);
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
  height: auto;
  transition: background 0.3s ease;
  margin-top: 10px;
}

#contactForm button[type="submit"]:hover {
  background: var(--btn-hover);
}

/* Share URL Input */
.share-url-container {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.share-url-input {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--btn-bg);
  border-radius: 8px;
  background: var(--bg-color);
  color: var(--fg-color);
  font-family: 'Merriweather Sans', sans-serif;
  font-size: 0.9rem;
}

.share-url-input:focus {
  outline: none;
  border-color: var(--fg-color);
}

.copy-btn {
  background: var(--btn-bg);
  color: var(--fg-color);
  border: none;
  padding: 0 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  width: auto;
  height: auto;
  transition: background 0.3s ease;
  white-space: nowrap;
}

.copy-btn:hover {
  background: var(--btn-hover);
}

.copy-btn.copied {
  background: #4CAF50;
  color: white;
}

/* ===========================
   Mobile Responsive
   =========================== */
@media (max-width: 768px) {
  /* Header adjustments */
  .title span {
    display: none;
  }
  
  header {
    padding: 10px 15px;
  }
  
  .title h1 {
    font-size: 1.3rem;
  }
  
  /* BMC button - icon only on mobile */
  .header-buttons a[href*="buymeacoffee"] {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    height: 48px !important;
    overflow: hidden !important;
    border-radius: 10px !important;
    padding: 0 !important;
    margin: 0 !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }
  
  .header-buttons a[href*="buymeacoffee"] span {
    display: none !important;
  }
  
  .header-buttons a[href*="buymeacoffee"] img {
    max-height: 28px !important;
    max-width: 28px !important;
    margin: 0 !important;
  }
  
  /* Contact modal adjustments */
  .modal-content {
    width: 95%;
    padding: 25px 20px;
  }
  
  .modal-content h2 {
    font-size: 1.3rem;
  }
  
  /* Bottom controls adjustments for mobile */
  .bottom-controls {
    bottom: 16px;
    padding: 0 15px;
    gap: 8px;
  }
  
  .about-trigger,
  .contact-trigger {
    width: 44px;
    height: 44px;
  }
  
  .about-trigger svg,
  .contact-trigger svg {
    width: 22px;
    height: 22px;
  }

  .right-buttons span {
    font-size: 0.8rem;
  }
  
  /* Floating text adjustments for mobile */
  .floating-text {
    max-width: 90vw;
  }
}

