/* ==========================================================================
   Portfolio styles

   Contents
   1.  Design tokens
   2.  Base
   3.  Header
   4.  Nav
   5.  Views (page sections)
   6.  Home
   7.  Projects
   8.  About
   9.  Contact
   10. Footer
   11. Section transition
   12. Keyframes
   13. Reduced motion
   ========================================================================== */


/* ---------- 1. Design tokens ---------- */
:root {
  /* Color */
  --bg: #0d0b09;
  --surface: #1a2029;
  --text: #e8ebf0;
  --muted: #9aa5b6;
  --border: #2b3340;
  --accent: #b75dce;
  --accent-fade: #b75dce15;
  --accent-text: #11151c;

  /* Type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-title: "Varela Round", sans-serif;

  /* Layout */
  --radius: 8px;
  --max-width: 60rem;
  --space: 4rem;
  --nav-width: 44rem;
}


/* ---------- 2. Base ---------- */
body {
  margin: 0;
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 20% 30% at 0% 0%, var(--accent-fade) 0%, transparent 100%),
    radial-gradient(ellipse 40% 50% at 100% 100%, var(--accent-fade) 0%, transparent 100%);
}


/* ---------- 3. Header ---------- */
header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 24px;
}

/* Logo: a link to #home */
.aperture {
  display: block;               /* lets width, height and transforms apply to the link */
  width: 70px;
  height: 70px;
  margin-bottom: 28px;
  align-self: center;
  color: var(--accent);
  border-radius: 50%;
  opacity: 0.85;
  animation:
    spinUp 1.5s cubic-bezier(0.15, 0.6, 0.3, 0.978),
    slowSpin 24s linear 1.5s infinite,
    fadeIn 0.8s ease both;
}

.aperture:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}


/* ---------- 4. Nav ---------- */
nav {
  position: relative;
  display: flex;
  justify-content: center;
  gap: var(--space);
  width: min(100%, var(--nav-width));
}

/* Line under the nav; "bottom" lifts it off the bottom edge */
nav::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.4rem;
  height: 1px;
  background: var(--accent);
}

.nav-button {
  position: relative;
  z-index: 0;                   /* own stacking context, keeps the box behind the text */
  min-width: 10rem;
  padding: 0.6rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 700;
}

/* Hover box: sits on the line and grows upward */
.nav-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0.4rem;               /* matches the line's "bottom" value */
  z-index: -1;                  /* behind the text */
  background: var(--accent);
  transform: scaleY(0);         /* collapsed down to the line */
  transform-origin: bottom;     /* grows up from the line */
  transition: transform 0.25s ease;
}

/* Dark copy of the label, sitting exactly on top of the real text */
.nav-button::after {
  content: attr(data-text);
  content: attr(data-text) / "";   /* hides the copy from screen readers where supported */
  position: absolute;
  inset: 0;
  padding: inherit;
  color: var(--accent-text);
  clip-path: inset(calc(100% - 0.4rem) 0 0.4rem 0);   /* hidden: flat strip on the line */
  transition: clip-path 0.25s ease;
}

.nav-button:hover::before,
.nav-button:focus-visible::before {
  transform: scaleY(1);
}

.nav-button:hover::after,
.nav-button:focus-visible::after {
  clip-path: inset(0 0 0.4rem 0);   /* same area as the box */
}

/* Small screens: let the buttons shrink so the nav fits */
@media (max-width: 700px) {
  nav {
    gap: 1rem;
  }

  .nav-button {
    min-width: 0;
    padding-inline: 0.5rem;
    font-size: 1.4rem;
  }
}


/* ---------- 5. Views (page sections) ---------- */
.view {
  width: min(100% - 2rem, var(--max-width));
  margin: 0 auto;
}

.view h2 {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 400;
  text-align: center;
}

.section-description {
  position: relative;
  top: -2rem;                   /* pulls the text up under the heading */
  margin: 0 0 2rem;
  font-family: var(--font-title);
  font-weight: 400;
  text-align: center;
}


/* ---------- 6. Home ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2rem;
  align-items: center;
  margin-top: 1rem;
}

.eyebrow {
  margin: 0;
  font-family: var(--font-title);
  color: var(--accent);
}

.hero h1 {
  margin: 0.25rem 0 0.5rem;
  font-family: var(--font-title);
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  font-weight: 400;
  line-height: 1.1;
}

.tagline {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}

.hero-blurb {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Buttons */
.button {
  padding: 0.6rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  transition: background-color 0.25s ease, color 0.25s ease;
}

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

.button.primary {
  background: var(--accent);
  color: var(--accent-text);
}

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

/* Profile picture */
.pfp {
  display: flex;
  justify-content: center;
}

.pfp img {
  display: block;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 32px var(--accent-fade);
}

@media (max-width: 700px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .hero-actions {
    justify-content: center;
  }

  .pfp {
    order: -1;                  /* photo above the text on phones */
  }
}


/* ---------- 7. Projects ---------- */
.project-grid {
  display: grid;
  gap: 1.5rem;
}

