/**
 * Card surfaces — issue #8
 * Modern, calm event (.ec) + player (.pc) cards: 8px grid, readable type, minimal chrome.
 */

:root {
  --card-radius: 14px;
  --card-pad: 16px;
  --card-pad-d: 18px;
  --card-gap: 12px;
  --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 14px rgba(15, 23, 42, 0.06);
  --card-shadow-hover: 0 2px 4px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);
  --card-meta: #64748b;
  --card-title: #0f172a;
  --card-pill-fs: 11px;
  --card-body-fs: 13px;
}

.ev-grid {
  gap: var(--card-gap);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

.ec {
  position: relative;
  border-radius: var(--card-radius);
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.ec::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--pg, #2e7d32);
  opacity: 0.85;
}

.ec[data-type="rr"]::before { background: #2e7d32; }
.ec[data-type="lg"]::before { background: #3949ab; }
.ec[data-type="ld"]::before { background: #e65100; }
.ec[data-type="op"]::before { background: #00897b; }
.ec[data-type="tm"]::before { background: #8e24aa; }
.ec.past-card::before { background: #90a4ae; }
.ec.mine::before { background: #f9a825; }

.ec:hover {
  border-color: rgba(46, 125, 50, 0.35);
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}

.ec.mine,
.ec.past-card {
  border-left: none;
}

.ec.past-card {
  opacity: 0.92;
}

.ec-hd {
  padding: var(--card-pad) var(--card-pad) 0;
  padding-left: calc(var(--card-pad) + 4px);
  border-bottom: none;
  display: block;
}

.ec-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
}

.ec-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--card-title);
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
}

.ec-menu {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  background: #f8fafc;
  margin-top: 2px;
}

.ec-menu .ti { font-size: 16px; }

.ec-badges,
.ec-hd .badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ec-hd .ec-badges,
.ec-hd .badges {
  display: none;
}

.ec-body > .ec-badges {
  margin-bottom: 10px;
}

/* Tags row — badges left, mobile expand chevron right */
.ec-tags-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ec-tags-row .ec-badges {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.ec-tags-row--solo {
  justify-content: flex-end;
}

/* Mobile — collapse DUPR / roster / RSVP below tags */
.ec-expand-toggle {
  display: none;
}

@media (max-width: 767px) {
  .ec-expand-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    border: 1.5px solid rgba(37, 99, 235, 0.32);
    border-radius: 11px;
    background: linear-gradient(145deg, #ffffff 0%, #eff6ff 55%, #dbeafe 100%);
    box-shadow:
      0 2px 8px rgba(37, 99, 235, 0.16),
      inset 0 1px 0 rgba(255, 255, 255, 0.95);
    color: #2563eb;
    cursor: pointer;
    position: relative;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, transform 0.12s;
  }

  .ec-expand-toggle-icon {
    font-size: 20px;
    line-height: 1;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ec-expand-toggle:hover,
  .ec-expand-toggle:focus-visible {
    border-color: rgba(37, 99, 235, 0.5);
    box-shadow:
      0 3px 12px rgba(37, 99, 235, 0.22),
      inset 0 1px 0 rgba(255, 255, 255, 1);
    outline: none;
    transform: translateY(-1px);
  }

  .ec-expand-toggle:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.14);
  }

  .ec.ec-drop-open .ec-expand-toggle {
    background: linear-gradient(145deg, #eff6ff 0%, #dbeafe 100%);
    border-color: rgba(29, 78, 216, 0.45);
    box-shadow:
      0 2px 10px rgba(37, 99, 235, 0.2),
      inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  }

  .ec.ec-drop-open .ec-expand-toggle-icon {
    transform: rotate(180deg);
  }

  .ec-drop {
    display: none;
  }

  .ec.ec-drop-open .ec-drop {
    display: block;
    padding-top: 10px;
    animation: ec-drop-reveal 0.24s ease-out;
  }

  @keyframes ec-drop-reveal {
    from {
      opacity: 0;
      transform: translateY(-6px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .ec:hover {
    transform: none;
  }
}

@media (min-width: 768px) {
  .ec-drop {
    display: block;
  }
}

.ec-body {
  padding: 10px var(--card-pad) var(--card-pad);
  padding-left: calc(var(--card-pad) + 4px);
}

/* Prominent date/time — card-in-card */
.ec-when {
  margin-bottom: 8px;
}

.ec-when-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 12px 14px;
  border-radius: 11px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid rgba(30, 58, 138, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.ec-when-card--solo {
  gap: 10px;
}

.ec-when-card--solo span {
  font-size: 17px;
  font-weight: 800;
  color: #1e3a8a;
  letter-spacing: -0.02em;
}

.ec-when-card--solo .ti {
  font-size: 18px;
  color: #2563eb;
}

.ec-when-date,
.ec-when-time {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ec-when-date .ti,
.ec-when-time .ti {
  font-size: 17px;
  color: #2563eb;
  flex-shrink: 0;
}

.ec-when-date span {
  font-size: 17px;
  font-weight: 800;
  color: #1e3a8a;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.ec-when-time span {
  font-size: 15px;
  font-weight: 700;
  color: #334155;
  line-height: 1.2;
}

.ec.past-card .ec-when-card {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-color: rgba(15, 23, 42, 0.08);
}

.ec.past-card .ec-when-date span,
.ec.past-card .ec-when-card--solo span {
  color: #475569;
}

/* Location — bolder, below when */
.ec-loc {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  line-height: 1.35;
}

.ec-loc .ti {
  font-size: 16px;
  color: #64748b;
  flex-shrink: 0;
  margin-top: 1px;
}

.ec-loc span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ec .meta {
  display: none;
}

.ec .mi {
  font-size: var(--card-body-fs);
  color: var(--card-meta);
  font-weight: 500;
  gap: 8px;
  line-height: 1.4;
}

.ec .mi i {
  font-size: 15px;
  color: #94a3b8;
  flex-shrink: 0;
}

.ec .mi-primary {
  color: #334155;
  font-weight: 600;
}

.ec .mi-loc span {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ec .tb,
#ev-grid .tb {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--card-pill-fs);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.ec .tb .ti,
#ev-grid .tb .ti {
  font-size: 13px !important;
  opacity: 0.92;
}

.ec .tb.tb-dupr {
  background: #e8eaf6;
  color: #1a237e;
}

.ec .joined-b {
  background: #e8f5e9;
  color: #2e7d32;
}

/* DUPR allowed range — only when organizer set skill limit at creation */
.ec-skill {
  margin-bottom: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.ec-skill-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.ec-skill-label {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ec-skill-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--pn, #1e3a8a);
  white-space: nowrap;
}

.ec-skill-scale {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ec-skill-track {
  position: relative;
  height: 5px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.ec-skill-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #43a047, #2e7d32);
}

.ec.past-card .ec-skill-fill {
  background: linear-gradient(90deg, #b0bec5, #90a4ae);
}

.ec-skill-bounds {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.02em;
}

.ec-dupr {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.ec-dupr-compact {
  min-height: 0;
}

.ec-dupr-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.ec-dupr-label {
  font-size: 9px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ec-dupr-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--pn, #1e3a8a);
  white-space: nowrap;
  flex-shrink: 0;
}

.ec-dupr-track {
  flex: 1;
  min-width: 40px;
  max-width: 72px;
  height: 4px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  position: relative;
}

.ec-dupr-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #43a047, #2e7d32);
}

.ec.past-card .ec-dupr-fill {
  background: linear-gradient(90deg, #b0bec5, #90a4ae);
}

.ec .sbar-wrap {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.ec .sbar-lbl {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 6px;
}

.ec .sbar-lbl span:last-child {
  font-size: 14px;
  font-weight: 700;
  color: var(--pn);
}

.ec .sbar-trk {
  height: 6px;
  border-radius: 999px;
}

.ec .slbls {
  display: none;
}

.ec .prow {
  margin-top: 4px;
  align-items: center;
  gap: 8px;
}

.ec .prow-players {
  display: flex;
  align-items: center;
  min-width: 0;
}

.ec .pavs .pa,
.ec .pa {
  width: 28px;
  height: 28px;
  font-size: 10px;
  border-width: 2px;
  margin-left: -6px;
}

.ec .pavs .pa:first-child,
.ec .pa:first-child {
  margin-left: 0;
}

.ec .pac {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  margin-left: 8px;
}

.ec .ec-cap {
  font-size: 13px !important;
  font-weight: 700;
  color: #334155 !important;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
}

.ec .pbar {
  height: 4px;
  margin-top: 10px;
  border-radius: 999px;
  background: #e2e8f0;
}

.ec-body .prow > div:first-child {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.ec-body .prow > span:last-child {
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}

.ec-inv-actions {
  margin-top: 10px;
}

.ec .inv-rsvp-bar {
  margin-top: 10px;
}

.ec .inv-rsvp-bar--card {
  margin-top: 10px;
}

#pl-grid {
  gap: var(--card-gap);
}

.pc {
  border-radius: var(--card-radius);
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: var(--card-pad);
  box-shadow: var(--card-shadow);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.pc:hover {
  border-color: rgba(46, 125, 50, 0.35);
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}

.pc-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: 12px;
  row-gap: 4px;
  margin-bottom: 10px;
  align-items: center;
}

.pc-info {
  min-width: 0;
}

.pc-av {
  width: 44px;
  height: 44px;
  font-size: 14px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.pc-n {
  font-size: 15px;
  font-weight: 700;
  color: var(--card-title);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.pc-h {
  font-size: 13px;
  color: #455a64;
  font-weight: 500;
  margin-top: 2px;
}

.pc-dupr-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #eef2ff 0%, #e8eaf6 100%);
  color: var(--pn, #1e3a8a);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  border: 1px solid rgba(30, 58, 138, 0.12);
  box-shadow: 0 1px 2px rgba(30, 58, 138, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.pc-scores {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .pc-top {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
  }

  .pc-av {
    grid-row: 1 / span 2;
    align-self: center;
  }

  .pc-info {
    grid-column: 2;
    grid-row: 1;
  }

  .pc-scores {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
    margin-top: 6px;
  }

  .pc-top .coach-card-badge {
    grid-column: 2;
    grid-row: 3;
    justify-self: start;
    margin-top: 4px;
  }

  #pl-grid.pl-view-list .pc-top {
    column-gap: 10px;
  }
}

.pc-dplus-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 52px;
  padding: 6px 11px 6px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 42%, #ede9fe 100%);
  color: #6b21a8;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  border: 1px solid rgba(107, 33, 168, 0.16);
  box-shadow: 0 1px 3px rgba(107, 33, 168, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.pc-dplus-mark {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.9;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pc-dplus-val {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.pc-dv {
  font-size: 16px;
  font-weight: 800;
  color: var(--pn);
}

.pc-dl {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pc-tags {
  gap: 6px;
  margin-bottom: 0;
}

.pc-tags .pt,
.pc .pt {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 1.2;
  white-space: nowrap;
}

.pt-format {
  background: #f1f5f9;
  color: #475569;
}

.pc-acts {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.pc-acts .btn {
  font-size: 12px;
  min-height: 36px;
  border-radius: 10px;
}

#pl-grid.pl-view-list .pc {
  padding: 10px;
}

@media (min-width: 768px) {
  #pl-grid.pl-view-list .pc {
    padding: 13px;
  }
}

@media (min-width: 1024px) {
  #pl-grid.pl-view-list .pc {
    padding: 14px;
  }
}

@media (max-width: 480px) {
  .pc-scores {
    gap: 4px;
  }

  .pc-dupr-pill {
    min-width: 40px;
    padding: 5px 9px;
    font-size: 13px;
  }

  .pc-dplus-pill {
    min-width: 44px;
    padding: 5px 9px 5px 7px;
  }

  .pc-dplus-val {
    font-size: 13px;
  }

  .pc-dplus-mark {
    font-size: 9px;
  }
}

@media (min-width: 640px) {
  .ec-when-date span {
    font-size: 18px;
  }

  .ec-when-time span {
    font-size: 16px;
  }

  .ec-loc {
    font-size: 15px;
  }
}

@media (min-width: 1024px) {
  :root {
    --card-pill-fs: 12px;
    --card-body-fs: 14px;
  }

  .ec-name {
    font-size: 17px;
  }

  .ec-hd {
    padding: var(--card-pad-d) var(--card-pad-d) 0;
    padding-left: calc(var(--card-pad-d) + 4px);
  }

  .ec-body {
    padding: 14px var(--card-pad-d) var(--card-pad-d);
    padding-left: calc(var(--card-pad-d) + 4px);
  }

  .pc-n {
    font-size: 16px;
  }

  .pc-h {
    font-size: 14px;
  }

  .pc-dupr-pill {
    font-size: 16px;
    padding: 7px 14px;
  }

  .pc-dplus-pill {
    padding: 7px 13px 7px 10px;
  }

  .pc-dplus-val {
    font-size: 16px;
  }

  .pc-dplus-mark {
    font-size: 11px;
  }

  .pc-av {
    width: 48px;
    height: 48px;
    font-size: 15px;
  }
}

/* Player directory — gray text, full location wrap */
#pl-grid.pl-view-list .pc-n {
  color: #455a64;
  font-weight: 600;
}

#pl-grid.pl-view-list .pc-h {
  font-size: 12px;
  font-weight: 500;
  color: #607d8b;
  line-height: 1.4;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  overflow-wrap: break-word;
}

@media (min-width: 768px) {
  #pl-grid.pl-view-list .pc-h {
    font-size: 13px;
    color: #607d8b;
  }
}

@media (min-width: 1024px) {
  #pl-grid.pl-view-list .pc-h {
    font-size: 14px;
    color: #607d8b;
  }
}
