/* 

Table of Contents:
  1.0 Setup
    1.1 Scrollbar
  2.0 Global Styling
    2.1 Elements
    2.2 Layout
    2.3 Other Site-Wide Styles
  3.0 Page-Specific Styles
    3.1 Homepage
    3.2 About Page
    3.3 Projects Page
    3.4 Contact Page

*/

/* 1.0 Setup */

/* :root {
  color-scheme: light; */

  /* --primary-background-color: hsl(205, 60%, 65%);
  --content-background-color: hsl(205, 55%, 85%);
  --highlight-background-color: hsl(205, 80%, 75%);
  --text-color: hsl(205, 35%, 15%);
  --text-color-secondary: hsl(205, 100%, 25%);
  --logo-background-color: hsl(180, 55%, 70%);
  --accent-item-color: hsl(205, 100%, 40%); */

  /* SVG Filters */
  /* --svg-invert: 20%;
  --svg-sepia: 88%;
  --svg-saturate: 1419%;
  --svg-hue-rotate: 183deg;
  --svg-brightness: 90%;
  --svg-contrast: 103%;

  --svg-hover-invert: 36%;
  --svg-hover-sepia: 88%;
  --svg-hover-saturate: 3205%;
  --svg-hover-hue-rotate: 186deg;
  --svg-hover-brightness: 87%;
  --svg-hover-contrast: 102%; */
/* } */

/* @media(prefers-color-scheme: dark) { */
  :root {
    color-scheme: dark;

    --primary-background-color: hsl(205, 50%, 10%);
    --content-background-color: hsl(205, 75%, 20%);
    --highlight-background-color: hsl(205, 80%, 30%);
    --text-color: hsl(205, 20%, 85%); 
    --text-color-secondary: hsl(200, 90%, 80%);
    --logo-background-color: hsl(180, 65%, 40%);
    --accent-item-color: hsl(180, 100%, 40%);

    /* SVG Filters */
    --svg-invert: 79%;
    --svg-sepia: 41%;
    --svg-saturate: 439%;
    --svg-hue-rotate: 170deg;
    --svg-brightness: 99%;
    --svg-contrast: 99%;

    --svg-hover-invert: 80%;
    --svg-hover-sepia: 38%;
    --svg-hover-saturate: 7414%;
    --svg-hover-hue-rotate: 135deg;
    --svg-hover-brightness: 97%;
    --svg-hover-contrast: 101%;

    /* Shared Values / magic numbers that multiple elements use */
    --border-radius: 0.75rem;
    --border-width: 0.2rem;
    --post-margin: 1.5rem;
    --scrollbar-width: 1rem;
    --post-padding-width: 1rem;

    /* Font sizes that scale on screen width */
    /* @link https://utopia.fyi/type/calculator?c=270,14,1.2,1240,18,1.333,5,0,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12 */
    --step-0: clamp(0.88rem, calc(0.81rem + 0.41vw), 1.13rem); /* 14.00px to 18.00px */
    --step-1: clamp(1.05rem, calc(0.92rem + 0.74vw), 1.50rem); /* 16.80px to 23.99px */
    --step-2: clamp(1.26rem, calc(1.05rem + 1.22vw), 2.00rem); /* 20.16px to 31.98px */
    --step-3: clamp(1.51rem, calc(1.19rem + 1.90vw), 2.66rem); /* 24.19px to 42.63px */
    --step-4: clamp(1.81rem, calc(1.33rem + 2.87vw), 3.55rem); /* 29.03px to 56.83px */
    --step-5: clamp(2.18rem, calc(1.47rem + 4.22vw), 4.74rem); /* 34.84px to 75.76px */
  }
/* } */

:focus, :focus-visible {
  border-style: dashed;
  border-width: var(--border-width);;
  border-color: var(--accent-item-color);
  outline: none;
}

::selection {
  background: var(--primary-background-color);
  color: var(--accent-item-color);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--post-margin);
}

/* 1.1 Scrollbar */

/* TLDR: hide the buttons, make the colors match normal content */

/* Firefox */
* {
  scrollbar-color: var(--content-background-color) var(--primary-background-color);
}

/* Chrome / Edge */
::-webkit-scrollbar {
  /* I don't care about the width, but if it's not set, it won't apply any other styles */
  width: var(--scrollbar-width);
}

::-webkit-scrollbar-button {
  display: none;
}

::-webkit-scrollbar-thumb {
  background: var(--content-background-color);
  border-top-left-radius: var(--border-radius);
  border-bottom-left-radius: var(--border-radius);
}

::-webkit-scrollbar-track {
  background: var(--primary-background-color);
}

/* 2.0 Global Styling */

/* 2.1 Main Elements */

body {
  background-color: var(--primary-background-color);
  margin: 0;
}

a {
  color: var(--text-color-secondary);
}

a:hover, a:focus {
  color: var(--accent-item-color);
  border: none; /* To override the default :focus border */
  border-radius: 0.5rem; /* Stay wider so it doesn't collide with the text */
  outline-style: dashed;
  outline-width: var(--border-width);;
  outline-color: var(--accent-item-color);
}