.project {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.project:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.project h3 {
  margin: 0 0 0.5rem;
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 400;
}

.project p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.tags li {
  padding: 0.15rem 0.7rem;
  font-size: 0.9rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
}

.project .links {
  display: flex;
  gap: 1rem;
  margin: auto 0 0;             /* pushes the links to the bottom of the card */
}

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

.project .links a:hover {
  color: var(--accent);
}


/* ---------- 8. About ---------- */
#about .text-box {
  color: var(--muted);
}

/* Text box on the left, skillset on the right */
.about-layout {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 2rem;
  align-items: center;          /* columns share a vertical center */
}

.skillset h3 {
  margin: 0 0 1rem;
}

.skill {
  margin-bottom: 1rem;
}

.skill-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.skill-header .proficiency {
  opacity: 0.7;
}

.skill-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.skill-fill {
  width: calc(var(--level) / 10 * 100%);   /* --level (0-10) is set inline in the HTML */
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

/* Stack on narrow screens */
@media (max-width: 700px) {
  .about-layout {
    grid-template-columns: 1fr;
  }
}


/* ---------- 9. Contact ---------- */

/* Row of icon links, centered */
.contact-links {
  display: flex;
  justify-content: center;
  gap: 4rem;
  margin-top: 1.5rem;
}

.contact-link {
  --hover-color: #888;          /* fallback; overridden per icon below */
  display: inline-flex;
  width: 56px;
  height: 56px;
  color: #666;                  /* resting color */
  transition: color 0.25s ease, transform 0.25s ease;
}

/* SVGs use currentColor, so changing "color" recolors the icon */
.contact-link svg {
  width: 100%;
  height: 100%;
}

.contact-link:hover,
.contact-link:focus-visible {
  color: var(--hover-color);
  transform: scale(1.12);
}

/* Per-icon hover colors */
.contact-link.github   { --hover-color: #8957e5; }
.contact-link.linkedin { --hover-color: #0a66c2; }
.contact-link.email    { --hover-color: #ea4335; }


/* ---------- 10. Footer ---------- */
footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
/* ---------- 11. Section transition ---------- */

/* The area that swaps between views; its own layer so only it animates */
main {
  position: relative;
  padding-block: 24px;
  view-transition-name: main;
  flex: 1;
  min-height: 60vh;             /* keeps every view the same height so the wipe edges line up */
}

/* Wipe: old content leaves and new content enters, top to bottom */
::view-transition-old(main),
::view-transition-new(main) {
  animation-duration: 0.5s;
  animation-delay: 0.3s;        /* waits for the line to draw first */
  animation-timing-function: ease;
  animation-fill-mode: both;
  mix-blend-mode: normal;
}

::view-transition-old(main) {
  animation-name: wipeOut;
}

::view-transition-new(main) {
  animation-name: wipeIn;
}

/* Line: an invisible element that only exists so the browser makes a layer for it */
.wipe-line {
  position: absolute;
  top: calc(-0.4rem - 1px);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
  view-transition-name: wipe-line;
}

::view-transition-old(wipe-line) {
  display: none;
}

/* The purple band, drawn only while the transition runs.
   Total 1s: 30% draws (0.3s), 50% travels (0.5s), 20% shrinks (0.2s).
   The wipe above uses delay 0.3s and duration 0.5s to match the travel stage. */
::view-transition-new(wipe-line) {
  background: var(--accent);
  mix-blend-mode: normal;
  animation: lineDraw 1s ease both;
}


/* ---------- 12. Keyframes ---------- */

/* Logo */
@keyframes spinUp {
  to { transform: rotate(720deg); }
}

@keyframes slowSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Section wipe */
@keyframes wipeOut {
  from { clip-path: inset(0 0 0 0); }
  to   { clip-path: inset(100% 0 0 0); }
}

@keyframes wipeIn {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 0 0); }
}

/* Transition line (1px band): draws out, travels down, shrinks at the bottom */
@keyframes lineDraw {
  0% {
    clip-path: inset(0 max(0px, calc((100% - var(--nav-width)) / 2)) calc(100% - 1px) max(0px, calc((100% - var(--nav-width)) / 2)));
    animation-timing-function: ease-out;
  }
  30% {
    clip-path: inset(0 0 calc(100% - 1px) 0);
    animation-timing-function: ease;
  }
  80% {
    clip-path: inset(calc(100% - 1px) 0 0 0);
    animation-timing-function: ease-in;
  }
  100% {
    clip-path: inset(calc(100% - 1px) 50% 0 50%);
  }
}


/* ---------- 13. Reduced motion ---------- */
/* Keep this last so it overrides everything above */
@media (prefers-reduced-motion: reduce) {
  /* Logo: keep the fade-in, drop the spinning */
  .aperture {
    animation: fadeIn 0.8s ease both;
  }

  /* Project cards and contact icons: keep color changes, drop the movement */
  .project {
    transition: border-color 0.25s ease;
  }

  .project:hover {
    transform: none;
  }

  .contact-link {
    transition: color 0.25s ease;
  }

  .contact-link:hover,
  .contact-link:focus-visible {
    transform: none;
  }

  /* Section transition: no wipe, no line */
  ::view-transition-old(main) {
    display: none;
  }

  ::view-transition-new(main) {
    animation: none;
  }

  ::view-transition-new(wipe-line) {
    display: none;
  }
}