/* ═══════════════════════════════════════════
   Memoroam — Links Tab Styles
   City-grouped link tiles with platform
   badges, edit mode, and save-link sheet.
   ═══════════════════════════════════════════ */

/* ── Wrapper ─────────────────────────────── */

.links-wrap {
  padding: 0 16px 100px;
}

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

.links-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 0 4px;
}

.links-title {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.links-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.links-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.links-edit-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.links-edit-btn:active {
  transform: scale(0.96);
}

.links-edit-btn--done {
  background: var(--text);
  color: var(--card);
  border-color: var(--text);
}

/* ═══════════════════════════════════════════
   CITY ISLAND — connected header + grid
   ═══════════════════════════════════════════ */

.links-city-island {
  background: var(--card);
  border-radius: 16px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: margin 0.3s ease;
}

/* ── City Header ─────────────────────────── */

.links-city-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: padding 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.links-city-header:active {
  opacity: 0.7;
}

.links-city-header--open {
  padding-bottom: 4px;
}

.links-city-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.links-city-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.links-city-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.links-city-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 2px;
}

.links-city-chevron {
  color: var(--muted);
  transition: transform 0.35s cubic-bezier(0.16,1,0.3,1);
  flex-shrink: 0;
}

.links-city-chevron--open {
  transform: rotate(180deg);
}

/* ── City Grid ───────────────────────────── */

.links-city-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 6px 12px 14px;
  max-height: 2000px;
  opacity: 1;
  transition: max-height 0.55s cubic-bezier(0.32,0.72,0,1),
              opacity 0.4s cubic-bezier(0.32,0.72,0,1),
              padding 0.45s cubic-bezier(0.32,0.72,0,1);
}

.links-city-grid--collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.32,0.72,0,1),
              opacity 0.25s ease,
              padding 0.35s cubic-bezier(0.32,0.72,0,1);
}

/* ═══════════════════════════════════════════
   LINK CARD — with platform tint background
   ═══════════════════════════════════════════ */

.link-card {
  position: relative;
  background: var(--card-tint, rgba(0,0,0,0.02));
  border-radius: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.link-card:active {
  transform: scale(0.97);
}

/* ── Edit mode: slow wobble ──────────────── */

@keyframes linkCardWobble {
  0%   { transform: rotate(-0.6deg); }
  50%  { transform: rotate(0.6deg); }
  100% { transform: rotate(-0.6deg); }
}

.link-card--editing {
  animation: linkCardWobble 0.25s ease-in-out infinite alternate;
  transform-origin: center center;
}

/* Stagger timing so cards don't wobble in sync (iOS style) */
.link-card--editing:nth-child(2n)   { animation-duration: 0.28s; animation-delay: -0.05s; }
.link-card--editing:nth-child(3n)   { animation-duration: 0.23s; animation-delay: -0.12s; }
.link-card--editing:nth-child(4n+1) { animation-duration: 0.26s; animation-delay: -0.08s; }
.link-card--editing:nth-child(5n+2) { animation-duration: 0.24s; animation-delay: -0.15s; }

/* ── External link arrow ─────────────────── */

.link-card-external {
  position: absolute;
  top: 12px;
  right: 12px;
  color: var(--muted);
  opacity: 0.5;
  transition: opacity 0.2s;
  padding: 4px;
  text-decoration: none;
}

.link-card-external:hover,
.link-card-external:active {
  opacity: 1;
}

/* ── Platform badge ──────────────────────── */

.link-card-platform {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.link-card-platform-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: currentColor;
  flex-shrink: 0;
}

.link-card-platform-icon svg {
  stroke: white;
  width: 10px;
  height: 10px;
}

.link-card-platform-label {
  white-space: nowrap;
}

/* ── Card content ────────────────────────── */

.link-card-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding-right: 16px;
}

.link-card-date {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.2px;
  margin-top: auto;
}

/* ── Edit mode: delete button ────────────── */

.link-card-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #E85D5D;
  border: 2px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.15s;
  padding: 0;
}

.link-card-delete:active {
  transform: scale(0.9);
}

/* ── Edit mode: grip handle ──────────────── */

.link-card-grip {
  position: absolute;
  bottom: 10px;
  right: 10px;
  color: var(--muted);
  opacity: 0.3;
  cursor: grab;
  padding: 4px;
}

