/*** default.css  -*- CSS -*- */

/*** Ivan Shmakov, 2016, 2017, 2018, 2019, 2020, 2021, 2022 */

/** To the extent possible under law, the author(s) have dedicated
 ** all copyright and related and neighboring rights to this software
 ** to the public domain worldwide.  This software is distributed
 ** without any warranty.
 **
 ** You should have received a copy of the CC0 Public Domain Dedication
 ** along with this software.  If not, see
 ** <http://creativecommons.org/publicdomain/zero/1.0/>.
 */

/*** Data: */

@page {
  margin:   2cm;
}

@page :left {
  margin-right: 1cm;
}

@page :right {
  margin-left:  1cm;
}

/** See: http://drafts.csswg.org/css-device-adapt/
 **
 ** NB: @viewport is not widely supported as of this writing,
 **     so we also have to use meta in the document proper
 */
@viewport {
  width: extend-to-zoom 100vw;
  zoom: 1;
}

@media screen {
  body {
    margin: 1em 0 0 2em;
    max-width:    72ex;
  }
  /** pre and textarea are somewhat prone to overflows;
   ** attempt to mitigate, though only on screen for now */
  pre, textarea {
    max-width:  100%;
  }
  pre {
    overflow-x: overlay;
  }
  textarea {
    max-height: 20em;
    overflow:   scroll;
  }
}

@media print {
  body {
    /* line-height:    1.5; */
    max-width:      none;
  }
  footer {
    line-height:    1.0;
  }

  /** NB: color them the same, mainly for privacy reasons */
  :link,
  :visited {
    color:  #00e;
  }
}

/** html, body */

html {
  color:        black;
  background:   white;
}

body {
  margin:   1.5em auto;
  padding:      1.5em;
  /*
  background:   #ccc;
  color:    navy;
   */
}

/** article, section */

article,
section {
  /** BTW, defaults for ol, ul seem more applicable here */
  margin-top:   initial;
  margin-bottom:    initial;
}

/** p, ol, ul, li, etc. */

article p,
article li,
article dd,
section p,
section li,
section dd {
  text-align:   justify;
}

article ol,
article ul,
section ol,
section ul {
  padding-inline-start: 0;
  /** Or if not supported: */
  padding-left:     0;
}

article dd,
article li,
section dd,
section li {
  margin-inline-start:  3em;
  /** Or if not supported: */
  margin-left:  3em;
}

article dd ol li,
article dd ul li,
section dd ol li,
section dd ul li {
  /** Make it smaller in this context */
  margin-inline-start:  1em;
  /** Or if not supported: */
  margin-left:  1em;
}

/** Revert justification for pre elements, however */
article pre,
section pre {
  text-align:   initial;
}

article p,
section p {
  margin:   0;
  text-indent:  3em;
}

/** Verses are conventionally unindented */
/** NB: formerly known as .lyrics */
.poem p,
p.poem {
  text-indent:  inherit;

  /** restore defaults */
  margin-top:   initial;
  margin-bottom:    initial;
}

article dl,
article ol,
article ul,
section dl,
section ol,
section ul {
  margin:   0;
}

li p,
dd p,
dt p {
  text-indent:  inherit;

  /** restore defaults */
  margin-top:   initial;
  margin-bottom:    initial;
}

/** header, footer */

header,
article header,
section header {
  text-align:   center;
  page-break-after: avoid;
}

header *,
article header *,
section header *,
footer *,
article footer *,
section footer * {
  text-align:   inherit;
  text-indent:  inherit;
}

article section header,
section section header {
  text-align:   left;
}

header p,
footer p {
  /** restore defaults */
  margin-top:   initial;
  margin-bottom:    initial;
}

header .author,
header .date,
header .subtitle {
  font-weight:  bold;
}

header h1 ~ .subtitle {
  /** Like h2 */
  margin-bottom:    0.83em;
  margin-top:       0.83em;
  font-size:    150%;
}

