/* ============================================================
   WCOPA Tracker — Pinterest-Inspired Design System
   Based on DESIGN.md spec: warm cream palette, Pin Sans/Inter,
   16px radius, masonry pin grid, flat surfaces, red CTAs
   ============================================================ */

/* ─── Font: Inter (Pin Sans substitute) ────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── Design Tokens (Light mode — default) ────────────────── */
:root {
  /* Brand & Accent */
  --primary: #e60023;
  --primary-pressed: #cc001f;

  /* Surface */
  --canvas: #ffffff;
  --surface-soft: #fbfbf9;
  --surface-card: #f6f6f3;
  --secondary-bg: #e5e5e0;
  --secondary-pressed: #c8c8c1;
  --surface-dark: #262622;
  --hairline: #dadad3;
  --hairline-soft: #e5e5e0;

  /* Text */
  --ink: #000000;
  --ink-soft: #211922;
  --body: #33332e;
  --charcoal: #262622;
  --mute: #62625b;
  --ash: #91918c;
  --stone: #c8c8c1;
  --on-dark: #ffffff;

  /* Semantic */
  --error: #9e0a0a;
  --success-deep: #103c25;
  --success-pale: #c7f0da;
  --focus-outer: #435ee5;
  --focus-inner: #ffffff;

  /* Typography tokens */
  --font-family: 'Inter', -apple-system, system-ui, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;

  /* Spacing */
  --space-xxs: 4px;
  --space-xs: 6px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-xxl: 32px;
  --space-section: 64px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 32px;
  --radius-full: 9999px;

  /* Elevation — flat by design, shadow only for modals */
  --shadow-modal: 0 16px 32px rgba(0, 0, 0, 0.12);
}

/* ─── Dark mode ────────────────────────────────────────────── */
[data-theme="dark"] {
  --canvas: #12121e;
  --surface-soft: #0f0f1a;
  --surface-card: #1a1a2e;
  --secondary-bg: #2a2a44;
  --secondary-pressed: #3a3a58;
  --surface-dark: #0a0a12;
  --hairline: #2a2a44;
  --hairline-soft: #222238;
  --ink: #eaeaea;
  --ink-soft: #d0d0d8;
  --body: #c8c8d2;
  --charcoal: #b0b0bc;
  --mute: #8899aa;
  --ash: #5a6a7a;
  --stone: #3a4a5a;
  --on-dark: #eaeaea;
  --focus-outer: #617bff;
  --focus-inner: #12121e;
  --shadow-modal: 0 16px 32px rgba(0, 0, 0, 0.5);
}

/* ─── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.4;
  color: var(--body);
  background: var(--surface-soft);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
}

.heading-xl {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -1.2px;
}

.heading-lg {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
}

.heading-md {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.body-md {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
}

.body-strong {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.body-sm {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--mute);
}

.caption-md {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--mute);
}

.caption-sm {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--mute);
}

a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.4;
  transition: opacity 0.15s;
}
a:hover { opacity: 0.7; }

/* ─── Buttons ──遵循 Pinterest button-primary / secondary ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* button-primary — Pinterest Red, the only CTA color */
.btn-primary {
  background: var(--primary);
  color: var(--canvas);
}
.btn-primary:hover { background: var(--primary-pressed); }
.btn-primary:active { background: var(--primary-pressed); }

/* button-secondary — gray-cream alternative */
.btn-secondary {
  background: var(--secondary-bg);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--secondary-pressed); }

/* button-tertiary — ghost */
.btn-tertiary {
  background: transparent;
  color: var(--ink);
}
.btn-tertiary:hover { background: var(--hairline-soft); }

/* button-danger */
.btn-danger {
  background: var(--error);
  color: var(--canvas);
}
.btn-danger:hover { background: #7d0808; }

/* Size modifiers */
.btn-sm { height: 36px; padding: 4px 12px; font-size: 12px; }
.btn-lg { height: 48px; padding: 10px 20px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-pill { border-radius: var(--radius-full); }

/* ─── Inputs ── Pinterest text-input spec ──────────────────── */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 11px 15px;
  height: 44px;
  background: var(--canvas);
  border: 1px solid var(--ash);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 4px var(--focus-outer);
}
input::placeholder, textarea::placeholder {
  color: var(--ash);
}
textarea { height: auto; min-height: 80px; resize: vertical; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%2333332e' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ─── Layout ───────────────────────────────────────────────── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Section rhythm — 64px gap between major blocks */
.section {
  margin-bottom: var(--space-section);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) 0;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: var(--space-xl);
}

/* ─── Pin Card ── The core Pinterest container ─────────────── */
.pin-card {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
  /* No padding — the content IS the card */
}
.pin-card:hover {
  transform: translateY(-2px);
}

.pin-card img {
  width: 100%;
  display: block;
}

.pin-card-body {
  padding: var(--space-sm) var(--space-md) var(--space-md);
}

.pin-card-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pin-card-subtitle {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--mute);
  margin-top: 2px;
}

.pin-card-meta {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--mute);
}

/* ─── Pin Card Large (32px radius) ─────────────────────────── */
.pin-card-large {
  border-radius: var(--radius-lg);
}

/* ─── Masonry Pin Grid ─────────────────────────────────────── */
.pin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-sm);
}

@media (max-width: 1024px) {
  .pin-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
@media (max-width: 768px) {
  .pin-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (max-width: 480px) {
  .pin-grid { grid-template-columns: 1fr; }
}

/* ─── Stats Row ────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -1.2px;
  color: var(--ink);
}
.stat-card .stat-label {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--mute);
  margin-top: 2px;
}

@media (max-width: 640px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Category Badge (pill chip) ────────────────────────────── */
.cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--canvas);
  white-space: nowrap;
}

