/* Masjid Display - Logan UT */
/* TV-optimized, colors matched to Cache County Islamic Society logo */

:root {
  --bg-dark: #0a0f0a;
  --bg-card: rgba(26, 51, 37, 0.9);
  --accent-green: #3d6b4a;
  --accent-green-light: #5a8c6a;
  --accent-highlight: #b8d4a0;
  --accent-gold: #c9a227;
  --accent-gold-light: #e5c84a;
  --text-primary: #f5f7fa;
  --text-secondary: #a8c9a8;
  --border-subtle: rgba(61, 107, 74, 0.5);
  --border-gold: 2px solid var(--accent-gold);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* Background carousel */
.background-carousel {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.carousel-track {
  position: absolute;
  inset: 0;
  display: flex;
}

.carousel-track .slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.2s ease-in-out;
}

.carousel-track .slide.active {
  opacity: 1;
  z-index: 1;
}

/* Sidebar - clocks and weather (left side) */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 14rem;
  height: calc(100vh - 4rem);
  padding: 1.5rem;
  padding-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  background: rgba(10, 15, 10, 0.92);
  border-right: var(--border-gold);
  z-index: 15;
}

.clock-cards {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.digital-clock {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.5rem;
  background: linear-gradient(145deg, rgba(26, 51, 37, 0.95) 0%, rgba(15, 35, 25, 0.98) 100%);
  border-radius: 12px;
  border: var(--border-gold);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(201, 162, 39, 0.2);
}

.analogue-clock-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(145deg, rgba(26, 51, 37, 0.95) 0%, rgba(15, 35, 25, 0.98) 100%);
  border-radius: 12px;
  border: var(--border-gold);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(201, 162, 39, 0.2);
}

.analogue-clock-face {
  width: 9rem;
  height: 9rem;
}

.analogue-clock-circle {
  fill: none;
  stroke: var(--accent-gold);
  stroke-width: 2;
}

.analogue-clock-ticks line {
  stroke: var(--accent-gold);
  stroke-width: 1.5;
  opacity: 0.8;
}

.analogue-hand {
  stroke: var(--text-primary);
  stroke-linecap: round;
}

.analogue-hour-hand {
  stroke-width: 2.5;
  stroke: var(--accent-green-light);
}

.analogue-minute-hand {
  stroke-width: 1.5;
}

.analogue-second-hand {
  stroke-width: 1;
  stroke: var(--accent-highlight);
}

.analogue-clock-center {
  fill: var(--text-primary);
}

.digital-clock::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
  opacity: 0.5;
  border-radius: 12px 12px 0 0;
}

.clock-time {
  font-family: 'Share Tech Mono', 'Consolas', monospace;
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  font-weight: 400;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.clock-colon {
  opacity: 0;
  transition: opacity 0.1s ease;
}

.clock-colon.clock-colon--visible {
  opacity: 1;
}

.sidebar .weather {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem;
  background: linear-gradient(145deg, rgba(26, 51, 37, 0.95) 0%, rgba(15, 35, 25, 0.98) 100%);
  border-radius: 12px;
  border: var(--border-gold);
  width: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(201, 162, 39, 0.2);
  position: relative;
  overflow: hidden;
}

.sidebar .weather::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
  opacity: 0.6;
}

