/* Theme */

/* Font Face */
@font-face {
    font-family: Montserrat;
    src: url('fonts/Montserrat-VariableFont_wght.ttf') format('truetype');
}

/* Root Variables */
:root {
    --font-family: Montserrat, -apple-system, system-ui, sans-serif;
    --font-family-monospace: Consolas, Menlo, Monaco, monospace;

    /* Colors */
    --color-gray-20: #e0e0e0;
    --color-gray-50: #C0C0C0;
    --color-gray-70: #8f8f8f;
    --color-gray-90: #333;

    --color-background: #fff;

    --color-brand: #0087c5;
    --color-brand-t50: #6699b1;
    --color-contrast: #005a83;

    --text-color: var(--color-gray-90);
    --text-color-link: #082840;
    --text-color-link-active: #5f2b48;
    --text-color-link-visited: #17050F;

    /* Typography */
    --body-font-size: 1rem;
    --type-ratio: 1.33;

    /* Fluid Typography */
    --font-size-4: calc(var(--body-font-size) * var(--type-ratio));
    --font-size-3: calc(var(--font-size-4) * var(--type-ratio));
    --font-size-2: calc(var(--font-size-3) * var(--type-ratio));
    --font-size-1: calc(var(--font-size-2) * var(--type-ratio));
}

/* Typography */
h1,
.h1 {
  --font-size: var(--font-size-1);
  font-size: var(--font-size);
}

h2,
.h2 {
  --font-size: var(--font-size-2);
  font-size: var(--font-size);
}

h3,
.h3 {
  --font-size: var(--font-size-3);
  font-size: var(--font-size);
}

h4,
.h4 {
  --font-size: var(--font-size-4);
  font-size: var(--font-size);
}

@supports (font-size: 1cqi) {
	:is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, .fluid-type) {
		font-size: clamp(
			max(1rem, var(--font-size) - var(--font-size) * var(--font-size-diff, 0.3)),
			var(--font-size-fluid, 5cqi),
			var(--font-size)
		);
	}
}

/* General Styles */
@media screen and (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }

    .accordion-content {
        transition: height 0.3s ease-out;
    }
}

html {
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    margin: 0 auto;
    font-family: var(--font-family);
    color: var(--text-color);
    background-color: var(--color-background);
    max-width: 80em;
}

header {
    background-color: var(--color-brand);
    color: #fff;
    text-align: center;
    padding: 20px;
}

main {
    display: flex;
    flex-direction: row;
    min-height: calc(100vh - 243px); /* Adjust for header height */
    height: auto;
    overflow: scroll;
}

nav {
    width: 300px;
    height: auto;
    background-color: #f4f4f4;
    box-sizing: border-box;
}

nav ul {
    list-style-type: none;
    padding: 0;
}

nav ol {
    padding-left: 2rem;
}

nav ul li a {
    text-decoration: none;
    color: var(--color-brand);
    font-weight: bold;
}

nav ul li a:hover {
    text-decoration: underline;
}

p, li {
    line-height: 1.5;
}

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

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

a:hover,
a:active {
    color: var(--text-color-link-active);
}

.graph-list {
    margin-top: 2.5rem;
    margin-bottom: 3rem;
}

.graph-list a {
    display: block;
    padding: 0.5rem;
    text-decoration: none;
}

.graph-list a:hover,
.accordion-trigger:hover {
    background-color: #d8d8d8;
    color: #0074D9;
}

.graph-list li::marker {
    color: var(--text-color);
    font-weight: normal;
}

.graph-active,
.graph-list .graph-active a:hover,
.accordion-trigger[aria-expanded="true"] {
    background-color: #0074D9;
    color: white;
    font-weight: bold;
}

.graph-active a {
    color: inherit;
    font-weight: inherit;
}

/* Accordion Styles (mobile) */

.accordion-trigger {
    width: 100%;
    padding: 1rem;
    text-align: left;
    border: 1px solid #ccc;
    border-radius: 2px;
    background: var(--color-gray-20);
    cursor: pointer;
    font-size: 1rem;
    position: relative;
    transition: background 0.2s;
    padding-right: 3rem;
}

