/* Y4Y — Yoked for Yachts · Dark Athletic Theme */

:root {
  --bg-deep: #0a0e17;
  --bg-card: #131a2b;
  --bg-card-hover: #1a2338;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.15);
  --accent-glow: rgba(0, 212, 170, 0.3);
  --gold: #f0c040;
  --gold-dim: rgba(240, 192, 64, 0.15);
  --text: #e8eaf0;
  --text-muted: #6b7a99;
  --danger: #ff4757;
  --danger-dim: rgba(255, 71, 87, 0.15);
  --border: rgba(0, 212, 170, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 64px;
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + 16px);
  line-height: 1.5;
}

/* ── Typography ────────────────────────────── */

h1, h2, h3 {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

.text-accent { color: var(--accent); }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }

/* ── Layout ────────────────────────────────── */

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* ── Views ─────────────────────────────────── */

.view {
  display: none;
}

.view.active {
  display: block;
}

/* ── Cards ─────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* ── Brand Header ──────────────────────────── */

.brand {
  text-align: center;
  padding: 24px 0 16px;
}

.brand-logo {
  height: 60px;
  width: auto;
}

.brand .tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ── Dashboard Header ──────────────────────── */

.dash-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0 8px;
}

.dash-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}

.dash-phase {
  text-align: right;
  flex: 1;
}

/* ── Score + Logo Row ─────────────────────── */

.dash-score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.dash-score-row .score-display {
  flex: 1;
  text-align: left;
}

.dash-logo-link {
  display: block;
  flex-shrink: 0;
}

.dash-logo {
  height: 72px;
  width: auto;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.dash-logo:hover {
  opacity: 1;
}

.phase-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.phase-day {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Forms ─────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
input[type="date"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
}

/* ── Buttons ───────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-deep);
  width: 100%;
}

.btn-primary:hover {
  background: #00e8bb;
  transform: translateY(-1px);
}

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

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  width: 100%;
}

.btn-secondary:hover {
  background: var(--accent-dim);
}

.btn-gold {
  background: var(--gold);
  color: var(--bg-deep);
}

.btn-gold:hover {
  background: #f5cc55;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.8rem;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 8px;
}

.btn-ghost:hover {
  color: var(--accent);
}

.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn-row .btn {
  flex: 1;
}

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

/* ── Checklist ─────────────────────────────── */

.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.checklist-item:hover {
  background: var(--bg-card-hover);
}

.checklist-item.checked {
  border-color: var(--accent);
  background: rgba(0, 212, 170, 0.08);
}

.checklist-item.checked .check-icon {
  background: var(--accent);
  border-color: var(--accent);
}

.checklist-item.checked .check-icon::after {
  opacity: 1;
}

/* Weekly goal already met — item is optional/bonus */
.checklist-item.weekly-met {
  opacity: 0.6;
  border-style: dashed;
}

.checklist-item.weekly-met:hover,
.checklist-item.weekly-met.checked {
  opacity: 1;
}

.checklist-item.weekly-met.checked {
  border-style: solid;
}

.check-icon {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: 2px solid var(--text-muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.check-icon::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid var(--bg-deep);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 0.2s;
}

.checklist-item {
  flex-wrap: wrap;
  position: relative;
}

.checklist-label {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
}

/* ── Weekly Progress Badge ─────────────────── */

.weekly-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: all 0.3s ease;
}

.weekly-badge.met {
  background: var(--gold-dim);
  color: var(--gold);
}

.weekly-badge.almost {
  background: var(--accent-dim);
  color: var(--accent);
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
  .weekly-badge.almost { animation: none; }
}

.weekly-badge.urgent {
  background: var(--danger-dim);
  color: var(--danger);
}

/* ── Detail Toggle Button ─────────────────── */

.detail-toggle {
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
  margin-left: auto;
}

.detail-toggle::before {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.3s ease;
}

.detail-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}

.detail-toggle:hover::before {
  border-color: var(--accent);
}

.checklist-item.expanded .detail-toggle::before {
  transform: rotate(-135deg) translateY(-2px);
}

/* ── Expandable Details Panel ─────────────── */

.checklist-details {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
  opacity: 0;
  margin-top: 0;
  padding-left: 36px;
}

.checklist-item.expanded .checklist-details {
  max-height: 300px;
  opacity: 1;
  margin-top: 10px;
}

.details-phase-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.checklist-details ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.checklist-details li {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding-left: 12px;
  position: relative;
}

.checklist-details li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
}

/* ── Weigh-in Item ─────────────────────────── */

