/* =========================
   Global Layout & Typography
   ========================= */
html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Inter", "Noto Sans Arabic", system-ui, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap {
  padding: 1rem 1.25rem;
}

h1,
h3 {
  margin: 0 0 1rem;
  color: #0f172a;
}

/* =========================
   Card Grid Layout
   ========================= */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.2rem;
  margin-top: 1rem;
}

/* =========================
   Cards
   ========================= */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 1rem;
  transition: box-shadow 0.25s ease, transform 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* =========================
   Title Styling
   ========================= */
.phrase-title {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
  padding: 0.75rem 0.5rem;
  width: 100%;
  background: linear-gradient(90deg, #e0f2fe 0%, #f0f9ff 50%, #e0f2fe 100%);
  border-bottom: 1px solid #cbd5e1;
  border-radius: 10px 10px 0 0;
  letter-spacing: 0.3px;
  box-shadow: inset 0 -1px 0 #cbd5e1;

  /* Wrap long titles */
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* =========================
   Phrase Text (Dhikr content)
   ========================= */
.phrase-text {
  font-family: "Noto Kufi Arabic", "Amiri", serif;
  text-align: center;
  font-size: 1.25rem;
  color: #1e293b;
  margin: 0.8rem 0 1rem;
  line-height: 1.8;
  direction: rtl;

  /* allow text to expand naturally */
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  padding: 0 6px;
}

/* =========================
   Counter Circle + Ripple
   ========================= */
.counter {
  --active-color: #0ea5e9;
  --zero-color: #22c55e;
  --ripple-color: var(--active-color);

  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--active-color);
  background: var(--active-color);

  display: flex;
  align-items: center;
  justify-content: center;

  font-weight: bold;
  font-size: 1.8rem;
  color:black;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.1s ease;
}

.counter:active {
  transform: scale(0.96);
}

.counter::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--ripple-color);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
}

.counter.splash::after {
  animation: rippleExpand 0.45s ease-out forwards;
}

@keyframes rippleExpand {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0.8;
  }
  80% {
    transform: translate(-50%, -50%) scale(6);
    opacity: 0.4;
  }
  100% {
    transform: translate(-50%, -50%) scale(8);
    opacity: 0;
  }
}

/* Counter value display */
.c-val {
  pointer-events: none;
}

/* Inline edit input for counter */
.count-edit {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  font: inherit;
  font-weight: 800;
  color: #0f172a;
  caret-color: #0f172a;
  border-radius: 9999px;
  display: none;
}

.counter.editing .count-edit {
  display: block;
}

.counter.editing .c-val {
  visibility: hidden;
}

/* =========================
   Buttons below counter
   ========================= */
.card-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

button {
  cursor: pointer;
  border: none;
  background: #e2e8f0;
  color: #0f172a;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 1rem;
  transition: background 0.2s ease;
}

button:hover {
  background: #cbd5e1;
}

.reset {
  background: #fef3c7;
}

.reset:hover {
  background: #fde68a;
}

.audio-btn,
.auto-btn,
.loop-btn {
  font-size: 1.2rem;
}

.audio-btn.playing {
  color: #0ea5e9;
}

/* =========================
   Responsive
   ========================= */
@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .counter {
    width: 70px;
    height: 70px;
  }

  .phrase-text {
    font-size: 1.1rem;
    line-height: 1.7;
    max-height: 200px;
  }
}

/* =========================
   Reset Animation
   ========================= */
.reset.pulse {
  animation: pulseOnce 0.4s ease;
}

@keyframes pulseOnce {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Hide empty titles */
.phrase-title:empty {
  display: none;
}

/* Button variants */
.btn.primary {
  background: #0ea5e9;
  color: #fff;
}

.btn.primary:hover {
  background: #0284c7;
}

.btn.success {
  background: #22c55e;
  color: #fff;
}

.btn.success:hover {
  background: #16a34a;
}

/* Page layout helpers */
.page-actions .btn {
  margin: 0 0.5rem;
}

.content-top h1 {
  flex: 1;
}

/* Footer always at bottom */
main#content {
  flex: 1;
}

.site-footer {
  margin-top: auto;
}
