/* =========================
   Award & Event Tables
   Responsive behavior aligned with ime-publications-block.css
   ========================= */

/* Base: wrapper (figure.wp-block-table.* OR raw table.*) */
figure.wp-block-table.award-table,
figure.wp-block-table.event-table,
table.award-table,
table.event-table {
  width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
  max-width: 100%;
}

/* Base: actual table element */
figure.wp-block-table.award-table table,
figure.wp-block-table.event-table table,
table.award-table,
table.event-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  font-family: sans-serif;
  font-size: 15px; /* match .ime-publications-block table default 15px */
  border: 1px solid #dcdcdc;
  box-sizing: border-box;
}

/* Reset cell borders & spacing */
figure.wp-block-table.award-table th,
figure.wp-block-table.award-table td,
figure.wp-block-table.event-table th,
figure.wp-block-table.event-table td,
table.award-table th,
table.award-table td,
table.event-table th,
table.event-table td {
  border: none !important;
  padding: 14px 10px; /* match .ime-publications-block td default */
  vertical-align: middle;
  word-break: break-word;
  word-wrap: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
}

/* Header row */
figure.wp-block-table.award-table thead tr,
figure.wp-block-table.event-table thead tr,
table.award-table thead tr,
table.event-table thead tr {
  background-color: #00539f;
  color: #ffffff;
}

figure.wp-block-table.award-table thead th,
figure.wp-block-table.event-table thead th,
table.award-table thead th,
table.event-table thead th {
  font-weight: 700;
  background-color: #00539f;
  color: #ffffff;
  text-align: left;
  padding: 8px; /* match .ime-publications-block th padding */
  box-sizing: border-box;
}

/* No rounded corners in header ends*/
figure.wp-block-table.award-table thead th:first-child,
figure.wp-block-table.event-table thead th:first-child,
table.award-table thead th:first-child,
table.event-table thead th:first-child,
figure.wp-block-table.award-table thead th:last-child,
figure.wp-block-table.event-table thead th:last-child,
table.award-table thead th:last-child,
table.event-table thead th:last-child {
  border-radius: 0;
}

/* Zebra stripes for tbody rows (when there IS a thead) */
figure.wp-block-table.award-table thead + tbody tr:nth-child(even),
figure.wp-block-table.event-table thead + tbody tr:nth-child(even),
table.award-table thead + tbody tr:nth-child(even),
table.event-table thead + tbody tr:nth-child(even) {
  background-color: #ececec;
}

figure.wp-block-table.award-table thead + tbody tr:nth-child(odd),
figure.wp-block-table.event-table thead + tbody tr:nth-child(odd),
table.award-table thead + tbody tr:nth-child(odd),
table.event-table thead + tbody tr:nth-child(odd) {
  background-color: #ffffff;
}

/* If there's no thead: first row behaves like header (blue) */
figure.wp-block-table.award-table tbody tr:first-child,
figure.wp-block-table.event-table tbody tr:first-child,
table.award-table tbody tr:first-child,
table.event-table tbody tr:first-child {
  background-color: #00539f;
  color: #ffffff;
  font-weight: 700;
}

/* After first row in "no thead" mode: zebra */
figure.wp-block-table.award-table tbody tr:not(:first-child):nth-child(even),
figure.wp-block-table.event-table tbody tr:not(:first-child):nth-child(even),
table.award-table tbody tr:not(:first-child):nth-child(even),
table.event-table tbody tr:not(:first-child):nth-child(even) {
  background-color: #ececec;
}

figure.wp-block-table.award-table tbody tr:not(:first-child):nth-child(odd),
figure.wp-block-table.event-table tbody tr:not(:first-child):nth-child(odd),
table.award-table tbody tr:not(:first-child):nth-child(odd),
table.event-table tbody tr:not(:first-child):nth-child(odd) {
  background-color: #ffffff;
}

/* Column widths on desktop */
figure.wp-block-table.award-table th:first-child,
figure.wp-block-table.award-table td:first-child,
table.award-table th:first-child,
table.award-table td:first-child {
  width: 120px;
  white-space: nowrap;
}

figure.wp-block-table.event-table th:first-child,
figure.wp-block-table.event-table td:first-child,
table.event-table th:first-child,
table.event-table td:first-child {
  width: 120px;
  white-space: nowrap;
}

