/* Editorial text links in classic and block content. Components keep their own palettes. */
:is(#penci-post-entry-inner, .penci-gdpr-message) {
  --te-prose-link: #145ac1;
  --te-prose-link-active: #0c427f;
}
body.pcdark-mode :is(#penci-post-entry-inner, .penci-gdpr-message) {
  --te-prose-link: #83b9ff;
  --te-prose-link-active: #b9daff;
}

:is(
  #penci-post-entry-inner,
  #penci-post-entry-inner > .te-ppt-index,
  #penci-post-entry-inner > :where(blockquote:not([class]), blockquote.wp-block-quote),
  #penci-post-entry-inner > section:not([class]),
  #penci-post-entry-inner :where(.wp-block-group, .wp-block-group__inner-container)
) > :where(
  p:not([class]), p.wp-block-paragraph, p.te-source-credit, p[class*="has-text-align-"],
  p.alignleft, p.aligncenter, p.alignright, p.alignwide, p.alignfull,
  ol:not([class]), ul:not([class]), .wp-block-list
) a[href]:not([class]:not([class=""]), [style], [role], [download]):not(:empty):not(:has(:not(strong, b, em, i, span, small, sup, sub, code))):not(:where(nav, aside, figure, table, .gallery, .wp-caption, .has-background, .has-text-color, [style*="color"], [role="navigation"]) a),
#penci-post-entry-inner .te-index-nav > a[href],
#penci-post-entry-inner .te-deck-card .te-source > a[href],
#penci-post-entry-inner:has(> .te-ppt-index) > aside:not([class], [style]) > p > a[href]:not([class], [style], [role], [download]):not(:has(img)),
#penci-post-entry-inner > .source > a[href]:not([class], [style]),
.penci-gdpr-message a#gdpr-comment[href] {
  color: var(--te-prose-link);
  background-image: none;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .16em;
  text-decoration-skip-ink: auto;

  &:hover,
  &:active,
  &:focus-visible {
    color: var(--te-prose-link-active);
    text-decoration-line: underline;
  }
  &:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
  }
}

/* This legacy surface has an important light fill in the manual stylesheet. */
body.pcdark-mode .post-entry.blockquote-style-2 #penci-post-entry-inner > :where(blockquote:not([class]), blockquote.wp-block-quote):not([style], .has-background) {
  background: var(--pcbg-l-cl, #292929) !important;
}

/* A row and its text links invert together. Preserve each cell's existing palette. */
#penci-post-entry-inner table tr:has(> :is(td, th) a[href]:not([class]:not([class=""]), [style], [role], [download])):not(:has(a :is(img, picture, svg, video, canvas))) {
  & > :is(td, th) {
    transition: none;
  }

  & > :is(td, th) a[href]:not([class]:not([class=""]), [style], [role], [download]):not(:empty):not(:has(:not(strong, b, em, i, span, small, sup, sub, code, abbr))) {
    background-image: none;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: .16em;
    text-decoration-skip-ink: auto;
    transition: none;

    &:focus-visible {
      outline: 2px solid currentColor;
      outline-offset: 2px;
    }
  }
}

/* Comparison-guide row-header anchors use the editor's native underline.
   Keep the author's inherited (white) text colour on blue header cells. */
#penci-post-entry-inner > .te-software-guide-table th[scope="row"] > a[href^="#"]:is([style*="text-decoration:underline" i], [style*="text-decoration: underline" i]) {
  background-image: none;
  &:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
  }
}

/* Post tags invert from outline to blue fill. Move only the chip, never tween foreground against background. */
#penci-post-entry-inner .post-tags:not(.penci-post-sources) > a {
  color: #666;
  transition-property: transform;
}
body:is(.pcdark-mode, .pcdm-enable:not(.pclight-mode)) #penci-post-entry-inner .post-tags:not(.penci-post-sources) > a {
  color: #fff;
}
#penci-post-entry-inner .post-tags:not(.penci-post-sources) > a:hover {
  color: #fff;
  background-color: #1165f1;
}
#penci-post-entry-inner .post-tags:not(.penci-post-sources) > a:focus-visible {
  outline: 2px solid var(--te-control-focus, #1165f1);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  #penci-post-entry-inner .post-tags:not(.penci-post-sources) > a {
    transition: none;
    transform: none;
  }
}

/* Keep the existing TOC hover. Indicate the row or disclosure that has keyboard focus. */
#penci-post-entry-inner .penci-toc-wrapper .penci-toc-link:focus-visible,
#penci-post-entry-inner .penci-toc-head:has(.penci-toc-toggle:focus-visible) {
  outline: 2px solid var(--te-control-focus, #1165f1);
  outline-offset: -2px;
  transition: none;
}

/* Only editorial lists directly in the article, plus plain nested lists.
   A navigation widget embedded in a step keeps its own component styles. */
