@import url("html5.css");

/* Extend html5.css with tweaks to make it more "book" looking and less
 * like a web page, especially needed with unstyled EPUB/HTML documents.
 * (styling similar to what we got with our older epub.css). */

/* Text justified by default */
body {
  text-align: justify;
}

/* Constant margin on all levels */
h6, h5, h4, h3, h2, h1 {
  margin-top: 0.7em;
  margin-bottom: 0.5em;
  hyphens: none;
}
/* Less radical font size changes */
h1 { font-size: 150%; }
h2 { font-size: 140%; }
h3 { font-size: 130%; }
h4 { font-size: 120%; }
h5 { font-size: 110%; }
h6 { font-size: 100%; }
/* The same for H1 in nested sections */
:where(article, aside, nav, section) h1 { font-size: 140%; }
:where(article, aside, nav, section) :where(article, aside, nav, section) h1 { font-size: 130%; }
:where(article, aside, nav, section) :where(article, aside, nav, section) :where(article, aside, nav, section) h1 { font-size: 120%; }
:where(article, aside, nav, section) :where(article, aside, nav, section) :where(article, aside, nav, section) :where(article, aside, nav, section) h1 { font-size: 110%; }
:where(article, aside, nav, section) :where(article, aside, nav, section) :where(article, aside, nav, section) :where(article, aside, nav, section) :where(article, aside, nav, section) h1 { font-size: 100%; }

/* Paragraphs: no spacing between them, and text-indentation */
p {
  text-indent: 1.2em;
  margin-top: 0;
  margin-bottom: 0;
}

/* Blockquote: smaller margins, based on font size; unbalanced but fine */
blockquote {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  margin-left: 2em;
  margin-right: 1em;
}
blockquote:dir(rtl) {
  margin-left: 1em;
  margin-right: 2em;
}

/* HR: less 1990s HTML */
hr {
  border-style: solid;
}

/* Lists: no vertical margin, a bit of margin left added to our -cr-special padding */
ol, ul {
  margin-left: 1em;
  margin-top: 0;
  margin-bottom: 0;
}
ol:dir(rtl), ul:dir(rtl) {
  margin-left: unset;
  margin-right: 1em;
}

/* Definitions: smaller margins all around, dt bold */
dl {
  margin-left: 0;
}
dt {
  margin-left: 0;
  margin-top: 0.3em;
  font-weight: bold;
}
dd {
  margin-left: 1.3em;
}
dd:dir(rtl) {
  margin-left: unset;
  margin-right: 1.3em;
}

/* Tables: smaller font size (for less wrapping and less height taken on our small screens) */
table {
  font-size: 80%;
  margin: 3px 0;
  border-spacing: 1px; /* needed for separate border to not look uneven */
}
table table { /* stop imbricated tables from getting smaller */
  font-size: 100%;
}

/* A bit more default padding in cells */
td {
  padding: 3px;
}

/* Background by default on table headers, and text-align center */
th {
  padding: 3px;
  background-color: #DDD;
  text-align: center;
}

/* Same for caption */
table caption {
  padding: 4px;
  background-color: #EEE;
}

/* Pre: smaller vertical margins, drop our inherited justification */
xmp, pre {
  text-align: left;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

/* sup/sub: smaller font size */
sup { font-size: 70%; }
sub { font-size: 70%; }

/* Have links darker blue, 'blue' looks too light gray on eInk */
a[href] {
  color: navy;
}

/* Keep ensuring this in legacy rendering */
h3, h2 {
  -cr-only-if: legacy html-document;
    page-break-before: always;
}
section h3, section h2 {
  -cr-only-if: legacy html-document;
    page-break-before: auto;
}

/* Old element or className based selectors involving display: that we need
 * to support for older gDOMVersionRequested (these were fixed in 20180528).
 * DO NOT MODIFY BELOW to not break past highlights */
@media (-cr-max-cre-dom-version: 20180527) {
  /* Images are now inline by default, and no more block with exceptions */
  img { text-align: center; text-indent: 0; display: block; }
  sup img { display: inline; }
  sub img { display: inline; }
  a img   { display: inline; }
  p img   { display: inline; }
  p image { display: inline; } /* non html */
  /* With dom_version < 20180528, unknown elements defaulted to 'display: inherit'
   * These ones here were explicitely set to inline (and some others not
   * specified here were also set to inline in fb2def.h */
  b, strong, i, em, dfn, var, q, u, del, s, strike, small, big, sub, sup, acronym, tt, samp, kbd, code {
    display: inline;
  }
  form { display: none; }
  .title, .title1, .title2, .title3, .title4, .title5, .subtitle { display: block; }
  .fb2_info { display: block; }
  .code     { display: block; }
}