.btn, .carousel-button {
  box-sizing: border-box;
  display: inline-block;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  padding: 0.75em;
  text-align: center;
  text-decoration: none;
}

.btn {
  background-color: var(--highlight-background-color);
  width: 100%;
}

a, h1, h2, h3, h4, p, li {
  font-family: 'Nunito', sans-serif;
}

h1, h2, h3, h4, p, li {
  color: var(--text-color);
}

h1, h2, h3, h4 {
  margin: 0;
}

footer p {
  text-wrap: balance;
  text-align: center;
}

h1 {
  font-size: var(--step-5);
}

h2 {
  font-size: var(--step-4);
}

h3 {
  font-size: var(--step-2);
}

h4, footer p {
  font-size: var(--step-1);
}

a, p, li {
  font-size: var(--step-0);
}

img {
  max-width: 100%;
}

strong {
  color: var(--accent-item-color);
}

/* 2.2 Layout */

.skip-to-contact-focusable {
  text-decoration: none;
}

.skip-to-contact-focusable:hover {
  outline: none;
}

.skip-to-contact-text {
  /* Basically, hide it until it is focused (via a screenreader or tabbing to it) */
  display: none;
}

.skip-to-contact-focusable:focus-visible .skip-to-contact-text {
  display: block;
}

.nowrap {
  white-space: nowrap;
}

.navigation {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 20%;
}

.small-screens {
  display: none;
}

nav {
  background-color: var(--content-background-color);
  border-top-right-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
  margin: 1.5rem 0;
  padding: 1rem 0;
}

#logo-holder, .navigation h4 {
  text-align: center;
}

.logo {
  max-width: 80%;
}

nav h4 {
  margin: 0.5em 0;
}

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

@media (min-width: 668px) {
  nav ul li {
    padding: 0.5em 1em;
    margin-inline-start: 1em;
  }

  nav ul li.active-tab {
    background-color: var(--primary-background-color);
    border-start-start-radius: var(--border-radius);
    border-end-start-radius: var(--border-radius);
    position: relative;
    
    --inverse-border-radii: 5px;
  }

  nav ul li.active-tab::before, nav ul li.active-tab::after {
    background-color: var(--content-background-color);
    content:'';
    position: absolute;
    width: var(--border-radius);
    height: var(--border-radius);
    right: 0;
  }

  nav ul li.active-tab::before {
    border-end-end-radius: var(--border-radius);
    top: calc(-1 * var(--border-radius));
    box-shadow: var(--inverse-border-radii) var(--inverse-border-radii) 0 var(--inverse-border-radii) var(--primary-background-color);
  }

  nav ul li.active-tab::after {
    border-start-end-radius: var(--border-radius);
    bottom: calc(-1 * var(--border-radius));
    box-shadow: var(--inverse-border-radii) calc(-1 * var(--inverse-border-radii)) 0 var(--inverse-border-radii) var(--primary-background-color);
  }
}

nav ul a {
  text-decoration: none;
}

.post {
  background-color: var(--content-background-color);
  margin: var(--post-margin);
  padding: var(--post-padding-width);
  border-radius: var(--border-radius);
}

.subpost {
  background-color: var(--highlight-background-color);
  border-radius: var(--border-radius);
  margin: 1em 0;
  padding: 1em;
}

main, footer {
  width: 80%;
  margin-left: 20%;
}

footer {
  text-align: center;
  height: 10%;
}

footer p {
  position: relative;
  top: 50%;
}

footer .only-image {
  text-decoration: none;
}

.footer-icon {
  max-height: 30px;
  vertical-align: middle;
}

.footer-icon, .contact-icon {
  /* See this article: https://css-tricks.com/change-color-of-svg-on-hover/ */
  filter: invert(var(--svg-invert)) sepia(var(--svg-sepia)) saturate(var(--svg-saturate)) hue-rotate(var(--svg-hue-rotate)) brightness(var(--svg-brightness)) contrast(var(--svg-contrast));
}

.footer-icon:hover, a:hover .contact-icon, a:focus .footer-icon, a:focus .contact-icon {
  filter: invert(var(--svg-hover-invert)) sepia(var(--svg-hover-sepia)) saturate(var(--svg-hover-saturate)) hue-rotate(var(--svg-hover-hue-rotate)) brightness(var(--svg-hover-brightness)) contrast(var(--svg-hover-contrast));
}

@media(max-width: 667px) {
  h1, h2 {
    text-wrap: balance;
    text-align: center;
  }

  .small-screens {
    display: block;
  }

  .logo {
    max-height: 2rem;
    margin: 0;
    padding: 0;
    vertical-align: middle;
  }

  .logo-label {
    display: inline;
    vertical-align: middle;
  }

  .navigation {
    position: sticky;
    text-align: left;
    top: 0;
    width: 100%;
    z-index: 10;
  }

  nav {
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    outline: 0.25rem solid var(--primary-background-color);
    border-top: 0;
    margin: 0 var(--post-margin);
    padding: 0.4rem var(--post-padding-width);
    display: grid;
    grid-template-columns: 2fr 5fr;
    gap: 0.5em;
    align-content: center;
    align-items: center;
    justify-content: center;
    justify-items: center;
    position: inherit;
    z-index: 1;
  }

  .site-nav h4 {
    display: none;
  }

  .site-nav ul {
    display: grid;
    grid-auto-flow: column;
    justify-content: center;
    justify-items: center;
    gap: 0.5em 1em;
  }

  .site-nav ul li {
    font-weight: bold;
  }

  /* Hide the "On This Page" section as it will take up a significate amount of space */
  /* Using a scroll-based animation to have it animate away makes the content that */
  /* moves to where it used to be non-functioning, so we just have to remove it */
  .page-nav-container{
    display: none;
  }

  /* Reset main and footer to take the full width */
  main, footer {
    width: 100%;
    margin-left: auto;
  }
}