.weather-icon {
  font-size: clamp(2.5rem, 4vw, 3rem);
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.sidebar .weather-label {
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  font-weight: 600;
  color: var(--accent-gold-light);
  letter-spacing: 0.05em;
}

.sidebar .weather-temp {
  font-size: clamp(2rem, 3.5vw, 2.5rem);
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar .weather-desc {
  font-size: clamp(0.9rem, 1.4vw, 1rem);
  color: var(--text-secondary);
  padding: 0.2rem 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.qr-code {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: 8px;
  border: var(--border-gold);
  width: 100%;
}

.qr-code img {
  display: block;
  border-radius: 4px;
}

.qr-label {
  font-size: clamp(0.75rem, 1.2vw, 0.9rem);
  color: var(--text-secondary);
  text-align: center;
}

.overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(10, 15, 10, 0.75) 0%,
    rgba(10, 15, 10, 0.5) 40%,
    rgba(10, 15, 10, 0.6) 100%
  );
  z-index: 2;
}

/* Main content - fit within viewport, leave space for sidebar and announcement bar */
.content {
  position: relative;
  z-index: 10;
  height: calc(100vh - 4rem);
  margin-left: 14rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 2rem 0.75rem;
  overflow: hidden;
}

/* Header - compact */
.header {
  text-align: center;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.masjid-name {
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  font-weight: 700;
  color: var(--accent-gold-light);
  letter-spacing: 0.02em;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 2px 12px rgba(0, 0, 0, 0.8), 0 4px 20px rgba(0, 0, 0, 0.6);
}

.masjid-name-arabic {
  font-family: 'Amiri Quran', serif;
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  color: var(--accent-gold-light);
  direction: rtl;
  margin-top: 0.15rem;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 2px 12px rgba(0, 0, 0, 0.8), 0 4px 20px rgba(0, 0, 0, 0.6);
}

.location {
  font-size: clamp(1.1rem, 2.2vw, 1.35rem);
  color: var(--accent-green-light);
  font-weight: 500;
  margin-top: 0.15rem;
  padding: 0.25rem 0.75rem;
  background: rgba(10, 15, 10, 0.75);
  border-radius: 6px;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.95), 0 2px 8px rgba(0, 0, 0, 0.9);
}

.datetime {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.35rem;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  padding: 0.35rem 0.9rem;
  background: rgba(10, 15, 10, 0.75);
  border-radius: 8px;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.95), 0 2px 8px rgba(0, 0, 0, 0.9);
}

.hijri-date {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--accent-gold-light);
  font-weight: 600;
  display: block;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.95), 0 2px 8px rgba(0, 0, 0, 0.9);
}

/* Prayer times section */
.prayer-times {
  background: var(--bg-card);
  border: var(--border-gold);
  border-radius: 12px;
  padding: 1rem 2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.section-title {
  font-size: clamp(1.5rem, 2.8vw, 1.85rem);
  font-weight: 600;
  color: var(--accent-green-light);
  text-align: center;
  margin-bottom: 0.4rem;
  letter-spacing: 0.05em;
}

.next-prayer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 0.75rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.next-prayer-label {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  color: var(--text-secondary);
}

.next-prayer-name {
  font-size: clamp(1.25rem, 2.2vw, 1.5rem);
  font-weight: 600;
  color: var(--accent-highlight);
}

.next-prayer-countdown {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.prayer-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem 1rem;
  min-width: 500px;
}

.prayer-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1rem;
  background: rgba(61, 107, 74, 0.15);
  border-radius: 8px;
  border: 1px solid var(--accent-gold);
}

.prayer-card .prayer-name {
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.prayer-time-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  margin-bottom: 0.25rem;
}

.prayer-time-row:last-child {
  margin-bottom: 0;
}

