/* Profile page (user.php) and settings.php */

.profile {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 24px;
  padding-bottom: 64px;
}

/* ----- Header: banner + avatar (with level shield) + actions ----- */
.profile-head {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.profile-banner {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 1;
  max-height: 280px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--unique) 60%, transparent),
    color-mix(in srgb, var(--unique) 15%, transparent));
}
.profile-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-head-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px 0;
  margin-top: -72px;
}

.profile-avatar-wrap {
  position: relative;
  width: 144px;
  height: 144px;
  flex-shrink: 0;
}
.profile-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 5px solid var(--surface-raised);
  background: var(--surface);
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 44px;
  font-weight: 700;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Level shield sits on the avatar's bottom-right, like iOS ProfileHeadUI. */
.profile-level-badge {
  position: absolute;
  bottom: -8px;
  right: -12px;
  height: 64px;
  width: auto;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(11, 37, 69, 0.25));
}

.profile-head-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.btn.btn-pill { border-radius: var(--radius-pill); }

/* ----- Info: name, flair, bio, weblink ----- */
.profile-info {
  padding: 12px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-name {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.profile-name-text { color: var(--text); }
.profile-flag { font-size: 22px; }
.profile-verified {
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}
.profile-flair-text {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.45;
}
.profile-bio {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.profile-web {
  margin-top: 2px;
  font-size: 15px;
  color: var(--unique);
  word-break: break-all;
}
.profile-web:hover { color: color-mix(in srgb, var(--unique) 80%, black); text-decoration: underline; }

@media (max-width: 640px) {
  .profile-banner       { aspect-ratio: 16 / 9; }
  .profile-head-row     { padding: 0 16px; margin-top: -56px; }
  .profile-info         { padding: 12px 16px 20px; }
  .profile-name         { font-size: 24px; }
  .profile-avatar-wrap  { width: 112px; height: 112px; }
  .profile-avatar       { border-width: 4px; font-size: 36px; }
  .profile-level-badge  { height: 52px; right: -10px; bottom: -6px; }
}

/* ----- Stats: horizontal scroll, icon + value + label (iOS pattern).
   Lives inside .profile-head, separated from the bio block by a hairline. */
.profile-head .stats {
  margin: 8px 0 0;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
}
.stats {
  display: flex;
  gap: 28px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.stats::-webkit-scrollbar { display: none; }
@media (max-width: 640px) {
  .profile-head .stats { padding: 14px 16px 18px; gap: 22px; }
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: max-content;
}
.stat-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.stat-icon       { font-size: 18px; line-height: 1; color: var(--text-muted); }
.stat-xp        .stat-icon { color: var(--accent); }
.stat-badges    .stat-icon { color: #A78BFA; }
.stat-spottings .stat-icon { color: var(--success); }
.stat-followers .stat-icon { color: var(--unique); }
.stat-following .stat-icon { color: var(--unique); }
.stat-streak    .stat-icon { color: #F97316; }

.stat-value {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.stat-label {
  font-size: 14px;
  color: var(--text-muted);
}
.stat-link {
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s var(--ease);
  cursor: pointer;
}
.stat-link:hover { opacity: 0.8; }
.stat-link:hover .stat-value { color: var(--unique); }

/* ----- Tab bar: Grid / List / Stats / Gear (segmented pill) ----- */
.profile-tabs {
  display: inline-flex;
  align-self: flex-start;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.profile-tabs::-webkit-scrollbar { display: none; }
.profile-tab {
  padding: 8px 18px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.profile-tab:hover { color: var(--text); }
.profile-tab.is-active {
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.profile-pane[hidden] { display: none; }

/* ----- List view (List tab) ----- */
.profile-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-raised);
}
.profile-list li + li { border-top: 1px solid var(--border); }
.profile-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  color: var(--text);
}
.profile-list-item:hover { background: var(--surface); }
.profile-list-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--surface);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 24px;
}
.profile-list-thumb img { width: 100%; height: 100%; object-fit: cover; }
.profile-list-meta { flex: 1; min-width: 0; }
.profile-list-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-list-sub {
  margin-top: 2px;
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-list-chevron { color: var(--text-muted); font-size: 14px; }

/* Section */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.section h2 {
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Gear */
.gear-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.gear-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--background);
}
.gear-item-camera { font-size: 15px; font-weight: 600; }
.gear-item-lens { font-size: 14px; color: var(--text-muted); margin-top: 2px; }
.gear-item.is-primary { border-color: var(--unique); box-shadow: 0 0 0 2px color-mix(in srgb, var(--unique) 18%, transparent); }
.gear-primary-tag {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--unique);
  background: color-mix(in srgb, var(--unique) 10%, transparent);
  border-radius: 999px;
}

/* Achievements */
.achievements {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.achievement {
  padding: 14px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--background);
  text-align: center;
}
.achievement-emoji { font-size: 28px; }
.achievement-id { font-size: 12px; font-weight: 600; margin-top: 4px; color: var(--text-muted); }
.achievement-count { font-size: 13px; color: var(--text); margin-top: 2px; }

/* Spotting grid — bigger rounded tiles, breathing-room gap (matches iOS). */
.spotting-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.spotting-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.spotting-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s ease; }
.spotting-tile:hover img { transform: scale(1.03); }
.spotting-tile-empty {
  display: grid;
  place-items: center;
  font-size: 32px;
  color: var(--text-muted);
}
@media (max-width: 768px) {
  .spotting-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 15px;
}
.pagination .btn { min-width: 90px; }
.pagination-disabled { opacity: 0.45; pointer-events: none; }

/* Settings */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-field { display: flex; flex-direction: column; gap: 6px; }
.settings-field label { font-size: 14px; color: var(--text-muted); }
.settings-field input,
.settings-field textarea {
  background: var(--input-field);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 15px;
  color: var(--text);
  width: 100%;
}
.settings-field textarea { min-height: 84px; resize: vertical; }
.settings-field input:focus,
.settings-field textarea:focus {
  outline: none;
  border-color: var(--unique);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--unique) 18%, transparent);
}

.settings-actions { display: flex; gap: 8px; }
.settings-error { color: var(--danger); font-size: 14px; }
.settings-success { color: #059669; font-size: 14px; }
.settings-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
}
.settings-toggle .desc { color: var(--text-muted); font-size: 14px; margin-top: 2px; }

.upload-row { display: flex; align-items: center; gap: 12px; }
.upload-preview {
  width: 64px; height: 64px;
  border-radius: 50%; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
}
.upload-preview.banner { width: 180px; height: 64px; border-radius: var(--radius-md); }
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }

