:root {
    /* Light Mode */
    --bg-color: #fdfbf7;
    --text-color: #4a4a4a;
    --primary: #a8d5e2;
    --secondary: #f9a8d4;
    --link-color: #6d9dc5;
    --nav-bg: #f4efea;
    --border-color: #e5e0db;
    --code-bg: #f0ebe6;
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg-color: #2b2a33;
    --text-color: #e8e6e3;
    --primary: #7a9ea8;
    --secondary: #b57a9b;
    --link-color: #8eb1ce;
    --nav-bg: #222129;
    --border-color: #403e4a;
    --code-bg: #1e1d24;
}

@font-face {
    font-family: 'Open Sans';
    src: url('/fonts/Open-Sans-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('/fonts/IBM-Plex-Mono-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

/**
 * web browser normalization
 */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
}

* { 
    box-sizing: border-box; 
}

*::selection{
	background-color: var(--text-color);
	color: var(--bg-color);
}

*:focus{
	outline: 5px solid var(--link-color)
}

/*
 * stop users selecting navigational items
 */
*{
	user-select:            none;
	-webkit-user-select:    none; /* Safari */
}

article *{
    user-select:            text !important;
	-webkit-user-select:    text !important; /* Safari */
}



body {
    margin: 0;
    padding: 0;
    font-size: 16px;
    font-family: 'Open Sans', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-text-size-adjust: 100%; /* safari fix */
}

.svg-icon{
    width:  24px;
    height: 24px;
    fill:   var(--text-color);
}

pre{
	border: 10px solid var(--border-color);
}

pre, code {
    font-family: 'IBM Plex Mono', monospace;
    background-color: var(--code-bg);
    padding: 0.2rem 0.4rem;
}

a{ 
    color: var(--link-color); 
    text-decoration: none; 
}

a:hover{ 
    opacity: 0.8;
}

/* Header & Nav */
header{
    background-color: var(--nav-bg);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

#logo{ 
    height: 40px; 
}

header nav ul{ 
    display: flex; 
    gap: 1rem; 
    align-items: center; 
    list-style: none;
    margin: 0px;
}

header nav ul a {
    color: var(--text-color);
    font-weight: bold;
    position: relative;
    height: 100%;
    display: block;
}

header nav ul a::after {
    content: '';
    position: absolute;
    width: 0; 
    height: 2px;
    bottom: 0; 
    left: 0;
    background-color: var(--primary);
}

header nav ul a:hover::after { 
    width: 100%; 
}

input{
	border: 10px solid var(--border-color);	
}

/* Main Layout */
main{ 
    flex: 1; 
    padding: 2rem; 
    max-width: 800px; 
    margin: 0 auto; 
    width: 100%; 
}

main a:focus{
    background-color: var(--link-color);
    box-shadow: 0 -2px var(--link-color),0 4px var(--text-color);
    color: var(--bg-color);
    outline: none;
}

/**
 * Mobile devices fixes
 */
article{
    word-break: break-word;
}

/* Articles & Search Lists */

/* additional space added for a cleaner layout when using drop caps */
article h1{
  margin-bottom: 2em;
}

/* first paragraph drop caps styling for the articles themselves */
article h1[id] + p:first-of-type::first-letter {
  font-weight: 900;
  font-size: 4.6rem;
  line-height: 3.5rem;
  float: left;
  display: inline-block;
  color: var(--text-color);
  padding: 0.9rem 1rem;
  margin-top: 0.5rem;
  margin-right: 1rem;
  background: var(--bg-color);
  border: 2px solid var(--text-color);
}

article p{
   text-align: justify;
}

article img, article video{
    width: 100%;
    height: auto;
}

article p:has(> video){ 
    padding: 7px;
}

article p{
    line-height: 2em;
    font-size: 1.1em;
    margin-bottom: 4em;
}

article ul{
    line-height: 2em;
}

/* half the spacing if there is no header tag */
article p:has(+ p)
{
    margin-bottom: 2em;
}

article img{
    cursor: pointer;
}

article pre{
    overflow: scroll;
}

article table {
    border-collapse: collapse;
    width: 100%;
}

article th, 
article td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #DDD;
}