.weigh-in-item {
  border-color: var(--gold-dim);
}

.weigh-in-item .check-icon {
  border-color: var(--gold);
}

.weigh-in-item.checked {
  border-color: var(--gold);
  background: rgba(240, 192, 64, 0.08);
}

.weigh-in-item.checked .check-icon {
  background: var(--gold);
  border-color: var(--gold);
}

.weight-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.weight-input-wrap input {
  width: 80px;
  padding: 6px 10px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.weight-input-wrap .unit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Inline Note Input ────────────────────── */

.note-row {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.25s ease, opacity 0.25s ease, margin 0.25s ease;
  margin-top: 0;
  padding-left: 36px; /* align with label (24px icon + 12px gap) */
}

.note-row.visible {
  max-height: 60px;
  opacity: 1;
  pointer-events: auto;
  margin-top: 6px;
}

.note-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.8rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
}

.note-input:focus {
  border-color: var(--accent);
}

.note-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* ── Score Display ─────────────────────────── */

.score-display {
  text-align: center;
  padding: 12px 0;
}

.score-big {
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.score-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-deep);
  border-radius: 4px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ── Leaderboard ───────────────────────────── */

.leaderboard-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .leaderboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.lb-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.lb-card-name {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--accent);
}

.lb-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.lb-stat:last-child {
  border-bottom: none;
}

.lb-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lb-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.lb-stat-value.not-logged {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
  font-size: 0.9rem;
}

.lb-stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  text-align: right;
}

/* ── History ───────────────────────────────── */

.history-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.history-controls input[type="date"] {
  flex: 1;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-dim);
}

.history-item.has-weight {
  border-left: 3px solid var(--gold);
}

.history-date {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 90px;
}

.history-score {
  font-weight: 800;
  color: var(--accent);
  font-size: 1.1rem;
  margin-left: auto;
}

.history-weight {
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 600;
}

.history-dots {
  display: flex;
  gap: 3px;
  flex: 1;
}

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-deep);
}

.history-dot.filled {
  background: var(--accent);
}

.history-notes {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding-left: 4px;
}

.history-note-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ── Edit Overlay (History edit mode) ──────── */

.edit-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.95);
  z-index: 100;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 32px);
}

.edit-overlay.active {
  display: block;
}

.edit-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* ── Profile ───────────────────────────────── */

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
}

/* ── Plan View ──────────────────────────────── */

.plan-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.plan-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.plan-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.plan-dot.active {
  background: var(--accent);
}

.plan-columns {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 8px;
}

.plan-columns::-webkit-scrollbar {
  display: none;
}

.plan-phase {
  min-width: 85vw;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin-right: 16px;
  flex-shrink: 0;
}

.plan-phase:last-child {
  margin-right: 0;
}

.plan-phase.current {
  border-color: var(--accent);
  border-left: 3px solid var(--accent);
  background: rgba(0, 212, 170, 0.04);
}

.plan-phase-header {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.plan-phase-num {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.plan-phase-name {
  font-size: 1.2rem;
  font-weight: 800;
  margin-top: 4px;
}

.plan-phase-dates {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.plan-category {
  margin-bottom: 16px;
}

.plan-category-name {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 8px;
}

.plan-item {
  margin-bottom: 10px;
}

.plan-item-label {
  font-weight: 600;
  font-size: 0.85rem;
}

.plan-item-details {
  list-style: none;
  padding: 0;
  margin: 4px 0 0 0;
}

.plan-item-details li {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 1px 0;
  padding-left: 12px;
  position: relative;
}

.plan-item-details li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

/* Desktop: 3-column grid, hide dots */
@media (min-width: 768px) {
  .plan-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    overflow-x: visible;
    scroll-snap-type: none;
  }

  .plan-phase {
    min-width: 0;
    margin-right: 0;
  }

  .plan-dots {
    display: none;
  }
}

/* ── Bottom Nav ────────────────────────────── */

#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: none;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

#bottom-nav.visible {
  display: flex;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 12px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

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

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

.nav-icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* ── Alerts / Messages ─────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.alert-error {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(255, 71, 87, 0.3);
}

.alert-success {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-glow);
}

/* ── Empty State ───────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ── Loading Spinner ───────────────────────── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent-dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Utility ───────────────────────────────── */

.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.hidden { display: none !important; }

/* ── Responsive ────────────────────────────── */

@media (min-width: 640px) {
  .container {
    max-width: 600px;
    padding: 24px;
  }

  h1 { font-size: 2rem; }
  .brand h1 { font-size: 2.5rem; }
}
