/* ========================================
   KANZ. The Watch.
   A jeweled compass + timekeeper.
   ======================================== */

/* ================================================================
   FIRST RUN — before location is set
   ================================================================ */
.watch-first-run {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  animation: watch-fade 400ms ease both;
}

@keyframes watch-fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.watch-first-run__compass {
  margin: 0 auto var(--space-lg);
  opacity: 0.7;
}

.watch-first-run__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--text);
  margin: 0 0 var(--space-xs);
  font-weight: var(--weight-medium);
}

.watch-first-run__subtitle {
  font-size: var(--text-sm);
  color: var(--text-light);
  margin: 0 0 var(--space-xl);
  line-height: 1.6;
}

.watch-first-run__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 280px;
  margin: 0 auto;
}

.watch-first-run__footer {
  margin-top: var(--space-xl);
  font-size: var(--text-xs);
  color: var(--text-lighter);
  font-style: italic;
}


/* ================================================================
   TAB LAYOUT
   ================================================================ */
.watch {
  max-width: 560px;
  margin: 0 auto;
  /* No bottom padding — .main-content adds a small gap, footer follows.
     Previous padding plus main-content's old 126px buffer created a huge
     empty zone below Tahajjud. */
  padding: var(--space-md) var(--space-md) 0;
  animation: watch-fade 400ms ease both;
}

.watch__header {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.watch__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--aged-brass);
  letter-spacing: 0.04em;
  margin: 0;
  font-weight: var(--weight-medium);
}

.watch__city {
  font-size: var(--text-sm);
  color: var(--text-light);
  margin: 4px 0 0;
  font-style: italic;
}

/* Countdown sits directly under the city line — reads as watch-face info,
   not a footer block. */
.watch__countdown {
  margin: 10px 0 0;
  font-size: var(--text-xs);
  color: var(--text-lighter);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: var(--font-body);
}

.watch__countdown-label {
  color: var(--text-lighter);
}

.watch__countdown-timer {
  color: var(--aged-brass);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  margin-left: 4px;
}


/* ================================================================
   COMPASS
   ================================================================ */
.watch-compass {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0 auto var(--space-lg);
  text-align: center;
}

.watch-compass__ring {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  /* Subtle ambient lift — stays at this soft level, even when aligned.
     Alignment glow comes from .watch-compass__align-glow below, which is a
     circle-masked radial gradient (can't render as a square on any browser). */
  filter: drop-shadow(0 4px 20px rgba(168, 144, 80, 0.12));
}

/* Alignment halo — circle-masked radial gradient. Off by default.
   Lights up when the Kaaba pip meets the top wedge. */
.watch-compass__align-glow {
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(212, 176, 103, 0)   55%,
    rgba(212, 176, 103, 0.48) 72%,
    rgba(212, 176, 103, 0)   100%
  );
  opacity: 0;
  transition: opacity 280ms ease;
  pointer-events: none;
  z-index: 0;
}
.watch-compass__ring > svg {
  position: relative;
  z-index: 1;
}

.watch-compass--aligned .watch-compass__align-glow {
  opacity: 1;
}

/* Rotating SVG group — N/E/S/W + ticks + Kaaba pip all track real-world north.
   Short linear transition matches the sensor cadence (~30 Hz); longer
   transitions lag behind real motion. */
#watch-compass-rotating {
  transform-origin: 50% 50%;
  transform-box: view-box;
  transition: transform 110ms linear;
  will-change: transform;
}

/* Aligned state: brighten the fixed target elements. */
.watch-compass--aligned .watch-compass__top-wedge {
  fill: #d4b067;
  filter: drop-shadow(0 0 6px rgba(168, 144, 80, 0.9));
}
.watch-compass--aligned .watch-compass__qibla-mark rect:first-of-type {
  fill: #d4b067;
}

/* Fixed overlays breathe with the alignment state. */
.watch-compass__top-wedge {
  transition: fill 180ms ease, filter 220ms ease;
}
.watch-compass__qibla-mark rect {
  transition: fill 180ms ease;
}
.watch-compass__center-jewel path,
.watch-compass__center-jewel circle {
  transition: stroke 200ms ease, fill 200ms ease, opacity 200ms ease;
}

/* Aligned state also lifts the center jewel — soft catch-light pulse. */
.watch-compass--aligned .watch-compass__center-jewel path {
  stroke: #d4b067;
  opacity: 0.85;
}
.watch-compass--aligned .watch-compass__center-jewel circle {
  fill: #d4b067;
  opacity: 1;
}