article p:has(+ ul), 
article p:has(+ ol), 
article p:has(+ div), 
article p:has(+ pre){
    margin-bottom: 0px;
}

/* extra spacing for sections with a list and div at the end */
article ul:has(+ h2), 
article ul:has(+ h3), 
article ul:has(+ h4), 
article ul:has(+ h5), 
article ul:has(+ h6), 
article ol:has(+ h2), 
article ol:has(+ h3), 
article ol:has(+ h4), 
article ol:has(+ h5), 
article ol:has(+ h6), 
article div:has(+ h2), 
article div:has(+ h3), 
article div:has(+ h4), 
article div:has(+ h5), 
article div:has(+ h6){
    margin-bottom: 4em;
}

article figure {
    margin: .8em;
    margin-bottom: 4em;
}

article code {
    text-align: left;
    overflow: scroll;
}

video{
    background-color: #000;
    cursor: pointer;
}

.item-list{
    list-style: none; 
    padding: 0; 
}

.item-list li{
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.item-list li:hover{ 
    background-color: var(--nav-bg); 
}

.item-list h2{ 
    margin: 0 0 0.5rem 0; 
    font-size: 1.25rem; 
}

.item-list p{ 
    margin: 0; 
    color: inherit; 
    opacity: 0.8; 
    font-size: 0.95rem; 
    text-align: justify;
}

.item-list p:after{ 
    content: " ..."; 
}

/* responsive article listing image */

.item-list li div div:first-child{
    background-size:        cover;
    background-position:    center center;
}

/* image side */ 
@media screen and (min-width: 650px) {

    /**
     * left image
     */
    .item-list li:nth-child(odd) div {
        flex-direction: row;
    }

    .item-list li:nth-child(odd) div .item-image-side{
        margin: 0 1.5rem 0 0;
    }

    /**
     * right image
     */
    .item-list li:nth-child(even) div{
        flex-direction: row-reverse;
    }

    .item-list li:nth-child(even) div .item-image-side{
        margin: 0 0 0 1.5rem;
    }

    .item-list li div .item-image-side{
        width: 150px;
        height: 150px;
    }

    .item-list li div .item-image-bottom{
        display: none;
    }

}

/* image bottom */

@media screen and (max-width: 649px) {
    .item-list li div{
        flex-direction: column;
    }

    .item-list li div .item-image-side{
        display: none;
    }

    .item-list li div .item-image-bottom{
        margin: 1.5rem 0 0 0;
        width: 100%;
        height: auto;
    }
}

/* Search Elements */
#search-container{
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#search-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 1px solid var(--border-color);
    background: var(--nav-bg);
    color: var(--text-color);
    margin-bottom: 1rem;
}

.search-instructions {
    background: var(--code-bg);
    padding: 1rem;
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    align-items: center;
    margin-top: 2rem;
    font-size: .8rem;
}

.pagination div{
    margin: .8rem 0;
}

.pagination{
    vertical-align: center;
}

.pagination button {
    background: var(--nav-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: .4rem;
    cursor: pointer;
    vertical-align: middle;
    height: 100%;
}

#articles-pagination-prev, #search-pagination-prev{
    margin-right: 1rem;
    margin-left: .2rem;
}

#articles-pagination-next, #search-pagination-next{
    margin-left: 1rem;
    margin-right: .2rem;
}

.pagination button:not(:disabled):hover{ 
   filter: invert(20%);
}

.pagination button:disabled { 
    opacity: 0.5; 
    cursor: not-allowed; 
}

.pagination svg{
    vertical-align: middle;
}

/* Footer */
footer {
    background-color: var(--nav-bg);
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-links { 
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

.footer-links li {
  padding-right: .4rem;
}

.footer-links:last-child{
  padding-right: 0;
}

.footer-links li::after {
  content: "•"; 
  font-weight: bold;
  padding-left: .4rem;
}

.footer-links li:last-child:after{
  content: ""; 
  padding-left: 0;
}

.footer-links li a { 
    color: var(--text-color); 
}

