/*
 * SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 *
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

:root {
  color-scheme: light dark;
  
  /* Light theme (default) */
  --bg-page: #f5f5f5;
  --bg-surface: white;
  --bg-header-code: #e8f5e0;
  
  --text-primary: #333;
  --text-on-accent: white;
  
  --accent: #5a8c3a;
  --accent-hover: #4a7230;
  --accent-dark: #2d5016;
  --accent-danger: #b22222;
  
  --border: #ddd;
  --border-accent: #5a8c3a;
  --shadow: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #1a1a1a;
    --bg-surface: #2a2a2a;
    --bg-header-code: #3a4a34;
    
    --text-primary: #e0e0e0;
    --text-on-accent: white;
    
    --accent: #7ab859;
    --accent-hover: #8cc96f;
    --accent-dark: #5a8c3a;
    --accent-danger: #d84444;
    
    --border: #444;
    --border-accent: #7ab859;
    --shadow: rgba(0, 0, 0, 0.3);
  }
}

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

body {
  font-family: "Atkinson Hyperlegible Next", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.hidden {
  display: none !important;
}

/* Start screen */
#start-screen {
  text-align: center;
  padding: 4rem 2rem;
}

#start-screen h1 {
  margin-bottom: 3rem;
  color: var(--accent-dark);
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.join-section {
  display: flex;
  gap: 0.5rem;
}

button {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s, transform 0.05s, box-shadow 0.2s;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--border-accent);
  outline-offset: 2px;
}

input, textarea {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg-surface);
  color: var(--text-primary);
}

input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--text-primary) 50%, transparent);
}

#join-code {
  width: 200px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#join-code::placeholder {
  text-transform: none;
}

.expiry-notice {
  font-size: 0.85rem;
  color: color-mix(in srgb, var(--text-primary) 60%, transparent);
  margin-top: 1rem;
}

#start-screen .expiry-notice {
  text-align: center;
}

#list-screen .expiry-notice {
  margin: 0.5rem 0 0 0;
  font-size: 0.8rem;
}

/* List screen */
#list-screen header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-accent);
}

#list-screen header h2 {
  margin-bottom: 0.25rem;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: color-mix(in srgb, var(--text-primary) 70%, transparent);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
}

.status-dot.connected {
  background: #4caf50;
  box-shadow: 0 0 4px #4caf50;
}

.status-dot.connecting {
  background: #ff9800;
  animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.disconnected {
  background: #f44336;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

#room-code {
  font-family: monospace;
  background: var(--bg-header-code);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

#copy-btn, #copy-link-btn, #set-title-btn, #reset-votes-btn {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

#copy-btn:hover, #copy-link-btn:hover, #set-title-btn:hover, #reset-votes-btn:hover {
  background: var(--bg-header-code);
  border-color: var(--border-accent);
}

.header-actions button svg {
  width: 20px;
  height: 20px;
  display: block;
}

#leave-btn {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--border-accent);
}

#leave-btn:hover {
  background: var(--bg-header-code);
}

.add-section {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.add-section input {
  flex: 1;
}

.bulk-section {
  margin-bottom: 2rem;
}

.bulk-section textarea {
  width: 100%;
  min-height: 100px;
  margin-bottom: 0.5rem;
  resize: vertical;
}

/* List items */
#list-container.disabled {
  pointer-events: none;
  opacity: 0.6;
}

.list-item {
  background: var(--bg-surface);
  padding: 1rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.3s ease, box-shadow 0.2s ease;
  border-left: 3px solid transparent;
}

.list-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow);
}

.list-item.selected {
  outline: 2px solid var(--border-accent);
  outline-offset: 2px;
}

.list-item.vetoed {
  opacity: 0.4;
  max-height: 3rem;
  overflow: hidden;
}

.list-item:has(.vote-btn.active) {
  border-left-color: var(--accent);
}

.list-item:has(.vote-btn.veto-active) {
  border-left-color: var(--accent-danger);
}

.list-item-text {
  flex: 1;
  padding-right: 1rem;
  cursor: pointer;
  user-select: none;
}

.list-item-text:hover {
  opacity: 0.9;
}

.edit-input {
  flex: 1;
  margin-right: 1rem;
}

.list-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.vote-btn {
  padding: 0.5rem;
  font-size: 0.9rem;
}

.delete-btn {
  padding: 0.5rem;
  font-size: 0.9rem;
  background: var(--accent-danger);
  opacity: 0.7;
  transition: opacity 0.2s, background 0.2s;
}

.delete-btn:hover {
  opacity: 1;
  background: var(--accent-danger);
}

.vote-btn.active {
  background: var(--accent-dark);
}

.vote-btn.veto-active {
  background: var(--accent-danger);
}

.vote-btn svg, .delete-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.score {
  min-width: 40px;
  text-align: center;
  font-weight: bold;
  color: var(--accent);
  background: var(--bg-header-code);
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-surface);
  padding: 2rem;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  color: var(--accent-dark);
}

.modal-close {
  background: transparent;
  color: var(--text-primary);
  border: none;
  font-size: 2rem;
  line-height: 1;
  padding: 0;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--accent-danger);
}

.modal-body h4 {
  color: var(--accent);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.modal-body h4:first-child {
  margin-top: 0;
}

.modal-body ul {
  margin: 0;
  padding-left: 1.5rem;
}

.modal-body li {
  margin-bottom: 0.5rem;
}

kbd {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  font-size: 0.85rem;
  font-family: monospace;
  background: var(--bg-header-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 2px var(--shadow);
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

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