/* ─── RESET & BASE ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f4f0;
  --surface: rgba(0, 0, 0, 0.035);
  --surface-hov: rgba(0, 0, 0, 0.06);
  --border: rgba(0, 0, 0, 0.1);
  --border-hov: rgba(0, 0, 0, 0.22);
  --text: #1c1c1e;
  --text-muted: rgba(60, 60, 67, 0.72);
  --accent: #d946ef;
  --accent-dim: rgba(217, 70, 239, 0.4);
  --radius: 14px;
  --radius-sm: 8px;

  /* Card sizes (updated by JS per orientation) */
  --card-portrait-w: 180px;
  --card-landscape-w: 280px;
  --card-square-w: 220px;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ─── HEADER ────────────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(245, 244, 240, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  transition: opacity 0.15s;
}

.brand:hover {
  opacity: 0.8;
}

.brand-logo {
  height: 32px;
  width: auto;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #1c1c1e;
}

.site-nav {
  display: flex;
  align-items: center;
}

.nav-link {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  transition: opacity 0.15s;
  padding: 0.5rem 1rem;
}

.nav-link:hover {
  opacity: 0.7;
}

/* ─── HERO ──────────────────────────────────────────────────────────────────── */
.hero {
  padding: 8rem 2.5rem 4rem;
  max-width: 1200px;
  margin: 0 auto;
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
  max-width: 800px;
  margin: 0;
}

/* ─── SECTIONS ──────────────────────────────────────────────────────────────── */
.projects-section {
  padding: 2rem 2.5rem 3.5rem;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 2.5rem;
  text-align: center;
}

/* ─── CARDS GRID ────────────────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  align-items: stretch;
}

/* ─── PROJECT CARD ──────────────────────────────────────────────────────────── */
.project-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100% !important;
}

.project-card[data-orientation="portrait"] .card-cover-wrap {
  aspect-ratio: 9 / 16;
  height: auto !important;
}

.project-card[data-orientation="landscape"] .card-cover-wrap,
.project-card[data-orientation="unknown"] .card-cover-wrap {
  aspect-ratio: 16 / 9;
  height: auto !important;
}

.project-card[data-orientation="square"] .card-cover-wrap {
  aspect-ratio: 1 / 1;
  height: auto !important;
}

.project-card:hover {
  transform: translateY(-8px);
  border-color: var(--border-hov);
  box-shadow: 0 20px 40px rgba(217, 70, 239, 0.12);
}

.card-cover-wrap {
  width: 100%;
  overflow: hidden;
  background: #dddbd5;
}

.card-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-card:hover .card-cover {
  transform: scale(1.05);
}

.card-info {
  padding: 1.25rem 1.5rem 1.5rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1c1c1e;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.6rem;
}

.card-tag {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.06);
  color: rgba(28, 28, 30, 0.75);
  border: 1px solid rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

/* ─── FOOTER ────────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2.5rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.site-footer> :first-child {
  justify-self: start;
}

.site-footer>.footer-home {
  justify-self: center;
  font-weight: 600;
  color: var(--text);
  font-size: 0.85rem;
  transition: opacity 0.15s;
}

.site-footer>.footer-home:hover {
  opacity: 0.7;
}

.site-footer> :last-child {
  justify-self: end;
}

.site-footer a:hover {
  color: var(--text);
}

/* ─── MODAL OVERLAY ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ─── MODAL CONTAINER ───────────────────────────────────────────────────────── */
.modal-container {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  width: 100%;
  max-width: 860px;
  max-height: 92vh;
  overflow-y: auto;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.22s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

.modal-overlay.open .modal-container {
  transform: translateY(0) scale(1);
}

.modal-container.portrait-mode {
  max-width: 600px;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  z-index: 10;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #1c1c1e;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1c1c1e;
  margin-bottom: 1.25rem;
  padding-right: 2.5rem;
  line-height: 1.3;
}

/* ─── MODAL BODY ────────────────────────────────────────────────────────────── */
.modal-body {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1.45fr 1fr;
}

.modal-body.portrait-layout {
  grid-template-columns: auto 1fr;
}

/* ─── MODAL MEDIA ───────────────────────────────────────────────────────────── */
.modal-media-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.modal-media-box {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.04);
  overflow: hidden;
  padding: 0.625rem;
}

.modal-media-viewer {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 280px;
}

.modal-media-box.portrait-box .modal-media-viewer {
  height: 340px;
  width: fit-content;
}

.modal-media-viewer img,
.modal-media-viewer video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
}

.modal-media-viewer img.portrait-img {
  height: 100%;
  width: auto;
}

.modal-embed-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #111;
}

.modal-embed-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ─── THUMBNAILS ────────────────────────────────────────────────────────────── */
.modal-thumbnails {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

.thumb-btn {
  flex-shrink: 0;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  padding: 0;
}

.thumb-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.thumb-btn.active {
  border-color: var(--accent-dim);
}

.thumb-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.05);
}

.thumb-inner img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.thumb-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: rgba(28, 28, 30, 0.65);
  background: rgba(0, 0, 0, 0.06);
}

/* ─── MODAL INFO ────────────────────────────────────────────────────────────── */
.modal-info-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-info-block {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.modal-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modal-text {
  font-size: 0.82rem;
  line-height: 1.6;
  color: rgba(28, 28, 30, 0.82);
}

/* ─── PLATFORM LINKS ────────────────────────────────────────────────────────── */
.modal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
}

.platform-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.45rem 0.875rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.05);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.platform-btn:hover {
  background: rgba(0, 0, 0, 0.09);
  border-color: var(--border-hov);
  color: #1c1c1e;
}

.platform-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ─── FREELANCE STRIP ───────────────────────────────────────────────────────── */
.freelance-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 3rem 2.5rem;
  border-top: 1px solid var(--border);
  background: rgba(111, 218, 68, 0.04);
}

.freelance-upwork-icon {
  width: 28px;
  height: 28px;
  color: #4aab16;
  flex-shrink: 0;
}

.freelance-label {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.freelance-links {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
}

.freelance-link {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.75rem;
  border-radius: 9999px;
  border: 1px solid rgba(74, 171, 22, 0.35);
  background: rgba(74, 171, 22, 0.07);
  color: #3a8c10;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.freelance-link:hover {
  background: rgba(74, 171, 22, 0.14);
  border-color: rgba(74, 171, 22, 0.55);
  color: #2e7009;
}

/* ─── RESPONSIVE ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .site-header {
    padding: 1rem 1.25rem;
  }

  .hero {
    padding: 4rem 1.25rem 2rem;
  }

  .projects-section {
    padding: 1.5rem 1.25rem 2.5rem;
  }

  .site-footer {
    padding: 2rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    text-align: center;
  }

  .freelance-strip {
    padding: 2rem 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
  }

  .freelance-links {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
  }

  .cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .modal-container {
    padding: 1.25rem;
    border-radius: 14px;
  }

  .modal-body,
  .modal-body.portrait-layout {
    grid-template-columns: 1fr;
  }

  .modal-media-viewer {
    height: 220px !important;
  }
}