figure.wp-block-table.event-table th:last-child,
figure.wp-block-table.event-table td:last-child,
table.event-table th:last-child,
table.event-table td:last-child {
  width: 120px;
  white-space: nowrap;
}

/* Make sure children elements don't overflow cells */
figure.wp-block-table.award-table *,
figure.wp-block-table.event-table *,
table.award-table td *,
table.event-table td * {
  max-width: 100%;
  box-sizing: border-box;
}

/* Root overflow safety (like publications-block) */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}


/* =========================
   响应式设计 (exactly mirrors ime-publications-block breakpoints)
   1) <=1024px: font-size 14px, padding 12px 8px, title ~16px
   2) <=768px: wrapper gets side padding 10px; table becomes block+scroll
   3) <=480px: font-size 13px; padding 8px 4px
   4) <=360px: card mode
   ========================= */


/* 1. 中等屏幕 (max-width:1024px)
   match .ime-publications-block @1024
*/
@media screen and (max-width: 1024px) {

  /* table text down to 14px */
  figure.wp-block-table.award-table table,
  figure.wp-block-table.event-table table,
  table.award-table,
  table.event-table {
    font-size: 14px;
  }

  /* cells padding 12px 8px just like .ime-publications-block td */
  figure.wp-block-table.award-table td,
  figure.wp-block-table.event-table td,
  table.award-table td,
  table.event-table td,
  figure.wp-block-table.award-table th,
  figure.wp-block-table.event-table th,
  table.award-table th,
  table.event-table th {
    padding: 12px 8px;
  }

  /* If you have "main content" cells like titles,
     publications-block nudges .pub-title a to 16px.
     We'll mirror that for non-first-child cells
     so visual hierarchy stays similar. */
  figure.wp-block-table.award-table td:not(:first-child),
  figure.wp-block-table.event-table td:not(:first-child),
  table.award-table td:not(:first-child),
  table.event-table td:not(:first-child) {
    font-size: 16px;
    line-height: 1.4;
  }
}

/* 2. 平板和小屏幕 (max-width:768px)
   match .ime-publications-block @768
   - outer gets padding 0 10px
   - table becomes block + horizontal scroll + nowrap
   - cells padding 10px 6px + allow wrapping
*/
@media screen and (max-width: 768px) {

  /* outer wrapper behaves like .ime-publications-block (padding + scroll shell) */
  figure.wp-block-table.award-table,
  figure.wp-block-table.event-table,
  table.award-table,
  table.event-table,
  .award-table-wrapper,
  .event-table-wrapper {
    padding: 0 10px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;                 /* horizontal scroll allowed */
    -webkit-overflow-scrolling: touch;
  }

  /* the table becomes block-like scrollable strip */
  figure.wp-block-table.award-table table,
  figure.wp-block-table.event-table table,
  table.award-table,
  table.event-table {
    font-size: 14px;                  /* same as publications-block @768 */
    display: block;
    overflow-x: auto;
    white-space: nowrap;              /* force horizontal scroll instead of ugly wraps */
    min-width: 600px;                 /* keep natural width > viewport */
    border-collapse: collapse;
    table-layout: auto;
  }

  /* cells adjust padding and re-allow wrapping*/
  figure.wp-block-table.award-table td,
  figure.wp-block-table.event-table td,
  table.award-table td,
  table.event-table td,
  figure.wp-block-table.award-table th,
  figure.wp-block-table.event-table th,
  table.award-table th,
  table.event-table th {
    padding: 10px 6px;                /* match publications-block @768 */
    white-space: normal;              /* allow multi-line text inside cell */
    font-size: 14px;                  /* titles shrink like .pub-title a -> ~15px; we'll unify to 14px base */
    line-height: 1.4;
  }

  /* keep first/last column narrow for time/date columns */
  figure.wp-block-table.award-table th:first-child,
  figure.wp-block-table.award-table td:first-child,
  table.award-table th:first-child,
  table.award-table td:first-child,
  figure.wp-block-table.event-table th:first-child,
  figure.wp-block-table.event-table td:first-child,
  table.event-table th:first-child,
  table.event-table td:first-child,
  figure.wp-block-table.event-table th:last-child,
  figure.wp-block-table.event-table td:last-child,
  table.event-table th:last-child,
  table.event-table td:last-child {
    width: 120px;
    white-space: nowrap;
  }
}