.gear-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.gear-form .settings-field { flex: 1; min-width: 200px; }

/* ============================================================
   Profile Stats tab — mirrors iOS ProfileStatsUI sections.
   ============================================================ */

/* Summary grid: 2 rows × 3 cols. */
.ps-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}
.ps-summary-cell {
  padding: 18px 16px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.ps-summary-cell:nth-child(3n)    { border-right: 0; }
.ps-summary-cell:nth-child(-n+3)  { border-bottom: 1px solid var(--border); }
.ps-summary-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
}
.ps-summary-label {
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-muted);
}

/* Section blocks. */
.ps-section { margin-bottom: 28px; }
.ps-section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.ps-section-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  font-size: 16px;
}
.ps-section-icon.icon-airports  { background: color-mix(in srgb, var(--unique)  16%, transparent); color: var(--unique); }
.ps-section-icon.icon-types     { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.ps-section-icon.icon-airlines  { background: color-mix(in srgb, var(--danger)  16%, transparent); color: var(--danger); }
.ps-section-icon.icon-repeat    { background: color-mix(in srgb, #A78BFA       18%, transparent); color: #A78BFA; }
.ps-section-icon.icon-grades    { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.ps-section-title-block { flex: 1; min-width: 0; }
.ps-section-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.ps-section-sub {
  margin-top: 2px;
  font-size: 14px;
  color: var(--text-muted);
}
.ps-collection-head { padding-left: 4px; }

/* Ranked rows (Airports / Types / Airlines / Repeat). */
.ps-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ps-list li + li { border-top: 1px solid var(--border); }
.ps-row { display: block; }
.ps-row-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  color: var(--text);
}
a.ps-row-link:hover { background: var(--surface); }

.ps-rank {
  width: 24px;
  flex-shrink: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.ps-rank.rank-1 { color: var(--tier-gold); }
.ps-rank.rank-3 { color: var(--tier-bronze); }

.ps-row-main { flex: 1; min-width: 0; }
.ps-row-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ps-bar {
  margin-top: 6px;
  height: 3px;
  background: transparent;
  border-radius: 999px;
  width: 100%;
}
.ps-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--text-muted);
  opacity: 0.55;
}
.ps-bar-fill.rank-1 { background: var(--tier-gold);   opacity: 1; }
.ps-bar-fill.rank-3 { background: var(--tier-bronze); opacity: 1; }

.ps-row-count {
  flex-shrink: 0;
  font-size: 17px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
}
.ps-row-chev {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.5;
}

.ps-see-all {
  margin-top: 10px;
  background: transparent;
  border: 0;
  color: var(--unique);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
}
.ps-see-all:hover { color: color-mix(in srgb, var(--unique) 80%, black); }

/* Photo Grades tier badges. */
.ps-tier {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.ps-tier-S { background: var(--tier-gold); }
.ps-tier-A { background: var(--tier-silver); color: var(--brand-deep); }
.ps-tier-B { background: var(--tier-bronze); }
.ps-tier-C { background: var(--unique); }
.ps-tier-D { background: var(--text-muted); color: var(--background); }
.ps-bar-fill.tier-S { background: var(--tier-gold);   opacity: 1; }
.ps-bar-fill.tier-A { background: var(--tier-silver); opacity: 1; }
.ps-bar-fill.tier-B { background: var(--tier-bronze); opacity: 1; }
.ps-bar-fill.tier-C { background: var(--unique);      opacity: 1; }
.ps-bar-fill.tier-D { background: var(--text-muted);  opacity: 1; }

/* Collection rows. */
.ps-collection-row .ps-row-link { padding: 14px 16px; cursor: default; }
.ps-collection-row .ps-row-link:hover { background: transparent; }
.ps-coll-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 16px;
  flex-shrink: 0;
}
.icon-military  { background: color-mix(in srgb, #6366F1     18%, transparent); color: #818CF8; }
.icon-4k        { background: color-mix(in srgb, #C084FC     18%, transparent); color: #C084FC; }
.icon-rare      { background: color-mix(in srgb, #F97316     18%, transparent); color: #F97316; }
.icon-comments  { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }

@media (max-width: 640px) {
  .ps-summary-value { font-size: 24px; }
  .ps-summary-cell  { padding: 14px 10px; }
  .ps-section-title { font-size: 18px; }
  .ps-row-name      { font-size: 15px; }
  .ps-row-count     { font-size: 16px; }
}
