/*
  JONATHAN CHAO PORTFOLIO
*/

:root {
  --page-width: 800px;
  --side-image-width: 180px;
  --header-height: 54px;
  --section-heading-height: 43px;
  --page-background: #262626;
  --page-text: #d1d1d1;
  --line-color: #d1d1d1;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + var(--section-heading-height) + 16px);
}

body {
  margin: 0;
  color: var(--page-text);
  background: var(--page-background);
  font-family: 'EB Garamond', 'Cardo', 'Garamond', 'Times New Roman', serif;
  font-size: 17px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.1em;
  text-decoration-thickness: 0.7px;
  color:#f6e3ff
}

img {
  display: block;
  max-width: 100%;
}

/* The navigation stays at the top of the browser window. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  padding: 12px 20px;
  background: var(--page-background);
  border-bottom: 0;
}

/* Draws the header line from left to right when the page loads. */
.site-header::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: var(--line-color);
  transform: scaleX(0);
  transform-origin: left;
  animation: header-line-right 1000ms ease-out 1000ms forwards;
}

@keyframes header-line-right {
  to {
    transform: scaleX(1);
  }
}

.site-name {
  flex: 0 0 auto;
  font-weight: bold;
  text-decoration: none;
}

nav,
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: #ECC2FF;
}

.purple {
  color: #ECC2FF;
}

main,
footer {
  width: min(var(--page-width), calc(100% - 40px));
  margin-inline: auto;
}

/* Controls the visible page order without changing the project markup. */
main {
  display: flex;
  flex-direction: column;
}

.intro {
  order: 0;
}

#education {
  order: 1;
}

#experience {
  order: 2;
}

#cybersecurity {
  order: 3;
}

#websites {
  order: 4;
}

#hobbies {
  order: 5;
}

.blog-footer {
  order: 6;
  width: 100%;
  margin-inline: 0;
}

#contact {
  order: 7;
}

section {
  margin-bottom: 88px;
}

.intro {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 24px;
  align-items: start;
  padding-top: 64px;
}

.portrait {
  width: 200px;
  height: 200px;
  object-fit: cover;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 2rem;
}

/*
  Each h2 remains below the main navigation while its section is on screen.
  The next h2 naturally pushes the previous one away.
*/

.portfolio-section > h2 {
  position: sticky;
  top: var(--header-height);
  z-index: 50;

  width: 99vw;
  margin-left: calc(50% - 50vw);
  padding: 0px max(16px, calc((100vw - var(--page-width)) / 2));

  background: #262626;
  /*
  this border at the bottom of subtitles does not exist.lol
  */
  border-bottom: 0px solid #d1d1d1;
}

h3 {
  margin-bottom: 4px;
  font-size: 1.1rem;
}

.eyebrow,
.subtitle,
figcaption {
  font-size: 1rem;
}

.subtitle {
  margin-bottom: 8px;
  font-style: italic;
}

.project-list {
  display: grid;
  gap: 72px;
}

/*
  PROJECT WITH A SIDE IMAGE

  --image-x moves only this project's image horizontally.
  --image-y moves only this project's image vertically.
  Positive x = right. Negative x = left. Positive y = down.
*/
.project {
  --image-x: 0px;
  --image-y: 0px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-image-width);
  gap: 32px;
  align-items: start;
}

.project.image-left {
  grid-template-columns: var(--side-image-width) minmax(0, 1fr);
}

.project.image-left .project-image {
  grid-column: 1;
  grid-row: 1;
}

.project.image-left .project-text {
  grid-column: 2;
}

.project.no-image {
  display: block;
  max-width: 620px;
}

/* The image follows its own project text as that text scrolls. */
.project-image {
  position: sticky;
  top: calc(var(--header-height) + var(--section-heading-height) + 24px);
  margin: 0;
  transform: translate(var(--image-x), var(--image-y));
}

.project-image img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.project-image figcaption {
  margin-top: 6px;
}

/*
  OPTIONAL CSS-ONLY FOREGROUND PARALLAX

  Add images inside .foreground-parallax using the commented HTML example.
  --parallax-top sets the starting height.
  --parallax-left or --parallax-right places the image on a side.
  --parallax-travel controls how far it moves while the page scrolls.
*/
.foreground-parallax {
  position: relative;
  z-index: 75;
  pointer-events: none;
}

.parallax-image {
  --parallax-top: 40vh;
  --parallax-left: auto;
  --parallax-right: auto;
  --parallax-travel: -400px;
  position: fixed;
  top: var(--parallax-top);
  left: var(--parallax-left);
  right: var(--parallax-right);
  width: 120px;
  max-height: 180px;
  object-fit: contain;
  animation: foreground-parallax linear both;
  animation-timeline: scroll(root block);
}

@keyframes foreground-parallax {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(var(--parallax-travel));
  }
}

.contact {
  min-height: 45vh;
}

footer {
  padding: 20px 0 48px;
  border-top: 1px solid var(--line-color);
}

.blog-footer {
  margin-bottom: 88px;
  border-top: 0;
}

.blog-button {
  display: inline-block;
  padding: 8px 12px;
  color: var(--page-background);
  background: var(--page-text);
  border: 1px solid var(--page-text);
}

.blog-button:hover,
.blog-button:focus-visible {
  color: var(--page-text);
  background: var(--page-background);
}

/*
  On narrow screens the navigation wraps, headings use the taller mobile
  header offset, and project images return to normal document flow.
*/
@media (max-width: 700px) {
  :root {
    --header-height: 82px;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    padding: 10px 16px;
  }

  .site-header nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
    white-space: nowrap;
  }

  main,
  footer {
    width: min(var(--page-width), calc(100% - 28px));
  }

  .intro {
    grid-template-columns: 1fr;
    padding-top: 40px;
  }

  .project,
  .project.image-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .project-text,
  .project-image,
  .project.image-left .project-text,
  .project.image-left .project-image {
    order: initial;
  }

  .project-image {
    position: static;
    width: min(80%, var(--side-image-width));
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .site-header::after {
    animation: none;
    transform: scaleX(1);
  }

  .parallax-image {
    animation: none;
  }
}