/* 3. 手机屏幕 (max-width:480px)
   match .ime-publications-block @480
   - font-size 13px table level
   - padding 8px 4px
   - still horizontal scroll mode
*/
@media screen and (max-width: 480px) {

  figure.wp-block-table.award-table,
  figure.wp-block-table.event-table,
  table.award-table,
  table.event-table,
  .award-table-wrapper,
  .event-table-wrapper {
    padding: 0 8px;
    font-size: 14px; /* publications-block sets container font-size:14px */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  figure.wp-block-table.award-table table,
  figure.wp-block-table.event-table table,
  table.award-table,
  table.event-table {
    font-size: 13px;          /* publications-block table @480 -> 13px */
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    min-width: 600px;
  }

  figure.wp-block-table.award-table td,
  figure.wp-block-table.event-table td,
  table.award-table td,
  table.event-table td,
  figure.wp-block-table.award-table th,
  figure.wp-block-table.event-table th,
  table.award-table th,
  table.event-table th {
    padding: 8px 4px;         /* publications-block td @480 -> 8px 4px */
    white-space: normal;
    font-size: 13px;          /* align cell text with table font-size */
    line-height: 1.4;
  }

  /* at super small screens we also shrank the fixed columns to 90px before;
     keep that here so time columns don't look insane */
  figure.wp-block-table.award-table th:first-child,
  figure.wp-block-table.award-table td:first-child,
  table.award-table th:first-child,
  table.award-table td:first-child,
  figure.wp-block-table.event-table th:first-child,
  figure.wp-block-table.event-table td:first-child,
  table.event-table th:first-child,
  table.event-table td:first-child,
  figure.wp-block-table.event-table th:last-child,
  figure.wp-block-table.event-table td:last-child,
  table.event-table th:last-child,
  table.event-table td:last-child {
    width: 90px;
    white-space: nowrap;
  }
}

/* 4. 超小屏幕 (max-width:360px)
   match .ime-publications-block @360
   - switch to card layout
   - hide thead
   - vertical stack cells
*/
@media screen and (max-width: 360px) {

  figure.wp-block-table.award-table,
  figure.wp-block-table.event-table,
  table.award-table,
  table.event-table,
  .award-table-wrapper,
  .event-table-wrapper {
    padding: 0 5px;
    overflow-x: visible;
  }

  figure.wp-block-table.award-table table,
  figure.wp-block-table.event-table table,
  table.award-table,
  table.event-table {
    font-size: 12px;         /* publications-block table @360 -> 12px */
    display: block;
    overflow-x: visible;
    white-space: normal;
    min-width: 0;            /* stop forcing horizontal scroll in card mode */
  }

  /* hide table header */
  figure.wp-block-table.award-table thead,
  figure.wp-block-table.event-table thead,
  table.award-table thead,
  table.event-table thead {
    display: none;
  }

  /* each row becomes a card */
  figure.wp-block-table.award-table tbody tr,
  figure.wp-block-table.event-table tbody tr,
  table.award-table tbody tr,
  table.event-table tbody tr {
    display: block;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    background: #f9f9f9;
    width: 100%;
    box-sizing: border-box;
  }

  /* cells become stacked lines */
  figure.wp-block-table.award-table td,
  figure.wp-block-table.event-table td,
  table.award-table td,
  table.event-table td {
    display: block;
    padding: 5px 0;
    text-align: left;
    border: none;
    width: 100% !important;
    white-space: normal !important;
    font-size: 12px;          /* publications-block secondary text @360 ~12px */
    line-height: 1.4;
  }

  /* first cell (date/year etc.) becomes highlighted like .pub-year in publications-block */
  figure.wp-block-table.award-table td:first-child,
  figure.wp-block-table.event-table td:first-child,
  table.award-table td:first-child,
  table.event-table td:first-child {
    margin-bottom: 5px;
    font-size: 14px;          /* publications-block pub-year @360 -> 14px */
    color: #00539f;
    font-weight: bold;
  }
}


