/*
 * Default styles for River's elements.
 *
 * Every rule sits in the `river` cascade layer, so any rule a host page writes
 * outside a layer wins over it, whatever its specificity. Colours come from these
 * custom properties when an ancestor sets them, and otherwise from the text colour:
 *
 *   --river-muted   times, sort controls, feed dates and never-read feeds
 *   --river-rule    lines between rows and river sections
 *   --river-cursor  the keyboard cursor's row
 *   --river-error   error messages
 *   --river-focus   the blogroll's focus outline
 *   --river-link    a river headline under the pointer or focus
 *   --river-bg      the page background, which river section labels sit on
 *   --river-code-bg code and preformatted text in river items
 *
 * The class names are FeedLand's, so a sheet written for FeedLand's blogroll or
 * river applies too.
 */

@layer river {
  river-blogroll {
    display: block;
    width: 100%;
    font-size: 1rem;
  }

  river-blogroll:focus {
    outline: 0;
  }

  river-blogroll:focus-visible {
    outline: 3px solid var(--river-focus, Highlight);
    outline-offset: 4px;
  }

  river-blogroll button {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
  }

  river-blogroll .river-status {
    color: var(--river-muted, color-mix(in srgb, currentColor 65%, transparent));
    font-size: 0.9rem;
  }

  river-blogroll .river-feed--never-updated .spTitleString {
    color: var(--river-muted, color-mix(in srgb, currentColor 65%, transparent));
    font-style: italic;
  }

  river-blogroll .river-status--error {
    color: var(--river-error, #b00020);
  }

  river-blogroll .divBlogrollSortLinks {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid
      var(--river-rule, color-mix(in srgb, currentColor 18%, transparent));
    font-size: 0.9rem;
    line-height: 1.4;
  }

  river-blogroll .spTitleLink,
  river-blogroll .spWhenLink {
    color: var(--river-muted, color-mix(in srgb, currentColor 65%, transparent));
  }

  /* Lines the label up with the titles, past the caret column. */
  river-blogroll .spTitleLink {
    margin-left: 1.75rem;
  }

  river-blogroll .spTitleLink:hover,
  river-blogroll .spWhenLink:hover {
    color: inherit;
    text-decoration: underline;
  }

  river-blogroll .divBlogrollSortLinks .selected {
    color: inherit;
    font-weight: 700;
  }

  river-blogroll .divBlogrollTable {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
  }

  /* Table cells ignore min-height, so padding brings each row to a 44px tap target. */
  river-blogroll .trBlogrollFeed td {
    padding: 0.65rem 0;
    border-bottom: 1px solid
      var(--river-rule, color-mix(in srgb, currentColor 18%, transparent));
  }

  river-blogroll .trBlogrollFeed:last-child td {
    border-bottom: 0;
  }

  river-blogroll .tdBlogrollWedge {
    width: 1.5rem;
    padding-right: 0.25rem;
    vertical-align: top;
    color: var(--river-muted, color-mix(in srgb, currentColor 65%, transparent));
    font-size: 1.15rem;
    line-height: 1.3;
    cursor: pointer;
  }

  river-blogroll .tdBlogrollWedge svg {
    display: block;
    width: 0.45em;
    height: 0.7em;
    margin-top: 0.3em;
    opacity: 0.9;
    transition: transform 75ms ease-out;
  }

  river-blogroll .tdBlogrollWedge [aria-expanded='true'] svg {
    opacity: 0.2;
    transform: rotate(90deg);
  }

  river-blogroll .tdBlogrollFeedTitle {
    font-size: 1.15rem;
    line-height: 1.3;
    cursor: pointer;
  }

  /* The cursor is where the arrow keys point, and the keys only work while the
     blogroll has focus. Shown always, it shades a row the reader never picked. */
  river-blogroll:focus-within .trBlogrollCursor {
    background-color: var(
      --river-cursor,
      color-mix(in srgb, currentColor 7%, transparent)
    );
  }

  river-blogroll .spWhenUpdated {
    float: right;
    margin-top: 0.15em;
    padding-left: 0.5rem;
    color: var(--river-muted, color-mix(in srgb, currentColor 65%, transparent));
    font-size: 0.9rem;
  }

  river-blogroll .divNewsPod {
    padding: 0.2rem 0 0.3rem;
    font-size: 1rem;
    font-weight: normal;
    cursor: auto;
  }

  river-blogroll .ulFeedItems {
    margin: 0.4rem 0 0;
    padding-left: 0.9rem;
    border-left: 2px solid
      var(--river-rule, color-mix(in srgb, currentColor 18%, transparent));
    list-style: none;
  }

  river-blogroll .liFeedItem {
    margin-bottom: 0.5rem;
    line-height: 1.5;
  }

  river-blogroll .liFeedItem:last-child {
    margin-bottom: 0;
  }

  river-blogroll .spItemPubdate a {
    font-size: 0.9rem;
    white-space: nowrap;
  }
}

/*
 * <river-river>. The sizes and spacing are those of River's hosted river page when
 * it ran FeedLand's riverviewer.js, which this element replaces.
 */
@layer river {
  river-river {
    display: block;
    width: 100%;
    font-size: 1rem;
    line-height: 1.5;
  }

  river-river .river-status {
    color: var(--river-muted, color-mix(in srgb, currentColor 65%, transparent));
    font-size: 0.9rem;
  }

  river-river .river-status--error {
    color: var(--river-error, #b00020);
  }

  /* The padding opens the gutter the favicons hang in, so feed titles, item bodies
     and footers share one left edge. The top margin makes room for the first
     header, which sits on its section's top rule. */
  river-river .divRiverDisplay {
    margin: 2rem 0 0;
    padding-left: 1.5rem;
  }

  river-river .divRiverSection {
    margin-bottom: 2.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid
      var(--river-rule, color-mix(in srgb, currentColor 18%, transparent));
  }

  river-river .divSectionHeader {
    margin-bottom: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
  }

  /* The negative margin lifts both labels onto the section's rule, and the page
     background makes the rule appear to break around them. */
  river-river .spFeedTitle,
  river-river .spFeedPubDate {
    margin-top: -1.35em;
    background: var(--river-bg, Canvas);
    font-size: 0.9rem;
    line-height: 1.3;
  }

  river-river .spFeedTitle {
    float: left;
    padding-right: 0.6rem;
    font-weight: 600;
  }

  river-river .spFeedPubDate {
    float: right;
    padding-left: 0.6rem;
    color: var(--river-muted, color-mix(in srgb, currentColor 65%, transparent));
    font-weight: normal;
  }

  river-river .imgFavIcon {
    float: left;
    width: 16px;
    height: 16px;
    margin: 0.15em 0 0 -1.5rem;
    border: 0;
  }

  /* A picture that failed to load: a favicon the icon service lacks, or a post's
     image that is gone or refuses hotlinking. */
  river-river img.river-img--broken {
    display: none;
  }

  /* An image enclosure's frame holds nothing but the image, so an empty frame goes
     too. Other .divInlineImage boxes can hold a caption and links, which stay. */
  river-river .divRiverItemImageEnclosure .divInlineImage:has(img.river-img--broken) {
    display: none;
  }

  river-river .divRiverItem {
    margin-bottom: 1.5rem;
  }

  river-river .divRiverItem:last-child {
    margin-bottom: 0;
  }

  /* A long post is cut off at this height. river-expand.js marks the bodies it
     cuts, and a click on one, or its button, opens or closes it. */
  river-river .divRiverItemBody {
    position: relative;
    max-height: 14rem;
    overflow: hidden;
  }

  river-river .divRiverItemBody.river-item--expanded {
    max-height: none;
  }

  river-river .divRiverItemBody.river-item--clipped {
    cursor: pointer;
  }

  river-river .divRiverItemBody.river-item--clipped:not(.river-item--expanded)::after {
    content: '';
    position: absolute;
    inset: auto 0 0 0;
    height: 3.5rem;
    background: linear-gradient(to bottom, transparent, var(--river-bg, Canvas));
    pointer-events: none;
  }

  /* A pointer opens a post with a click on it. The button is for the keyboard, so
     it shows only while it has focus. */
  river-river .river-more {
    margin: 0.4rem 0 0;
    padding: 0.1rem 0.5rem;
    border: 1px solid var(--river-rule, color-mix(in srgb, currentColor 18%, transparent));
    border-radius: 0.25rem;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
  }

  river-river .river-more:not(:focus-visible) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  river-river .divTitledItem,
  river-river .divSingularItem {
    line-height: 1.6;
  }

  river-river .divSingularItem {
    margin-bottom: 7px;
  }

  river-river .divTitledItem .divTitle {
    margin-bottom: 0.4rem;
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.3;
  }

  /* Headlines in body colour, so link colour marks the links inside a post. */
  river-river .divTitledItem .divTitle a {
    color: inherit;
    text-decoration: none;
  }

  river-river .divTitledItem .divTitle a:hover,
  river-river .divTitledItem .divTitle a:focus-visible {
    color: var(--river-link, LinkText);
    text-decoration: underline;
  }

  river-river .divTitledItem .divTitledItemBody {
    line-height: 1.4;
  }

  river-river .divRiverItemBody p {
    margin: 0 0 10px;
  }

  river-river .divRiverItemBody :is(ul, ol) {
    margin: 0 0 10px 25px;
    padding: 0;
  }

  /* oldschoolrender.js nests an outline's lists for structure, not bullets. */
  river-river .divTitledItem .ulLevel0 {
    margin-left: 0;
  }

  river-river .divTitledItem li {
    margin-bottom: 0.6em;
    line-height: 1.5;
    list-style-type: none;
  }

  river-river .divMarkdownGeneratedText li {
    list-style-type: inherit;
  }

  river-river .divRiverItemBody blockquote {
    margin: 0 0 20px;
    padding: 0 0 0 15px;
    border-left: 4px solid
      var(--river-rule, color-mix(in srgb, currentColor 18%, transparent));
  }

  /* Feeds put h1 and h2 in post bodies, which would outsize the post's own title.
     Every heading in a body reads as a bold line at body size, a little larger for
     h1 and h2. */
  river-river .divRiverItemBody :is(h1, h2, h3, h4, h5, h6) {
    margin: 1rem 0 0.4rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
  }

  river-river .divRiverItemBody :is(h1, h2) {
    font-size: 1.05em;
  }

  river-river .divRiverItemBody :is(img, video) {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
  }

  /* oldschoolrender.js floats an outline's picture with an inline style, which a
     strict page refuses. River's server writes the class alone, and this floats it. */
  river-river .divRiverItemBody .imgRightMargin {
    float: right;
    max-width: 40%;
    margin: 0.2rem 0 0.6rem 1.25rem;
  }

  river-river .divRiverItemImageEnclosure {
    margin-top: 0.5em;
  }

  river-river .divInlineImage {
    padding: 0.5rem;
    border: 1px solid var(--river-rule, color-mix(in srgb, currentColor 18%, transparent));
    border-radius: 0.35rem;
    font-size: 0.8em;
    line-height: 1.3;
    text-align: center;
  }

  river-river .divRiverItemBody code {
    padding: 0.1em 0.3em;
    border-radius: 0.25rem;
    background: var(--river-code-bg, color-mix(in srgb, currentColor 7%, transparent));
    font-size: 0.9em;
  }

  river-river .divRiverItemBody pre {
    padding: 0.5rem;
    overflow-x: auto;
    border-radius: 0.25rem;
    background: var(--river-code-bg, color-mix(in srgb, currentColor 7%, transparent));
  }

  river-river .divRiverItemBody pre code {
    padding: 0;
    background: none;
  }

  river-river .divRiverItemFooter {
    display: flow-root;
    min-height: 1.5rem;
    margin-top: 0.5rem;
    color: var(--river-muted, color-mix(in srgb, currentColor 65%, transparent));
    font-size: 0.85rem;
  }

  river-river .spRiverItemPermalink {
    float: right;
    line-height: 1;
  }

  river-river .divRiverItemFooter a {
    color: inherit;
  }

  river-river .spEnclosureButton {
    margin-right: 15px;
  }

  river-river .spEnclosureButton svg {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
  }
}
