/* ==========================================================================
   share.css
   Matchday reel modal, header chip, sortable table headers, fixtures.
   Built on the design tokens defined in styles.css.
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Header chip (opens the latest matchday reel)
   -------------------------------------------------------------------------- */
.matchday-chip.is-clickable {
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
}

.matchday-chip.is-clickable:hover {
  background: rgba(16, 185, 129, .22);
  border-color: rgba(52, 211, 153, .6);
  transform: translateY(-1px);
}

.matchday-chip.is-clickable:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}


/* --------------------------------------------------------------------------
   2. Sortable table headers
   -------------------------------------------------------------------------- */
th .sortable-th {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  transition: color .18s ease;
}

th .sortable-th:hover { color: var(--cyan); }

th .sortable-th:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
  border-radius: 4px;
}

th.is-sorted {
  color: var(--gold-bright);
  background: rgba(234, 179, 8, .1);
}

th .sort-icon {
  font-size: .85em;
  opacity: .7;
}

th.is-sorted .sort-icon { opacity: 1; }


/* --------------------------------------------------------------------------
   3. Fixtures & results
   -------------------------------------------------------------------------- */
.fixtures-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.fixture-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 16px 18px;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(15, 24, 43, .92), rgba(9, 14, 26, .94));
  color: inherit;
  font: inherit;
  text-align: left;
}

.fixture-card.is-played {
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.fixture-card.is-played:hover {
  transform: translateY(-2px);
  border-color: rgba(52, 211, 153, .5);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .4);
}

.fixture-card.is-played:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.fixture-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fixture-label {
  font-family: 'Chakra Petch', sans-serif;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.fixture-status {
  padding: 3px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-muted);
  font-family: 'Chakra Petch', sans-serif;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.fixture-status.is-final {
  border-color: rgba(52, 211, 153, .4);
  background: var(--pitch-soft);
  color: #a7f3d0;
}

.fixture-line {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.fixture-team {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-family: 'Chakra Petch', sans-serif;
  font-size: .9rem;
  font-weight: 700;
}

.fixture-team.is-away { justify-content: flex-end; }

.fixture-team img {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 6px;
  object-fit: cover;
}

.fixture-team span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.fixture-score {
  padding: 0 6px;
  color: #fff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fixture-vs {
  color: var(--text-muted);
  font-family: 'Chakra Petch', sans-serif;
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.fixture-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font-size: .78rem;
}

.fixture-cta {
  color: var(--cyan);
  font-family: 'Chakra Petch', sans-serif;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  transition: color .2s ease;
}

.fixture-card.is-played:hover .fixture-cta { color: var(--gold-bright); }


/* --------------------------------------------------------------------------
   4. Reel modal
   -------------------------------------------------------------------------- */
body.post-open { overflow: hidden; }

.post-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 5, 10, .8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: postFade .2s ease-out both;
}

.post-overlay[hidden] { display: none; }

.post-modal {
  position: relative;
  width: min(100%, 400px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 22px 18px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 22px;
  background: #0b1220;
  box-shadow: 0 40px 90px rgba(0, 0, 0, .7);
  animation: postRise .26s cubic-bezier(.22, 1, .36, 1) both;
}

/* Thin brand gradient across the top edge */
.post-modal::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-bright), var(--pitch-bright), var(--blue-bright));
}

.post-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.post-eyebrow {
  margin: 0 0 4px;
  color: var(--pitch-bright);
  font-family: 'Chakra Petch', sans-serif;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.post-title {
  margin: 0;
  color: var(--text-main);
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.25;
}

.post-close {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
  color: var(--text-main);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease;
}

.post-close:hover {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .28);
}

/* 9:16 preview frame with a soft brand glow */
.post-preview {
  position: relative;
  width: 100%;
  max-height: min(62vh, 640px);
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 16px;
  background: #061218;
  box-shadow: 0 24px 48px rgba(0, 0, 0, .55), 0 0 0 1px rgba(253, 224, 71, .04);
  isolation: isolate;
}

.post-reel-canvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  width: 100%;
  height: 100%;
}

/* Fallback layers (used only if the canvas preview cannot be drawn) */
.post-pitch-photo {
  position: absolute;
  inset: -12px;
  z-index: 0;
  background: #0b241d url("../assets/stadium-pitch.svg") center 62% / cover no-repeat;
  filter: blur(6px) brightness(.8);
  transform: scale(1.06);
}

.post-pitch-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(4, 11, 22, .7), rgba(3, 8, 16, .88));
}

.post-details-layer {
  position: relative;
  z-index: 3;
  height: 100%;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.post-detail-scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px;
  background: rgba(5, 12, 22, .6);
}

.post-detail-kicker {
  color: #bbf7d0;
  font-family: 'Chakra Petch', sans-serif;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-align: center;
  text-transform: uppercase;
}

.post-detail-score {
  color: #fff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.post-detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px;
  background: rgba(4, 10, 18, .66);
  font-size: .8rem;
}

.post-team-col h4 {
  margin: 0 0 6px;
  font-family: 'Chakra Petch', sans-serif;
  font-size: .8rem;
  letter-spacing: .1em;
}

.post-team-col p { margin: 0 0 6px; color: var(--text-main); font-weight: 700; }
.post-team-col span { display: block; font-size: .72rem; color: var(--text-muted); }

/* Action row: one clear primary action, one secondary, one quiet dismiss */
.post-actions {
  display: grid;
  grid-template-columns: 1.6fr 1fr .8fr;
  gap: 8px;
}

.post-btn {
  padding: 12px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #fff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, transform .15s ease, opacity .2s ease;
}

.post-btn:active:not([disabled]) { transform: scale(.98); }

.post-btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
}

.post-btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 10px 24px rgba(16, 185, 129, .25);
}

.post-btn-primary:hover:not([disabled]) {
  background: linear-gradient(135deg, #34d399, #10b981);
}

.post-btn-alt {
  border-color: rgba(253, 224, 71, .42);
  background: rgba(234, 179, 8, .12);
  color: #fef08a;
}

.post-btn-alt:hover:not([disabled]) {
  border-color: var(--gold-bright);
  background: rgba(234, 179, 8, .22);
}

.post-btn-ghost {
  border-color: rgba(148, 163, 184, .3);
  background: transparent;
  color: var(--text-muted);
}

.post-btn-ghost:hover:not([disabled]) {
  border-color: rgba(255, 255, 255, .4);
  color: var(--text-main);
}

.post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.post-note {
  margin: 0;
  flex: 1 1 200px;
  color: var(--text-muted);
  font-size: .76rem;
  line-height: 1.45;
}

.post-link-btn {
  appearance: none;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--cyan);
  font-family: 'Chakra Petch', sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.post-link-btn:hover { color: #fff; }

.post-close:focus-visible,
.post-btn:focus-visible,
.post-link-btn:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

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

@keyframes postRise {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 540px) {
  .post-overlay { padding: 12px; }
  .post-modal { padding: 18px 16px 16px; gap: 14px; }
  .post-actions { grid-template-columns: 1fr 1fr; }
  .post-btn-ghost { grid-column: 1 / -1; }
}


/* --------------------------------------------------------------------------
   5. Motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .post-overlay,
  .post-modal,
  .matchday-chip.is-clickable,
  .fixture-card.is-played,
  .post-btn,
  .post-close,
  .fixture-cta,
  th .sortable-th {
    animation: none !important;
    transition: none !important;
  }
}
