/* ============================================
   RESET & GLOBAL - MINIMAL & CLEAN
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  transition: background-color 0.6s ease, color 0.5s ease;
  font-family: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  font-weight: 900;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0;
  line-height: 1.4;
  min-height: 100vh;
}

/* ============================================
   MAIN WRAPPER
   ============================================ */
.main-wrapper {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 100vh;
  padding: 6rem 1.5rem 5rem 1.5rem;
}

/* ============================================
   TEXT DISPLAY
   ============================================ */
.text-display {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  flex: 1 1 auto;
  padding: 2rem 0.5rem;
  margin: auto 0;
}

.quote-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 0;
  max-height: none;
  overflow: visible;
}

.persian-quote {
  font-size: clamp(2.2rem, 10vw, 5.5rem);
  font-weight: 900;
  line-height: 1.5;
  letter-spacing: -0.01em;
  word-break: break-word;
  white-space: pre-wrap;
  max-width: 100%;
  width: 100%;
  transition: opacity 0.65s ease-in-out, transform 0.5s ease;
  opacity: 1;
  transform: scale(1);
  text-rendering: optimizeLegibility;
  padding: 0.25rem 0;
  margin: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
  display: block;
  max-height: none;
  height: auto;
}

.fade-out {
  opacity: 0 !important;
  transform: scale(0.98);
}

/* ============================================
   TIMER CIRCLE - Top Left
   ============================================ */
.timer-wrapper {
  position: fixed;
  top: 2rem;
  left: 2rem;
  z-index: 80;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.timer-wrapper:hover {
  opacity: 1;
}

.timer-circle {
  position: relative;
  width: 60px;
  height: 60px;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(0deg);
}

.timer-bg {
  stroke: currentColor;
  opacity: 0.15;
}

.timer-progress {
  stroke: currentColor;
  transition: stroke-dashoffset 0.05s linear;
  filter: drop-shadow(0 0 3px currentColor);
  will-change: stroke-dashoffset;
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.1rem;
  font-weight: 700;
  font-family: "Vazirmatn", monospace;
  color: currentColor;
  opacity: 0.8;
  line-height: 1;
  transition: opacity 0.2s ease;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

.timer-text.pulse {
  animation: subtlePulse 0.3s ease;
}

@keyframes subtlePulse {
  0% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ============================================
   TEXT POSITION INDICATOR - Top Right
   ============================================ */
.position-indicator {
  position: fixed;
  top: 2.2rem;
  right: 2.2rem;
  z-index: 80;
  font-family: "Vazirmatn", monospace;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.25;
  color: currentColor;
  letter-spacing: 0.5px;
  padding: 0.3rem 0.6rem;
  border-radius: 2rem;
  background-color: rgba(128, 128, 128, 0.02);
  backdrop-filter: blur(2px);
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.position-indicator:hover {
  opacity: 0.5;
}

.position-separator {
  margin: 0 0.1rem;
  opacity: 0.5;
}

#current-text-number,
#total-texts-count {
  font-feature-settings: "ss02";
  min-width: 1.5rem;
  text-align: center;
}

/* ============================================
   CONTROL BUTTONS - Bootstrap-style breakpoints
   ============================================ */
.control-button {
  background: transparent;
  border: 2px solid currentColor;
  border-radius: 3rem;
  padding: 0.7rem 1.8rem;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: "Vazirmatn", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: all 0.25s ease;
  backdrop-filter: blur(6px);
  background-color: rgba(255, 255, 255, 0.04);
  border-color: currentColor;
  color: inherit;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  white-space: nowrap;
}

.control-button:hover {
  background-color: rgba(128, 128, 128, 0.08);
  transform: scale(0.97);
}

.control-button img {
  filter: invert(0);
  transition: filter 0.3s ease;
}

/* Extra small devices (xs: < 576px) - Icons only */
@media (max-width: 575.98px) {
  .control-button {
    padding: 0.7rem;
    border-radius: 50%;
    aspect-ratio: 1/1;
  }

  .control-button span {
    display: none;
  }
}

/* Small devices (sm: 576px - 767px) - Show text */
@media (min-width: 576px) and (max-width: 767.98px) {
  .control-button {
    padding: 0.6rem 1.4rem;
    font-size: 0.95rem;
  }

  .control-button span {
    display: inline-block;
  }
}

/* Medium devices (md: 768px - 991px) - Default styling */
@media (min-width: 768px) and (max-width: 991.98px) {
  .control-button {
    padding: 0.7rem 1.6rem;
    font-size: 1rem;
  }
}

/* ============================================
   BUTTON POSITIONING
   ============================================ */
.theme-toggle-wrapper {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  z-index: 90;
}

.list-button-wrapper {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
}

.share-wrapper {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 90;
}

/* Responsive positioning */
@media (max-width: 575.98px) {
  .theme-toggle-wrapper {
    bottom: 1rem;
    left: 1rem;
  }

  .list-button-wrapper {
    bottom: 1rem;
  }

  .share-wrapper {
    bottom: 1rem;
    right: 1rem;
  }
}

@media (min-width: 576px) and (max-width: 767.98px) {
  .theme-toggle-wrapper {
    bottom: 1.2rem;
    left: 1.2rem;
  }

  .list-button-wrapper {
    bottom: 1.2rem;
  }

  .share-wrapper {
    bottom: 1.2rem;
    right: 1.2rem;
  }
}

/* Landscape mode adjustments */
@media (orientation: landscape) and (max-height: 500px) {
  .control-button {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
  }

  .theme-toggle-wrapper,
  .list-button-wrapper,
  .share-wrapper {
    bottom: 0.6rem;
  }
}

/* ============================================
   SHARE MENU
   ============================================ */
.share-menu {
  position: absolute;
  bottom: calc(100% + 1rem);
  right: 0;
  width: 320px;
  max-width: 90vw;
  max-height: 70vh;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 1.8rem;
  padding: 1.4rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(128, 128, 128, 0.12);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1;
  transform: translateY(0);
  display: flex;
  flex-direction: column;
}

.share-menu.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.share-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: inherit;
  border-bottom: 1px solid rgba(128, 128, 128, 0.15);
  padding-bottom: 0.8rem;
  flex-shrink: 0;
}

.close-share {
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 0.5rem;
  border-radius: 2rem;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-share:hover {
  background-color: rgba(128, 128, 128, 0.1);
}

.share-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
}

.share-options::-webkit-scrollbar {
  width: 4px;
}

.share-options::-webkit-scrollbar-track {
  background: rgba(128, 128, 128, 0.05);
  border-radius: 10px;
}

.share-options::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.2);
  border-radius: 10px;
}

