/* ═══════════════════════════════════════════════════════════════
   main.css
   ═══════════════════════════════════════════════════════════════ */

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ══════════════════════════════════════
   § 1  CSS CUSTOM PROPERTIES (TOKENS)
   ══════════════════════════════════════ */
:root {
  --bg1:              #e9eef5;
  --bg2:              #cfd9e6;
  --card-bg:          rgba(255,255,255,0.38);
  --card-border:      rgba(255,255,255,0.6);
  --text:             #1a1a2e;
  --text-muted:       #666;
  --accent:           #007aff;
  --accent-text:      #ffffff;
  --accent-text-dark: #0053ad;
  --btn-secondary-bg: rgba(0,0,0,0.07);
  --btn-secondary-text: #1a1a2e;
  --card-shadow:      0 20px 50px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  --card-opacity:     1;
  --anim-speed-factor: 1;
  --anim-duration-factor: 1;
  --anim-intensity: 1;
  --surface-glow: rgba(255,255,255,0.11);
  --surface-glow-2: rgba(255,255,255,0.05);
  --fx1: #8db7ff;
  --fx2: #ffffff;
  --fx3: #c4d6f4;
  --fx-before-static-opacity: .9;
  --fx-after-static-opacity: .18;
  --browser-nav-offset: 46px;
  --ui-zoom-factor: 1;
}

/* ══════════════════════════════════════
   § 2  BASE / BODY
   ══════════════════════════════════════ */
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
}

/* index.html body */
body.clock-body {
  overflow: hidden;
  min-height: 100vh;
  font-family: 'DM Sans', sans-serif;
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  display: grid;
  place-items: center;
  transition: background 0.6s ease;
  padding: 2%;
  position: relative;
  isolation: isolate;
}
body.clock-body::before,
body.clock-body::after {
  content: '';
  position: fixed;
  inset: -18%;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.35s ease;
}
body.clock-body::before {
  background:
    radial-gradient(circle at 14% 18%, color-mix(in srgb, var(--fx1) 34%, transparent) 0%, transparent 30%),
    radial-gradient(circle at 82% 20%, color-mix(in srgb, var(--fx2) 30%, transparent) 0%, transparent 36%),
    radial-gradient(circle at 50% 76%, color-mix(in srgb, var(--fx3) 32%, transparent) 0%, transparent 42%),
    radial-gradient(circle at 24% 84%, color-mix(in srgb, var(--fx1) 18%, transparent) 0%, transparent 28%);
  filter: blur(40px) saturate(calc(1.12 + (var(--anim-intensity) - 1) * .42));
}
body.clock-body::after {
  background:
    linear-gradient(118deg,
      transparent 0%,
      color-mix(in srgb, var(--fx2) 18%, transparent) 16%,
      transparent 34%,
      color-mix(in srgb, var(--fx1) 22%, transparent) 54%,
      transparent 74%,
      color-mix(in srgb, var(--fx3) 16%, transparent) 92%,
      transparent 100%),
    radial-gradient(circle at 68% 34%, color-mix(in srgb, var(--fx3) 16%, transparent) 0%, transparent 34%);
  filter: blur(26px) saturate(calc(1.08 + (var(--anim-intensity) - 1) * .30));
}
body.clock-body > * {
  position: relative;
  z-index: 1;
}
body.clock-body[data-theme-animation="soft"]::before {
  opacity: .9;
  animation: ambient-drift-soft calc(20s * var(--anim-duration-factor)) ease-in-out infinite alternate;
}
body.clock-body[data-theme-animation="aurora"]::before {
  opacity: .95;
  animation: aurora-sweep calc(14s * var(--anim-duration-factor)) linear infinite;
}
body.clock-body[data-theme-animation="pulse"]::before,
body.clock-body[data-theme-animation="pulse"]::after {
  opacity: .75;
  animation: glass-pulse calc(8.5s * var(--anim-duration-factor)) ease-in-out infinite;
}
body.clock-body[data-theme-animation="shimmer"]::before {
  opacity: .82;
  animation: ambient-drift calc(16s * var(--anim-duration-factor)) ease-in-out infinite alternate;
}
body.clock-body[data-theme-animation="shimmer"]::after {
  opacity: .45;
  animation: shimmer-sweep calc(10.5s * var(--anim-duration-factor)) ease-in-out infinite alternate;
}
body.clock-body.animations-disabled::before,
body.clock-body.anim-speed-zero::before {
  animation: none !important;
  opacity: var(--fx-before-static-opacity, .9) !important;
}
body.clock-body.animations-disabled::after,
body.clock-body.anim-speed-zero::after {
  animation: none !important;
  opacity: var(--fx-after-static-opacity, .18) !important;
}