/* ── Delete confirmation overlay ─────────── */

.link-card-confirm {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 14px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 10;
  animation: linkConfirmFade 0.2s ease;
}

@keyframes linkConfirmFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.link-card--confirming {
  animation: none !important; /* stop wobble during confirm */
}

.link-card-confirm-text {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.link-card-confirm-actions {
  display: flex;
  gap: 8px;
}

.link-card-confirm-no,
.link-card-confirm-yes {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  transition: transform 0.15s;
}

.link-card-confirm-no {
  background: var(--bg);
  color: var(--text);
}

.link-card-confirm-yes {
  background: #E85D5D;
  color: white;
}

.link-card-confirm-no:active,
.link-card-confirm-yes:active {
  transform: scale(0.94);
}

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

.links-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 32px 48px;
  gap: 8px;
}

.links-empty-icon {
  margin-bottom: 6px;
  opacity: 0.5;
}

.links-empty-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.links-empty-text {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.1px;
  max-width: 220px;
}

/* ── FAB ─────────────────────────────────── */

.links-fab {
  position: fixed;
  right: calc(50% - 175px);
  bottom: 100px;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--text);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  transition: transform 0.2s cubic-bezier(0.16,1,0.3,1);
  z-index: 60;
  -webkit-tap-highlight-color: transparent;
  animation: linksFabIn 0.3s cubic-bezier(0.16,1,0.3,1);
}

@keyframes linksFabIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.links-fab:active {
  transform: scale(0.92);
}

/* ═══════════════════════════════════════════
   SAVE LINK SHEET (bottom sheet / modal)
   ═══════════════════════════════════════════ */

.link-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: linkSheetFadeIn 0.2s ease;
}

@keyframes linkSheetFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.link-sheet {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 0 20px 32px;
  max-height: 85vh;
  overflow-y: auto;
  animation: linkSheetSlideUp 0.35s cubic-bezier(0.16,1,0.3,1);
}

@keyframes linkSheetSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ── Sheet top bar ───────────────────────── */

.link-sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 20px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}

.link-sheet-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.link-sheet-cancel {
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}

.link-sheet-save {
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.2s;
}

.link-sheet-save:active {
  color: var(--text);
}

/* ── Form groups ─────────────────────────── */

.link-form-group {
  margin-bottom: 22px;
}

.link-form-label {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.link-form-required {
  color: #C96B72;
}

.link-form-optional {
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--muted);
  opacity: 0.6;
  margin-left: 4px;
}

/* ── URL input ───────────────────────────── */

.link-form-url-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color 0.2s;
}

.link-form-url-wrap:focus-within {
  border-color: var(--text);
}

.link-form-url-icon {
  color: var(--muted);
  opacity: 0.5;
  flex-shrink: 0;
}

.link-form-url {
  flex: 1;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--muted);
  background: none;
  border: none;
  outline: none;
}

.link-form-url::placeholder {
  color: var(--muted);
  opacity: 0.4;
}

.link-form-url--error {
  animation: linkFormShake 0.4s ease;
}

@keyframes linkFormShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ── Platform chips ──────────────────────── */

.link-form-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  transition: outline 0.3s;
  border-radius: 8px;
}

.link-form-platforms--error {
  outline: 2px solid #E85D5D;
  outline-offset: 4px;
  animation: linkFormShake 0.4s ease;
}

.link-form-platform-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.link-form-platform-chip:active {
  transform: scale(0.96);
}

.link-form-platform-chip--active {
  border-color: var(--platform-color, var(--text));
  color: var(--platform-color, var(--text));
  background: white;
}

.link-form-platform-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.link-form-platform-icon svg {
  width: 14px;
  height: 14px;
}

/* ── Text input ──────────────────────────── */

.link-form-input {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s;
}

.link-form-input:focus {
  border-color: var(--text);
}

.link-form-input::placeholder {
  color: var(--muted);
  opacity: 0.4;
}

/* ── City chips ──────────────────────────── */

.link-form-cities {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.link-form-city-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.link-form-city-chip:active {
  transform: scale(0.96);
}

.link-form-city-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.link-form-city-chip--active {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.link-form-city-chip--active .link-form-city-dot {
  box-shadow: 0 0 0 1.5px white;
}

/* ── Dark Mode ── */
[data-theme="dark"] .link-form-platform-chip--active{background:var(--card);}
