/* ==========================================================================
   Projects page: gallery grid and cards for the static previews.
   Loaded after css/site.css and only adds what that file does not have.
   ========================================================================== */

.projects-status {
  min-height: 1.5em;
  margin: 18px 0 0;
  font-size: 14px;
  text-align: center;
  color: var(--muted);
  transition: color .2s;
}
.projects-status[data-tone="ok"] { color: var(--accent-2); }
.projects-status[data-tone="error"] { color: var(--danger); }

/* --------------------------------------------------------------------------
   Gallery
   -------------------------------------------------------------------------- */
.projects-head__side {
  display: grid;
  gap: 10px;
}
.projects-count {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1;
}

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

.project-card {
  min-width: 0;
  padding: 12px 12px 22px;
  animation: project-in .6s var(--ease-reveal) both;
}
.project-card__preview {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0f0f0f;
  cursor: pointer;
}
.project-card__frame {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 1280px;
  height: 800px;
  border: 0;
  background: transparent;
  transform-origin: 0 0;
  transform: scale(var(--scale, .25));
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
}
.project-card__frame.is-loaded { opacity: 1; }
.project-card__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(22, 22, 22, .78);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  pointer-events: none;
}
.project-card__badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  vertical-align: 1px;
}
.project-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 0 12px;
}
.project-card__title {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.15;
  margin: 20px 0 6px;
  overflow-wrap: anywhere;
}
.project-card__meta {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--dim);
  overflow-wrap: anywhere;
}
.project-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}
.project-card__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  letter-spacing: .02em;
  text-decoration: none;
  cursor: pointer;
  transition: background .25s, border-color .25s, color .25s, transform .25s var(--ease-soft);
}
.project-card__btn:hover { border-color: var(--ink); }
.project-card__btn:active { transform: translateY(1px); }
.project-card__btn:focus-visible { border-radius: 999px; }
.project-card__btn--primary {
  background: var(--ink);
  color: var(--surface);
  border-color: transparent;
}
.project-card__btn--primary:hover { background: var(--grad); border-color: transparent; }

@keyframes project-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Preview modal (opens a site in place instead of a new tab)
   -------------------------------------------------------------------------- */
.preview-open, .preview-open body { overflow: hidden; }
.project-card__preview:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }
.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 3vw, 36px);
}
.preview-modal[hidden] { display: none; }
.preview-modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.preview-modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1280px, 100%);
  height: min(900px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  animation: project-in .35s var(--ease-reveal) both;
}
.preview-modal__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 20px;
  border-bottom: 1px solid var(--line);
}
.preview-modal__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-modal__actions { display: flex; gap: 8px; flex: none; }
.preview-modal__close {
  flex: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.preview-modal__close:hover { border-color: var(--ink); }
.preview-modal__stage { position: relative; flex: 1; min-height: 0; background: #fff; }
.preview-modal__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.preview-modal__summary {
  margin: 0;
  padding: 12px 20px 14px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Apps: App Store cards
   -------------------------------------------------------------------------- */
.apps-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.app-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  animation: project-in .6s var(--ease-reveal) both;
}
.app-card__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.app-card__icon {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 1px solid var(--line);
  object-fit: cover;
}
.app-card__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.app-card__title {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.15;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}
.app-card__meta {
  margin: 0;
  font-size: 13px;
  color: var(--dim);
  overflow-wrap: anywhere;
}
.app-card__shots {
  list-style: none;
  margin: 0;
  padding: 0 0 6px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.app-card__shots li {
  flex: none;
  scroll-snap-align: start;
}
.app-card__shots img {
  display: block;
  height: 220px;
  width: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f0f0f;
}
.app-card .btn { align-self: flex-start; margin-top: auto; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .projects-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .apps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  /* minmax(0, 1fr), not 1fr: WebKit otherwise keeps a card's stale
     min-content width after a resize and the grid overflows the viewport. */
  .projects-grid { grid-template-columns: minmax(0, 1fr); }
  .apps-grid { grid-template-columns: minmax(0, 1fr); }
  .project-card { padding: 10px 10px 20px; }
  .project-card__title { font-size: 22px; }
  .app-card { padding: 16px; }
  .app-card__shots img { height: 190px; }
  .app-card .btn, .project-card__btn { width: 100%; justify-content: center; text-align: center; }
  .project-card__actions { display: grid; grid-template-columns: 1fr 1fr; }
  .preview-modal { padding: 0; }
  .preview-modal__panel { height: 100%; border-radius: 0; border: 0; }
  .preview-modal__bar { flex-wrap: wrap; padding: 10px 12px; }
  .preview-modal__actions { order: 3; width: 100%; }
  .preview-modal__actions .project-card__btn { flex: 1; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .preview-modal__panel { animation: none; }
  .project-card { animation: none; }
  .project-card__btn, .project-card__frame, .projects-status { transition: none; }
}