/* Cardinal markers on the compass ring. SVG attributes don't resolve CSS
   variables — apply via CSS class instead. */
.watch-compass__marks text {
  fill: var(--aged-brass);
  opacity: 0.55;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.watch-compass__readout {
  margin-top: var(--space-sm);
}

.watch-compass__degree {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--aged-brass);
  letter-spacing: 0.03em;
  font-weight: var(--weight-medium);
}

.watch-compass__distance {
  font-size: var(--text-xs);
  color: var(--text-light);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

/* Live device-heading readout. Empty until a compass reading arrives. */
.watch-compass__heading {
  font-size: var(--text-xxs);
  color: var(--text-lighter);
  margin-top: 6px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  min-height: 14px;
}

.watch-compass__calibrate {
  margin-top: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--aged-brass);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(168, 144, 80, 0.3);
  text-underline-offset: 3px;
  opacity: 0.75;
  transition: opacity var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: 32px;
}

.watch-compass__calibrate:hover {
  opacity: 1;
}


/* ================================================================
   SETTINGS BUTTON (divider between compass and times)
   ================================================================ */
.watch-settings-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-md) var(--space-sm);
  margin: var(--space-md) 0;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-light);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.watch-settings-btn:hover {
  background: rgba(168, 144, 80, 0.04);
  color: var(--aged-brass);
}

.watch-settings-btn__label { font-weight: var(--weight-medium); }

.watch-settings-btn__chev {
  color: var(--aged-brass);
  opacity: 0.6;
  font-size: var(--text-lg);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.watch-settings-btn:hover .watch-settings-btn__chev {
  opacity: 1;
  transform: translateX(3px);
}


/* ================================================================
   PRAYER TIMES LIST
   ================================================================ */
.watch-times {
  display: flex;
  flex-direction: column;
}

.watch-time-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-md) var(--space-sm);
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-body);
  transition: background var(--transition-fast);
  min-height: 52px;
}

.watch-time-row:last-child { border-bottom: none; }

.watch-time-row__label {
  font-family: var(--font-display);
  font-size: var(--text-base);
  color: var(--text);
  letter-spacing: 0.02em;
  font-weight: var(--weight-normal);
}

.watch-time-row__time {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

/* Active (current) prayer */
.watch-time-row--active {
  background: linear-gradient(90deg, rgba(168, 144, 80, 0.08), transparent);
  border-left: 2px solid var(--aged-brass);
  padding-left: calc(var(--space-sm) - 2px);
}

.watch-time-row--active .watch-time-row__label,
.watch-time-row--active .watch-time-row__time {
  color: var(--aged-brass);
  font-weight: var(--weight-semibold);
}

/* Muted rows (midnight, tahajjud) */
.watch-time-row--muted .watch-time-row__label,
.watch-time-row--muted .watch-time-row__time {
  color: var(--text-lighter);
  font-style: italic;
}

.watch-times__divider {
  height: 1px;
  margin: var(--space-sm) var(--space-sm);
  background: linear-gradient(90deg, transparent, rgba(168, 144, 80, 0.25), transparent);
}


/* ================================================================
   BUTTONS
   ================================================================ */
.watch-btn {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  letter-spacing: 0.02em;
}

.watch-btn--primary {
  background: var(--aged-brass);
  border: 1px solid var(--aged-brass);
  color: #1c1917;
}

.watch-btn--primary:hover {
  background: #b89a5e;
  border-color: #b89a5e;
}

.watch-btn--ghost {
  background: transparent;
  border: 1px solid rgba(168, 144, 80, 0.35);
  color: var(--aged-brass);
}

.watch-btn--ghost:hover {
  background: rgba(168, 144, 80, 0.08);
  border-color: var(--aged-brass);
}


/* ================================================================
   SETTINGS DRAWER
   ================================================================ */
.watch-drawer {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(6, 5, 4, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.watch-drawer--open {
  opacity: 1;
  pointer-events: auto;
}

.watch-drawer__panel {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-bottom: none;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 250ms cubic-bezier(0.2, 0.8, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.watch-drawer--open .watch-drawer__panel {
  transform: translateY(0);
}

@media (min-width: 600px) {
  .watch-drawer {
    align-items: center;
  }
  .watch-drawer__panel {
    max-height: 82vh;
    border: 1px solid var(--border);
    border-radius: 16px;
  }
}

.watch-drawer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.watch-drawer__title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  color: var(--aged-brass);
  letter-spacing: 0.04em;
  font-weight: var(--weight-medium);
}

.watch-drawer__close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.watch-drawer__close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.watch-drawer__body {
  padding: var(--space-md) var(--space-lg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}


/* ================================================================
   DRAWER SECTIONS
   ================================================================ */
.watch-sec {
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-md) 0;
}

.watch-sec:last-child { border-bottom: none; }

.watch-sec--flat {
  /* always-visible sections (Location, Calculation) */
}

.watch-sec__flathead {
  margin-bottom: var(--space-sm);
}

.watch-sec__eyebrow {
  font-size: var(--text-xxs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--aged-brass);
  font-weight: var(--weight-semibold);
  display: block;
  margin-bottom: 2px;
}

.watch-sec__value {
  display: block;
  font-size: var(--text-sm);
  color: var(--text);
  font-family: var(--font-body);
}

/* Collapsible sections (Notifications, Display) */
.watch-sec__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 4px 0;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.watch-sec__title {
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--aged-brass);
  font-weight: var(--weight-semibold);
}

.watch-sec__chev {
  color: var(--aged-brass);
  opacity: 0.75;
  font-size: var(--text-base);
  transition: transform var(--transition-base);
}

.watch-sec--open .watch-sec__chev {
  transform: rotate(180deg);
}

.watch-sec__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms ease;
}

.watch-sec--open .watch-sec__body {
  max-height: 2000px;
  margin-top: var(--space-sm);
}

.watch-sec__group-title {
  font-size: var(--text-xxs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-light);
  margin: var(--space-md) 0 var(--space-xs);
  font-weight: var(--weight-semibold);
}

.watch-sec__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 8px 0;
  min-height: 40px;
}

.watch-sec__row--indent {
  padding-left: var(--space-md);
  border-left: 1px solid rgba(168, 144, 80, 0.15);
  margin-left: 4px;
}

.watch-sec__label {
  font-size: var(--text-sm);
  color: var(--text);
}

.watch-sec__actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-sm);
}

