/*
 * Stylesheet for the Silencing the Mind playground.  
 * The app provides controls to adjust the perceived mental noise,
 * a dark/light theme toggle, a guided breathing exercise and a set
 * of mindfulness tasks. The CSS utilises custom properties for
 * colours and animation speed so that JavaScript can update them
 * dynamically based on user interaction.  
 */

/* Root variables for colours and animation timing. These values
   adjust automatically when the data-theme attribute on the html
   element changes. */
:root {
  --color-background: #f7f9fc;
  --color-surface: #ffffff;
  --color-text: #202020;
  --color-muted: #666666;
  --color-accent: #5b7fff;
  --color-accent-muted: #859eff;
  /* Solid button colors chosen for readable (4.5:1+) labels */
  --color-button: #3f62e8;
  --color-button-hover: #2f50d0;
  --color-on-button: #ffffff;
  --color-link: #3f62e8;
  --animation-speed: 30s;
}

/* Dark theme overrides. */
[data-theme="dark"] {
  --color-background: #0f131a;
  --color-surface: #1d2533;
  --color-text: #e5eaf5;
  --color-muted: #8a92a5;
  --color-accent: #7c90f9;
  --color-accent-muted: #5a6bd3;
  --color-button: #7c90f9;
  --color-button-hover: #9fb0fb;
  --color-on-button: #0f131a;
  --color-link: #9fb0fb;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background: var(--color-background);
  color: var(--color-text);
  min-height: 100%;
  overflow-x: hidden;
}

/* Animated gradient background. A pseudo-element expands beyond the
   viewport and animates its background position. The speed of this
   animation is controlled via the --animation-speed custom property. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 200%;
  height: 200%;
  background: linear-gradient(60deg, var(--color-accent), var(--color-accent-muted), var(--color-accent));
  background-size: 300% 300%;
  z-index: -1;
  opacity: 0.25;
  animation: gradientMove var(--animation-speed) ease-in-out infinite;
}

@keyframes gradientMove {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

header h1 {
  margin: 0;
  font-size: 2.5rem;
  line-height: 1.2;
}

.tagline {
  margin-top: 0.5rem;
  font-size: 1.1rem;
  color: var(--color-muted);
}

/* Layout container for controls and sections. */
section {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
}

#controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
  align-items: center;
}

.slider-container,
.theme-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.slider-container label,
.theme-toggle label {
  font-size: 0.9rem;
  color: var(--color-muted);
}

/* Custom range slider styling. */
input[type="range"] {
  -webkit-appearance: none;
  width: 200px;
  height: 6px;
  border-radius: 3px;
  background: var(--color-surface);
  outline: none;
  transition: background 0.3s;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: background 0.3s;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Theme toggle styled as a switch. */
.theme-toggle {
  position: relative;
}

.theme-toggle label {
  margin-bottom: 0.5rem;
  display: block;
}

.theme-toggle input[type="checkbox"] {
  -webkit-appearance: none;
  width: 48px;
  height: 24px;
  background: var(--color-surface);
  border-radius: 12px;
  position: relative;
  outline: none;
  cursor: pointer;
  transition: background 0.3s;
}

.theme-toggle input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  transition: transform 0.3s;
}

.theme-toggle input[type="checkbox"]:checked {
  background: var(--color-accent-muted);
}

.theme-toggle input[type="checkbox"]:checked::before {
  transform: translateX(24px);
}

/* Breathing section styling */
#breathing {
  text-align: center;
}

#breathing-circle-container {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 1rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

#breathing-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-accent) 0%, var(--color-accent-muted) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(1);
  transition: transform 1s ease-in-out;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

#breathing-instructions {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.1rem;
  font-weight: 500;
  pointer-events: none;
  color: var(--color-surface);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.breathing-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}

.breathing-controls button {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: var(--color-button);
  color: var(--color-on-button);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  transition: background 0.3s, box-shadow 0.3s;
}

.breathing-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.breathing-controls button:not(:disabled):hover {
  background: var(--color-button-hover);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

/* Mindfulness tasks section */
#task-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.task-card {
  display: block;
  width: 100%;
  font: inherit;
  text-align: left;
  color: inherit;
  border: 0;
  background: var(--color-surface);
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.3s;
}

.task-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.task-card .task-title {
  display: block;
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
}

.task-card .task-desc {
  display: block;
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-muted);
  line-height: 1.4;
}

/* Reference section styling */
#reference p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text);
  text-align: center;
}

#reference a {
  color: var(--color-link);
  text-decoration: underline;
}

/* Modal overlay */
#modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.hidden {
  display: none !important;
}

.modal-content {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.4rem;
}

.modal-content p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--color-muted);
}

#modal-timer {
  margin: 1rem 0;
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--color-accent);
}

.modal-content button {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: var(--color-button);
  color: var(--color-on-button);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  transition: background 0.3s, box-shadow 0.3s;
}

.modal-content button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.modal-content button + button {
  margin-left: 0.5rem;
}

.modal-content button:not(:disabled):hover {
  background: var(--color-button-hover);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

/* On the light circle of the dark theme, plain dark ink reads best. */
[data-theme="dark"] #breathing-instructions {
  color: #0f131a;
  text-shadow: none;
}

/* Link back to the main site */
.home-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--color-muted);
  text-decoration: none;
}

.home-link:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

/* Visible keyboard focus everywhere (the switch removed the default outline) */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
  }

  .task-card,
  .task-card:hover {
    transition: none;
    transform: none;
  }
}
