/*
  Science Kids USA - responsive layer for tablets and phones.

  Linked as the LAST stylesheet on every page, so it can override the older
  fixed-width (1000px table) layout. Everything is inside @media queries, so the
  desktop layout (wider than 1040px) is unchanged.
*/

/* ---------- Tablets and smaller (1040px and under) ---------- */
@media (max-width: 1040px) {

  html { -webkit-text-size-adjust: 100%; }

  img { max-width: 100%; height: auto; }

  /* The page is one big 1000px-wide table: let it shrink to the screen. */
  table[width="1000"] { width: 100% !important; max-width: 1000px; }
  table[width="1000"] td[width] { width: auto !important; }
  td[height] { height: auto !important; }
  td[height="550"], td[height="500"] { height: 330px !important; }

  /* Hero photo: scale and centre it instead of showing the left corner of a 1920px image. */
  body {
    background-size: auto 470px !important;
    background-position: center top !important;
  }

  /* Menu tabs: wrap onto several lines instead of being cut off. */
  .mattblacktabs ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 10px 8px;
  }
  .mattblacktabs li { display: block; }
  .mattblacktabs li:empty { display: none; }
  .mattblacktabs li a {
    display: block;
    margin: 0;
    padding: 12px 16px;
    text-align: center;
  }

  /* Embedded videos and the slideshow keep their proportions. */
  iframe[src*="youtube"] {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
    max-width: 100%;
  }
  iframe[src*="slideshow"] {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 950 / 330;
    min-height: 300px;
    max-width: 100%;
  }
  iframe[src*="acuityscheduling"] { width: 100% !important; max-width: 100%; }

  /* Boxes inside the page: use the full width. */
  table[width="80%"], table[width="800"] { width: 100% !important; }
  table[width="80%"] td[width], table[width="800"] td[width] { width: auto !important; }

  .BOX-IMAGE, .BOX-LIST, .BOX-FAVORS, .BOX-LEFT, .C-content-Box4 { box-sizing: border-box; }
  .BOX-LIST { font-size: 13pt; }
}

/* ---------- Phones (700px and under) ---------- */
@media (max-width: 700px) {

  body {
    background-size: auto 500px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Stack the page layout: one column. */
  table[width="1000"],
  table[width="1000"] > tbody,
  table[width="1000"] > tbody > tr,
  table[width="1000"] > tbody > tr > td {
    display: block;
    width: auto !important;
    box-sizing: border-box;
  }
  table[width="1000"] > tbody > tr > td { text-align: center; }
  table[width="1000"] > tbody > tr > td.selected { padding: 8px 0 0; }

  /* Rows with exactly three cells (the BOOK / CALL / MAIL buttons and the footer links) stay side by side. */
  table[width="1000"] > tbody > tr:has(> td:nth-child(3):last-child) { display: flex; }
  table[width="1000"] > tbody > tr:has(> td:nth-child(3):last-child) > td {
    flex: 1 1 0;
    min-width: 0;
  }

  /* Hero area: shorter, with the big title scaled to fit. */
  td[height="550"], td[height="500"] { height: auto !important; min-height: 150px; padding-top: 10px; }
  td[height="550"] > p:empty,
  td[height="500"] > p:empty { display: none; }

  .SWANKY-HEAD {
    font-size: 19pt;
    line-height: 1.15;
    text-shadow: 2px 2px #336699;
  }
  .SWANKY-INDEX { font-size: 17pt; line-height: 1.4; text-shadow: 2px 2px #336699; }
  .SWANKY-ORANGE, .SWANKY-BLUE { font-size: 22pt; line-height: 1.2; }
  .SWANKY-ORANGE .BOX-IMAGE { display: block; }

  /* Headings and text */
  .aHead-04, .aHead-06-c { font-size: 14pt; }
  .aHead-05 { font-size: 14pt; }
  .headline1 { font-size: 13pt; }
  .C-content-B { font-size: 11pt; line-height: 1.5; }
  .C-content-A { font-size: 11pt; }
  .BOX-IMAGE { font-size: 12pt; padding: 8px; }
  .BOX-LIST { font-size: 12pt; padding-left: 12px; padding-right: 12px; }
  .C-content-Box4 { font-size: 13pt; }
  .FOOTER { padding-left: 10px; text-align: center; }
  .bullet-02 { font-size: 12pt; }
  .bullet-04, .bullet-05 { font-size: 11pt; margin-left: 4px; margin-right: 4px; }
  .bullet-03 { font-size: 10pt; margin-left: 4px; margin-right: 4px; }
  .headline-Center, .headline-Center p { font-size: 10pt; }
  .headline-Center a { font-size: 9pt; letter-spacing: 0; }
  iframe[src*="slideshow"] { aspect-ratio: auto; height: 250px !important; min-height: 0; }

  /* Tables inside the page (experiment lists etc.) */
  table[width="80%"], table[width="800"] { width: 100% !important; }
  table[width="80%"] tr:has(img) > td {
    display: block;
    width: auto !important;
    text-align: center;
  }

  /* Menu tabs a little tighter */
  .mattblacktabs li a { padding: 10px 12px; font-size: 9pt; }
}
