/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License Version 3, as described below:
 *
 * This file is free software: you may copy, redistribute and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 *
 * Changes: 
 * - replace Firefox specific css extensions with WebKit css extensions
 * - append FeedView css selectors
 *
 * - Adjusted for Epiphany (Removing footer)
 *
 * - updated all the colours to use css variables
 * - include missing styling for tables
 * - updates font-families to use common fonts
 * - switch to using em units where it makes sense
 * - fixed lack of link styling
 *
 * Notes:
 *
 * - WCAG 2.0 level AA recommends at least 4.5 for normal text, 3 for large
 *   text. See: https://marijohannessen.github.io/color-contrast-checker/
 *
 * - The @font-face rules try to use locally installed copies of the fonts,
 *   and fallback to the bundled versions. As per W3C recommendation, the
 *   rules include both full font names and PostScript names to assure
 *   proper matching across platforms and installed font formats. See:
 *   https://www.w3.org/TR/css-fonts-3/#font-face-rule
 */

/* Text and Color Styles */

.light {
  /* Contrast ratio: 10.99 */
  --bg-color: #efefef;
  --fg-color: #333333;

  --base-color: #fff;
  --text-color: #000;
  --link-color: #0095dd;
  --visited-link-color: #b700dd;
  --borders-color: #d3d7cf;
}

.dark {
  /* Contrast ratio: 15.44 */
  --bg-color: #181818;
  --fg-color: #efefef;

  --base-color: #2d2d2d;
  --text-color: #fff;
  --link-color: #4cc4ff;
  --visited-link-color: #e14cff;
  --borders-color: #1b1b1b;
}

/* Use known common fonts */
.sans {
  font-family: "Adwaita Sans", Helvetica, Arial, sans-serif;
}

.serif {
  font-family: "DejaVu Serif", Georgia, "Times New Roman", serif;
}


html {
  width: 95%;
  margin: 0 2.5%;
}

body {
  background-color: var(--bg-color);
  color: var(--fg-color);

  line-height: 1.6;
  text-rendering: optimizeLegibility;
  
  /* To allow for scroll overflow and let the content move to center of screen */
  margin-bottom: 16em;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: bold;
  color: var(--text-color);
}

tt,
code,
pre {
  font-family: ephy-reader-mono, monospace;
}

hr {
  border: none;
  border-top: 1px solid var(--borders-color);
}

picture img {
  border-radius: 3px;
}

h1 {
  font-size: 1.8em;
}

h2 {
  font-size: 1.4em;
}

h3 {
  font-size: 1.2em;
}

a {
  text-decoration: underline;
  font-weight: normal;
}

a,
a:active {
  color: var(--link-color);
  font-weight: inherit;
}

a:hover {
  text-decoration: none;
}

a:visited {
  color: var(--visited-link-color);
}

* {
  max-width: 100%;
  height: auto;
}

p,
code,
pre,
blockquote,
ul,
ol,
figure,
.wp-caption {
  margin: 0 0 2em 0;
}


p > img:only-child,
p > a:only-child > img:only-child,
.wp-caption img,
figure img {
  display: block;
}

@media (prefers-color-scheme: dark) {
p > img:only-child,
p > a:only-child > img:only-child,
.wp-caption img,
figure img {
  filter: brightness(0.8) contrast(1.2);
}
}

.caption,
.wp-caption-text,
caption,
figcaption {
  font-size: 0.9em;
  font-style: italic;
}

code,
pre {
  white-space: pre-wrap;
}

/* Fix sub- and superscript from altering line-height */
sup, sub {
  vertical-align: baseline;
  position: relative;
  top: -0.4em;
}

sub { 
  top: 0.4em; 
}

blockquote {
  padding: 0;
  -webkit-padding-start: 1em;
}

ul,
ol {
  padding: 0;
}

ul {
  -webkit-padding-start: 2em;
  list-style: disc;
}

ol {
  -webkit-padding-start: 2em;
  list-style: decimal;
}

li {
  margin: 0 0 0.5em 0;
}

table,
th,
td {
  border: 1px solid var(--borders-color);
  border-collapse: collapse;
  padding: 6px;
  vertical-align: top;
}

tr {
  vertical-align: top;
}

table {
  background-color: var(--base-color);
  margin: 1.5em 0;
}

/* Hide elements with common "hidden" class names */
.visually-hidden,
.visuallyhidden,
.hidden,
.invisible,
.sr-only {
  display: none;
}

article {
  overflow-y: hidden;
  margin: 1.5em auto;
  width: 640px;
  font-size: 1em;
  word-wrap: break-word;
}

mark {
  padding: 2px;
  margin: -2px;
  border-radius: 3px;
  background: var(--borders-color);
}

body mark {
  background: var(--bg-color);
  color: var(--fg-color);
}

/* Force hiding elements with navigation role */
[role=navigation] {
  display: none;
}
