/*
 * M2 · Policies: D-06 list, D-07 detail (M-02 phones, A-20 impersonation), D-08 signature dialog
 * (M-03 full screen on phones). Built on the shared list, card, statement, chip, dialog and
 * signature-pad components; only page layout lives here.
 * E-02 (Employees) is the same list with .policies-list--staff: icon tile + title, Version,
 * Effective, Status and the button, and the search field at the end of the toolbar.
 */
@layer pages {
  /* D-06 Policies list ----------------------------------------------------------------------- */
  .policies-list {
    --list-cols: minmax(0, 2.6fr) 84px 120px 120px minmax(0, 1.7fr) 210px;
  }

  .policies-list__title {
    color: var(--color-text);
    text-decoration: none;
  }
  .policies-list__title:hover { color: var(--color-text); text-decoration: underline; }

  .policies-list__none { font-size: 13px; }

  /* E-02 Policies for Employees -------------------------------------------------------------- */
  .policies-toolbar__search { margin-left: auto; }

  .policies-list--staff {
    --list-cols: minmax(0, 1.8fr) 100px 140px 140px 150px;
  }

  .policies-list--staff .policies-list__main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  .policies-list__icon {
    width: 36px;
    height: 36px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: var(--radius-thumb);
    background: var(--petal-policy-bg);
    color: var(--petal-policy-fg);
    font-size: 17px;
  }

  .policies-list__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .policies-list--staff .policies-list__title { font-weight: 700; }

  /* "v4.1 · Effective Sep 30, 2026" under the title, where the two columns are dropped. */
  .policies-list__meta { display: none; }

  .policies-list__version { font: 700 12px var(--font-mono); }

  .policies-list--staff .policies-list__end {
    display: flex;
    align-items: center;
  }

  /* D-07 Policy detail ----------------------------------------------------------------------- */
  /* The M-02 one-line meta ("v4.1 · Effective Oct 1, 2026 · Global") rides in the page-head
     description slot and only shows on phones; desktop uses the meta pills. */
  .policy-head .page-head__desc { display: none; }

  .policy-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
    align-items: start;
  }

  .policy-detail__doc {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
  }

  /* The acknowledgment panel stays in view while the policy is read. */
  .policy-detail__aside {
    position: sticky;
    top: 16px;
  }
  .app--banner .policy-detail__aside { top: calc(var(--banner-height) + 16px); }

  .policy-ack__head {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .policy-ack__title {
    font-size: 20px;
    letter-spacing: -0.01em;
    line-height: 1.2;
  }
  .policy-ack__due {
    font-size: 13.5px;
    color: var(--color-neutral-800);
  }
  .policy-ack .btn--lg { height: 50px; }
  .policy-ack__note {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--color-neutral-700);
  }

  /* D-08 · done */
  .policy-ack--done { gap: 18px; }
  .policy-ack__done-head {
    display: flex;
    align-items: center;
    gap: 14px;
  }
  .policy-ack__done-icon {
    width: 46px;
    height: 46px;
    font-size: 22px;
  }
  .policy-ack__done-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .policy-ack__done-title {
    font-size: 18px;
    letter-spacing: 0;
    line-height: 1.3;
  }
  .policy-ack__done-when {
    font-size: 13.5px;
    color: var(--color-neutral-800);
  }
  .policy-ack__signature { max-height: 68px; }

  .policy-video {
    padding: 14px;
    border-radius: var(--radius-card);
    background: var(--color-surface);
  }
  .policy-video__player {
    width: 100%;
    max-height: 600px;
    border-radius: var(--radius-row);
    background: var(--color-text);
  }

  /* M-02 bottom sheet */
  .policy-sheet__days {
    flex: none;
    font-size: 12.5px;
    font-weight: 700;
  }

  /* D-08 signature dialog -------------------------------------------------------------------- */
  .policy-sign {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  /* Laptop: the fixed columns would squeeze titles; drop the two date columns. */
  @media (max-width: 1199px) {
    .policies-list:not(.policies-list--staff) { --list-cols: minmax(0, 2fr) 60px minmax(0, 1.6fr) 190px; }
    .policies-list:not(.policies-list--staff) > .list-header > :is(:nth-child(3), :nth-child(4)),
    .policies-list:not(.policies-list--staff) > .list-row > :is(:nth-child(3), :nth-child(4)) { display: none; }
    .policy-detail { grid-template-columns: minmax(0, 1fr) 340px; }

    /* E-02: Version and Effective move under the title. */
    .policies-list--staff { --list-cols: minmax(0, 1fr) 140px 150px; }
    .policies-list--staff > .list-header > :is(:nth-child(2), :nth-child(3)),
    .policies-list__version,
    .policies-list__effective { display: none; }
    .policies-list__meta { display: block; }
  }

  /* Tablet: the panel moves under the document. */
  @media (max-width: 1023px) {
    .policy-detail { grid-template-columns: minmax(0, 1fr); }
    .policy-detail__aside { position: static; }
  }

  /* Phones (M-02): title + one-line meta, preview, "Open Full Document"; the action is in the
     bottom sheet. List rows stack: title over the status chip and a short "Review" button. */
  @media (max-width: 767px) {
    .policies-list .list-row {
      grid-template-columns: minmax(0, 1fr) auto;
      grid-template-areas: "main main" "status end";
      gap: 10px 12px;
    }
    .policies-list__main { grid-area: main; }
    .policies-list__status { grid-area: status; }
    .policies-list__end { grid-area: end; }
    /* The whole stacked card opens the policy (the title link is stretched over it); the
       Review/View button stays on top. */
    .policies-list__title::after {
      content: "";
      position: absolute;
      inset: 0;
      border-radius: var(--radius-row);
    }
    .policies-list__end {
      position: relative;
      z-index: 1;
    }
    .policies-list--staff .policies-list__main { align-items: flex-start; }
    .policies-list--staff .policies-list__title { font-size: 15px; }
    .policies-list--staff .policies-list__status { align-items: center; }

    .policy-head .page-head--detail .page-head__text { gap: 8px; }
    .policy-head .petal,
    .policy-head .page-head__meta,
    .policy-head .page-head__actions { display: none; }
    .policy-head .page-head__desc {
      display: block;
      font-size: 13px;
    }

    .policy-detail { gap: 14px; }

    .policy-sign { gap: 14px; }
  }
}
