/* Fenzhi reading navigation: contextual Back / Previous and the primary Next. */
@media screen {
  html:root body main.site-flow > nav.reading-end-nav,
  html:root body main.site-flow > nav.reading-end-nav:not(:has(.reading-end-top)) {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    align-items:stretch;
    gap:clamp(.45rem,2vw,1rem);
    padding-block:.55rem .45rem;
  }
  html:root body main.site-flow > nav.reading-end-nav > a:is(.reading-end-prev,.reading-end-next):not([hidden]) {
    box-sizing:border-box;
    display:grid;
    grid-template-columns:.8em minmax(0,1fr) .8em;
    grid-template-rows:auto;
    align-items:center;
    column-gap:.15rem;
    block-size:3.5rem;
    min-block-size:44px;
    min-inline-size:0;
    inline-size:min(100%,10.75rem);
    max-inline-size:100%;
    padding:.25rem clamp(.30rem,1vw,.55rem);
    border:1px solid transparent;
    border-radius:.48rem;
    text-align:center;
    line-height:1.25;
    overflow-wrap:anywhere;
  }
  html:root body main.site-flow > nav.reading-end-nav > a.reading-end-prev:not([hidden]) {
    grid-column:1;
    justify-self:start;
    background:transparent;
    color:var(--fz-fg-green,#173b2d);
    text-decoration:underline;
    text-underline-offset:.16em;
    font-weight:600;
  }
  html:root body main.site-flow > nav.reading-end-nav > a.reading-end-next:not([hidden]) {
    grid-column:2;
    justify-self:end;
    border-color:var(--fz-edge-line,#aebeb4);
    background:var(--fz-bg-soft,#eef4ed);
    color:var(--fz-fg-green,#173b2d);
    text-decoration:none;
    font-weight:650;
  }
  html:root body main.site-flow > nav.reading-end-nav > a:is(.reading-end-prev,.reading-end-next) > .reading-destination {
    grid-area:1/2;
    align-self:center;
    min-inline-size:0;
    text-wrap:pretty;
  }
  html:root body main.site-flow > nav.reading-end-nav > a:is(.reading-end-prev,.reading-end-next) .match-en {
    display:block;
    color:inherit;
    font-size:.75rem;
    font-weight:550;
    margin:0;
  }
  html:root body main.site-flow > nav.reading-end-nav > a:is(.reading-end-prev,.reading-end-next) > .reading-arrow {
    grid-area:1/1;
    justify-self:center;
    line-height:1;
    font-size:.88em;
  }
  html:root body main.site-flow > nav.reading-end-nav > a.reading-end-next > .reading-arrow {grid-column:3}
  html:root body main.site-flow > nav.reading-end-nav > a:is(.reading-end-prev,.reading-end-next):not([hidden]):hover {
    background:var(--fz-bg-hover,#e7eee4);
    color:var(--fz-fg-green,#173b2d);
  }
  html:root body main.site-flow > nav.reading-end-nav > a:is(.reading-end-prev,.reading-end-next):focus-visible {
    outline:3px solid var(--fz-edge-focus,#9a4c12);
    outline-offset:2px;
  }
}

@media screen and (max-width:460px) {
  html:root body main.site-flow > nav.reading-end-nav > a:is(.reading-end-prev,.reading-end-next):not([hidden]) {
    block-size:4.75rem;
    padding:.25rem .25rem;
  }
}

/* A single forward control is centered. A paired forward control stays right. */
@media screen {
  html:root body main.site-flow > nav.reading-end-nav > a.reading-end-next:only-child:not([hidden]) {
    grid-column:1 / -1;
    justify-self:center;
  }
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths ul {gap:.55rem}
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths a {
    min-block-size:44px;
    padding:.45rem .65rem;
  }
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths .fen-resource-note {margin-top:.25rem}
}
@media screen and (max-width:35rem) {
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths ul {gap:.35rem}
}

/* Three compact bilingual homepage resource buttons on phone-sized screens. */
@media screen and (max-width:35rem) {
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths ul {
    grid-template-columns:repeat(3,minmax(0,1fr));
    align-items:stretch;
    gap:.35rem;
  }
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths a {
    display:grid;
    align-content:center;
    gap:.18rem;
    min-block-size:4rem;
    padding:.40rem .25rem;
    text-align:center;
    line-height:1.24;
  }
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths :is(strong,.fen-label-en) {
    display:block;
    margin:0;
    text-wrap:balance;
  }
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths .fen-resource-note {display:none}
}

html:root body main.site-flow[data-layout="home"] > .fen-resource-paths .fen-home-orientation-en {display:inline;margin-inline-start:.75ch}

/* Keep the mobile resource titles on one baseline without shrinking them. */
@media screen and (max-width:35rem) {
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths a {
    grid-template-rows:max-content max-content;
  }
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths .fen-label-en {min-block-size:2lh}
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths .fen-home-orientation-en {display:block;margin-inline-start:0}
  html:root body main.site-flow[data-layout="home"] > .fen-resource-paths :is(.fen-home-orientation,.fen-home-orientation-en) {
    text-wrap:balance;
  }
}