.share-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-radius: 2rem;
  text-decoration: none;
  color: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
  font-family: "Vazirmatn", sans-serif;
  cursor: pointer;
  flex-shrink: 0;
}

.share-option:hover {
  background-color: rgba(128, 128, 128, 0.08);
  transform: translateX(-2px);
}

.share-option-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.copy-link {
  border-top: 1px solid rgba(128, 128, 128, 0.2);
  margin-top: 0.6rem;
  padding-top: 1rem;
}

.native-share {
  background-color: rgba(0, 122, 255, 0.08);
  border-radius: 2rem;
  color: #007aff;
}

/* ============================================
   TEXT LIST MODAL
   ============================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

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

.modal-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 2rem;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  transform: scale(1);
  transition: transform 0.3s ease;
}

.modal.hidden .modal-content {
  transform: scale(0.95);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: inherit;
}

.close-modal {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  color: inherit;
}

.close-modal:hover {
  background-color: rgba(128, 128, 128, 0.1);
}

.modal-body {
  padding: 1rem;
  overflow-y: auto;
  max-height: 60vh;
  scroll-behavior: smooth;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: rgba(128, 128, 128, 0.05);
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.2);
  border-radius: 10px;
}

.text-list-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.text-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-radius: 1.5rem;
  background-color: rgba(128, 128, 128, 0.03);
  border: 1px solid rgba(128, 128, 128, 0.05);
  transition: all 0.2s ease;
  cursor: pointer;
  font-family: "Vazirmatn", sans-serif;
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.6;
  text-align: right;
}

.text-list-item:hover {
  background-color: rgba(128, 128, 128, 0.08);
  transform: translateX(-2px);
}

.text-list-item.current {
  background-color: rgba(0, 122, 255, 0.08);
  border-color: rgba(0, 122, 255, 0.3);
  font-weight: 700;
}

.text-list-item-number {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  background-color: rgba(128, 128, 128, 0.1);
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: inherit;
}

.text-list-item.current .text-list-item-number {
  background-color: rgba(0, 122, 255, 0.2);
  color: #007aff;
}

.modal-footer {
  padding: 1rem 2rem;
  border-top: 1px solid rgba(128, 128, 128, 0.2);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.8;
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */
.toast {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.9);
  backdrop-filter: blur(8px);
  color: white;
  padding: 0.8rem 2rem;
  border-radius: 3rem;
  font-size: 0.95rem;
  font-weight: 500;
  z-index: 200;
  transition: opacity 0.3s ease;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

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

