/* variables */

:root {
  --foreground: #f8f8ff;
  --background: #181c1f;
  --accent: #059669;
}

/* z-index */

/* 
iphone mask = 30
iphone statusbar = 25
project description = 20
nav = 10
about content (h1, slogans) = 5
about splash background = 0 (::before, auto)
*/

/* base*/
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  /* Set font size for easy rem calculations
   * default document font size = 16px, 1rem = 16px, 100% = 16px
   * (100% / 16px) * 10 = 62.5%, 1rem = 10px, 62.5% = 10px
   */
  font-size: 62.5%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* I use the following max-widths as styling points for media query */
/* 1200px / 16px = 75em */
@media (max-width: 75em) {
  html {
    font-size: 60%;
  }
}

/* 980px / 16px = 61.25em */
@media (max-width: 61.25em) {
  html {
    font-size: 58%;
  }
}

/* 460px / 16px = 28.75em */
@media (max-width: 28.75em) {
  html {
    font-size: 55%;
  }
}

/* poppins-regular - latin */
@font-face {
  font-display: swap;
  font-family: "Poppins";
  font-style: normal;
  font-weight: 400;
  src: url("../fonts/poppins-v20-latin-regular.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* raleway-regular - latin */
@font-face {
  font-display: swap;
  font-family: "Raleway";
  font-style: normal;
  font-weight: 400;
  src: url("../fonts/raleway-v28-latin-regular.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* raleway-700 - latin */
@font-face {
  font-display: swap;
  font-family: "Raleway";
  font-style: normal;
  font-weight: 700;
  src: url("../fonts/raleway-v28-latin-700.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

@font-face {
  font-family: "Fira Mono";
  src: url("../fonts/FiraMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

body {
  font-family: "Poppins", sans-serif;
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--foreground);
}

h1,
h2 {
  font-family: "Raleway", sans-serif;
  font-weight: 700;
  text-align: center;
}

h1 {
  font-size: 6rem;
}

h2 {
  font-size: 4.2rem;
  margin-top: 6rem;
}

ul {
  list-style: none;
}

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

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

.about-section,
.projects-section,
.contact-section,
.impressum-section,
.datenschutz-section {
  min-height: 100dvh;
  padding: 2rem;
  /* .nav is position: fixed, so anchor jumps have to stop below it */
  scroll-margin-top: 8rem;
}

/* navigation on small media devices > 450px */
.hamburger-menue {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
}

.hamburger-menue-bar {
  font-size: 4rem;
  color: var(--foreground);
  transition: transform 0.3s cubic-bezier(0.4, 2, 0.6, 1), color 0.2s;
}

.hamburger-menue.open .hamburger-menue-bar {
  transform: rotate(90deg) scale(1.2);
  color: var(--accent);
}

@media (max-width: 28.125em) {
  /* 450px / 16 = 28.125em */
  .hamburger-menue {
    display: flex;
    margin: 1rem;
  }
  .nav-list {
    position: absolute;
    top: 70px;
    left: 15px;
    flex-direction: column;
    background: var(--background);
    box-shadow: 0 2px 8px 0
        color-mix(in srgb, var(--foreground) 15%, transparent),
      0 1.5px 4px 0 color-mix(in srgb, var(--accent) 10%, transparent);
    border-radius: 1.5rem;
    padding: 2rem 0;

    /* 'display' is not animatable, so fade instead */
    display: flex;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s, visibility 0.5s;
  }
  .nav-list.open {
    opacity: 1;
    visibility: visible;
  }
}

/* navigation desktop */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: var(--background);
  z-index: 10;
  box-shadow: 0 4px 16px -6px rgba(0, 0, 0, 0.13);
}

@media (min-width: 28.126em) {
  /* 450px + 1px */
  .nav-list {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
  }
}

.nav-list a {
  display: block;
  font-size: 2.2rem;
  padding: 2rem;
  transition: background 0.2s;
}

.nav-list a:hover {
  background: var(--accent);
  color: var(--background);
}

/* about section */
.about-section {
  position: relative;
  display: flex;
  flex-direction: column;
  /* flex-start + margin: auto on .about-hero instead of justify-content: center:
   * centred justify would push overflowing content past the top edge, where
   * overflow: hidden cuts it off (happens on short mobile viewports) */
  justify-content: flex-start;
  align-items: center;
  gap: 2rem;
  overflow: hidden;
  background-color: var(--background);
}

.about-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/img/background.webp") center center/cover no-repeat;
  -webkit-mask-image: url("/img/splash.webp");
  mask-image: url("/img/splash.webp");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100%;
  mask-size: 100%;
  -webkit-mask-position: center center;
  mask-position: center center;
  pointer-events: none;
  opacity: 0.5;
}

@media (max-width: 61.25em) {
  .about-section::before {
    -webkit-mask-size: 140%;
    mask-size: 140%;
  }
}

@media (max-width: 28.75em) {
  .about-section::before {
    -webkit-mask-size: 180%;
    mask-size: 180%;
  }
}

.about-section h1 {
  font-size: clamp(2.6rem, 3.6vw, 4rem);
  position: relative;
  hyphens: auto;
  text-align: left;
  line-height: 1.1;
  margin: 0 0 1.5rem;
  z-index: 5;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.visually-hidden.focusable:focus {
  position: relative !important;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--accent);
  color: var(--background);
  padding: 0.8rem 1.6rem;
  font-size: 1.6rem;
  z-index: 100;
}

.about-section .code {
  color: var(--accent);
}

.about-section-slogans {
  position: relative;
  text-align: left;
  font-size: 2rem;
  font-weight: 200;
  font-family: "Fira Mono", monospace;
  z-index: 5;
  margin: 0;
  color: color-mix(in srgb, var(--foreground) 80%, transparent);
}

/* Typewriter: the text stays in the HTML and is only revealed visually with
 * clip-path + steps(). Each line carries --chars (its character count, one step
 * per character – works because the font is monospace) and --start (characters
 * typed before it). Both are inherited by the text and the caret. */
.typewriter {
  --typing-speed: 0.045s;
}

.typewriter-line {
  display: block;
  width: max-content; /* reserve final width up front → no layout shift */
  white-space: nowrap;
}

.typewriter-text {
  display: inline-block;
  clip-path: inset(0 100% 0 0);
  animation: typewriter-reveal calc(var(--chars) * var(--typing-speed))
    steps(var(--chars)) calc(var(--start, 0) * var(--typing-speed)) forwards;
}

/* sits outside the clipped text, so it shows up once its line is typed.
 * No fill-mode → it stays invisible during the delay. */
.typewriter-caret {
  display: inline-block;
  width: 1ch;
  height: 1.1em;
  vertical-align: -0.2em;
  background: var(--accent);
  opacity: 0;
  animation: typewriter-caret-blink 1.1s steps(1, end)
    calc((var(--start, 0) + var(--chars)) * var(--typing-speed)) infinite;
}

@keyframes typewriter-reveal {
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes typewriter-caret-blink {
  0%,
  50% {
    opacity: 1;
  }
  50.01%,
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .typewriter-text {
    animation: none;
    clip-path: none;
  }
  .typewriter-caret {
    animation: none;
    opacity: 1;
  }
  .code-window,
  .about-cta {
    transition: none;
  }
}

/* about hero: text column + portrait side by side, stacked on small screens */
.about-hero {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: clamp(3rem, 5vw, 6rem);
  margin: auto; /* centres without ever overflowing the section */
}

/* the portrait sits in a faux code window – picks up the < /> and monospace motif */
.code-window {
  flex: 0 0 auto;
  width: clamp(200px, 26vw, 280px);
  margin: 0;
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid color-mix(in srgb, var(--foreground) 14%, transparent);
  background: color-mix(in srgb, var(--foreground) 6%, var(--background));
  box-shadow: 0 2rem 5rem color-mix(in srgb, #000 55%, transparent);
  transform: rotate(1.5deg);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.code-window:hover {
  transform: rotate(0deg) translateY(-0.5rem);
  box-shadow: 0 2.5rem 6rem color-mix(in srgb, #000 65%, transparent);
}

.code-window-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  background: color-mix(in srgb, var(--foreground) 8%, var(--background));
  border-bottom: 1px solid color-mix(in srgb, var(--foreground) 12%, transparent);
}

.code-window-dots {
  display: flex;
  gap: 0.5rem;
}

.code-window-dots span {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--foreground) 20%, transparent);
}

.code-window-dots span:first-child {
  background: var(--accent);
}

.code-window-file {
  font-family: "Fira Mono", monospace;
  font-size: 1.2rem;
  color: color-mix(in srgb, var(--foreground) 60%, transparent);
}

.about-portrait {
  display: block;
  width: 100%;
  height: auto; /* overrides the height="" attribute so aspect-ratio wins */
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: 50% 45%; /* centres the face, crops the watermarks off */
}

.about-cta {
  display: inline-block;
  margin-top: 3rem;
  padding: 1.4rem 3rem;
  border-radius: 0.8rem;
  background: var(--accent);
  color: var(--foreground);
  /* 2rem bold keeps white on --accent within AA (large-text threshold) */
  font-size: 2rem;
  font-weight: 700;
  transition: background 0.2s ease, transform 0.2s ease;
}

.about-cta:hover {
  background: color-mix(in srgb, var(--accent) 85%, var(--foreground));
  transform: translateY(-2px);
}

.about-cta:focus-visible {
  outline: 2px solid var(--foreground);
  outline-offset: 4px;
}

@media (max-width: 61.25em) {
  .about-hero {
    flex-direction: column;
    gap: 2.5rem;
  }
  .code-window {
    order: -1; /* portrait first on small screens */
    width: clamp(160px, 44vw, 210px);
    transform: rotate(1deg);
  }
  .about-hero-text,
  .about-section h1 {
    text-align: center;
  }
  .typewriter-line {
    margin-inline: auto;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .about-hero {
    animation: about-hero-fade-in 0.7s ease-out 0.2s both;
  }
}

@keyframes about-hero-fade-in {
  from {
    opacity: 0;
    transform: translateY(1.5rem);
  }
}

/* projects section */
.projects-section {
  background-color: var(--background);
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

/* projects carousel */
.carousel {
  overflow: hidden;
}

.carousel-cell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 50vw;
  margin: 2rem 5rem;
}

/* 28.75 x 16px = 460px */
@media (max-width: 28.125em) {
  .carousel-cell {
    width: 50vw;
  }
}

.project {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  text-align: center;
}

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

.project-title {
  text-align: center;
  font-size: 2rem;
}

.code {
  color: var(--background);
  transition: color 0.3s ease-out;
}

/* iphone */
.preview {
  position: relative;
  width: 210px;
  cursor: pointer;
}

.preview:hover::after {
  content: "Tippe für Details";
  position: absolute;
  bottom: -2.4rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.2rem;
  color: var(--accent);
  white-space: nowrap;
  pointer-events: none;
}

.status-bar {
  position: absolute;
  top: 10px;
  left: 0px;
  width: 100%;
  height: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  margin: 0 auto;
  font-size: 1rem;
  color: var(--foreground);
  border-radius: 100%;
  background: var(--background);
  z-index: 25;
  box-sizing: border-box;
  pointer-events: none;
  overflow: hidden;
}

.mask {
  background: url("/img/iphone-frame.webp");
  background-size: cover;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
}

.preview:before {
  display: block;
  content: "";
  padding-top: 200%;
  border-radius: 3.5rem;
}

.canvas {
  position: absolute;
  left: 6.409266409266409%;
  right: 6.409266409266409%;
  top: 30px;
  bottom: 2.908587257617734%;
  overflow: hidden;
}

.project-description {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  transition: opacity 0.2s;
  background: var(--foreground);
  color: var(--background);
  padding: 1rem;
  margin: 0 10px 10px 10px;
  text-align: center;
  z-index: 20;
}

.project-description.visible {
  opacity: 1;
}

/* contact section */
.contact-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2rem;
  background: var(--background);
}

.contact-section-text {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (max-width: 28.125em) {
  .contact-section-header > h2 {
    font-size: 4rem;
  }
}

.contact-section-link {
  font-size: 2.4rem;
  transition: transform 0.3s ease-out;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 1.5rem 3rem;
  border-radius: 5px;
  box-shadow: 0 2px 8px 0 color-mix(in srgb, var(--foreground) 15%, transparent),
    0 1.5px 4px 0 color-mix(in srgb, var(--accent) 10%, transparent);
}

.contact-section-link:hover,
.contact-section-link:focus {
  transform: translateY(-0.4rem);
  background: var(--accent);
  color: var(--background);
}

/* footer */
footer {
  font-weight: 300;
  display: flex;
  justify-content: space-evenly;
  padding: 2rem;
  background: var(--background);
}

footer ul {
  font-size: 1.5rem;
  display: flex;
  gap: 2rem;
}

footer a:hover,
footer a:focus {
  color: var(--accent);
  text-decoration: underline;
}

/* impressum */
.impressum-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  margin: 0 auto;
  background-color: var(--background);
  color: var(--foreground);
}

.impressum-section h1 {
  text-align: left;
  font-size: 5rem;
  margin-bottom: 20px;
}

.impressum-section p strong {
  display: block;
  margin: 1.5rem 0 0.5rem 0;
  font-size: 2rem;
  color: var(--accent);
}

/* datenschutz */
.datenschutz-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  margin: 0 auto;
  background-color: var(--background);
  color: var(--foreground);
}

.datenschutz-section h1 {
  text-align: left;
  font-size: 5rem;
  margin-top: 6rem;
  line-break: auto;
}

.datenschutz-section h4 {
  margin: 1.5rem 0 0.5rem 0;
  font-size: 2rem;
  color: var(--accent);
}

.datenschutz-section p {
  margin: 1.5rem 0 0.5rem 0;
}

.back-btn {
  font-size: 3rem;
  border: none;
  margin-bottom: 2rem;
  background: none;
  color: var(--accent);
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