header h1 ~ .author {
  /** Like h3 */
  margin-top:       1.00em;
  margin-bottom:    1.00em;
  font-size:    117%;
}

article header {
  margin:   1em 0;
  /*
  border-top:       medium solid;
  border-bottom:    medium solid;
   */
}

article header h1 {
  font-size:    200%;
}

article header:first-child {
  margin-top:   0;
}

section header {
  margin:   .7em 0;
  /*
  border-color:     gray !important;
  border-top:       thin solid;
  border-bottom:    thin solid;
   */
}

section section header,
section section footer {
  border:   none;
}

article footer {
  border-top:       medium solid;
  margin-top:       1.25em;
}

section footer {
  border-top:       thin solid;
  margin-top:       1em;
}

article footer nav:first-child {
  /** To offset the border-top: above; or put elsewhere? */
  margin-top:   .3em;
}

/** Tables */

table.table {
  border-collapse:  collapse;
  margin:           .3em auto .5em;
}

table.table > caption {
  margin-bottom:    .3em;
}

table.table td,
table.table th {
  vertical-align:   baseline;
  padding-top:      inherit;
  padding-bottom:   inherit;
}

table.table td:not(:first-child),
table.table th:not(:first-child) {
  padding-left:     .15em;
}

table.table td:not(:last-child),
table.table th:not(:last-child) {
  padding-right:    .15em;
}

.toprule {
  border-top:       medium solid;
}

.midrule {
  border-bottom:    thin solid;
}

.toprule,
.midrule + * {
  padding-top:      .3em;
}

.midrule,
.bottomrule {
  padding-bottom:   .3em;
}

.bottomrule {
  border-bottom:    medium solid;
}

/** Miscellaneous */

:lang(de) > q {
    quotes: '»' '«' '‹' '›'
}

:lang(fr) > q {
    quotes: '« ' ' »'
}

:lang(ru) > q {
    quotes: '«' '»' '„' '“'
}

:link {
  text-decoration:  none !important;
}

/** E. g.: … where <var class="angled" >output</var> is the output file name */
.angled:before  { content: "⟨"; }
.angled:after   { content: "⟩"; }

/** Special-case figure elements; we’d rather use original font size for the captions */
:not(figure).extra,
figure.extra > :not(figcaption) {
  font-size:    small;
}

/** Mainly for floating figures, but should fit other cases as well */
.float {
  float:  right;
  max-width:  20ex;
  /** This appears to allow for the elements to line up better */
  /** (in particular, the apparent default figure margins
   **  are a tad too wide */
  margin: 0 0 1em 1em;
}

.wrap-long-lines {
  white-space:  pre-wrap;
}

.elision {
  font-family:  serif !important;
}

/** Not unlike http://mediawiki.org/wiki/Snippets/Horizontal_lists; my assumption is that the fragment below is /not/ copyrightable, as it follows technical necessity, and includes no creativity proper */
.hlist > dt,
.hlist > li {
  display: inline;
}

.hlist > dt::after,
.hlist > li::after {
  content: " · ";
}

.hlist > li:not(:first-child) {
  /** Cancel the indent-like margin applied to list items otherwise */
  margin-inline-start:  0;
  /** Or if not supported: */
  margin-left:  0;
}

/** The following typographic convention applies to several cases */

.prompt,
kbd kbd,
mark {
  font-weight:  bold;
}

[title] {
  text-decoration: solid grey underline;
}

/** Revert the default presentation for this one, however */
mark {
  background-color: transparent;
  color:    inherit;
}

/** FIXME: workaround for these elements to get normal text size. */
code, kbd, pre, samp {
  font-family:      monospace, Courier !important;
}

/** Make code examples stand out somewhat on :hover */
@media screen {
  /** FIXME: somehow unhighlight .elision as well? */
  kbd:hover {
    background-color:   lightgreen;
  }
  mark:hover {
    background-color:   yellow;
  }
  samp:hover {
    background-color:   lightblue;
  }
}

.this-qr {
  float:    right;
}

/*** default.css ends here */