/* ============================================
   DARK MODE ADJUSTMENTS
   ============================================ */
body.dark .share-menu {
  background: rgba(26, 29, 33, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark .native-share {
  background-color: rgba(10, 132, 255, 0.15);
  color: #0a84ff;
}

body.dark .toast {
  background: rgba(250, 250, 250, 0.9);
  color: #1a1d21;
}

body.dark .control-button img,
body.dark .close-modal img,
body.dark .close-share img,
body.dark .share-option img,
body.dark .share-option-icon {
  filter: brightness(0) invert(1) !important;
}

body.dark .timer-progress {
  stroke: #f0ebe5;
}

body.dark .timer-text,
body.dark .position-indicator {
  color: #f0ebe5;
}

body.dark .modal-content {
  background: rgba(26, 29, 33, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark .text-list-item.current {
  background-color: rgba(10, 132, 255, 0.15);
  border-color: rgba(10, 132, 255, 0.3);
}

body.dark .text-list-item.current .text-list-item-number {
  background-color: rgba(10, 132, 255, 0.25);
  color: #0a84ff;
}

/* ============================================
   LIGHT THEME
   ============================================ */
body.light {
  background-color: #faf9f7;
  color: #1a1c1e;
}

body.light .persian-quote {
  color: #0b0c0e;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* ============================================
   DARK THEME
   ============================================ */
body.dark {
  background-color: #1a1d21;
  color: #efeeea;
}

body.dark .persian-quote {
  color: #f2efea;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

/* ============================================
   SAFE AREA INSETS
   ============================================ */
@supports (padding: max(0px)) {
  .theme-toggle-wrapper {
    bottom: max(2rem, env(safe-area-inset-bottom));
    left: max(2rem, env(safe-area-inset-left));
  }

  .share-wrapper {
    bottom: max(2rem, env(safe-area-inset-bottom));
    right: max(2rem, env(safe-area-inset-right));
  }

  .list-button-wrapper {
    bottom: max(2rem, env(safe-area-inset-bottom));
  }

  .timer-wrapper {
    top: max(2rem, env(safe-area-inset-top));
    left: max(2rem, env(safe-area-inset-left));
  }

  .position-indicator {
    top: max(2.2rem, env(safe-area-inset-top));
    right: max(2.2rem, env(safe-area-inset-right));
  }

  @media (max-width: 575.98px) {
    .theme-toggle-wrapper {
      bottom: max(1rem, env(safe-area-inset-bottom));
      left: max(1rem, env(safe-area-inset-left));
    }

    .share-wrapper {
      bottom: max(1rem, env(safe-area-inset-bottom));
      right: max(1rem, env(safe-area-inset-right));
    }

    .list-button-wrapper {
      bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .timer-wrapper {
      top: max(1.2rem, env(safe-area-inset-top));
      left: max(1.2rem, env(safe-area-inset-left));
    }

    .position-indicator {
      top: max(1.4rem, env(safe-area-inset-top));
      right: max(1.4rem, env(safe-area-inset-right));
    }
  }
}

/* ============================================
   RESPONSIVE TEXT SIZES
   ============================================ */
@media (max-width: 600px) {
  .main-wrapper {
    padding: 5rem 1.2rem;
  }

  .persian-quote {
    font-size: clamp(2rem, 8.5vw, 3.2rem);
    line-height: 1.6;
  }

  .timer-circle {
    width: 48px;
    height: 48px;
  }

  .timer-text {
    font-size: 0.95rem;
  }

  .position-indicator {
    font-size: 0.8rem;
  }
}

@media (max-width: 380px) {
  .timer-circle {
    width: 42px;
    height: 42px;
  }

  .timer-text {
    font-size: 0.85rem;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .main-wrapper {
    padding: 4rem 1.5rem;
  }

  .persian-quote {
    font-size: clamp(1.8rem, 7vw, 3.5rem);
  }
}
