:root {
  --ink: #181817;
  --paper: #b7bfc5;
  --line: #d9d7ce;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Mono", monospace;
}

html { scroll-behavior: smooth; }

main {
  width: min(1120px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

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

h1 {
  font-family: Caveat, cursive;
  font-size: clamp(4.5rem, 11vw, 8.5rem);
  font-weight: 600;
  line-height: 0.8;
  letter-spacing: -0.06em;
}

.about {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: clamp(2rem, 7vw, 6rem);
  align-items: center;
  margin-top: 0; /* header uses its own spacing now */
}

.intro-row {
  display: flex;
  gap: clamp(1.25rem, 4vw, 3rem);
  align-items: center;
  justify-content: space-between;
  margin-top: 2.25rem;
}

.intro-text {
  flex: 1 1 60%;
}

.work-row {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  align-items: center;
  margin-top: 1.75rem;
}

.work-text {
  display: flex;
  flex-direction: column;
}

.work-text p { margin-bottom: 0.9rem; font-size: 1.2rem; }

.work-image {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 160px;
}

#work-media-container {
  width: 160px;
  height: 160px;
  flex: 0 0 160px;
  overflow: hidden;
  border-radius: 8px;
  background: #e9e6dc;
}

#work-media-container img,
#work-media-container video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.centered { justify-content: center; }

.arrow-row { display: flex; justify-content: center; margin-top: 1rem; }

.portrait {
  width: 320px;
  height: 320px;
  display: block;
  aspect-ratio: 1;
  object-fit: cover;
  border: none;
  flex: 0 0 320px;
}

.about p {
  max-width: 44rem;
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  line-height: 1.75;
}

.intro-text p {
  max-width: none;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.6;
  margin-bottom: 0.9rem;
}

.work-row .current-work {
  margin: 0;
}

.cta-row {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  padding: 0.6rem 1rem;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  background: var(--ink);
  color: white;
}

.current-work {
  margin-top: 1.6rem;
  font-size: 1.2rem;
}

.current-work p {
  margin-bottom: 0.9rem;
}

.project-link-inline {
  color: #0967d2;
  text-decoration: underline;
}

.down-arrow-wrap {
  margin-top: 1.8rem;
  display: flex;
  justify-content: center;
}

.down-arrow svg {
  color: var(--ink);
  opacity: 0.95;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.down-arrow:hover svg {
  transform: translateY(4px);
  opacity: 0.8;
}

section {
  margin-top: 7rem;
}

h2 {
  margin-bottom: 1.4rem;
  font-size: 4rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.project {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
}

.project-link {
  display: block;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: #e9e6dc;
  color: #79766c;
  font-size: 0.74rem;
  letter-spacing: 0.11em;
}

.project-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.project-info {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem 1.35rem;
  color: white;
  text-align: center;
  background: rgba(24, 24, 23, 0.9);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.project:hover .project-image,
.project:focus-within .project-image {
  transform: scale(1.04);
}

.project:hover .project-info,
.project:focus-within .project-info {
  opacity: 1;
  transform: translateY(0);
}

.project-info h3 {
  margin-bottom: 1.5rem;
  font-size: clamp(1.45rem, 2.3vw, 2.1rem);
}

.project-info p {
  font-size: 1.4rem;
  line-height: 1.7;
}

/* Applied Invention page */

.project-page {
  max-width: 760px;
}

.back-link {
  color: var(--ink);
  font-size: 0.8rem;
}

.project-page-header {
  margin: 4rem 0 6rem;
}

.company-logo {
  display: block;
  width: min(260px, 100%);
  max-height: 100px;
  margin-bottom: 2.5rem;
  object-fit: contain;
  object-position: left;
}

.project-page-header h1 {
  font-size: clamp(4rem, 10vw, 7rem);
}

.project-page-header p {
  margin-top: 1.5rem;
  font-size: 0.9rem;
}

.project-page-section {
  margin-top: 3.5rem;
}

.project-page-section h2 {
  margin-bottom: 1.2rem;
  font-size: 1rem;
}

.project-page-section p {
  font-size: 1rem;
  line-height: 1.8;
}

#projects-title {
  margin-bottom: 2.6rem;
}

@media (max-width: 620px) {
  main {
    width: min(100% - 2rem, 1120px);
    padding-top: 2rem;
  }

  .about {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 2.5rem;
  }

  .intro-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .work-row { flex-direction: column; align-items: flex-start; }

  .portrait {
    width: min(100%, 320px);
    height: min(calc(100vw - 2rem), 320px);
  }

  section {
    margin-top: 5rem;
  }

  h2 {
    font-size: 2.4rem;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  /* On small screens always show project text over the image and scale it to fit */
  .project {
    aspect-ratio: 16/9;
  }

  .project-info {
    opacity: 1 !important;
    transform: none !important;
    background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.6) 100%);
    align-items: flex-start;
    justify-content: flex-end;
    text-align: left;
    padding: 0.85rem;
  }

  .project-info h3 {
    font-size: clamp(1rem, 3.6vw, 1.25rem);
    margin-bottom: 0.4rem;
  }

  .project-info p {
    font-size: clamp(0.85rem, 3vw, 1rem);
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}