/* ---- Voice credit line (adhan attribution) ---- */
.watch-voice-credit {
  margin-top: 6px;
  padding-left: calc(var(--space-md) + 4px);
  font-size: var(--text-xxs);
  color: var(--text-lighter);
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

/* ---- City search (Nominatim) ---- */
.watch-city-search {
  margin-top: var(--space-sm);
  display: block;
}

.watch-city-search__input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--bg-aside);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  transition: border-color var(--transition-fast);
}

.watch-city-search__input:focus {
  outline: none;
  border-color: var(--aged-brass);
}

.watch-city-search__status {
  margin-top: var(--space-xs);
  min-height: 18px;
  font-size: var(--text-xs);
  color: var(--text-lighter);
  font-style: italic;
  letter-spacing: 0.02em;
}

.watch-city-search__results {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.watch-city-result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  min-height: 52px;
}

.watch-city-result:hover {
  border-color: var(--aged-brass);
  background: rgba(168, 144, 80, 0.06);
}

.watch-city-result__label {
  font-size: var(--text-sm);
  color: var(--text);
  line-height: 1.35;
}

.watch-city-result__coords {
  font-size: var(--text-xxs);
  color: var(--text-lighter);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}


/* ================================================================
   TOGGLE
   ================================================================ */
.watch-toggle {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  position: relative;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  padding: 0;
}

.watch-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #c8c0b8;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.watch-toggle--on {
  background: rgba(168, 144, 80, 0.35);
  border-color: var(--aged-brass);
}

.watch-toggle--on::after {
  transform: translateX(20px);
  background: var(--aged-brass);
}


/* ================================================================
   SELECT
   ================================================================ */
.watch-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg-aside);
  color: var(--text);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  max-width: 60%;
}


/* ================================================================
   RADIO
   ================================================================ */
.watch-sec__radios {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: var(--space-xs);
}

.watch-sec__radio {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-sm);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.watch-sec__radio input[type="radio"] {
  accent-color: var(--aged-brass);
  margin: 0;
}

.watch-sec__radio span {
  font-size: var(--text-sm);
  color: var(--text);
}

.watch-sec__radio--on {
  border-color: var(--aged-brass);
  background: rgba(168, 144, 80, 0.06);
}


/* ================================================================
   TOAST
   ================================================================ */
.watch-toast {
  position: fixed;
  /* Anchored at the TOP (below the site header) so it can never sit on top
     of the Settings & Location button or any compass UI. */
  top: calc(env(safe-area-inset-top, 0) + 64px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(48, 43, 39, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(168, 144, 80, 0.6);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  color: var(--text);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 250ms ease, transform 250ms ease;
  z-index: 500;
  max-width: 90vw;
  text-align: center;
}

.watch-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
