/* Partner Portal: layout and accessibility rules that utilities don't cover.
   Loaded after tailwind.css. */

html, body { margin: 0; padding: 0; }
body { overscroll-behavior: none; }
main > :first-child { margin-top: 0 !important; }
main > :last-child { margin-bottom: 0 !important; }
::-webkit-scrollbar { display: none; }
input[type="search"]::-webkit-search-cancel-button { display: none; }

html { scroll-padding-top: calc(5rem + env(safe-area-inset-top, 0px)); }
.pt-safe { padding-top: env(safe-area-inset-top, 0px); }
.pb-safe { padding-bottom: env(safe-area-inset-bottom, 0px); }
main { padding-top: calc(4rem + env(safe-area-inset-top, 0px)); }

/* Keyboard focus */
:focus-visible { outline: 2px solid #316bf3; outline-offset: 2px; }
header :focus-visible, footer :focus-visible { outline-color: #ffffff; }

/* Room for the fixed bottom navigation */
@media (max-width: 1023.98px) {
  body { padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px)); }
}

/* Phones: same cards, mobile arrangement */
@media (max-width: 767.98px) {
  /* Pinned cards become a horizontal swipe row */
  .pinned-row {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    margin-inline: -1rem;
    padding: 0.5rem 1rem;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 1rem;
  }
  .pinned-card {
    flex: 0 0 240px;
    padding: 1rem;
    scroll-snap-align: start;
  }
  .pinned-card:hover { transform: none; }
  .pinned-actions { margin-top: 0.75rem; padding-top: 0; }
  .pinned-actions button {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  /* Module cards: icon, badge and title in a row; text and action below */
  .module-card {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    column-gap: 0.75rem;
    padding: 1rem;
    align-items: center;
  }
  .module-card.hidden { display: none; }
  .module-card:hover { transform: none; }
  .module-card > div:first-child,
  .module-card > div:first-child > div:first-child { display: contents; }
  .module-card > div:first-child > div:first-child > div:first-child {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 44px;
    height: 44px;
  }
  .module-card .module-badge {
    grid-column: 2;
    grid-row: 1;
    justify-self: start;
    margin-bottom: 0.125rem;
  }
  .module-card h3 {
    grid-column: 2;
    grid-row: 2;
    font-size: 17px;
    line-height: 24px;
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
  }
  .module-card .module-pin { grid-column: 3; grid-row: 1 / span 2; }
  .module-card p {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 0.75rem;
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
  }
  .module-card > div:last-child {
    grid-column: 1 / -1;
    grid-row: 4;
    margin-top: 0.5rem;
    padding-top: 0;
  }
  .module-card > div:last-child button {
    width: auto;
    min-height: 44px;
    padding-inline: 1rem;
  }
}

/* Comfortable bookmark tap target below desktop */
@media (max-width: 1023.98px) {
  .module-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }
}

/* 24px minimum target on desktop; the negative margin keeps the icon in place */
@media (min-width: 1024px) {
  .module-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
    margin: -3px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
