/* ================================================================
   שעון משניות — עיצוב
   ================================================================ */

:root {
  --bg-deep: #0a0f1e;
  --bg-card: #0f172a;
  --bg-card-2: #131c2f;
  --border: #1e293b;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --gold: #fbbf24;
  --gold-soft: #fcd34d;
  --blue: #60a5fa;
  --green: #22c55e;
  --green-soft: #4ade80;
  --red: #ef4444;
  --red-soft: #fca5a5;
  --yellow: #facc15;
  --orange: #f97316;

  --shadow-glow: 0 0 28px rgba(251, 191, 36, 0.15);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  background:
    radial-gradient(ellipse at top, #15203d 0%, transparent 60%),
    radial-gradient(ellipse at bottom right, #1f1a3a 0%, transparent 60%),
    var(--bg-deep);
  color: var(--text);
  font-family: 'Heebo', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  direction: rtl;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ---------------- Header ---------------- */
.masthead {
  text-align: center;
  margin-bottom: 36px;
}
.dedication {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 18px;
  color: var(--gold-soft);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.masthead h1 {
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 900;
  font-size: 44px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-soft) 50%, #f0e68c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 12px;
  text-shadow: 0 0 40px rgba(251, 191, 36, 0.2);
}
.date-range {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 18px;
  color: var(--text-dim);
}
.date-range .sep {
  margin: 0 12px;
  color: var(--gold);
}

/* ---------------- Clock ---------------- */
.clock-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 24px 0 40px;
}

.clock-wrap {
  width: min(420px, 90vw);
  aspect-ratio: 1 / 1;
  position: relative;
  filter: drop-shadow(var(--shadow-glow));
}

#clock {
  width: 100%;
  height: 100%;
}

/* hand rotations applied by JS via transform; CSS only the transition */
#timeHand, #mishnaHand {
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: 0 0;
}

#monthLabels text {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 14px;
  fill: var(--text-dim);
  text-anchor: middle;
  dominant-baseline: middle;
}

#ticks line {
  stroke: var(--text-faint);
}

.legend {
  margin-top: 18px;
  display: flex;
  gap: 24px;
  font-size: 14px;
  color: var(--text-dim);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.dot.blue { background: var(--blue); box-shadow: 0 0 12px var(--blue); }
.dot.gold { background: var(--gold); box-shadow: 0 0 12px var(--gold); }

/* ---------------- Stats ---------------- */
.stats-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 36px;
}

.stat-card {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-card-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}
.stat-card:hover { border-color: rgba(251, 191, 36, 0.3); }

.stat-label {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}
.stat-value {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 6px;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-dim);
}

/* Status card colored by state */
.status-card[data-state="ahead"] {
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.12), rgba(34, 197, 94, 0.04));
  border-color: rgba(34, 197, 94, 0.4);
}
.status-card[data-state="ahead"] .stat-value { color: var(--green-soft); }

.status-card[data-state="behind"] {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.04));
  border-color: rgba(239, 68, 68, 0.4);
}
.status-card[data-state="behind"] .stat-value { color: var(--red-soft); }

.status-card[data-state="onpace"] {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.12), rgba(250, 204, 21, 0.03));
  border-color: rgba(250, 204, 21, 0.4);
}
.status-card[data-state="onpace"] .stat-value { color: var(--yellow); }

/* ---------------- Controls ---------------- */
.controls-section {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-card-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow-card);
}

.controls-section h2 {
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--gold-soft);
  margin: 0;
}

.hint {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 20px;
  line-height: 1.6;
}

/* ---------------- Picker (4 cascading dropdowns + checkboxes) ---------------- */
.picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.picker-row {
  display: grid;
  grid-template-columns: 70px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.picker-row:hover { border-color: rgba(251, 191, 36, 0.25); }
.picker-row[data-fully-done="true"] {
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.08), rgba(34, 197, 94, 0.02));
  border-color: rgba(34, 197, 94, 0.3);
}

.picker-label {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 16px;
  color: var(--gold-soft);
  font-weight: 700;
}

.picker-select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  text-align: right;
  transition: var(--transition);
  min-width: 0;
  width: 100%;
}
.picker-select:hover { border-color: rgba(251, 191, 36, 0.4); }
.picker-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.15);
}

.cb-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.cb-wrap:hover {
  background: rgba(251, 191, 36, 0.06);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--text);
}
.cb-level {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--gold);
  flex-shrink: 0;
}

.picker-count {
  font-size: 12px;
  color: var(--text-faint);
  font-family: 'Heebo', sans-serif;
  white-space: nowrap;
  min-width: 80px;
  text-align: left;
}
.picker-count.complete { color: var(--green-soft); font-weight: 700; }
.picker-count.partial  { color: var(--gold); font-weight: 500; }

@media (max-width: 640px) {
  .picker-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .cb-wrap { justify-content: center; }
  .picker-count { text-align: center; }
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.action-row.secondary-row {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.btn {
  flex: 1;
  min-width: 110px;
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition);
}
.btn:hover {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.08);
}
.btn.primary {
  background: linear-gradient(135deg, var(--gold) 0%, #e2a838 100%);
  color: #1a1505;
  border-color: var(--gold);
  font-weight: 700;
}
.btn.primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 20px rgba(251, 191, 36, 0.3);
}
.btn.ghost {
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
}
.btn.ghost:hover { color: var(--text); }


/* ---------------- Footer ---------------- */
footer {
  margin-top: 48px;
  text-align: center;
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 14px;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}

/* ---------------- Mobile ---------------- */
@media (max-width: 640px) {
  .page { padding: 20px 14px 48px; }
  .masthead h1 { font-size: 34px; }
  .dedication { font-size: 16px; }
  .date-range { font-size: 15px; }
  .stat-value { font-size: 24px; }
  .controls-section { padding: 20px 16px; }
  .btn { font-size: 14px; padding: 11px 12px; min-width: 90px; }
}