@media (max-width: 700px) {
  #penci-post-entry-inner > :is(ol, ul):where(:not([class]), [class=""], [class="wp-block-list"]):not([type]) {
    &,
    & > li > :is(ol, ul):where(:not([class]), [class=""], [class="wp-block-list"]):not([type]),
    & > li > :is(ol, ul):where(:not([class]), [class=""], [class="wp-block-list"]):not([type]) > li > :is(ol, ul):where(:not([class]), [class=""], [class="wp-block-list"]):not([type]) {
      padding: 0;
      padding-inline-start: 1.55em;
      min-width: 0;
      margin-block: 0.8em 1.15em;
      box-shadow: none;
      border: 0;
      border-radius: 0;
      background: transparent;

      list-style-type: revert;

      & > li {
        display: list-item;
        margin: 0.55em 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
        list-style-position: outside;
        list-style-type: inherit;
      }
      & > li::before {
        content: none;
      }
      & > li::marker {
        color: currentColor;
        font-weight: 600;
        font-variant-numeric: tabular-nums;
      }
    }

    & > li > :is(ol, ul):where(:not([class]), [class=""], [class="wp-block-list"]):not([type]),
    & > li > :is(ol, ul):where(:not([class]), [class=""], [class="wp-block-list"]):not([type]) > li > :is(ol, ul):where(:not([class]), [class=""], [class="wp-block-list"]):not([type]) {
      padding-inline-start: 1.2em;
      margin-block: 0.4em 0.65em;
    }
  }
}

/* In the theme's step cards an unordered child otherwise inherits the
   numbered badge's size, border and counter increment. Keep the card
   geometry, use a small dot beside the first line. */
@media (min-width: 701px) {
  #penci-post-entry-inner > ol:where(:not([class]), [class=""], [class="wp-block-list"]):not([type])
    > li > ul:where(:not([class]), [class=""], [class="wp-block-list"]):not([type]) > li::before {
    content: "";
    counter-increment: none;
    top: calc(10px + 0.73em - 2.5px);
    inset-inline-start: 0.625em;
    width: 5px;
    height: 5px;
    margin: 0;
    border: 0;
    border-radius: 50%;
    background: currentColor;
    color: inherit;
    box-shadow: none;
    font-size: inherit;
    opacity: 1;
    pointer-events: none;
    will-change: auto;
  }
}

@counter-style te-reader-step {
  system: extends decimal;
  suffix: "\2002\2009";
  speak-as: numbers;
}

@media (max-width: 700px) {
  #penci-post-entry-inner > ol:where(:not([class]), [class=""], [class="wp-block-list"]):not([type]):not([start]):not([reversed]):not(:has(> li[value], > li:nth-child(100))) {
    padding-inline-start: 2em;

    & > li {
      position: relative;
      isolation: isolate;
      list-style-type: te-reader-step;
    }
    & > li::marker {
      font-size: .88em;
      font-weight: 650;
      font-variant-numeric: tabular-nums;
      color: #fff;
    }
    & > li::before {
      content: "";
      counter-increment: none;
      position: absolute;
      inset: .13em auto auto;
      inset-inline-start: auto;
      inset-inline-end: calc(100% + .35em);
      width: 1.22em;
      height: 1.22em;
      margin: 0;
      border: 0;
      border-radius: 50%;
      background: linear-gradient(145deg, #173555, #456783);
      box-shadow: none;
      pointer-events: none;
      z-index: -1;
    }
    &:has(> li:nth-child(10)) { padding-inline-start: 2.4em; }
    & > li:nth-child(n + 10)::before {
      width: 1.78em;
      border-radius: 1em;
    }
  }
}

/* The existing Soledad step badge sits halfway down the entire list item.
   Align it with the first line even when a step contains a gallery. */
@media (min-width: 701px) {
  #penci-post-entry-inner > ol:where(:not([class]), [class=""], [class="wp-block-list"]):not([type]):not([start]):not([reversed]):not(:has(> li[value])) > li::before {
    top: .36em;
    margin-top: 0;
  }
}
@media (forced-colors: active) and (max-width: 700px) {
  #penci-post-entry-inner > ol > li::marker { color: CanvasText !important; }
  #penci-post-entry-inner > ol > li::before { background: Canvas; }
}

/* Explicit sequences keep the browser's real marker, including start,
   reversed and per-item values. Some engines support the "s" attribute
   flag, others distinguish case on explicitly no-namespace attributes.
   Apply the A/a (or I/i) repair only when one casing matches exclusively. */