.prayer-time-row .time-label {
  font-size: clamp(0.8rem, 1.4vw, 0.95rem);
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.prayer-card .prayer-time {
  font-size: clamp(1.5rem, 3vw, 1.95rem);
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Main announcement area - compact */
.main-announcement {
  margin-top: 0.5rem;
  text-align: center;
  flex-shrink: 0;
}

.main-announcement-text {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 600;
  color: var(--accent-highlight);
  background: var(--bg-card);
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  border: var(--border-gold);
  display: inline-block;
  box-shadow: var(--shadow);
}

/* Adhan overlay - full screen when prayer time */
.athan-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 15, 10, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.athan-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.athan-content {
  text-align: center;
  padding: 2rem;
}

.athan-prayer-name {
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 700;
  color: var(--accent-highlight);
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
}

.athan-verse {
  font-family: 'Amiri Quran', serif;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  color: var(--text-secondary);
  direction: rtl;
  margin-bottom: 1rem;
}

.athan-time {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2rem;
  font-variant-numeric: tabular-nums;
}

.athan-arabic {
  font-family: 'Amiri Quran', serif;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 600;
  color: var(--text-primary);
  direction: rtl;
  min-height: 3em;
  transition: opacity 0.6s ease;
}

.athan-arabic.fade {
  opacity: 0;
}

/* Content fade when Adhan is shown */
.content.athan-active .header,
.content.athan-active .prayer-times,
.content.athan-active .main-announcement {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.content .header,
.content .prayer-times,
.content .main-announcement {
  transition: opacity 0.8s ease;
}

/* Announcement bar */
.announcement-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4rem;
  background: linear-gradient(180deg, rgba(10, 15, 10, 0.95), rgba(10, 15, 10, 1));
  border-top: var(--border-gold);
  z-index: 20;
  overflow: hidden;
}

.ticker-wrap {
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.ticker {
  display: flex;
  align-items: center;
  white-space: nowrap;
  padding-left: 100%;
  /* Animation applied via JS for Safari compatibility */
}

.ticker span {
  display: inline-block;
  padding: 0 3rem;
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  color: var(--text-primary);
  font-weight: 500;
}

.ticker span::after {
  content: " • ";
  color: var(--accent-green-light);
  opacity: 0.7;
}

.ticker span:last-child::after {
  content: "";
}

/* Responsive adjustments for TV (typically 1920x1080 or similar) */
@media (max-width: 1200px) {
  .prayer-grid {
    grid-template-columns: repeat(3, 1fr);
    min-width: auto;
  }
}

/* Mobile-optimized layout - 1024px catches phones (incl. landscape) and tablets */
@media (max-width: 1024px) {
  html, body {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: manipulation;
  }

  /* Hide sidebar on mobile - !important for Safari */
  .sidebar {
    display: none !important;
  }

  /* Main content full width, scrollable */
  .content {
    margin-left: 0;
    margin-top: 0;
    height: auto;
    min-height: calc(100vh - 4rem);
    padding: 1rem;
    padding-bottom: calc(4rem + env(safe-area-inset-bottom));
    overflow: visible;
    justify-content: flex-start;
  }

  .header {
    margin-bottom: 1rem;
  }

  .masjid-name,
  .masjid-name-arabic {
    font-size: 1.5rem;
  }

  .location {
    font-size: 1rem;
  }

  .datetime {
    font-size: 0.95rem;
  }

  .hijri-date {
    font-size: 0.95rem;
  }

  .prayer-times {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    padding: 1rem;
    margin-bottom: 1rem;
    box-sizing: border-box;
  }

  .section-title {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
  }

  .next-prayer {
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
  }

  .next-prayer-label,
  .next-prayer-name,
  .next-prayer-countdown {
    font-size: 1.1rem;
  }

  .prayer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    min-width: auto;
  }

  .prayer-card {
    padding: 0.6rem 0.5rem;
    min-height: 4.5rem;
  }

  .prayer-card .prayer-name {
    font-size: 1.1rem;
  }

  .prayer-card .prayer-time {
    font-size: 1.35rem;
  }

  .prayer-time-row .time-label {
    font-size: 0.75rem;
  }

  .main-announcement {
    margin-top: 0.5rem;
  }

  .main-announcement-text {
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
  }

  /* Announcement bar - safe area for home indicator */
  .announcement-bar {
    height: 3.5rem;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .ticker span {
    font-size: 1rem;
    padding: 0 1.5rem;
  }

  /* Adhan overlay - compact on mobile */
  .athan-content {
    padding: 1.5rem;
  }

  .athan-prayer-name {
    font-size: 2rem;
  }

  .athan-verse {
    font-size: 1rem;
  }

  .athan-time {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .athan-arabic {
    font-size: 1.25rem;
  }
}

/* Extra small phones - single column prayer grid */
@media (max-width: 400px) {
  .prayer-grid {
    grid-template-columns: 1fr;
  }
}