/* ══════════════════════════════════════
   § 3  MAIN CLOCK CARD
   ══════════════════════════════════════ */
.main-card-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 320px;
  max-width: 100%;
  transform: scale(var(--ui-zoom-factor, 1));
  transform-origin: center center;
  transition: transform 0.22s ease;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(30px) saturate(1.4);
  -webkit-backdrop-filter: blur(30px) saturate(1.4);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  padding: 24px 22px 22px;
  width: 100%;
  max-width: 100%;
  text-align: center;
  box-shadow: var(--card-shadow);
  opacity: var(--card-opacity);
  transition: opacity 0.3s, transform 0.3s ease;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.07), transparent 26%, transparent 74%, rgba(255,255,255,0.04));
  opacity: .8;
}
.card > * { position: relative; z-index: 1; }

/* ── CLOCK ── */
.clock-wrap { margin: 10px 0 18px; }
#clock {
  font-family: inherit;
  font-size: 42px;
  font-weight: 300;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
}
#date-display {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── ALARM STATUS ── */
#alarm-status {
  font-size: 11px;
  color: var(--accent);
  min-height: 16px;
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: 0.03em;
  transition: opacity 0.3s;
}

/* ── Alarm mode note ── */
.alarm-mode-note {
  min-height: 30px;
  margin: 0 0 8px;
  font-size: 10px;
  line-height: 1.35;
  letter-spacing: 0.02em;
}
.alarm-mode-note.warning { color: #b35b00; }
.alarm-mode-note.ok { color: #2b7a2b; }

/* ── TIME INPUT ── */
.input-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
input[type="time"] {
  width: min(170px, 100%);
  background: rgba(0,122,255,0.10);
  border: 1.5px solid rgba(0,122,255,0.2);
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
input[type="time"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit-fields-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
}
input[type="time"]:focus { border-color: var(--accent); }

/* ══════════════════════════════════════
   § 4  BUTTONS (SHARED)
   ══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  transition: transform 0.12s, opacity 0.2s, background 0.3s;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  padding: 11px 22px;
  width: 100%;
  margin-top: 12px;
  font-size: 15px;
}
.btn-primary.armed {
  background: #ff3b30;
  color: #fff;
}
.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  padding: 9px 16px;
  font-size: 12px;
  margin-top: 8px;
  width: 100%;
}

/* ── DIVIDER ── */
.divider {
  height: 1px;
  background: rgba(0,0,0,0.08);
  margin: 16px 0;
}



@keyframes ambient-drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1); }
  50%  { transform: translate3d(1.5%, 2%, 0) scale(calc(1.02 + (var(--anim-intensity) - 1) * .02)); }
  100% { transform: translate3d(2.5%, -2%, 0) scale(calc(1.045 + (var(--anim-intensity) - 1) * .04)); }
}
@keyframes ambient-drift-soft {
  0%   { transform: translate3d(-8%, -4.5%, 0) scale(1); }
  33%  { transform: translate3d(4.5%, 5.5%, 0) scale(calc(1.03 + (var(--anim-intensity) - 1) * .03)); }
  66%  { transform: translate3d(9%, -3.5%, 0) scale(calc(1.065 + (var(--anim-intensity) - 1) * .05)); }
  100% { transform: translate3d(-5.5%, 6%, 0) scale(calc(1.05 + (var(--anim-intensity) - 1) * .04)); }
}
@keyframes aurora-sweep {
  0%   { transform: translateX(-10%) rotate(0deg) scale(1); }
  50%  { transform: translateX(8%) rotate(6deg) scale(calc(1.03 + (var(--anim-intensity) - 1) * .03)); }
  100% { transform: translateX(-6%) rotate(-5deg) scale(1.02); }
}
@keyframes glass-pulse {
  0%, 100% { transform: scale(1); opacity: .5; }
  50%      { transform: scale(calc(1.055 + (var(--anim-intensity) - 1) * .04)); opacity: .88; }
}
@keyframes shimmer-sweep {
  0%   { transform: translate3d(-20%, 0, 0) skewX(-10deg) scaleX(0.98); opacity: .32; }
  50%  { transform: translate3d(0%, 0, 0) skewX(-9deg) scaleX(1.02); opacity: .46; }
  100% { transform: translate3d(20%, 0, 0) skewX(-10deg) scaleX(0.98); opacity: .32; }
}

/* ══════════════════════════════════════
   § 9  ALARM RINGING STATE
   ══════════════════════════════════════ */
@keyframes ring-pulse {
  0%, 100% { box-shadow: 0 20px 50px rgba(255,59,48,0.3),  0 2px 8px rgba(0,0,0,0.08); }
  50%       { box-shadow: 0 20px 60px rgba(255,59,48,0.55), 0 2px 8px rgba(0,0,0,0.08); }
}
.card.ringing { animation: ring-pulse 1s ease-in-out infinite; }