#penci-post-entry-inner > ol:where(:not([class]), [class=""], [class="wp-block-list"]) {
  &:is([type="a" s], [|type="a"]:not([|type="A"])) { --te-list-type: lower-alpha; }
  &:is([type="A" s], [|type="A"]:not([|type="a"])) { --te-list-type: upper-alpha; }
  &:is([type="i" s], [|type="i"]:not([|type="I"])) { --te-list-type: lower-roman; }
  &:is([type="I" s], [|type="I"]:not([|type="i"])) { --te-list-type: upper-roman; }

  &:not([type]):is([start], [reversed], :has(> li[value])),
  &:is([type="1"], [type="a" s], [type="A" s], [type="i" s], [type="I" s],
    [|type]:is([type="a" i], [type="i" i]):not([|type="A"][|type="a"], [|type="I"][|type="i"])) {
    padding-inline-start: 2.5em;

    & > li {
      display: list-item;
      list-style: var(--te-list-type, decimal) outside;
      padding: 0;
      border: 0;
      border-radius: 0;
      box-shadow: none;
      background: transparent;
      margin-block: .55em;
    }
    & > li::before { content: none; }
    & > li::marker { content: normal; color: inherit; }
  }
}

/* Editorial downloads and inline related-post cards. Keep the existing boxes and hit areas. */
#penci-post-entry-inner {
  --te-download-base: #314755;
  --te-download-band: #087697;
  --te-download-edge: rgb(19 55 71 / 16%);
  --te-download-text: #fff;
  --te-card-surface: #fff;
  --te-card-heading: #283746;
  --te-card-label: #526170;
  --te-card-hover: var(--te-prose-link-active, #0c427f);
  --te-card-edge: rgb(26 49 75 / 14%);
  --te-control-focus: #1165f1;
}
body.pcdark-mode #penci-post-entry-inner {
  --te-download-base: #2a4354;
  --te-download-text: #fff;
  --te-download-band: #097b9c;
  --te-download-edge: #719eae;
  --te-card-surface: #202b38;
  --te-card-heading: #eaf1f8;
  --te-card-label: #bdc9d8;
  --te-card-hover: var(--te-prose-link-active, #b9daff);
  --te-card-edge: rgb(191 212 235 / 25%);
  --te-control-focus: #a9cdff;
}
#penci-post-entry-inner :is(a.download-button, .wp-block-button.download-button > a) {
  color: var(--te-download-text);
  background-color: var(--te-download-base);
  background-image: linear-gradient(100deg, var(--te-download-base), var(--te-download-band) 50%, var(--te-download-base));
  background-size: 200% 100%;
  background-position: left center;
  background-repeat: no-repeat;
  text-shadow: none;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--te-download-edge), 0 1px 3px rgb(22 43 70 / 18%);
  transition: none;
}
#penci-post-entry-inner a.IRPP_kangoo {
  background-color: var(--te-card-surface);
  box-shadow: inset 0 0 0 1px var(--te-card-edge), 0 1px 4px rgb(13 35 67 / 12%);
}
#penci-post-entry-inner a.IRPP_kangoo .ctaText { color: var(--te-card-label); }
#penci-post-entry-inner a.IRPP_kangoo .postTitle { color: var(--te-card-heading); }
#penci-post-entry-inner a.IRPP_kangoo .imgUrl {
  transform: none;
  transition: none;
  will-change: auto;
}
#penci-post-entry-inner :is(a.download-button, .wp-block-button.download-button > a):is(:focus-visible, :active) {
  background-position: right center;
}
@media (hover: hover) {
  #penci-post-entry-inner :is(a.download-button, .wp-block-button.download-button > a) {
    transition: background-position 420ms ease-in-out;
  }
  #penci-post-entry-inner :is(a.download-button, .wp-block-button.download-button > a):hover {
    color: var(--te-download-text);
    background-color: var(--te-download-base);
    background-position: right center;
  }
  #penci-post-entry-inner a.IRPP_kangoo:hover .postTitle { color: var(--te-card-hover); }
}
#penci-post-entry-inner :is(a.download-button, .wp-block-button.download-button > a, a.IRPP_kangoo):focus-visible {
  outline: 2px solid var(--te-control-focus);
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  #penci-post-entry-inner :is(a.download-button, .wp-block-button.download-button > a) {
    transition: none;
  }
}
@media (forced-colors: active) {
  #penci-post-entry-inner :is(a.download-button, .wp-block-button.download-button > a, a.IRPP_kangoo) {
    outline: 1px solid LinkText;
  }
  #penci-post-entry-inner :is(a.download-button, .wp-block-button.download-button > a, a.IRPP_kangoo):focus-visible {
    outline: 2px solid Highlight;
  }
}

/* Limit the mobile sequence to this post's two WordPress galleries.
   The gallery's own post ID also works when a reader loads the article by scrolling. */
