/* ---- Base / Theme ---- */
:root{
  --bg-left: #0c151c;
  --bg-right: #040a11;
  --text: #e8edf2;
  --muted: #98a2ad;
  --tile: #d9dde2;
  --tile-title: #ffffff;
  --gap: 28px;
  --radius: 16px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg-right);
  color: var(--text);
  font-family: "futura-pt", sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Layout ---- */
.app {
  display: grid;
  grid-template-columns: 27vw 1fr;
  height: 100vh;
}

.sidebar{
  background: var(--bg-left);
  padding: 28px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 28px;
  border-right: 1px solid rgba(255,255,255,0.06);
  opacity: 0; /* first-load fade only (no transforms) */
}

.sidebar-reveal { animation: sidebarFadeIn 420ms ease forwards; }
@keyframes sidebarFadeIn { to { opacity: 1; } }

.brand{
  letter-spacing: 0.25em;
  font-weight: 700;
  font-size: 24px;
}

/* NAV */
.nav{
  display: grid;
  gap: 14px;
  align-content: start;
}

.sidebar-reveal .nav .nav-item {
  opacity: 0;
  animation: navFadeIn 420ms ease forwards;
}
.sidebar-reveal .nav .nav-item:nth-child(1){ animation-delay: 120ms; }
.sidebar-reveal .nav .nav-item:nth-child(2){ animation-delay: 180ms; }
.sidebar-reveal .nav .nav-item:nth-child(3){ animation-delay: 240ms; }
.sidebar-reveal .nav .nav-item:nth-child(4){ animation-delay: 300ms; }
@keyframes navFadeIn { to { opacity: 1; } }

.nav.secondary{ margin-top: auto; padding-top: 16px; }

.nav-item{
  all: unset;
  display: inline-block;
  color: var(--text);
  letter-spacing: 0.12em;
  font-size: 16px;
  padding: 6px 0;
  transition: transform 160ms ease, opacity 160ms ease;
  will-change: transform;
  cursor: pointer;
}
.nav-item:hover{ transform: translateX(6px); opacity: 0.9; }

.footer{
  color: var(--muted);
  letter-spacing: 0.14em;
  font-size: 11px;
}

/* Content panel */
.content{
  background: var(--bg-right);
  overflow-y: auto;
  padding: var(--gap);
}

/* Grid */
.grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

/* global fades used by the grid transition pipeline */
.grid-out   { animation: gridFadeOut 200ms ease forwards; }
.grid-in    { animation: gridFadeIn 260ms ease forwards; }
@keyframes gridFadeOut { to { opacity: 0; } }
@keyframes gridFadeIn  { from { opacity: 0; } to { opacity: 1; } }

/* fade used when jumping to project/about/random */
.fade-out { opacity: 0; transition: opacity 0.26s ease; }

/* Tile */
.tile{
  position: relative;
  background: var(--tile);
  border-radius: var(--radius);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    opacity 0.22s ease,
    translate 0.22s ease;
  opacity: 1;
  translate: 0 0;
}
.tile.hidden{
  opacity: 0;
  translate: 0 8px;
  box-shadow: none;
  pointer-events: none;
}
.tile:hover { transform: scale(1.02); box-shadow: 0 6px 16px rgba(0,0,0,0.25); }
.tile-title{
  position: absolute;
  top: 10px; left: 12px; right: 12px;
  font-weight: 700; font-size: 18px;
  color: var(--tile-title);
  text-shadow: 0 2px 6px rgba(0,0,0,0.85);
  letter-spacing: 0.06em;
  user-select: none; pointer-events: none;
}

/* ---------- PROJECT VIEW ---------- */
.project-view{
  display: flex; flex-direction: column; gap: 32px;
  animation: fadeInUp 0.4s ease both;
}
@keyframes fadeInUp { from { opacity:0; transform: translateY(8px);} to{opacity:1; transform:none;} }
.project-view-out{ animation: fadeOutDown 0.32s ease both; }
@keyframes fadeOutDown { from{opacity:1; transform:none;} to{opacity:0; transform: translateY(8px);} }

.project-hero{
  position: relative;
  width: 100%;
  height: 320px;
  border-radius: var(--radius);
  background-color: #222;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.project-hero-title{
  position: absolute;
  top: 24px; left: 28px;
  font-size: 24px; font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--tile-title);
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}
.project-back-btn{
  position: absolute; top: 62px; left: 28px;
  background: rgba(0,0,0,0.45); color:#fff;
  font-family: inherit; font-size: 14px; letter-spacing: 0.05em;
  border: none; border-radius: 4px; padding: 6px 10px; cursor: pointer;
  transition: background 0.2s ease;
}
.project-back-btn:hover{ background: rgba(0,0,0,0.7); }

/* ---------- PROJECT CONTENT BLOCKS ---------- */
.project-content { display: flex; flex-direction: column; gap: 48px; }
.paragraph-block { width: 100%; }