/* ─── Filter Chips ──────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  height: 36px;
  border-radius: var(--radius-full);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  background: var(--surface-card);
  color: var(--ink);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.chip.active {
  background: var(--ink);
  color: var(--on-dark);
}

/* ─── Song Header / Hero ────────────────────────────────────── */
.song-header {
  background: var(--canvas);
  border-radius: var(--radius-md);
  padding: var(--space-xxl);
  margin-bottom: var(--space-xl);
}
.song-header h2 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -1.2px;
  margin-top: var(--space-sm);
}
.song-header .artist {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--mute);
  margin-top: 2px;
}

/* ─── Tabs ── Inspired by Pinterest pill filter variant ────── */
.tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  padding: 6px 14px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--mute);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { background: var(--hairline-soft); }
.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Gallery Grid (costumes, accessories) ─────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-sm);
}
.gallery-item {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.gallery-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}
.gallery-item .item-title {
  padding: var(--space-sm) var(--space-md);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}

/* ─── Recording List ────────────────────────────────────────── */
.recording-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--surface-card);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}
.recording-item .info { flex: 1; min-width: 0; }
.recording-item .rec-type {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.recording-item .rec-date {
  font-size: 14px;
  font-weight: 400;
  color: var(--mute);
}
.recording-item audio { height: 40px; }

/* ─── Ratings ───────────────────────────────────────────────── */
.rating-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}
.rating-bar .label {
  width: 140px;
  font-size: 14px;
  font-weight: 400;
  color: var(--mute);
  flex-shrink: 0;
}
.rating-bar .track {
  flex: 1;
  height: 8px;
  background: var(--hairline-soft);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.rating-bar .fill {
  height: 100%;
  background: var(--ink);
  border-radius: var(--radius-full);
  transition: width 0.3s;
}
.rating-bar .score {
  width: 40px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: var(--charcoal);
}

/* ─── Rating Form Sliders ───────────────────────────────────── */
.rating-slider-group {
  margin-bottom: var(--space-md);
}
.rating-slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 400;
  color: var(--mute);
  margin-bottom: var(--space-xs);
}
.rating-slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  height: 6px;
}

/* ─── Recorder Controls ─────────────────────────────────────── */
.recorder-controls {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
  padding: var(--space-lg);
  background: var(--surface-card);
  border-radius: var(--radius-md);
}
.recorder-controls .status {
  font-size: 14px;
  font-weight: 400;
  color: var(--mute);
}
.recorder-controls .status.recording {
  color: var(--primary);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ─── Upload Area ───────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--hairline);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.upload-area:hover { border-color: var(--primary); }
.upload-area p {
  font-size: 16px;
  font-weight: 400;
  color: var(--mute);
}

/* ─── Modal ── Pinterest modal-card spec ────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-lg);
}
.modal {
  background: var(--canvas);
  border-radius: var(--radius-lg);
  padding: var(--space-xxl);
  max-width: 484px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}
.modal h3 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: var(--space-xl);
  text-align: center;
}
.modal-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

@media (max-width: 480px) {
  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-top: auto;
    max-height: 85vh;
  }
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
}

/* ─── Timeline ──────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: var(--space-xl);
}
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--hairline);
}
.timeline-item {
  position: relative;
  margin-bottom: var(--space-lg);
  padding: var(--space-lg);
  background: var(--surface-card);
  border-radius: var(--radius-md);
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.35rem;
  top: 1.2rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface-soft);
}

/* ─── Chart ─────────────────────────────────────────────────── */
.chart-container {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
  height: 280px;
  position: relative;
}

/* ─── Login Page ────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-lg);
  background: var(--surface-soft);
}
.login-card {
  width: 100%;
  max-width: 400px;
}
.login-card h2 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  margin-bottom: var(--space-xl);
}

/* ─── Primary Nav ── Pinterest top nav ──────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  height: 64px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
  gap: var(--space-lg);
  flex-wrap: wrap;
}
header .brand {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}
header nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}
header nav a {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
header .user-info {
  font-size: 14px;
  font-weight: 400;
  color: var(--mute);
}

@media (max-width: 768px) {
  header { height: auto; padding: var(--space-md); }
  header nav { width: 100%; justify-content: center; }
}

/* ─── Footer ─── Pinterest footer spec ──────────────────────── */
.footer {
  background: var(--canvas);
  border-top: 1px solid var(--hairline);
  padding: var(--space-xxl) var(--space-xl);
  margin-top: var(--space-section);
}
.footer-grid {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xl);
}
.footer-col h4 {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--charcoal);
  margin-bottom: var(--space-sm);
}
.footer-col a {
  display: block;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--mute);
  padding: 2px 0;
}
.footer-col a:hover { color: var(--ink); }
.footer-bottom {
  max-width: 1280px;
  margin: var(--space-xl) auto 0;
  padding-top: var(--space-lg);
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  font-weight: 400;
  color: var(--mute);
  text-align: center;
}

@media (max-width: 768px) {
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
}

/* ─── Utility ───────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--mute); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-section { margin-bottom: var(--space-section); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-center { align-items: center; }
.flex-between { justify-content: space-between; }

/* ─── Empty States ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-section) var(--space-lg);
  color: var(--mute);
}
.empty-state-icon {
  font-size: 32px;
  margin-bottom: var(--space-sm);
}
.empty-state-text {
  font-size: 16px;
  font-weight: 400;
  color: var(--mute);
}

/* ─── Toast Notifications ───────────────────────────────────── */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  display: none;
  box-shadow: var(--shadow-modal);
}
.toast.visible { display: block; }
.toast.success { border-color: var(--success-pale); background: var(--success-pale); color: var(--success-deep); }
.toast.error { border-color: var(--error); color: var(--error); }