/* ───────── CSS Variables ───────── */
:root {
  --header-padding-top: 20px;
  --header-padding-mobile: 16px;
  --edge-spacing-desktop: 0px;
  --edge-spacing-mobile: 24px;
}

/* ───────── Header Container ───────── */
.header-section {
  position: relative;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  padding: var(--header-padding-top) 0 10px;
  font-family: 'Fira Sans', system-ui, sans-serif;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-bottom: 16px;
}

.header-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ───────── Header Main Row ───────── */
.header-main {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 10px;
  position: relative;
}

/* ───────── Logo Container (Always Absolute, Always Touches Top) ───────── */
.header-logo {
  position: absolute;
  left: var(--edge-spacing-desktop);
  top: calc(-1 * var(--header-padding-top));
  display: flex;
  align-items: flex-start;
  z-index: 1;
}

.logo-container {
  position: relative;
  width: auto;
  height: 72px; /* Desktop: spans from screen top through both header rows */
  cursor: pointer;
  transition: transform 0.1s ease;
  /* Scale up 15% and move up to keep bottom edge in same position */
  transform: scale(1.15) translateY(-5.4px); /* -5.4px = -15% of 72px / 2 */
  /* Disable mobile tap highlight and selection */
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.logo-container:hover {
  transform: scale(1.17) translateY(-5.4px); /* Slightly bigger on hover, maintaining position */
}

.logo-container:active {
  transform: scale(1.13) translateY(-5.4px); /* Slightly smaller on click, maintaining position */
}

.logo-image.static-logo {
  width: auto;
  height: 100%;
  object-fit: contain;
  display: block;
  /* Prevent image selection and dragging */
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

/* Animation container */
.logo-animation {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

/* Animation states - no fade, just swap visibility */
.logo-container.animating .static-logo {
  opacity: 0;
}

.logo-container.animating .logo-animation {
  opacity: 1;
}

/* ───────── Header Content (Naturally Centered) ───────── */
.header-content {
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.main-title {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  color: #111827;
  line-height: 1;
}

.subtitle {
  font-size: 1.7rem;
  color: #6b7280;
  font-weight: 400;
  position: relative;
  padding-left: 12px;
  line-height: 1;
}

.subtitle::before {
  content: "•";
  position: absolute;
  left: -5px;
  color: #d1d5db;
  font-weight: 400;
}

/* ───────── Header Footer (Naturally Centered) ───────── */
.header-footer {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
  width: 100%;
}

.telegram-link {
  margin: 0;
  font-size: 0.8rem;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 4px;
  font-style: italic;
  font-weight: 400;
}

.telegram-link a {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.2s;
}

.telegram-link a:hover {
  color: #4b5563;
}

.telegram-icon {
  width: 12px;
  height: 12px;
  opacity: 0.7;
}

/* ───────── Help Button (Always Absolute, Symmetrical to Logo) ───────── */
.help-btn {
  position: absolute;
  right: var(--edge-spacing-desktop);
  top: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  color: #6b7280;
  font-size: 16px;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.2s;
  font-family: 'Open Sans', system-ui, sans-serif;
}

.help-btn:hover {
  background: #e5e7eb;
  color: #4b5563;
}

/* ───────── Help Modal ───────── */
.help-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
}

.help-modal.show {
  display: block;
}

.help-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 24px;
  border-radius: 12px;
  max-width: 480px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  font-family: 'Open Sans', system-ui, sans-serif;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.help-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #9ca3af;
  font-family: 'Open Sans', system-ui, sans-serif;
  transition: color 0.2s;
}

.help-close:hover {
  color: #6b7280;
}

.help-content h3 {
  margin: 0 0 20px 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
}

.help-section {
  margin-bottom: 20px;
}

.help-section:last-of-type {
  margin-bottom: 16px;
}

.help-content h4 {
  margin: 0 0 10px 0;
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
}

.help-content p {
  margin: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.5;
  color: #4b5563;
}

.help-description {
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.6;
  color: #374151;
}

.help-description a {
  color: #3b82f6;
  text-decoration: none;
}

.help-description a:hover {
  color: #2563eb;
  text-decoration: underline;
}

.help-footer {
  margin-top: 20px;
  margin-bottom: 0;
  font-size: 13px;
  color: #6b7280;
  text-align: center;
}

.help-footer a {
  color: #3b82f6;
  text-decoration: none;
}

.help-footer a:hover {
  color: #2563eb;
  text-decoration: underline;
}

.help-content ul {
  margin: 0;
  padding-left: 20px;
  list-style-type: disc;
}

.help-content li {
  margin: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.5;
  color: #4b5563;
}

.help-content li:last-child {
  margin-bottom: 0;
}

.help-content p:last-child {
  margin-bottom: 0;
}

.help-tip {
  background: #f8fafc;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 3px solid #3b82f6;
  font-size: 13px;
  color: #475569;
  margin: 0 0 12px 0;
}

/* ───────── Mobile Responsive ───────── */

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

@media (max-width: 700px) {
  .header-section {
    padding: var(--header-padding-mobile) 0 8px;
    margin-bottom: 12px;
  }
  
  .header-container {
    padding: 0 12px;
  }
  
  .header-main {
    margin-bottom: 8px;
  }
  
  /* Update positioning variables for mobile */
  .header-logo {
    left: var(--edge-spacing-mobile);
    top: calc(-1 * var(--header-padding-mobile));
  }
  
  /* Smaller logo container on mobile - still touches top, but appears single-line height */
  .logo-container {
    height: 56px; /* Smaller but still extends from screen top */
    /* Scale up 15% and move up to keep bottom edge in same position */
    transform: scale(1.15) translateY(-4.2px); /* -4.2px = -15% of 56px / 2 */
  }
  
  .logo-container:hover {
    transform: scale(1.17) translateY(-4.2px); /* Slightly bigger on hover, maintaining position */
  }

  .logo-container:active {
    transform: scale(1.13) translateY(-4.2px); /* Slightly smaller on click, maintaining position */
  }
  
  .help-btn {
    right: var(--edge-spacing-mobile);
  }
  
  .header-title {
    flex-direction: column;
    gap: 2px;
    align-items: center;
  }
  
  .main-title {
    font-size: 1.4rem;
  }
  
  .subtitle {
    font-size: 1rem;
    padding-left: 0;
    font-weight: 400;
  }
  
  .subtitle::before {
    display: none;
  }
  
  .telegram-link {
    font-size: 0.8rem;
  }

  /* Fullscreen modal on mobile */
  .help-content {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 60px 20px 20px 20px;
    border-radius: 0;
    transform: none;
    overflow-y: auto;
    box-sizing: border-box;
  }

  .help-close {
    position: fixed;
    top: 16px;
    right: 20px;
    font-size: 28px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2001;
  }

  .help-content h3 {
    font-size: 1.3rem;
    margin-bottom: 24px;
    margin-top: 0;
  }

  .help-content h4 {
    font-size: 1rem;
  }

  .help-section {
    margin-bottom: 24px;
  }
}

@media (max-width: 500px) {
  /* Header footer - allow wrapping when needed */
  .telegram-link {
    flex-wrap: wrap;
    justify-content: center;
    line-height: 1.2;
  }
  
  .telegram-link .link-with-icon {
    display: flex;
    align-items: center;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .help-content {
    padding: 60px 16px 16px 16px;
  }

  .help-tip {
    padding: 12px 14px;
    font-size: 13px;
  }
}

@media (max-width: 400px) {
  :root {
    --edge-spacing-mobile: 12px; /* Reduce edge spacing for very small screens */
  }
}

@media (max-width: 370px) {
  :root {
    --edge-spacing-mobile: 0px;
  }

  .header-container {
    padding: 0 8px;
  }

  .logo-container {
    transform: scale(1.0) translateY(-3.2px);
  }

  .logo-container:hover {
    transform: scale(1.02) translateY(-3.2px);
  }

  .logo-container:active {
    transform: scale(0.98) translateY(-3.2px);
  }

  .main-title {
    font-size: 1.35rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }
}