@media (max-width: 600px) {
  #penci-post-entry-inner .galleryid-86518.gallery-columns-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    margin-block: 0.65em 1em;
  }
  #penci-post-entry-inner .galleryid-86518.gallery-columns-2 > .gallery-item {
    width: 100%;
    float: none;
    margin: 0;
  }
  #penci-post-entry-inner .galleryid-86518.gallery-columns-2 > br {
    display: none;
  }
  #penci-post-entry-inner .galleryid-86518 .gallery-icon a {
    display: block;
    padding: 0;
    background-image: none;
  }
  #penci-post-entry-inner .galleryid-86518 .gallery-icon img {
    margin: 0;
    padding: 0;
  }
}
#penci-post-entry-inner .galleryid-86518 .gallery-icon a:focus-visible {
  outline: 2px solid var(--te-control-focus);
  outline-offset: 2px;
}

/* A sublist belongs to its numbered step. Keep the outer card as the one surface. */
@media (min-width: 701px) {
  #penci-post-entry-inner > ol:where(:not([class]), [class=""], [class="wp-block-list"]):not([type])
    > li > ul:where(:not([class]), [class=""], [class="wp-block-list"]):not([type]) {
    margin-block: .55em .75em;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;

    & > li {
      margin-block: .55em 0;
      padding: 0;
      padding-inline-start: 1.55em;
      background: transparent;
      border: 0;
      box-shadow: none;
    }
    & > li::before {
      top: calc(.73em - 2.5px);
    }
  }
}

/* Subscription actions keep their component styling and expose pointer and keyboard states. */
@media (hover: hover) {
  #penci-post-entry-inner .soc-buttons > a.soc-buttons-item:hover {
    color: var(--te-prose-link-active);
    border-color: currentColor;
  }
}
#penci-post-entry-inner .soc-buttons > a.soc-buttons-item:focus-visible {
  color: var(--te-prose-link-active);
  border-color: currentColor;
}
#penci-post-entry-inner :is(.soc-buttons > a.soc-buttons-item, a.tg_link):focus-visible {
  outline: 2px solid var(--te-control-focus);
  outline-offset: 2px;
}

/* In a Gutenberg three-column comparison, Soledad's fixed label column
   should fit a word. The table already provides its own scrollport. */
#post-81393 .wp-block-table .pcrstb-wrap > table.has-fixed-layout:has(> :is(tbody, thead) > tr:first-child > :nth-child(3):last-child) {
  & > :is(thead, tbody, tfoot) > tr > :is(th, td) {
    padding: .5em .65em;
    word-break: normal;
    overflow-wrap: normal;
  }
  @media (max-width: 700px) {
    & > :is(thead, tbody, tfoot) > tr > :is(th, td) {
      font-size: 14px;
    }
  }
  /* A pinned label would cover part of the last data column here. */
  @media (max-width: 375px) {
    & > :is(thead, tbody, tfoot) > tr > :first-child {
      position: static;
    }
  }
  &:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
  }
}

/* Portrait Android screenshots in the four galleries of the Google Play installation guide. */
@media (max-width: 600px) {
  #penci-post-entry-inner .galleryid-44650 {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: min(84%, 280px);
    align-items: start;
    gap: 12px;
    max-width: 100%;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 18%;
    margin-block: 0.65em 1em;
    padding-bottom: 4px;
  }
  #penci-post-entry-inner .galleryid-44650 > .gallery-item {
    width: 100%;
    min-width: 0;
    float: none;
    margin: 0;
    scroll-snap-align: start;
  }
  #penci-post-entry-inner .galleryid-44650 > br,
  #penci-post-entry-inner .galleryid-44650::after {
    display: none;
  }
  #penci-post-entry-inner .galleryid-44650 .gallery-icon a {
    display: block;
    padding: 0;
    background-image: none;
  }
  #penci-post-entry-inner .galleryid-44650 .gallery-icon img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
  }
  #penci-post-entry-inner .galleryid-44650 .gallery-icon a:focus-visible {
    outline: 2px solid var(--te-control-focus, #1165f1);
    outline-offset: -3px;
  }
}

/* Classic downloads share a row when their intrinsic widths fit. */
#penci-post-entry-inner .te-download-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-block: 25px;
}
#penci-post-entry-inner .te-download-group > br {
  display: none;
}
#penci-post-entry-inner .te-download-group > a.download-button {
  margin: 0;
  max-width: 100%;
  box-sizing: border-box;
}
@media (max-width: 590px) {
  #penci-post-entry-inner .te-download-group {
    margin-inline: 17px 25px;
  }
  #penci-post-entry-inner .te-download-group > a.download-button {
    flex: 1 1 auto;
  }
}

/* Native Buttons blocks keep the editor's orientation, wrapping and alignment. */
#penci-post-entry-inner .wp-block-buttons.te-download-block-group {
  gap: 12px;
}
#penci-post-entry-inner .te-download-block-group > .wp-block-button > a {
  margin: 0;
}
