@font-face {
  font-family: "Aleo";
  src: url("https://files.cutegay.software/fonts/Aleo-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
}
@font-face {
  font-family: "Aleo";
  src: url("https://files.cutegay.software/fonts/Aleo-Italic-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: italic;
}

@font-face {
  font-family: "Honk";
  src: url("https://files.cutegay.software/fonts/Honk-Regular-VariableFont_MORF,SHLN.ttf") format("truetype");
  font-weight: 400;
  font-style: normal; /* hah */
}
/* values for MORF:
 * 15 (default): Regular
 * 0: Brush
 * 5: Ninja
 * 10: Irregular
 * 20: Compressed
 * 25: Rounded
 * 30: Ballon
 * 40: Wood
 * 45: Flower
 */
/* color overrides:
 * 0: shadow below
 * 1: shadow above
 * 2-7: inner gradient
 */

@font-face {
  font-family: "RampartOne";
  src: url("https://files.cutegay.software/fonts/RampartOne-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  src: url("https://files.cutegay.software/fonts/Mplus/MPLUSRounded1c-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  src: url("https://files.cutegay.software/fonts/Mplus/MPLUSRounded1c-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: "Hunnin";
  src: url("https://files.cutegay.software/fonts/jf-openhuninn-2.1.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}

:root {
  /* These depend on specific fonts */
  --line-height-latin: 1.37;
  --line-height-kkmrubi: 1.5rlh; /* kanji-kana-majiribun with rubi */
}

body {
    font-family: "Aleo",  "M PLUS Rounded 1c", sans-serif;
    font-weight: normal;
    font-size: max(16pt, 1.3vw); /* ~75ch */
    line-height: var(--line-height-latin);
}


:root {
  /* core unit for typographical grid alignment horizontally */
  --indent: 1.5rem;
  --inline-list-gap: calc(0.5*var(--indent));
  /* snapped to grid; ca. 2 indents, unless the screen is small, then 1 or 0) */
  --minimum-left-margin: min(
    round(down, 1vw, var(--indent)),
    calc(2*var(--indent))
    );
}


@font-palette-values --sapphic-honk {
  font-family: "Honk";
  override-colors:
      0 #639,
      1 #639,
      2 #f69,
      3 #f69,
      4 #fc3,
      5 #fc3,
      6 #6c3,
      7 #6c3
  ;
}
@font-palette-values --sapphic-honk-stronk {
  font-family: "Honk";
  override-colors:
      0 #636,
      1 #333,
      2 #f69,
      3 #f69,
      4 #fc3,
      5 #fc3,
      6 #f69,
      7 #f69
  ;
}


body {
    /* Left margin is 1 indent in small screens, up to 3 indents on big ones */
    margin: 2rlh 0 1rlh clamp(
      var(--indent),
      round(nearest, 8vw, var(--indent)),
      calc(3*var(--indent))
    );
    padding: 0;
}

header {
  margin: 1rlh 0 1rlh var(--minimum-left-margin);
  padding: 0;
}

nav {
  margin: 0.5rlh 0;
  padding: 0.5rlh 0;
}

nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--inline-list-gap);
  list-style: none;
  margin: 0; padding: 0;
}
nav li {
  font-style: italic;
  font-weight: 500;
  margin: 0; padding: 0;
  display: inline-flex;
}
nav li + li::before {
  content: "❦" / "";
  /* content: "🏵"; */
  margin: 0 var(--inline-list-gap) 0 0;
  padding: 0;
  font-style: normal;
}

main, footer {
  --column-width: round(nearest, 
                         clamp(50vw,85rch,85vw),
                         var(--indent));
  width: var(--column-width);

  /* more or less centered but snap to indent.
   * left margin when centered is (100%-width)/2. */
  /*
  margin: 0 0 0 round(down,
                      calc((100% - var(--column-width))/2),
                      var(--indent));
                      */
  margin: 1rlh 0;
  padding: 0;
}
main hr {
  /* ca. 75% of column, but snapped to grid */
  width: round(up,calc(0.75*var(--column-width)),var(--indent));
  text-align: center;
  margin: 1lh auto; padding: 0;
  border-top: thin solid;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

p {
  margin: 0;
  padding: 0;
  text-indent: var(--indent);
  text-wrap: pretty;
}
/*
p + p, div+p, p:lang(ja) {
  text-indent: var(--indent);
}
*/
:is(li, blockquote, aside) p:first-child {
  text-indent: 0;
}

article {
  margin: 0;
  padding: 0;
}
article > p , article > p + p {
  max-width: round(nearest,67ch,var(--indent));
  text-indent: var(--indent);
  position: relative;
}
article > p::before {
  content: "¶" / "";
  /* content: "❧" / ""; */
  position: absolute;
  left: 0;
  top: 0;
  margin-left: calc(-0.75 * var(--indent));
  user-select: none;
}

:lang(zh):not(i):not(.pinyin) {
    font-family: Hunnin, "PingFang TC", PingFang, "Heiti TC", Heiti, "Noto Sans CJK TC", "Microsoft JhengHei", JhengHei, sans;
}
/* Use Japanese fonts for all lang=ja elements... */
:lang(ja) {
  font-family: "M PLUS Rounded 1c", "Noto Sans CJK JP", sans;
}
/* ...with extra allowance for rubi at block-level content… */
p:lang(ja) {
  /* line-height: 2rlh; */
  line-height: var(--line-height-kkmrubi);
}
/*  *except* don't do J setting for class=roma, nor for <i>.
 *
 *  it's simplest and most robust to fully reset here to <body> settings;
 *  attempts with comples :not() or :where() selectors are fragile in scenarios
 *  with lang= inheritance. */
i:lang(ja), .roma:lang(ja) {
    font-family: "Aleo",  "M PLUS Rounded 1c", sans-serif;
    line-height: var(--line-height-latin);
}
h1 span:lang(ja) {
  font-family: "RampartOne", serif;
  font-size: 100%;
}

:not(.roma, i):lang(ja) {
  font-style: normal;
}


.ipa {
    font-family: "M PLUS Rounded 1c", "Noto Sans", "Voces", sans;
    white-space: nowrap;
}

a {
  text-decoration: none;
  border-bottom-width: thin;
  border-bottom-style: solid;
  font-weight: 500; /* compensation for lower contrast */
}
h1, h2, h3, h4, h5, h6, 
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, 
h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited 
{
  font-family: "Honk", serif;
  font-weight: bold;
  border-bottom: none;
  margin: 0;
  padding: 0;
  /* softie */
  font-variation-settings: "MORF" 25, "SHLN" 00;
}
.title-before {
  font-family: "Honk", serif;
  font-variation-settings: "MORF" 20.5, "SHLN" 10;
  display: inline-block;
  transform: translate(.33ch,-.33ch) rotate(-37deg);
}
.title-after {
  font-family: "Honk", serif;
  font-variation-settings: "MORF" 35, "SHLN" 00;
}
h1 {
  white-space: nowrap;
  overflow: hidden;
}
h1 { font-size: clamp(1.5rem, 4vw + 1rem, 5rem); }
h2 { font-size: clamp(1.25rem, 3.00vw + 1rem, 4.0rem); }
h3 { font-size: clamp(1.20rem, 2.50vw + 1rem, 3.0rem); }
h4 { font-size: clamp(1.15rem, 2.25vw + 1rem, 2.5rem); }
h5 { font-size: clamp(1.10rem, 2.00vw + 1rem, 2.0rem); }
h6 { font-size: clamp(1.05rem, 1.50vw + 1rem, 1.5rem); }

article + hr {
  border: none;
  display: block;
  margin: 1lh auto; padding: 0;
  text-align: center;
}
article + hr::before {
  content: "⁂" / "";
  font-size: 2rem;
  text-align: center;
  margin: auto;
}

/*
hr.big {
  border-bottom: thin solid;
}
hr.big::before {
  content: "🏵" / "";
  font-size: 2rem;
  text-align: center;
  margin: 0; padding: 0;
  font-style: normal;
}
*/


/* if this had been implemented it would be nice to handle nested italics... */
/*
i, em, cite, blockquote, aside, figcaption, .roma, nav li {
  font-style: cycle(italic, normal);
}
*/
/* manually cycle a few levels */
:is(i, em, cite, blockquote, aside, figcaption, .roma, nav li) {
  font-style: italic;
}
:is(i, em, cite, blockquote, aside, figcaption, .roma, nav li)
:is(i, em, cite, blockquote, aside, figcaption, .roma, nav li) {
  font-style: normal;
}
:is(i, em, cite, blockquote, aside, figcaption, .roma, nav li)
:is(i, em, cite, blockquote, aside, figcaption, .roma, nav li)
:is(i, em, cite, blockquote, aside, figcaption, .roma, nav li) {
  font-style: italic;
  letter-spacing: 0.1ch;
  border-bottom: thin solid ;
}

/* use OTF sups/subs features rather than vertical-align hack */
sup, sub {
  vertical-align: baseline;
  font-size: inherit;
}
sup {
  font-variant-position: super;
}
sub {
  font-variant-position: sub;
}

ul, ol {
  margin: 0;
  padding: 0 0 0 var(--indent);
  list-style-position: outside;
}
/* extra indent for top level list only */
/* bigger on big screens */
article > ol, article > ul {
  padding: 1lh 0 1lh clamp(
    var(--indent),
    round(nearest, 5vw, var(--indent)),
    calc(2*var(--indent))
   );
}
li {
  margin: 0;
  padding: 0;
}
ol {
  list-style-type: hiragana-iroha;
}
ol ol {
  list-style-type: katakana-iroha;
}
ol ol ol {
  list-style-type: cjk-ideographic;
}
ol ol ol ol {
  list-style-type: lower-latin;
}
ul li::marker {
  /* content: "☛  "; */
  content: "✿  " / "";
}
ul ul li::marker {
  /* content: "☞  "; */
  content: "❀  " / "";
}
ul ul ul li::marker {
  /* content: "🖛 "; */
  content: "❁  " / "";
}
ul ul ul ul li::marker {
  /* content: "🖙 "; */
  content: "✾  " / "";
}

aside {
  /* font-size: smaller; */
  margin: 0.5lh var(--indent);
  padding: 0;
  position: relative;
}
aside::before {
  content: "☞" / "";
  /* content: "❧" / ""; */
  position: absolute;
  left: 0;
  margin-left: calc(-1*var(--indent));
  user-select: none;
  font-style: normal;
}

blockquote {
  margin: 1lh 0 1lh 0;
  padding: 0 0 0 calc(2*var(--indent));
  position: relative;
}
blockquote::before {
  content: "“" / "";
  font-size: 5rem;
  position: absolute;
  top: 0rem;
  left: calc(+0.25*var(--indent));
  line-height: 1;
}
blockquote:lang(ja)::before {
  content: "『" / "";
  top: 0em;
  font-size: 3.5em;
  left: calc(-1.2*var(--indent));
}
figure {
  margin: 1lh 0 1lh 0;
  padding: 0 0 0 calc(2*var(--indent));
}

figure blockquote {
  border-left: none;
  margin: 0; padding: 0;
}
figure blockquote::before{
  left: calc(-2.5*var(--indent));
}
figure blockquote:lang(ja)::before{
  left: calc(-3.0*var(--indent));
}
figure:has(> blockquote) figcaption {
  margin: 1rlh 0 0 0;
  padding: 0;
}

.tate {
  writing-mode: vertical-rl;
  letter-spacing: 0.25ch;
  /* due to oddities with tate-rubi in MPLUS */
  line-height: 2.25;
}
p:lang(ja).tate, .tate p:lang(ja) {
  line-height: inherit;
  /* max-height: 75vh; */
}
.tate rt {
  /* compensate for big horizontal space in MPLUS tate-rubi metrics */
  margin: 0 0 0 -1em; 
  padding: 0;
  letter-spacing: 0;
  /* outline: thin solid red; */
}
blockquote.tate {
  padding: 0 calc(2*var(--indent)) 0 0;
}
blockquote:lang(ja).tate::before {
  right: +0.1em;
  top: -0.75em;
  font-size: 3em;
}


:root {
  --light-red: #f33;
  --pastel-scarlet: #f66;
  /* --hot-pink: #f39; */
  /* sapphic flag colours */
  /* (all the violet tiaras, braided rosebuds, dill / */
  /*  and crocus, twined around your young neck… ) */
  --sapphic-violet: #639;
  --sapphic-rosebud: #f69;
  --sapphic-dill: #6c3;
  --sapphic-crocus: #fc3;

  --cl-fg: black;
  --cl-bg: #ffc;
  --cl-accent: var(--light-red);
  --cl-soft-accent: var(--pastel-scarlet);
  --cl-link: var(--sapphic-rosebud);
  --cl-soft-link: var(--sapphic-violet);
  --cl-subtle: var(--sapphic-crocus);
  --cl-selection: var(--cl-accent);
  --cl-separator: var(--sapphic-dill);
  --cl-marginalia: var(--cl-subtle);

  --cd-fg: #ccc;
  --cd-bg: #000;

  --debug-color: var(--cl-subtle);
}
/*
@media (prefers-color-scheme: light) {
*/
  body {
    color: var(--cl-fg);
    background-color: var(--cl-bg);
    background-image: url("https://files.cutegay.software/bg/wasi2.webp");
  }

  a {
    color: var(--cl-link);
    border-bottom-color: var(--cl-link);
    font-weight: 600;
  }
  a:visited, a:active {
    color: var(--cl-soft-link);
    border-bottom-color: var(--cl-soft-link);
  }
  h1, h2, h3, h4, h5, h6, 
  h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, 
  h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited 
  {
    color: var(--cl-accent);
  }
  h1, h2 { font-palette: --sapphic-honk-stronk; }
  h3, h4, h5, h6 { font-palette: --sapphic-honk; }

  article + hr::before {
    color: var(--cl-separator);
  }
  hr {
    color:var(--cl-subtle);
  }
  nav li + li::before {
    color: var(--cl-separator);
  }
  span:lang(zh), span:lang(ja) {
    color: var(--cl-accent);
  }
  rt {
    color: var(--cl-accent);
  }
  ::selection, ::-moz-selection {
    color: var(--cl-bg); /* reverse */
    background: var(--cl-selection);
    font-weight: 600; /* APCA for this colour combo */
  }
  article p::before {
    color: var(--cl-marginalia);
  }
  h1 > span:lang(ja) {
    border: 3px solid var(--cl-accent);
    padding-left: var(--indent);
  }
  h1 span.title-after-ja {
    color: var(--cl-bg); /* reverse */
    background-color: var(--cl-accent);
    padding-right:  var(--indent);
  }
  h1 span.title-after-ja::selection
  {
    background-color: var(--cl-bg); /* reverse */
    color: var(--cl-accent);
  }
  li::marker {
    color: var(--cl-soft-accent);
  }
  aside::before {
    color: var(--cl-soft-accent);
  }

  blockquote, figure:has(> blockquote) {
    border-left: medium dotted var(--cl-soft-accent);
  }
  blockquote.tate, figure:has(> blockquote).tate {
    border-left: none;
    border-right: medium dotted var(--cl-soft-accent);
  }
  blockquote::before {
    color: var(--cl-subtle);
  }

/*
}
*/

/* TODO
@media (prefers-color-scheme: dark) {
  body {
    color: var(--cd-fg);
    background-color: var(--cd-bg);
  }
}
*/

/* debug ruler for typographical grid */

/*
body {
  --tick-heigth: 100%;
  --tick-unit: var(--indent);
  --tick-thickness: 1px;
  --tick-color:  var(--debug-color);

  background-image:
    linear-gradient(90deg, var(--tick-color) 0 var(--tick-thickness), transparent 0);
  background-repeat: repeat-x;
  background-size: var(--tick-unit) var(--tick-heigth);
  background-attachment: fixed;
}
*/