@media(max-width: 500px) {
  nav {
    grid-template-columns: 1fr;
  }

  .page-nav {
    grid-column: unset;
  }
}

@media(max-width: 350px) {
  .site-nav ul {
    grid-template-columns: 1fr 1fr;
    grid-auto-flow: unset;
  }
}

/* 2.3 Other Site-Wide Styles */

/* Line everything up in a row and set up a scrollbar for if (when) it goes off-screen */
.carousel {
  border-radius: var(--border-radius);
  display: flex;
  gap: 1em;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  scrollbar-color: var(--primary-background-color) transparent; /* Firefox scrollbar styling - Chrome is below */
}

/* Have each item take up the full available space and have the scroll lock onto on each item as it goes by */
.carousel > * {
  flex-basis: 100%;
  flex-shrink: 0;
  scroll-snap-align: center;
}

.carousel img {
  width: 100%;
  filter: brightness(85%);
}

.carousel-button-holder {
  margin: 1em auto;
  text-align: center;
}

.carousel-button {
  background-color: var(--primary-background-color);
  width: 2.75em;
  height: 2.75em;
  margin-left: 1em;
}

.carousel-button:first-of-type {
  margin-left: 0;
}

.carousel::-webkit-scrollbar {
  width: var(--scrollbar-width);
  height: var(--scrollbar-width);
}

.carousel::-webkit-scrollbar-thumb {
  border-radius: var(--border-radius);
  background-color: var(--primary-background-color);
}

.carousel::-webkit-scrollbar-track {
  background-color: transparent;
}

@media screen and (orientation:portrait) {
  /* The scrollbar is really not for mobile */
  /* I'd rather just have them swipe the images or tap the buttons to the other image */
  /* Plus, mobile users are much less likely to be blocking the JS which adds the buttons, so less navigation options is a nicety */
  .carousel::-webkit-scrollbar {
    display: none;
  }
}

.techlogos {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  justify-content: center;
}

.techlogos img {
  aspect-ratio: 1;
  background-color: var(--logo-background-color);
  border-radius: var(--border-radius);
  box-sizing: border-box;
  display: inline-block;
  height: 6em;
  padding: 0.5em;
}

/* 3.0 Page-Specific Styles */

/* 3.1 Homepage */

/* 3.2 About Page */

#languages-label, #tools-label {
  margin-block-end: 0.5rem;
}

.about-image-grid {
  display: grid;
  gap: 1em;
  grid-template-columns: repeat(auto-fit, minmax(7em, 1fr));
}

.about-image-grid img {
  aspect-ratio: 1;
  border-radius: var(--border-radius);
  background-color: var(--logo-background-color);
  box-sizing: border-box;
  padding: 0.4em;
  width: 100%; /* of their column in the grid */
}

/* Override the default a border-radius. The default a:hover/:focus border is less round than everything else to avoid colliding with text */
.about-image-grid a:hover {
  border-radius: var(--border-radius);
}

.tooltip {
	position: relative;
	text-align: center;
}

.tooltip::after {
  border-radius: var(--border-radius);
  padding: var(--border-radius);
	background-color: #222;
	content: attr(tooltip-text);
  color: var(--text-color);
	display: none;
	position: absolute;
	z-index: 2;
	bottom: 110%; /* float slightly above the top of the element */
	left: calc(-0.75em - 1em); /* half the width over 100% of the tooltip (currently 2em, see below) - the padding-left */
  /* The width is the width of the image + some of the minimum extra space around the image (.post margin + .post padding) */
  /* wider looks better (such as 250% of the image width), but will go off the screen for items in the first and last columns. */
  width: calc(100% + 2em);
}

/* :nth-col is still part a draft (as part of selectors 4), so it has zero support in browers at this moment */
/* However, it would solve the above-mentioned width issue in a pure-CSS way. */
/*
.about-image-grid:nth-col(1) .tooltip::after {
  left: -1em;
}

.about-image-grid:nth-last-col() .tooltip::after {
  left: unset;
  right: -1em;
}
*/

/* Override the "display: none;" when interacted with */
.tooltip:hover::after, .tooltip:focus::after {
	display: block;
}

/* 3.3 Projects Page */

/* 3.4 Contact Page */

.contact-icon {
  vertical-align: middle;
  width: 2em;
}

.contact-link {
  padding: 0.5em 0.2em;
  margin-right: 1em;
}
