/* ---------------- ROOT VARIABLES ---------------- */

:root {
  --scale: min(1vw, 1vh);

  --buttons-margin: clamp(10px, 2.6vw, 18px);
  --photo-vertical-buffer: calc(var(--scale) * 9);
  --photo-side-margin: clamp(10px, 2.6vw, 18px);
  --ui-font-size: clamp(16px, 1.1vw, 22px);
  --ui-line-height: 1.5;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --gallery-offset: calc(var(--scale) * 1.125);
  --nav-gap: 0.6rem;
}

/* ---------------- RESET ---------------- */

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

body {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  font-family: source-serif-pro, serif;
  font-weight: 400;
  font-size: var(--ui-font-size);
  line-height: var(--ui-line-height);
  background: white;
  overscroll-behavior: none;
}

body.index {
  overflow: hidden;
}

main {
  flex: 1;
  background: white;
  min-height: 0;
}

.index main {
  overflow: hidden;
}

/* ---------------- BUTTONS ---------------- */

#buttons {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  font-size: var(--ui-font-size);
  font-weight: 500;
  z-index: 2;
  pointer-events: none;
}

#buttons a:nth-child(1),
#buttons span:nth-child(1) {
  position: absolute;
  left: var(--buttons-margin);
  top: var(--buttons-margin);
  color: black;
  pointer-events: auto;
}

#buttons a:nth-child(2),
#buttons span:nth-child(2) {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: var(--buttons-margin);
  color: black;
  pointer-events: auto;
}

#buttons a:nth-child(3),
#buttons span:nth-child(3) {
  position: absolute;
  right: var(--buttons-margin);
  top: var(--buttons-margin);
  color: black;
  pointer-events: auto;
}

#buttons span {
  text-decoration: none;
}

#buttons a {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 0.075em;
  text-underline-offset: 0.075em;
  transition: opacity 0.25s ease;
}

/* ---------------- NEW UNDERLINE WITH FADE ---------------- */

a {
  color: black;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 0.075em;
  text-underline-offset: 0.075em;
  transition: opacity 0.25s ease;
}

#buttons a.inactive {
  opacity: 0.5;
}

body.page-loaded #buttons a.inactive {
  opacity: 0.5;
}

/* ---------------- BACK BUTTON ---------------- */
.back-button {
  position: fixed;
  left: var(--buttons-margin);
  bottom: var(--buttons-margin);
  display: inline-flex;
  align-items: center;
  gap: 0;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: opacity 0.25s ease;
}

.arrow {
font-family: cormorant-garamond, serif;
}

/* ---------------- HOME BUTTON ---------------- */
.home-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: opacity 0.25s ease-out;
  z-index: 1;
  margin-top: 0.6rem;
  margin-bottom: var(--buttons-margin);
  opacity: 0;
}

.home-button .arrow {
  font-family: eb-garamond, serif;
  font-variant-emoji: text;
  font-size: calc(var(--ui-font-size) + 3px);
}

/* ---------------- INDEX — GALLERY ---------------- */

.index #gallery {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  padding-top: calc(var(--photo-vertical-buffer) + var(--gallery-offset));
  padding-bottom: var(--photo-vertical-buffer);
  box-sizing: border-box;
}

#photo-wrapper {
  position: relative;
  display: inline-block;
  width: max-content;
  max-width: calc(100% - 2 * var(--photo-side-margin));
}

#photo {
  display: block;
  width: auto;
  height: auto;
  max-height: calc(100dvh - 2 * var(--photo-vertical-buffer));
  max-width: 100%;
  object-fit: contain;
  margin: 0;
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

#photo-info {
  position: absolute;
  left: 0;
  top: 100%;
  font-size: calc(var(--ui-font-size) * 0.55);
  opacity: 0;
  transition: opacity 0.25s ease-out;
  pointer-events: auto;
  width: 100%;
  text-align: center;
  padding-top: 0.3em;
}

#photo-info p {
  margin: 0;
}

#photo-placeholder {
  width: 100%;
  background: transparent;
}

#photo.loaded {
  opacity: 1;
}

#photo-info.loaded {
  opacity: 1;
}

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

/* ---------------- CV & CONTACT PAGES ---------------- */

body:not(.index) main {
  padding-top: calc(var(--buttons-margin) + 1.5em + var(--nav-gap) + env(safe-area-inset-top));
  padding-left: var(--buttons-margin);
  padding-right: var(--buttons-margin);
  box-sizing: border-box;
}

#cv-content,
#contact-content {
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

body.page-loaded #cv-content,
body.page-loaded #contact-content {
  opacity: 1;
}

body.page-loaded .home-button {
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  #buttons a:hover {
    opacity: 0.6;
    text-decoration-color: currentColor;
  }

  body.page-loaded #buttons a:hover {
    opacity: 0.6;
    text-decoration-color: currentColor;
  }

  body.page-loaded #buttons a.inactive:hover {
    opacity: 1;
  }
}


#cv-content {
  font-size: var(--ui-font-size);
  text-align: left;
  box-sizing: border-box;
  overflow-wrap: break-word;
  width: 100%;
  padding-bottom: var(--buttons-margin);
}

#cv-content .section .entry {
  display: block;
}
#cv-content .section .entry .date {
  display: block;
  margin-bottom: 0.2em;
  min-width: auto;
  text-align: left;
  overflow-wrap: break-word;
}

#cv-content,
#cv-content .section,
#cv-content .entry,
#cv-content .desc {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
}

#cv-content .section:last-child {
  margin-bottom: var(--nav-gap);
}


#contact-content {
  font-size: var(--ui-font-size);
  text-align: right;
  box-sizing: border-box;
  width: 100%;
  margin-left: 0;
  max-width: none;
}

#contact-content a {
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}

#cv-content a,
#contact-content a {
  transition: text-decoration-color 0.2s ease;
}

#cv-content a:hover,
#contact-content a:hover {
  text-decoration-color: currentColor;
}

#contact-content .section:last-child {
  margin-bottom: var(--nav-gap);
}


/* ---------------- TYPOGRAPHY ---------------- */

em { font-style: italic; }
.title { font-weight: 400; margin-bottom: 0.6rem; }
.entry { margin-bottom: 0.6rem; }
.section { margin-bottom: 4rem; }

/* ---------- PAGE TRANSITION ---------- */
main {
  opacity: 1;
}

@media (max-width: 700px) {
  #cv-content { width: auto !important; }
}

/* ---------------- MOBILE ---------------- */
@media (max-width: 700px) {
  :root {
    --mobile-margin: 18px;
  }
}

@media (max-width: 700px) {
  .back-button {
    left: var(--buttons-margin);
    text-align: left;
  }
}
