/* =============================================================
   TEMPLATE.CSS — Shared design system
   Derived from: passwordGen, pomodoro, wheelOfFortune
   ============================================================= */

/* ── 1. Reset ─────────────────────────────────────────────── */

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

/* ── 2. Design tokens — Dark mode (default) ───────────────── */

:root {
  --bg:           #0f172a;
  --surface:      #1e293b;
  --border:       #334155;
  --accent:       #818cf8;
  --accent-hover: #a5b4fc;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --text-dim:     #475569;
  --danger:       #ef4444;
  --danger-bg:    rgba(239, 68, 68, 0.1);

  --radius:    14px;
  --radius-sm:  8px;
  --trans:     0.18s ease;

  --s1: #ef4444;
  --s2: #f97316;
  --s3: #eab308;
  --s4: #84cc16;
  --s5: #22c55e;
}

/* ── 3. Light mode tokens ─────────────────────────────────── */

@media (prefers-color-scheme: light) {
  :root {
    --bg:           #f1f5f9;
    --surface:      #ffffff;
    --border:       #e2e8f0;
    --accent:       #6366f1;
    --accent-hover: #4f46e5;
    --text:         #0f172a;
    --text-muted:   #64748b;
    --text-dim:     #94a3b8;
    /* --danger, --s1-s5 unchanged */
  }
}

/* ── 4. Base ──────────────────────────────────────────────── */

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.app {
  width: 100%;
  max-width: 460px;
}

/* ── 5. Typography ────────────────────────────────────────── */

h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Section labels — uppercase small caps */
.label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Monospace utility */
.mono {
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  letter-spacing: 0.03em;
}

/* ── 6. Layout ────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-section {
  padding: 1.5rem;
}

.divider {
  height: 1px;
  background: var(--border);
}

/* ── 7. App header ────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1.25rem;
  padding: 0 2px;
}

.app-logo {
  width: 26px;
  height: 26px;
  color: var(--accent);
  flex-shrink: 0;
}

/* ── 8. Tabs ──────────────────────────────────────────────── */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 0.875rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: color var(--trans);
  position: relative;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* ── 9. Buttons ───────────────────────────────────────────── */

/* Base shared styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
  border: 1px solid transparent;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Primary — filled accent */
.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Ghost — outline */
.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn--ghost:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.06);
}

/* Icon — square icon button */
.btn--icon {
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.btn--icon svg {
  width: 15px;
  height: 15px;
}

.btn--icon:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.1);
}

/* Danger — ghost with red hover */
.btn--danger {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn--danger:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-bg);
}

/* Add — dashed border for "add item" affordance */
.btn--add {
  width: 100%;
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
}

.btn--add:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.06);
}

/* ── 10. Form elements ────────────────────────────────────── */

/* Text input */
.input {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--trans), box-shadow var(--trans);
}

.input::placeholder {
  color: var(--text-dim);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

@media (prefers-color-scheme: light) {
  .input {
    background: rgba(0, 0, 0, 0.04);
  }
}

/* Checkbox — hidden native + styled .checkmark sibling */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background var(--trans);
}

.checkbox-label:hover {
  background: rgba(255, 255, 255, 0.04);
}

@media (prefers-color-scheme: light) {
  .checkbox-label:hover {
    background: rgba(0, 0, 0, 0.04);
  }
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 5px;
  background: transparent;
  transition: background var(--trans), border-color var(--trans);
  position: relative;
}

.checkbox-label input:checked ~ .checkmark {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input:checked ~ .checkmark::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* Toggle switch — hidden native + styled .toggle-track sibling */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  display: none;
}

.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 99px;
  transition: background var(--trans);
  flex-shrink: 0;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--trans);
}

.toggle-label input:checked ~ .toggle-track {
  background: var(--accent);
}

.toggle-label input:checked ~ .toggle-track::after {
  transform: translateX(16px);
}

/* Range slider */
.slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
  transition: background var(--trans), box-shadow var(--trans);
}

.slider::-webkit-slider-thumb:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 0 1px var(--accent-hover), 0 0 0 4px rgba(129, 140, 248, 0.2);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
}

/* ── 11. Output / result box ──────────────────────────────── */

.output-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 56px;
}

@media (prefers-color-scheme: light) {
  .output-box {
    background: rgba(0, 0, 0, 0.04);
  }
}

.output-text {
  flex: 1;
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 1rem;
  word-break: break-all;
  color: var(--text);
  letter-spacing: 0.03em;
  line-height: 1.5;
}

/* ── 12. Progress bar ─────────────────────────────────────── */

.progress-track {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  overflow: hidden;
}

@media (prefers-color-scheme: light) {
  .progress-track {
    background: rgba(0, 0, 0, 0.08);
  }
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s ease;
}

/* ── 13. Status / strength colors ─────────────────────────── */

.str-1 { background-color: var(--s1); }
.str-2 { background-color: var(--s2); }
.str-3 { background-color: var(--s3); }
.str-4 { background-color: var(--s4); }
.str-5 { background-color: var(--s5); }

.lbl-1 { color: var(--s1); }
.lbl-2 { color: var(--s2); }
.lbl-3 { color: var(--s3); }
.lbl-4 { color: var(--s4); }
.lbl-5 { color: var(--s5); }

/* ── 14. Animations ───────────────────────────────────────── */

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin-once {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.anim-fade-in {
  animation: fade-in 0.18s ease forwards;
}

.anim-spin svg {
  animation: spin-once 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
