/* ==========================================================================
   Louis Dupasquier-Meynard — portfolio
   One stylesheet for every page. Plain CSS, no framework.
   ========================================================================== */

:root {
  --bg: #F5F5F7;
  --text: #111111;
  --muted: #5F5F5F;
  --line: #111111;
  --rule: #E2E2E2;
  --placeholder: #E9E9E9;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --page-width: 1200px;
  --text-width: 680px;
  --gutter: clamp(20px, 5vw, 48px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

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

.page {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: clamp(28px, 4vw, 48px) var(--gutter) clamp(40px, 6vw, 72px);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.button {
  display: inline-block;
  padding: 11px 22px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.button:hover {
  background: var(--text);
  color: var(--bg);
}

/* --------------------------------------------------------------------------
   Homepage introduction
   -------------------------------------------------------------------------- */

.intro {
  text-align: center;
}

.intro h1 {
  font-size: clamp(32px, 5.2vw, 56px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.intro .subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 20px);
  font-weight: 400;
}

/* The PNG is cropped to the letters, so its height is the letter height.
   0.716em is the cap height of Helvetica/Arial: the logo's letters match the
   capitals of the surrounding text and sit on the same baseline. */
.epfl-logo {
  display: inline-block;
  width: auto;
  height: 0.716em;
  margin: 0 0.08em;
  vertical-align: baseline;
}

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.contact {
  margin-top: 16px;
  font-size: 15px;
}

.contact h2 {
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.contact a {
  display: block;
  width: fit-content;
  margin: 0 auto;
  text-decoration: none;
  user-select: text;
}

.contact a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.nowrap {
  white-space: nowrap;
}

/* On narrow screens the full institution name starts on its own line. */
@media (max-width: 700px) {
  .institution {
    display: block;
  }
}

@media (max-width: 480px) {
  .links {
    gap: 8px;
  }

  .links .button {
    padding: 10px 14px;
  }
}

.visa {
  margin-top: 4px;
  color: var(--text);
  font-size: 14px;
}

/* --------------------------------------------------------------------------
   Project grid
   -------------------------------------------------------------------------- */

.projects-section {
  margin-top: clamp(28px, 3.5vw, 40px);
}

.projects-title {
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.2;
}

.projects {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(24px, 3vw, 40px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: block;
  color: inherit;
  text-decoration: none;
}

.card h3 {
  margin-top: 18px;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.3;
}

.card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
}

.card .media img {
  transition: opacity 0.2s ease;
}

.card:hover .media img {
  opacity: 0.88;
}

.card:hover h3 {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

@media (max-width: 860px) {
  .projects {
    grid-template-columns: 1fr;
    gap: 32px;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* --------------------------------------------------------------------------
   Media boxes (16:9). The grey background is the placeholder: if the image
   or video file is missing, the empty box still keeps the layout.
   -------------------------------------------------------------------------- */

.media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--placeholder);
}

.media img,
.media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media video {
  object-fit: contain;
  background: #000000;
}

/* --------------------------------------------------------------------------
   Project pages
   -------------------------------------------------------------------------- */

.project {
  max-width: 920px;
}

.back {
  display: inline-block;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.back:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.project-header {
  margin-top: clamp(40px, 7vw, 72px);
}

.project-header h1 {
  font-size: clamp(30px, 4.6vw, 48px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.project-header .subtitle {
  margin-top: 10px;
  color: var(--muted);
  font-size: clamp(16px, 1.8vw, 19px);
}

.project-image {
  margin-top: clamp(32px, 5vw, 48px);
}

.description {
  max-width: var(--text-width);
  margin-top: clamp(32px, 5vw, 48px);
  font-size: 17px;
  line-height: 1.7;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.text-links {
  margin-top: 24px;
  font-size: 17px;
  line-height: 1.7;
}

/* The underline sits below the descenders (g, p, y) instead of crossing them. */
.text-links a {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.32em;
  text-decoration-skip-ink: none;
}

.section {
  margin-top: clamp(48px, 7vw, 72px);
}

/* Shown whole, at its own proportions (not cropped to 16:9). */
.certificate {
  display: block;
  width: 100%;
  max-width: 760px;
  height: auto;
}

.section h2 {
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   PDF viewer
   -------------------------------------------------------------------------- */

.pdf-viewer {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--bg);
}

.pdf-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.pdf-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pdf-toolbar button,
.pdf-toolbar a {
  min-width: 34px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 30px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.pdf-toolbar button:hover,
.pdf-toolbar a:hover {
  background: var(--text);
  color: var(--bg);
}

.pdf-toolbar button:disabled {
  opacity: 0.35;
  cursor: default;
}

.pdf-toolbar button:disabled:hover {
  background: transparent;
  color: var(--text);
}

.pdf-toolbar input {
  width: 48px;
  height: 32px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #F5F5F7;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: center;
  -moz-appearance: textfield;
}

.pdf-toolbar input::-webkit-outer-spin-button,
.pdf-toolbar input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.pdf-zoom-level {
  min-width: 46px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pdf-count {
  color: var(--muted);
  white-space: nowrap;
}

.pdf-pages {
  position: relative; /* page offsets are measured from this box */
  height: min(80vh, 900px);
  overflow: auto;
  padding: 16px;
  background: #EDEDED;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Pages narrower than the viewer are centred; wider drawings start at the
   left edge and overflow to the right, where the viewer scrolls sideways. */
.pdf-stack {
  width: 100%;
}

.pdf-page {
  position: relative;
  margin: 0 auto 16px;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px #DADADA;
}

.pdf-page:last-child {
  margin-bottom: 0;
}

.pdf-page canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pdf-status {
  padding: 40px 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.pdf-viewer:fullscreen {
  border: 0;
}

.pdf-viewer:fullscreen .pdf-pages {
  flex: 1;
  height: auto;
}

/* Fallback for browsers without the Fullscreen API on elements (iPhone). */
.pdf-viewer.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 100;
  border: 0;
}

.pdf-viewer.is-expanded .pdf-pages {
  flex: 1;
  height: auto;
}

body.no-scroll {
  overflow: hidden;
}

@media (max-width: 600px) {
  .pdf-toolbar {
    justify-content: center;
  }

  .pdf-pages {
    height: 72vh;
    padding: 8px;
  }

  .pdf-page {
    margin-bottom: 8px;
  }
}

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