/* Grace Flow — Stage & Projection Screen Stylesheet */

:root {
  --stage-bg: #0b0d19;
  --text-main: #ffffff;
  --text-muted: #94a3b8;
  --color-green: #10b981;
  --color-amber: #f59e0b;
  --color-red: #ef4444;
  --color-alert: #ff0033;
  --color-purple: #9d5cf7;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--stage-bg);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  user-select: none;
}

/* Transparent mode for OBS / vMix Browser Source Overlay */
body.transparent-mode {
  background-color: transparent !important;
}

/* ================= PERIMETER WARNING BORDER ================= */
.perimeter-border {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  border-width: 18px;
  border-style: solid;
  border-color: transparent;
  transition: border-color 0.8s ease, box-shadow 0.8s ease;
}

.border-green {
  border-color: var(--color-green);
  box-shadow: inset 0 0 35px rgba(16, 185, 129, 0.65), 0 0 20px rgba(16, 185, 129, 0.4);
}

.border-amber {
  border-color: var(--color-amber);
  box-shadow: inset 0 0 45px rgba(245, 158, 11, 0.75), 0 0 25px rgba(245, 158, 11, 0.5);
}

.border-red {
  border-color: var(--color-red);
  box-shadow: inset 0 0 60px rgba(239, 68, 68, 0.85), 0 0 35px rgba(239, 68, 68, 0.6);
}

.border-times-up {
  border-color: var(--color-alert);
  box-shadow: inset 0 0 90px rgba(255, 0, 51, 1), 0 0 50px rgba(255, 0, 51, 0.8);
  animation: flashBorder 0.7s infinite alternate;
}

@keyframes flashBorder {
  0% {
    border-color: #ff0033;
    box-shadow: inset 0 0 90px rgba(255, 0, 51, 1);
  }
  100% {
    border-color: rgba(255, 0, 51, 0.2);
    box-shadow: inset 0 0 20px rgba(255, 0, 51, 0.2);
  }
}

/* ================= STAGE VIEWPORT ================= */
.stage-viewport {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 3vh 4vw;
  position: relative;
  z-index: 10;
}

/* Stage Header / Active Item */
.stage-header {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
}

.stage-header.hidden-header,
body.mode-analog .stage-header,
body.mode-analog .stage-footer {
  display: none !important;
}