.accordion-trigger::after {
    content: '\276F';
    font-weight: bold;
    transition: all .35s;
    position: absolute;
    right: 2rem;
    text-align: center;
    font-size: 1rem;
    color: #333;
}

/* When expanded, show X */
.accordion-trigger[aria-expanded="true"]::after {
    transform: rotate(90deg);
    color: white;
}

.accordion-content {
    display: none;
    padding-left: 1rem;
    padding-right: 1rem;
    background: var(--color-background);
}

.accordion-trigger[aria-expanded="true"] + .accordion-content {
    display: block;
}

/* Plaecholder for graph on mobile */
.graph-placeholder {
    margin-top: 0rem;
}

/* Legend Styles */
#legend {
    width: 100%;
}

#legend ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    width: 100%;
}

#legend li {
    flex: 1;
}

.legend-button {
    width: 100%;
    height: 2.5rem;
    line-height: 2.5rem;
    text-align: center;
    color: white;
    cursor: pointer;
    opacity: 0.7;
    font-size: clamp(0.7rem, 2.5vw, 1rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: none;
    border: none;
}

.legend-button:hover,
.legend-active .legend-button {
    opacity: 1.0;
}

.legend-observations {
    background-color: black;
}

.legend-implications {
    background-color: var(--color-contrast);
}

.legend-recommendations {
    background-color: var(--color-brand);
}

/* Loader Styles */
.loader {
    border: 10px solid #f3f3f3;
    border-top: 10px solid #4baad6;
    border-bottom: 10px solid #4baad6;
    border-radius: 50%;
    width: 120px;
    height: 120px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Graph Container */
#graph-section {
    flex-grow: 1;
    position: relative;
    padding: 0;
}

#cy {
    width: 100%;
    height: 80vh;
    display: block;
    box-sizing: border-box;
    overflow: visible;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    padding-top: 20vh;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fff;
    margin: auto;
    width: 80%;
    max-width: 600px;
    min-height: 10rem;
    border-radius: 5px;
    position: relative;
}

.modal-header {
    padding: 2rem;
    padding-bottom: 0.5rem;
}

.modal-header h2 {
    margin: 0;
}

.modal-header .modal-category {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-variant-caps: small-caps;
    font-weight: bold;
}

.observation .modal-category {
    color: rgba(0,0,0,0.5);
}

.implication .modal-category {
    color: rgb(from var(--color-contrast) r g b / 1);
}

.recommendation .modal-category {
    color: rgb(from var(--color-brand) r g b / 1);
}

.modal-header.observation {
    background-color: rgba(0,0,0,0.2);
}

.modal-header.implication {
    background-color: rgb(from var(--color-contrast) r g b / 0.3);
}

.modal-header.recommendation {
    background-color: rgb(from var(--color-brand) r g b / 0.3);
}

.modal-body {
    padding: 2rem;
    padding-top: 1.5rem;
}

.modal-body > * {
    margin-top: 1rem;
}
.modal-body :first-child {
    margin-top: 0;
}

.close-button {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    border: none;
    background: none;
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
}

.close-button:hover {
    color: #000;
}

/* Mobile Styles */
@media screen and (max-width: 768px) {
    main {
        flex-direction: column;
        width: 100%;
    }

    nav {
        width: 100%;
    }

    #graph-section {
        width: 100%;
    }

    .graph-list {
        margin: 0;
        padding: 0;
    }

    .graph-item-container {
        border-bottom: 1px solid #ddd;
    }

    .graph-list a {
        display: block;
        padding: 0.4rem;
        text-decoration: none;
    }

    #cy {
        height: 50vh;
    }
}

/* Desktop Styles */
@media screen and (min-width: 768px) {
    .graph-list li, 
    .graph-list li:hover,
    .graph-list a:hover {
        border-top-left-radius: 8px;
        border-bottom-left-radius: 8px;
    }

    .accordion-trigger {
        display: none;
    }

    .accordion-content {
        display: none !important;
    }

    #graph-section {
        display: block !important;
    }
}

/* Accessibility Focus States */
.legend-button:focus {
    outline: 2px solid #fff;
    outline-offset: -2px;
}