/* ══════════════════════════════════════
   § 10  CUSTOM TITLEBAR (desktop-only styles moved to /electron/titlebar.css)
   ══════════════════════════════════════ */
#titlebar { display: none; }

/* ══════════════════════════════════════
   § 11  TOAST
   ══════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a2e;
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
  z-index: 999;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════
   § 12  MISC HELPERS
   ══════════════════════════════════════ */
.dark-text { --text: #f0f0f0; --text-muted: rgba(255,255,255,0.5); }

@media (max-width: 280px) {
  .theme-grid { grid-template-columns: repeat(3, 1fr); }
  .btn-preview-row { flex-direction: column; }
}

body.native-app #browser-nav { display: none !important; }
body.native-app.clock-body { padding-top: 16px !important; }

/* ── Native-app transparent window ────────────────────────────────────────────
   Remove the gradient background entirely so the OS compositor shows the
   desktop through the window.  The card's own border-radius becomes the
   effective "window shape" — matching its glass corners automatically.     */
body.native-app.clock-body {
  background: transparent;
}

/* Slightly stronger shadow so the floating card reads well over any desktop */
body.native-app .card {
  box-shadow: 0 24px 60px rgba(0,0,0,0.38), 0 4px 14px rgba(0,0,0,0.18);
}
/* ── Wake from Sleep button ── */
.wake-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(0,0,0,0.10);
  background: rgba(0,0,0,0.04);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  margin-top: 4px;
}
.wake-btn:hover { background: rgba(0,0,0,0.08); }
.wake-btn:active { transform: scale(0.985); }
.wake-btn:disabled { opacity: 0.55; cursor: default; transform: none; }

.wake-btn--active {
  border-color: rgba(52,199,89,0.45);
  background: rgba(52,199,89,0.07);
}
.wake-btn--active:hover { background: rgba(52,199,89,0.12); }

.wake-btn--inactive {
  border-color: rgba(255,59,48,0.35);
  background: rgba(255,59,48,0.05);
}
.wake-btn--inactive:hover { background: rgba(255,59,48,0.10); }

.wake-btn--loading {
  border-color: rgba(0,0,0,0.10);
  background: rgba(0,0,0,0.04);
}

.wake-btn-os {
  font-size: 12px;
  font-weight: 500;
  color: #1a1a2e;           /* hardcoded: settings card is always light */
  display: flex;
  align-items: center;
  gap: 5px;
}

.wake-btn-status {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.wake-btn--active   .wake-btn-status { color: #1d9e3e; }
.wake-btn--inactive .wake-btn-status { color: #cc3333; }
.wake-btn--loading  .wake-btn-status { color: #888; }


/* ── Window Opacity slider ── */
.opacity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  gap: 12px;
}
.opacity-row:last-child { border-bottom: none; }
.opacity-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
}
.opacity-value {
  font-size: 12px;
  color: var(--accent-text-dark, var(--accent, #007aff));
  min-width: 40px;
  text-align: right;
  font-weight: 600;
}


/* ══════════════════════════════════════
   § 13  RESPONSIVE / SMALL RESOLUTION TUNING
   ══════════════════════════════════════ */
.setting-group--compact { margin-top: 12px; }




@media (max-width: 560px) {
  body.clock-body {
    padding: 14px;
  }
  .card {
    max-width: 300px;
  }
}

@media (max-width: 420px) {
  body.clock-body {
    padding: 10px;
  }
  .card {
    border-radius: 24px;
    padding: 18px 16px 16px;
    max-width: 296px;
  }
  .clock-wrap { margin: 8px 0 14px; }
  #date-display { font-size: 10px; }
  .divider { margin: 14px 0; }
  .btn-primary { margin-top: 10px; }
  .btn-secondary { margin-top: 6px; }
}

@media (max-width: 360px) {
  .card {
    max-width: 286px;
    border-radius: 22px;
    padding: 16px 14px 14px;
  }
  .clock-wrap { margin: 8px 0 12px; }
  #alarm-status { margin-bottom: 6px; }
  input[type="time"] {
    padding: 8px 10px;
    font-size: 14px;
    width: 100%;
    max-width: 156px;
  }
  .btn-primary {
    padding: 10px 18px;
    font-size: 14px;
  }
  .btn-secondary {
    padding: 8px 14px;
    font-size: 12px;
  }
}

@media (max-width: 320px) {
  .card {
    max-width: 272px;
    padding: 14px 12px 12px;
  }
  #clock { letter-spacing: -0.5px; }
  .toggle-label-text,
  .toggle-row > span {
    font-size: 12px;
  }
}
