/* Kids Timer - Task Scheduler Styles */
:root {
  --bg: #fff7ec;
  --face: #ffffff;
  --face-stroke: #e8d9b8;
  --tick: #b89d6f;
  --num: #5a4628;
  --primary: #2bb673;
  --primary-dark: #1f8a57;
  --secondary: #f0c419;
  --secondary-dark: #c89d10;
  --neutral: #ece4d3;
  --neutral-dark: #c8bfa6;
  --text: #3a2c14;
  --shadow: 0 4px 14px rgba(60, 40, 10, 0.12);
  --danger: #e74c3c;
  --danger-dark: #c0392b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Comic Sans MS", "Chalkboard SE", "Quicksand",
               -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ---------- Mode Switch ---------- */
.mode-switch {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 100;
  display: flex;
  gap: 0.25rem;
}

.mode-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.25rem;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.mode-btn:hover { opacity: 1; transform: scale(1.1); }
.mode-btn:active { transform: scale(0.93); }

/* Hide the button for the mode you're already on */
.mode-btn.active { display: none; }

/* ---------- Sections ---------- */
.section {
  display: none;
  padding: 1rem;
  min-height: 100dvh;
}

.section.active {
  display: block;
}

/* ---------- Admin Section ---------- */
.admin-container {
  max-width: 800px;
  margin: 0 auto;
}

.admin-container h1 {
  text-align: center;
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
}

.hint {
  text-align: center;
  color: var(--num);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
}

#taskTable {
  width: 100%;
  border-collapse: collapse;
  background: var(--face);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

#taskTable th,
#taskTable td {
  padding: 0.75rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--neutral);
}

#taskTable th {
  background: var(--neutral);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#taskTable td {
  vertical-align: middle;
}

/* Input fields in table */
.task-input {
  width: 100%;
  padding: 0.5rem;
  border: 2px solid var(--neutral-dark);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
}

.task-input:focus {
  outline: none;
  border-color: var(--primary);
}

.task-input.name { max-width: 120px; }
.task-input.emoji { width: 50px; text-align: center; font-size: 1.5rem; }
.task-input.time { width: 120px; text-align: center; }

/* Color picker */
.color-select {
  width: 40px;
  height: 40px;
  border: 2px solid var(--neutral-dark);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}

/* Delete button */
.delete-btn {
  padding: 0.5rem 0.75rem;
  background: var(--danger);
  color: white;
  border-radius: 8px;
  font-size: 1rem;
  transition: background 0.15s ease;
}

.delete-btn:hover { background: var(--danger-dark); }

/* Add task button */
.add-btn {
  display: block;
  width: 100%;
  padding: 1rem;
  background: var(--neutral);
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  transition: background 0.15s ease;
}

.add-btn:hover { background: var(--neutral-dark); }

/* Action buttons */
.actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.primary-btn, .secondary-btn {
  padding: 0.9rem 1.5rem;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, background 0.15s ease;
}

.primary-btn {
  background: var(--primary);
  color: white;
}

.primary-btn:hover { background: var(--primary-dark); }

.secondary-btn {
  background: var(--face);
  border: 2px solid var(--neutral-dark);
}

.secondary-btn:hover { background: var(--neutral); }

.primary-btn:active, .secondary-btn:active {
  transform: scale(0.97);
}

/* Share URL section */
.share-url {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--face);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.share-url.hidden { display: none; }

.share-url p {
  margin: 0 0 0.5rem;
  font-weight: 700;
}

.share-url input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--neutral-dark);
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.copy-btn {
  padding: 0.5rem 1rem;
  background: var(--secondary);
  color: var(--text);
  border-radius: 8px;
  font-weight: 700;
}

.copy-btn:hover { background: var(--secondary-dark); }

/* ---------- Visualization Section ---------- */
.visual-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  overflow: hidden;
  gap: 0.5rem;
  padding: 0.5rem;
}

.clock-display {
  /* fit smaller viewport dimension; reserve space for task info below */
  width: min(90vmin, calc(100dvh - 9rem));
  max-width: none;
  aspect-ratio: 1;
  flex-shrink: 0;
}

#clock {
  width: 100%;
  height: 100%;
  filter: drop-shadow(var(--shadow));
}

.clock-face {
  fill: var(--face);
  stroke: var(--face-stroke);
  stroke-width: 4;
}

.clock-numbers text {
  fill: var(--num);
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.clock-ticks line {
  stroke: var(--tick);
  stroke-linecap: round;
}

.clock-ticks .major { stroke-width: 2.5; }
.clock-ticks .minor { stroke-width: 1; }

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

.hour-hand {
  stroke-width: 5;
}

.minute-hand {
  stroke-width: 3;
}

.center-dot {
  fill: var(--text);
}

/* Task arc */
.task-arc {
  fill-opacity: 0.7;
  stroke-width: 0;
  transition: fill-opacity 0.3s ease;
}

.task-arc.active {
  fill-opacity: 1;
}

.arc-emoji {
  font-size: 16px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* Current task display */
.current-task {
  text-align: center;
}

.task-emoji {
  display: block;
  font-size: 4rem;
  line-height: 1;
}

.task-name {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .mode-btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }
  
  #taskTable th,
  #taskTable td {
    padding: 0.5rem 0.3rem;
  }
  
  .task-input.name { max-width: 80px; }
  .task-input.emoji { width: 40px; }
  .task-input.time { width: 95px; }
  
  .task-emoji { font-size: 3rem; }
  .task-name { font-size: 1.2rem; }
  .digital-time { font-size: 1.5rem; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