.stage-title-badge {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 28px;
  border-radius: 30px;
  font-size: clamp(1rem, 2.5vw, 1.8rem);
  font-weight: 700;
  letter-spacing: 1px;
  color: #e2e8f0;
  text-transform: uppercase;
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Stage Center Content */
.stage-center-content {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.view-panel {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

.view-panel.active {
  display: flex;
}

/* ================= 1. DIGITAL VIEW ================= */
.digital-digits {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "SF Mono", monospace;
  font-size: clamp(7rem, 24vw, 24rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
  color: #ffffff;
  text-shadow: 0 0 45px rgba(255, 255, 255, 0.3);
  font-variant-numeric: tabular-nums;
}

.digits-green { color: #ffffff; text-shadow: 0 0 35px rgba(16, 185, 129, 0.5); }
.digits-amber { color: #fbbf24; text-shadow: 0 0 40px rgba(245, 158, 11, 0.6); }
.digits-red   { color: #f87171; text-shadow: 0 0 50px rgba(239, 68, 68, 0.7); }

/* ================= 2. ANALOG / CIRCULAR RING VIEW (MATCHING USER IMAGE 1) ================= */
.circular-countdown-wrapper {
  position: relative;
  width: min(82vh, 82vw);
  height: min(82vh, 82vw);
  max-width: 86vw;
  max-height: 86vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: auto;
  container-type: inline-size;
}

.circular-countdown-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg); /* Start at 12 o'clock (top) */
}

.ring-track {
  fill: none;
  stroke: rgba(139, 92, 246, 0.16);
  stroke-width: 13;
}

.ring-progress {
  fill: none;
  stroke-width: 15;
  stroke-linecap: round;
  stroke-dasharray: 1350.88;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.8s ease, stroke 0.5s ease;
}

.ring-purple {
  stroke: #9d5cf7;
  filter: drop-shadow(0 0 16px rgba(157, 92, 247, 0.85));
}

.ring-amber {
  stroke: #f59e0b;
  filter: drop-shadow(0 0 18px rgba(245, 158, 11, 0.85));
}

.ring-red {
  stroke: #ef4444;
  filter: drop-shadow(0 0 22px rgba(239, 68, 68, 0.95));
}

.ring-center-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 0 14%;
  box-sizing: border-box;
}

.ring-digits {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: clamp(1.2rem, 14.5vh, 8.5rem);
  font-size: 18cqi;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.03em;
  color: #ffffff;
  text-shadow: 0 0 35px rgba(255, 255, 255, 0.45);
  font-variant-numeric: tabular-nums;
  text-align: center;
  max-width: 76%;
  white-space: nowrap;
}

.ring-digits.digits-long {
  font-size: clamp(0.9rem, 10.5vh, 6rem);
  font-size: 13cqi;
  max-width: 80%;
}

.ring-subtitle {
  font-size: clamp(0.55rem, 2.5vh, 1.6rem);
  font-size: 3.5cqi;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-top: 8px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  max-width: 66%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

/* Mirror Preview Mode in Operator Panel */
body.preview-mode .perimeter-border {
  border-width: 6px !important;
}

body.preview-mode .stage-viewport {
  padding: 6px 8px !important;
}

body.preview-mode .circular-countdown-wrapper {
  width: min(80vh, 80vw) !important;
  height: min(80vh, 80vw) !important;
  max-width: 84vw !important;
  max-height: 84vh !important;
}

body.preview-mode .ring-digits {
  font-size: clamp(0.9rem, 14vh, 3.5rem) !important;
  font-size: 18cqi !important;
  max-width: 74% !important;
}

body.preview-mode .ring-digits.digits-long {
  font-size: clamp(0.7rem, 10vh, 2.6rem) !important;
  font-size: 13cqi !important;
  max-width: 78% !important;
}

body.preview-mode .ring-subtitle {
  font-size: clamp(0.45rem, 2.4vh, 0.8rem) !important;
  font-size: 3.4cqi !important;
  letter-spacing: 0.14em !important;
  margin-top: 4px !important;
  max-width: 64% !important;
}

/* ================= 3. NORMAL CLOCK TIME VIEW ================= */
.clock-time-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.wall-clock-digits {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  font-size: clamp(6rem, 20vw, 20rem);
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 0 35px rgba(255, 255, 255, 0.3);
}

.wall-clock-ampm {
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 800;
  color: #818cf8;
  letter-spacing: 2px;
}

.wall-clock-date {
  font-size: clamp(1.2rem, 2.5vw, 2rem);
  color: var(--text-muted);
  font-weight: 600;
}

/* ================= TIME'S UP ALERT BANNER ================= */
.times-up-banner {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.times-up-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  animation: pulseTimesUp 0.8s infinite alternate;
}

.times-up-icon {
  font-size: clamp(4rem, 10vw, 9rem);
}

.times-up-text {
  font-size: clamp(4rem, 14vw, 13rem);
  font-weight: 950;
  letter-spacing: 4px;
  color: #ff0033;
  text-shadow: 0 0 50px rgba(255, 0, 51, 0.9), 0 0 100px rgba(255, 0, 51, 0.6);
  text-transform: uppercase;
}

@keyframes pulseTimesUp {
  0% { transform: scale(0.96); }
  100% { transform: scale(1.04); }
}

/* ================= STAGE MESSAGE / ALERT OVERLAY ================= */
.stage-message-overlay {
  position: absolute;
  bottom: 8%;
  max-width: 90%;
  z-index: 60;
  animation: slideUpMsg 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.stage-message-box {
  background: rgba(15, 23, 42, 0.92);
  border: 3px solid #f59e0b;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(245, 158, 11, 0.4);
  backdrop-filter: blur(12px);
  padding: 18px 36px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.msg-bell-icon {
  font-size: clamp(2rem, 4vw, 3.5rem);
  filter: drop-shadow(0 0 10px #f59e0b);
}

.stage-message-text {
  font-size: clamp(1.8rem, 4vw, 3.8rem);
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}

.stage-message-overlay.flash-pulse {
  animation: flashMsg 0.8s infinite alternate cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes flashMsg {
  0% { transform: scale(0.98); filter: brightness(0.9); }
  100% { transform: scale(1.03); filter: brightness(1.2); }
}

@keyframes slideUpMsg {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Stage Footer */
.stage-footer {
  width: 100%;
  min-height: 10px;
}

/* Fullscreen floating button */
.fs-toggle-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0.15;
  transition: opacity 0.3s ease;
}

.fs-toggle-btn:hover {
  opacity: 1;
  background: rgba(30, 41, 59, 0.9);
}

/* Blackout State */
body.blackout .stage-center-content,
body.blackout .stage-header,
body.blackout .stage-footer,
body.blackout .perimeter-border {
  opacity: 0 !important;
  visibility: hidden !important;
}

.hidden {
  display: none !important;
}
