/* --- ZEN DESIGN SYSTEM --- */
:root {
  /* Default to Light Mode variables */
  --bg: #ffffff;
  --text: #111111;
  --subtle: #888888;
  --border: #eeeeee;
  --surface: #fafafa;
  --accent: #111111;
  --error: #ff3b30;
  --font-main: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --surface-rgb: 250, 250, 250;
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --text: #f0f0f0;
  --subtle: #888888;
  /* Slightly lighter for better contrast if needed, but keeping consistent for now */
  --border: #222222;
  --surface: #111111;
  --accent: #ffffff;
  --surface-rgb: 17, 17, 17;
}

/* System Preference Support (only if no theme is set, but JS will handle this mostly) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --text: #f0f0f0;
    --subtle: #888888;
    --border: #222222;
    --surface: #111111;
    --accent: #ffffff;
    --surface-rgb: 17, 17, 17;
  }
}

* {
  box-sizing: border-box;
  outline: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* justify-content: center;  <-- Removed to allow scrolling if needed, handled by flex layout */
  transition: background 0.5s ease, color 0.5s ease;
}

/* Typography */
h1 {
  font-weight: 300;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
}

h2 {
  font-weight: 400;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

p {
  color: var(--subtle);
  margin: 0 0 1rem 0;
  line-height: 1.6;
}

button {
  font-family: inherit;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

a:hover {
  color: var(--subtle);
}

/* Layout */
.zen-container {
  width: 100%;
  max-width: 1400px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 10;
  flex: 1;
  /* Push footer down */
  justify-content: flex-start;
  /* Align to top to reduce vertical scroll */
}

@media (max-width: 768px) {
  .zen-container {
    max-width: 600px;
    padding: 2rem;
    gap: 2rem;
    justify-content: center;
  }
}

/* Video/Canvas Area - Minimalist */
.visual-area {
  position: relative;
  width: 100%;
  aspect-ratio: 16/10;
  border-radius: 24px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.05);
  transition: all 0.5s ease;
}

.visual-area.monitoring {
  opacity: 0.1;
  /* Fade out when monitoring to reduce distraction */
  filter: blur(10px);
  transform: scale(0.95);
}

.visual-area.monitoring:hover {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
}

video,
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  /* Mirror */
}

/* Status Indicator - The "Zen Circle" */
.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--subtle);
  transition: all 0.3s ease;
  margin-top: 1rem;
}

.status-indicator.active {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--accent);
}

.status-indicator.warn {
  background: var(--error);
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--error);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    opacity: 1;
  }
}

/* Controls - Primary Actions */
.primary-actions {
  display: flex;
  gap: 1rem;
  z-index: 20;
}

.btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: 99px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  /* For link buttons */
}

.btn:hover {
  background: var(--border);
  transform: translateY(-1px);
  color: var(--text);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.btn-primary:hover {
  opacity: 0.9;
  background: var(--accent);
  color: var(--bg);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Settings Drawer (Hidden by default) */
.settings-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 2rem;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.05);
  max-height: 80vh;
  overflow-y: auto;
}

.settings-drawer.open {
  transform: translateY(0);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 600px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.control-group {
  margin-bottom: 1.5rem;
}

.control-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--subtle);
  margin-bottom: 0.5rem;
}

.control-group input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Overlay for settings */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 90;
  backdrop-filter: blur(2px);
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Gate / Permissions */
.gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.gate-content {
  max-width: 400px;
}

/* Utility */
.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer */
footer {
  width: 100%;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--subtle);
  border-top: 1px solid transparent;
  /* Placeholder for potential border */
  margin-top: auto;
}

footer a {
  color: var(--subtle);
  text-decoration: none;
  margin-left: 10px;
  border-bottom: 1px dotted var(--subtle);
}

footer a:hover {
  color: var(--text);
  border-bottom-style: solid;
}

/* Cookie Consent Banner */
.cookie-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 600px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cookie-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 1rem;
}

.cookie-content p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--subtle);
}

.cookie-content a {
  color: var(--text);
  text-decoration: underline;
}

.cookie-banner.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* Tool Grid (Dashboard) */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  width: 100%;
  padding: 0 1rem;
}

.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
  border-color: var(--accent);
  color: var(--text);
}

.tool-icon {
  font-size: 3rem;
  line-height: 1;
}

.tool-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.tool-description {
  font-size: 0.9rem;
  color: var(--subtle);
  line-height: 1.6;
  margin: 0;
}

.tool-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 900px) {
  .tool-grid {
    grid-template-columns: 1fr;
    max-width: 500px;
    margin: 0 auto;
  }
}

@media (max-width: 600px) {
  .cookie-banner {
    bottom: 10px;
    width: 95%;
    padding: 1.25rem;
  }

  .cookie-content {
    flex-direction: column;
    text-align: center;
    gap: 1.25rem;
  }

  .cookie-content p {
    font-size: 0.85rem;
  }

  .cookie-content button {
    width: 100%;
    justify-content: center;
    padding: 14px;
  }

  .mobile-only-warning {
    display: block !important;
  }

  .tool-grid {
    padding: 0;
  }

  .tool-card {
    padding: 1.5rem;
  }
}