/* =========================================================
   Custom Tables (responsive)
   Wrapper: .custom-table
   ========================================================= */

/* ===== theme tokens (can be overridden per-page) ===== */
:root {
  --casino-bg:
  #0f1229
  ;
  --casino-text:
  #f2f2f2
  ;
  --casino-muted:
  #f2f2f2
  ;

  /* table colors (fallback) */
  --table-bg: var(--casino-bg);
  --col1-bg: var(--casino-bg);
  --text: var(--casino-text);
  --muted: var(--casino-muted);

  /* lines on dark / variable backgrounds */
  --line: rgba(255, 255, 255, .14);
  --line-soft: rgba(255, 255, 255, .10);

  --radius: 14px;
  --hover: rgba(255, 255, 255, .04);
}

/* modern browsers */
@supports (color: color-mix(in oklch, white, black)) {
  :root {
    /* slightly lighter surface on top of bg */
    --table-bg: color-mix(in oklch, var(--casino-bg) 55%, white);
    --col1-bg: var(--casino-bg);

    --muted: color-mix(in oklch, var(--casino-text) 78%, white);

    --line: color-mix(in oklch, var(--casino-text) 18%, transparent);
    --line-soft: color-mix(in oklch, var(--casino-text) 12%, transparent);

    --hover: color-mix(in oklch, var(--table-bg) 92%, white);
  }
}

/* ========================================================= */
/* =================== DESKTOP TABLE BASE ================== */
/* ========================================================= */

.custom-table table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--table-bg);
  color: var(--text);
}

/* cells */
.custom-table th,
.custom-table td {
  padding: 16px 18px 16px 20px;
  vertical-align: top;
  line-height: 1.45;
  word-break: break-word;
  border-bottom: 1px solid var(--line-soft);
  background: var(--table-bg);
  text-align: left;
}

/* last row */
.custom-table tr:last-child th,
.custom-table tr:last-child td {
  border-bottom: none;
}

/* left column (2-col tables + first column in 3+ col tables) */
.custom-table th[scope="row"],
.custom-table tbody tr>td:first-child {
  width: 34%;
  padding-left: 24px;
  font-weight: 600;
  color: var(--muted);
  background: var(--col1-bg);
}

/* vertical divider */
.custom-table th[scope="row"]+td,
.custom-table td+td {
  border-left: 1px solid var(--line-soft);
}

/* remove margins inside cells */
.custom-table td>p {
  margin: 0;
}

/* hover (desktop only) */
@media (hover:hover) {

  .custom-table tr:hover th,
  .custom-table tr:hover td {
    background: var(--hover);
  }
}

/* ========================================================= */
/* ================= MOBILE: 2 COLUMNS ===================== */
/* tables WITHOUT thead (label/value pairs)                  */
/* ========================================================= */

@media (max-width:640px) {

  /* ONLY tables without thead */
  .custom-table table:not(:has(thead)) {
    border: 0;
    background: transparent;
  }

  .custom-table table:not(:has(thead)) tbody {
    display: grid;
    gap: 12px;
  }

  .custom-table table:not(:has(thead)) tr {
    display: block;
    background: var(--table-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
  }

  .custom-table table:not(:has(thead)) th[scope="row"],
  .custom-table table:not(:has(thead)) td {
    display: block;
    border: 0;
    padding: 14px 16px 14px 18px;
    width: auto;
    /* kill desktop widths */
  }

  .custom-table table:not(:has(thead)) th[scope="row"],
  .custom-table table:not(:has(thead)) td:first-child {
    background: var(--col1-bg);
    color: var(--muted);
    font-size: 14px;
    border-bottom: 1px solid var(--line);
  }

  .custom-table table:not(:has(thead)) td {
    font-size: 16px;
  }
}

/* ========================================================= */
/* ============== MOBILE: 3+ COLUMNS (CARDS) =============== */
/* tables WITH thead                                         */
/* ========================================================= */

@media (max-width:640px) {

  /* hide table header */
  .custom-table table:has(thead) thead {
    display: none;
  }

  .custom-table table:has(thead) {
    border: 0;
    background: transparent;
  }

  .custom-table table:has(thead) tbody {
    display: grid;
    gap: 12px;
  }

  .custom-table table:has(thead) tbody tr {
    display: block;
    background: var(--table-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
  }

  /* card title (first cell) — FULL WIDTH */
  .custom-table table:has(thead) tbody th[scope="row"],
  .custom-table table:has(thead) tbody tr>td:first-child {
    display: block;
    width: 100%;
    padding: 14px 16px 14px 20px;
    font-weight: 700;
    background: var(--col1-bg);
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    border-left: 0;
  }

  /* fields (rest cells) */
  .custom-table table:has(thead) tbody td {
    /* reset desktop */
    width: auto;
    background: var(--table-bg);
    border: 0;
    border-top: 1px solid var(--line-soft);
    border-left: 0;

    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px;
    padding: 12px 16px 12px 20px;
  }

  /* do not treat first cell as field row (if it exists as td) */
  .custom-table table:has(thead) tbody tr>td:first-child {
    display: block;
  }

  /* label from data-label */
  .custom-table table:has(thead) tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 13px;
    color: var(--muted);
    opacity: .9;
  }
}

/* very small screens */
@media (max-width:380px) {
  .custom-table table:has(thead) tbody td {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}