/*
 * YOBB responsive overflow corrections.
 * Loaded after the migrated snippet styles so these narrow, page-specific
 * rules remain stable when Elementor content is edited.
 */

@media (max-width: 1024px) {
  /*
   * Oma sivu: nested Elementor flex containers inherited a full viewport
   * width even when their parent had a small inset. Let them stretch inside
   * the available content box instead of extending past its right edge.
   */
  body:has(.yobb-cv-page) {
    overflow-x: clip;
  }

  body:has(.yobb-cv-page) .e-con.e-child:has(.yobb-cv-page),
  body:has(.yobb-cv-page) .elementor-widget-shortcode:has(.yobb-cv-page) {
    width: auto !important;
    max-width: 100% !important;
    min-width: 0 !important;
    align-self: stretch !important;
  }

  body:has(.yobb-cv-page)
    .elementor-widget-shortcode:has(.yobb-cv-page)
    > .elementor-widget-container,
  body:has(.yobb-cv-page)
    .elementor-widget-shortcode:has(.yobb-cv-page)
    .elementor-shortcode,
  body:has(.yobb-cv-page) .yobb-cv-page {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /*
   * Suosikit: the Elementor child has 5 px margins on both sides. Its width
   * must account for those margins instead of adding them to width: 100%.
   */
  body:has(.yobb-saved-jobs-page) {
    overflow-x: clip;
  }

  body:has(.yobb-saved-jobs-page)
    .e-con.e-child:has(.yobb-saved-jobs-page) {
    width: calc(100% - 10px) !important;
    max-width: calc(100% - 10px) !important;
    min-width: 0 !important;
    flex-basis: calc(100% - 10px) !important;
  }

  body:has(.yobb-saved-jobs-page)
    .elementor-widget-shortcode:has(.yobb-saved-jobs-page),
  body:has(.yobb-saved-jobs-page)
    .elementor-widget-shortcode:has(.yobb-saved-jobs-page)
    > .elementor-widget-container,
  body:has(.yobb-saved-jobs-page)
    .elementor-widget-shortcode:has(.yobb-saved-jobs-page)
    .elementor-shortcode,
  body:has(.yobb-saved-jobs-page) .yobb-saved-jobs-page {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
}

@media (max-width: 767px) {
  /* Keep the full job title on one line at normal mobile title lengths. */
  .yobb-feed-list-main .yobb-feed-title,
  .yobb-feed-list-main .yobb-feed-title.yobb-heading {
    font-size: clamp(16px, 5.3vw, 20px) !important;
    line-height: 1.08;
    letter-spacing: -0.01em;
  }

  /*
   * Privacy tables become labelled cards on mobile. This removes the hidden
   * horizontal swipe while retaining the original semantic table in HTML.
   */
  body.privacy-policy .wp-block-table {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    overflow: visible;
  }

  body.privacy-policy .wp-block-table table,
  body.privacy-policy .wp-block-table tbody {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
  }

  body.privacy-policy .wp-block-table thead {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
  }

  body.privacy-policy .wp-block-table tbody {
    display: grid;
    gap: 12px;
  }

  body.privacy-policy .wp-block-table tbody tr {
    display: block;
    width: 100%;
    overflow: hidden;
    border: 1px solid rgb(0 61 45 / 14%);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 24px rgb(0 61 45 / 6%);
  }

  body.privacy-policy .wp-block-table tbody td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 10px;
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px 14px;
    overflow-wrap: anywhere;
    border: 0;
    border-top: 1px solid rgb(0 61 45 / 10%);
    vertical-align: start;
  }

  body.privacy-policy .wp-block-table tbody td:first-child {
    border-top: 0;
  }

  body.privacy-policy .wp-block-table tbody td::before {
    color: #258c35;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
  }

  body.privacy-policy
    .wp-block-table:has(thead th:nth-child(2):last-child)
    tbody td:nth-child(1)::before {
    content: "Tarkoitus";
  }

  body.privacy-policy
    .wp-block-table:has(thead th:nth-child(2):last-child)
    tbody td:nth-child(2)::before {
    content: "Oikeusperuste";
  }

  body.privacy-policy
    .wp-block-table:has(thead th:nth-child(3))
    tbody td:nth-child(1)::before {
    content: "Palveluntarjoaja";
  }

  body.privacy-policy
    .wp-block-table:has(thead th:nth-child(3))
    tbody td:nth-child(2)::before {
    content: "Käyttötarkoitus";
  }

  body.privacy-policy
    .wp-block-table:has(thead th:nth-child(3))
    tbody td:nth-child(3)::before {
    content: "Käsiteltävät tiedot";
  }
}

@media (max-width: 380px) {
  .yobb-feed-list-main .yobb-feed-title,
  .yobb-feed-list-main .yobb-feed-title.yobb-heading {
    font-size: clamp(15px, 5vw, 18px) !important;
  }

  body.privacy-policy .wp-block-table tbody td {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* Keep the mobile CV contact details readable beside the profile header. */
@media (max-width: 767px) {
  body:has(.yobb-cv-page) .yobb-cv-profile-card {
    grid-template-columns: clamp(88px, 30%, 108px) minmax(0, 1fr) !important;
    column-gap: clamp(11px, 3vw, 16px) !important;
  }

  body:has(.yobb-cv-page) .yobb-cv-profile-side {
    display: contents;
  }

  body:has(.yobb-cv-page) .yobb-cv-photo-wrap {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
  }

  body:has(.yobb-cv-page) .yobb-cv-profile-content {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }

  body:has(.yobb-cv-page) .yobb-cv-contact {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    width: 100%;
    margin-top: 2px;
  }

  body:has(.yobb-cv-page) .yobb-cv-contact-item {
    max-width: 100%;
    font-size: clamp(11px, 3.2vw, 13px) !important;
    line-height: 1.35;
  }
}
