/*
 * Portfolio UI
 * The intro/glitch remains in index.html.
 * From the moment #portfolio becomes visible, the site switches to a Windows 98 / 98.css look.
 */

html,
body {
  min-height: 100%;
}

body {
  background: #008080;
  color: #222;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
}

a {
  color: #000080;
}

a:visited {
  color: #800080;
}

a:hover {
  color: #000080;
}

#portfolio {
  display: none;
  position: relative;
  z-index: 20;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(45deg, rgba(255,255,255,.035) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.035) 75%),
    linear-gradient(45deg, rgba(255,255,255,.035) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.035) 75%),
    #008080;
  background-position: 0 0, 4px 4px;
  background-size: 8px 8px;
  color: #222;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  opacity: 0;
  transition: opacity .8s ease;
}

#portfolio.visible {
  display: block;
  opacity: 1;
}

#portfolio.no-transition {
  transition: none;
}

/* Desktop header / navigation */
.portfolio-header { width:min(1180px,100%); margin:0 auto 18px; display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:3px; background:silver; box-shadow:inset -1px -1px #0a0a0a,inset 1px 1px #dfdfdf,inset -2px -2px grey,inset 2px 2px #fff; }
.portfolio-heading { min-width:0; flex:1; padding:5px 8px; }
.portfolio-heading h1 { margin:0; color:#fff; background:linear-gradient(90deg,navy,#1084d0); padding:4px 6px; font-family:"Pixelated MS Sans Serif",Arial,sans-serif; font-size:16px; font-weight:700; }
.portfolio-heading p { margin:6px 0 0; color:#222; font-family:Arial,sans-serif; font-size:12px; }
.portfolio-toolbar { padding:5px 6px; flex:0 0 auto; }
#contacts-btn { min-width:92px; }
#welcome-window { position:fixed; left:50%; top:50%; transform:translate(-50%,-50%); margin:0; touch-action:none; }
#welcome-window .title-bar { cursor:move; user-select:none; }
#welcome-window.dragging { user-select:none; }

.period {
  width: min(1180px, 100%);
  margin: 0 auto 24px;
}

.period-title {
  display: inline-block;
  margin: 0 0 10px;
  padding: 2px 6px;
  background: silver;
  color: #222;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 18px;
  font-weight: 700;
  box-shadow:
    inset -1px -1px #0a0a0a,
    inset 1px 1px #fff,
    inset -2px -2px grey,
    inset 2px 2px #dfdfdf;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 14px;
  align-items: start;
}

.project-card {
  min-width: 0;
  background: silver;
  border-radius: 0;
  padding: 3px;
  box-shadow:
    inset -1px -1px #0a0a0a,
    inset 1px 1px #dfdfdf,
    inset -2px -2px grey,
    inset 2px 2px #fff;
  cursor: pointer;
  overflow: hidden;
}

.project-card.expanded {
  grid-column: 1 / -1;
  cursor: default;
}

.card-header {
  min-height: 22px;
  padding: 3px 2px 3px 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(90deg, navy, #1084d0);
  color: #fff;
  cursor: pointer;
  user-select: none;
}

.card-header::after {
  content: "×";
  flex: 0 0 16px;
  width: 16px;
  height: 14px;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: silver;
  color: #000;
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  box-shadow:
    inset -1px -1px #0a0a0a,
    inset 1px 1px #fff,
    inset -2px -2px grey,
    inset 2px 2px #dfdfdf;
}

.card-thumb,
.card-thumb-placeholder {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  object-fit: cover;
  border-radius: 0;
  background: #fff;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 10px;
  font-weight: 700;
}

.card-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.card-content {
  display: none;
  margin: 3px 0 0;
  padding: 8px;
  background: silver;
}

.project-card.expanded .card-content {
  display: block;
}

.card-close {
  float: right;
  min-width: 24px;
  min-height: 21px;
  padding: 0 8px;
  margin-left: 8px;
}

.card-description {
  max-width: 760px;
  margin-bottom: 10px;
  color: #222;
  font-family: Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
}

.card-description p {
  margin-bottom: .8em;
}

.card-description p:last-child {
  margin-bottom: 0;
}

.card-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 8px;
  margin-top: 10px;
}

.gallery-item {
  min-width: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  padding: 2px;
  background: silver;
  cursor: pointer;
  box-shadow:
    inset -1px -1px #fff,
    inset 1px 1px grey,
    inset -2px -2px #dfdfdf,
    inset 2px 2px #0a0a0a;
}

.gallery-item img,
.gallery-item video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
}

.gallery-item:hover img {
  transform: none;
}

.gallery-item-svg {
  aspect-ratio: auto;
}

.gallery-item-svg img {
  object-fit: contain;
  padding: 6px;
  background: #fff;
}

.card-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.file-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 23px;
  padding: 3px 10px;
  background: silver;
  border: 0;
  border-radius: 0;
  color: #222;
  text-decoration: none;
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  box-shadow:
    inset -1px -1px #0a0a0a,
    inset 1px 1px #fff,
    inset -2px -2px grey,
    inset 2px 2px #dfdfdf;
}

.file-link:hover {
  color: #222;
}

.file-link:active {
  box-shadow:
    inset -1px -1px #fff,
    inset 1px 1px #0a0a0a,
    inset -2px -2px #dfdfdf,
    inset 2px 2px grey;
}

.card-empty {
  padding: 8px 2px;
  color: #555;
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-style: normal;
}

/* Welcome modal */

#welcome-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .38);
}

#welcome-overlay.active {
  display: flex;
}

#welcome-window {
  width: min(560px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  overflow: auto;
}

.welcome-body {
  margin: 8px;
}

.welcome-text {
  margin: 0 0 12px;
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.welcome-body fieldset {
  margin-top: 8px;
}

.contact-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  margin: 7px 0;
  font-family: Arial, sans-serif;
  font-size: 12px;
}

.contact-row strong {
  font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
}

.contact-row a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.welcome-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Lightbox */

#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .78);
  cursor: pointer;
}

#lightbox.active {
  display: flex;
}

#lightbox img {
  max-width: min(86vw, 1100px);
  max-height: 86vh;
  object-fit: contain;
  padding: 3px;
  background: silver;
  cursor: default;
  box-shadow:
    inset -1px -1px #0a0a0a,
    inset 1px 1px #dfdfdf,
    inset -2px -2px grey,
    inset 2px 2px #fff;
}

.lb-arrow {
  position: absolute;
  top: 50%;
  z-index: 1001;
  transform: translateY(-50%);
  min-width: 30px;
  min-height: 30px;
  padding: 0 8px;
  font-family: Arial, sans-serif;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.lb-prev { left: 12px; }
.lb-next { right: 12px; }

#portfolio::-webkit-scrollbar {
  width: 16px;
}

#portfolio::-webkit-scrollbar-track {
  background: silver;
}

#portfolio::-webkit-scrollbar-thumb {
  background: silver;
  box-shadow:
    inset -1px -1px #0a0a0a,
    inset 1px 1px #fff,
    inset -2px -2px grey,
    inset 2px 2px #dfdfdf;
}

@media (max-width: 600px) {
  #portfolio {
    padding: 12px;
  }

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

  .card-gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  #welcome-window {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .portfolio-header { align-items:stretch; flex-direction:column; }
  .portfolio-toolbar { padding-top:0; }
  #contacts-btn { width:100%; }

  .welcome-text {
    font-size: 13px;
  }

  .contact-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  #lightbox {
    padding: 12px;
  }

  #lightbox img {
    max-width: 90vw;
    max-height: 82vh;
  }

  .lb-prev { left: 4px; }
  .lb-next { right: 4px; }
}