.block-header { font-size: 18px; font-weight: 700; letter-spacing: 0.05em; margin-bottom: 8px; }
.block-text { font-size: 15px; line-height: 1.6; color: #d4d8dd; max-width: 90%; }
.block-text a { color: #7aa9ff; text-decoration: none; border-bottom: 1px solid rgba(122,169,255,0.4); transition: color .2s,border-bottom-color .2s; }
.block-text a:hover { color:#a7c6ff; border-bottom-color: rgba(167,198,255,0.8); }

.media-block img, .media-block video { width: 100%; border-radius: var(--radius); display:block; }
.split-block { display:flex; align-items:flex-start; gap:24px; }
.split-block.text-left .paragraph-block,
.split-block.text-right .paragraph-block { flex:1; }
.split-block.text-left .media-block,
.split-block.text-right .media-block { flex:1; }
.double-media { display:flex; gap:24px; }
.double-media .media-block { flex:1; }

/* ---------- ABOUT VIEW ---------- */
.about-view{
  display: flex; flex-direction: column; gap: 28px;
  animation: fadeInUp 0.4s ease both;
}
.about-view-out{ animation: fadeOutDown 0.32s ease both; }

.about-hero {
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 28px;
  margin-bottom: 6px;
}

.about-intro {
  position: relative;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius);
  padding: 20px 24px 46px 24px;
  padding-right: min(32%, 340px);
  overflow: visible;
}
.about-intro h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  letter-spacing: 0.08em;
}
.about-intro p {
  margin: 0 0 18px 0;
  max-width: 720px;
  line-height: 1.65;
  color: #d6dbe0;
}
.about-intro .action-row{
  display: flex; gap: 28px; align-items: center; flex-wrap: wrap;
}

.btn {
  appearance: none;
  background: transparent;
  color: var(--text);
  border: 2px solid rgba(255,255,255,0.5);
  padding: 10px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  text-decoration: none;
  transition: background .18s ease, border-color .18s ease, transform .12s ease;
}
.btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.7); transform: translateY(-1px); }

.about-intro .contact-label{
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.16em;
}
.about-intro .contact-value{
  font-weight: 700;
  letter-spacing: 0.14em;
}

.about-divider {
  height: 1px;
  background: rgba(255,255,255,0.8);
  margin-top: 18px;
}

.about-portrait {
  position: absolute;
  right: 18px;
  bottom: -10px;
  width: 300px;
  max-width: 32%;
  pointer-events: none;
  user-select: none;
  filter: saturate(0) contrast(1.05) brightness(1.05);
}

.about-section { padding: 4px 2px; }
.about-section h3 {
  margin: 0 0 8px 0;
  letter-spacing: 0.12em;
  font-size: 18px;
}
.about-section p {
  margin: 0;
  max-width: 880px;
  line-height: 1.65;
  color: #d6dbe0;
}

/* ---------- RANDOM VIEW ---------- */
.random-view{
  display: grid;
  gap: 24px;
  animation: fadeInUp 0.4s ease both;
}
.random-view-out{ animation: fadeOutDown 0.32s ease both; }

.random-hero{
  text-align: center;
  margin-top: 32px;
  margin-bottom: 6px;
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 22px;
}

.random-intro{
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  color: #d6dbe0;
  line-height: 1.6;
}
.random-intro p{ margin: 0; }
.random-intro .btn{ margin-top: 12px; }

/* Card */
.random-card{
  max-width: 760px;
  margin: 0 auto;
}
.random-title{
  letter-spacing: 0.14em;
  font-weight: 700;
  margin: 0 0 10px 6px;
}
.random-media{
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
  padding: 10px;
}

/* ✅ Constrain media size while keeping aspect ratio */
.random-media img,
.random-media video{
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 12px;
}

.random-desc{
  color: #d6dbe0;
  line-height: 1.55;
  margin: 8px 8px 12px 8px;
}
.random-actions{
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px){
  .about-portrait { width: 260px; max-width: 30%; }
  .about-intro { padding-right: min(30%, 300px); }
}

@media (max-width: 1024px){
  :root{ --gap: 22px; }
  .app{ grid-template-columns: 33vw 1fr; }
  .grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .about-portrait { width: 240px; max-width: 28%; }
  .about-intro { padding-right: min(28%, 280px); }
}

@media (max-width: 860px){
  .about-portrait { width: 220px; max-width: 26%; }
  .about-intro { padding-right: min(26%, 240px); }
}

@media (max-width: 720px){
  :root{ --gap: 18px; }
  .app{ grid-template-columns: 38vw 1fr; }
  .grid{ grid-template-columns: repeat(2, minmax(140px, 1fr)); justify-content: center; }
  .tile-title{ font-size: 16px; }

  .split-block, .double-media { flex-direction: column; }

  /* Mobile About portrait centered above divider */
  .about-portrait {
    position: static;
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 14px auto -6px auto;
    filter: saturate(0) contrast(1.05) brightness(1.05);
    pointer-events: none;
  }
  .about-intro { padding-right: 24px; }
  .about-divider { margin-top: 12px; }

  /* Random card padding tweak */
  .random-card{ padding: 0 6px; }
}
