:root {
  --bg: #000000;
  --text: #fff7f1;
  --muted: rgba(255, 226, 218, 0.52);
  --line: rgba(255, 78, 68, 0.18);
  --font-sans: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-arabic: "Noto Naskh Arabic", "Geeza Pro", "Traditional Arabic",
    serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Black field with red embers */
.bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  background: #000000;
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.3) 0%,
      transparent 36%,
      transparent 64%,
      rgba(0, 0, 0, 0.42) 100%
    ),
    radial-gradient(
      112% 92% at 50% 47%,
      transparent 38%,
      rgba(0, 0, 0, 0.46) 100%
    );
  pointer-events: none;
}

.sand {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Page */
.site-name {
  position: fixed;
  top: clamp(20px, 3.4vh, 34px);
  left: clamp(20px, 2.4vw, 36px);
  z-index: 2;
  margin: 0;
  color: rgba(255, 239, 229, 0.7);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  line-height: 1;
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.85);
}

.page {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding: clamp(24px, 2.4vw, 36px);
}

/* Timer */
.timer-stage {
  display: grid;
  width: 100%;
  max-width: 1360px;
  opacity: 0;
  animation: timerIn 1s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.timer-panel {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s ease, visibility 0s linear 0.9s;
  will-change: opacity;
}

.timer-panel.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.9s ease;
}

.timer-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 1.8vw, 22px);
  margin: 0 0 clamp(26px, 4.2vh, 42px);
  color: rgba(255, 246, 239, 0.78);
  font-family: var(--font-sans);
  font-size: clamp(13px, 1.45vw, 18px);
  font-weight: 500;
  letter-spacing: 0.32em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.timer-name::before,
.timer-name::after {
  content: "";
  display: block;
  width: clamp(20px, 4vw, 62px);
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 88, 78, 0.34)
  );
}

.timer-name::after {
  background: linear-gradient(
    90deg,
    rgba(255, 88, 78, 0.34),
    transparent
  );
}

.timer {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  width: 100%;
  gap: clamp(38px, 7vh, 76px) clamp(36px, 4vw, 56px);
  text-align: center;
}

.timer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
  pointer-events: none;
}

.timer:focus-visible {
  outline: 1px solid rgba(255, 92, 82, 0.42);
  outline-offset: 18px;
}

.unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.unit-value {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: clamp(22px, 2.85vw, 38px);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.34);
  white-space: nowrap;
}

.unit-label {
  margin-top: clamp(10px, 1.4vh, 14px);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: clamp(10px, 0.9vw, 11px);
  font-weight: 500;
  letter-spacing: 0.2em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Hover / focus reflection */
.quote-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: clamp(18px, 4vh, 44px) clamp(16px, 4vw, 44px);
  background:
    radial-gradient(
      90% 84% at 50% 48%,
      rgba(25, 7, 3, 0.72) 0%,
      rgba(5, 1, 1, 0.92) 76%
    ),
    rgba(5, 1, 1, 0.58);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.55s ease, visibility 0s linear 0.55s;
}

.quote-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.55s ease;
}

.quote-overlay.is-locked {
  pointer-events: auto;
}

.quote-card {
  width: min(980px, 100%);
  max-height: calc(100dvh - 2 * clamp(18px, 4vh, 44px));
  overflow-y: auto;
  padding: clamp(26px, 3.6vw, 48px) clamp(22px, 4vw, 56px);
  border: 1px solid rgba(255, 188, 145, 0.18);
  border-radius: 3px;
  background:
    linear-gradient(
      148deg,
      rgba(53, 14, 7, 0.82) 0%,
      rgba(20, 5, 2, 0.84) 54%,
      rgba(10, 2, 1, 0.9) 100%
    );
  box-shadow:
    0 34px 100px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 226, 205, 0.07);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateY(16px) scale(0.985);
  transition: opacity 0.55s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 190, 150, 0.34) transparent;
}

.quote-overlay.is-visible .quote-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.quote-card::before {
  content: "";
  display: block;
  width: clamp(38px, 5vw, 58px);
  height: 1px;
  margin: 0 0 clamp(18px, 2.4vw, 26px) auto;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 194, 151, 0.55)
  );
}

.quote-card p {
  margin: 0;
  color: rgba(255, 247, 240, 0.92);
  font-family: var(--font-arabic);
  font-size: clamp(14px, 1.52vw, 22px);
  font-weight: 400;
  line-height: 2.05;
  text-align: right;
  text-wrap: pretty;
}

.quote-close {
  position: fixed;
  top: clamp(16px, 3vh, 28px);
  right: clamp(16px, 3vw, 30px);
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 194, 151, 0.28);
  border-radius: 50%;
  background: rgba(37, 9, 4, 0.72);
  color: rgba(255, 242, 232, 0.9);
  font-family: var(--font-sans);
  font-size: 25px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.quote-close:hover,
.quote-close:focus-visible {
  border-color: rgba(255, 194, 151, 0.5);
  background: rgba(68, 18, 8, 0.82);
  outline: none;
}

.quote-overlay.is-locked .quote-close {
  display: flex;
}

@keyframes timerIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* Mobile */
@media (max-width: 720px) {
  .timer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(30px, 5.6vh, 46px) 28px;
  }

  .timer::after {
    display: none;
  }

  .unit-value {
    font-size: clamp(22px, 6vw, 38px);
  }

  .unit-label {
    font-size: 10px;
  }

  .timer-name {
    margin-bottom: clamp(22px, 3.8vh, 32px);
    font-size: clamp(12px, 3.3vw, 15px);
    letter-spacing: 0.28em;
  }

  .quote-overlay {
    padding: 16px;
  }

  .quote-card {
    max-height: calc(100dvh - 32px);
    padding: 24px 22px;
  }

  .quote-card p {
    font-size: 15px;
    line-height: 1.95;
  }
}

@media (max-width: 420px) {
  .page {
    padding-inline: 16px;
  }

  .site-name {
    top: 18px;
    left: 16px;
    font-size: 10px;
  }

  .timer {
    gap: 32px 20px;
  }

  .unit-label {
    font-size: 10px;
    letter-spacing: 0.16em;
  }

  .timer-name {
    gap: 12px;
  }
}

@media (max-width: 360px) {
  .page {
    padding-inline: 14px;
  }

  .timer {
    gap: 30px 14px;
  }

  .unit-value {
    font-size: 20px;
  }

  .timer-name {
    font-size: 11px;
  }

  .quote-card {
    padding: 20px 18px;
  }

  .quote-card p {
    font-size: 14px;
    line-height: 1.9;
  }
}

/* Short landscape screens */
@media (max-height: 500px) and (max-width: 900px) {
  .page {
    padding: 16px;
  }

  .timer {
    gap: 18px 20px;
  }

  .unit-label {
    margin-top: 6px;
    font-size: 8.5px;
    letter-spacing: 0.12em;
  }

  .timer-name {
    margin-bottom: 16px;
    font-size: 13px;
  }

  .quote-overlay {
    padding: 12px;
  }

  .quote-card {
    max-height: calc(100dvh - 24px);
    padding: 18px 22px;
  }

  .quote-card::before {
    margin-bottom: 12px;
  }

  .quote-card p {
    font-size: 14px;
    line-height: 1.75;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .timer-stage {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }

  .timer-panel {
    transition: opacity 0.01ms linear, visibility 0s;
  }

}
