:root{
  --max:1400px;
  --reading:740px;

  --text:#111;
  --muted:#6b6b6b;
  --rule:#eeeeee;

  --vh-offset:90px;

  --gap-home:96px;
  --gap-mobile:64px;
}

/* ===== BASE ===== */
html,body{
  margin:0;
  padding:0;
  width:100%;
  overflow-x:hidden;
  overflow-y:scroll;
  font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
  color:var(--text);
  background:#fff;
}

*{ box-sizing:border-box; }

img{
  max-width:100%;
  height:auto;
  display:block;
}

a{
  color:var(--text);
  text-decoration:none;
}

a[href^="mailto:"]{
  text-decoration:underline;
  text-underline-offset:3px;
}

a:focus-visible,
button:focus-visible{
  outline: 2px solid #111;
  outline-offset: 2px;
  border-radius: 2px;
}

/* ===== LAYOUT ===== */
.wrap{
  max-width:var(--max);
  margin:0 auto;
  padding:22px 22px 40px;
}

/* ===== HEADER ===== */
header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  padding:16px 0 18px;

  position:sticky;
  top:0;
  background:rgba(255,255,255,.96);
  backdrop-filter: blur(6px);

  /* remove thin rule under header everywhere */
  border-bottom:none;

  z-index:20;
}

.brand{
  font-size:14px;
  font-weight:500;
  letter-spacing:.04em;
  white-space:nowrap;
}

nav{
  display:flex;
  gap:18px;
  align-items:center;
}

nav a{
  font-size:14px;
  color:var(--muted);
  font-weight:400;
  transition: color .18s ease, opacity .18s ease;
}

/* HOVER: darken */
nav a:hover{
  color:var(--text);
  opacity:1;
}

/* ACTIVE: black */
nav a[aria-current="page"]{
  color: var(--text);
  opacity: 1;
}

/* ===== PROJECT CLOSE (X) FIXED OVERLAY ===== */
.project-close-fixed{
  position:fixed;
  z-index:9999;

  width:32px;
  height:32px;
  border-radius:999px;
  border:1px solid var(--rule);
  background:rgba(255,255,255,.92);

  display:flex;
  align-items:center;
  justify-content:center;

  color: var(--muted);
  transition: color .18s ease, border-color .18s ease, opacity .18s ease;

  /* JS sets top/right */
  top: 100px;
  right: 22px;

  /* keeps fixed stable on iOS WebKit */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}

/* NO movement on hover; only darken */
.project-close-fixed:hover{
  color: var(--text);
  border-color: var(--rule);
}

.project-close-fixed:active{
  color: var(--text);
}

.project-close-fixed svg{ display:block; }

/* ===== TYPO ===== */
.section-title{
  margin:28px 0 18px;
  font-size:13px;
  color:var(--muted);
  letter-spacing:.06em;
}

h1,h2{
  font-size:18px;
  margin:56px 0 20px;
  letter-spacing:.02em;
}

p{
  max-width:var(--reading);
  font-size:18px;
  line-height:1.65;
  margin:0 0 26px 0;
  hyphens:auto;
}

.desc{
  font-size:18px;
  line-height:1.7;
  max-width:var(--reading);
}

.contact-kv{
  margin-top:18px;
  font-size:18px;
  line-height:1.8;
}

/* ===== HOME ===== */
.project-list{
  display:flex;
  flex-direction:column;
  gap:var(--gap-home);
  margin-top:12px;
}

.project{
  scroll-margin-top:90px;
  padding-top:4px;
}

.hero{
  width:100%;
  display:flex;
  justify-content:center;
}

.hero a{
  display:inline-block;
  overflow:hidden;
}

.hero img{
  width:auto;
  height:auto;
  max-width:100%;
  max-height:78vh;
  object-fit:contain;
}

.ptitle{
  font-size:14px;
  margin-top:12px;
  letter-spacing:.01em;
}

.psub{
  font-size:14px;
  color:var(--muted);
  margin-top:4px;
}

.project-featured .hero img{ max-height:86vh; }
.project-featured .ptitle{ font-size:15px; }

/* ===== PROJECT PAGE ===== */
.proj-head{
  max-width:var(--reading);
  margin:0 auto;
  padding-top:24px;
}

.proj-head h1{
  font-size:34px;
  line-height:1.15;
  margin:0 0 20px;
  font-weight:600;
  letter-spacing:-0.01em;
}

.proj-head p{
  margin:0 0 18px 0;
  font-size:18px;
  line-height:1.7;
  text-align:justify;
  text-justify:inter-word;
}

.meta{
  margin-top:14px;
  padding-top:12px;
  font-size:15px;
  line-height:1.55;
  color:#333;
}

.gallery{
  max-width:var(--reading);
  margin:38px auto 0;
  display:flex;
  flex-direction:column;
  gap:28px;
}

.gimg{
  display:flex;
  justify-content:center;
  width:100%;
}

.gimg img{
  width:auto;
  height:auto;
  max-width:100%;
  max-height:calc(100vh - var(--vh-offset));
  object-fit:contain;
  display:block;
}

/* ===== FOOTER ===== */
footer{
  margin-top:100px;
  padding-top:18px;
  font-size:12px;
  color:var(--muted);
  opacity:.7;
}

/* ===== MOBILE ===== */
@media (max-width:768px){

  :root{ --vh-offset:170px; }

  .wrap{ padding:16px 14px 40px; }

  header{
    flex-direction:column;
    align-items:flex-start;
    gap:8px;
    padding:12px 0 14px;
  }

  .brand{
    font-size:12px;
    width:100%;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  nav{
    flex-wrap:wrap;
    gap:14px;
  }

  .hero img{
    height:auto;
    max-height:none;
    object-fit:contain;
    object-position:center;
  }

  .proj-head p{
    text-align:left;
    text-justify:auto;
  }

  p{
    font-size:17px;
    line-height:1.6;
    hyphens:none;
  }

  .proj-head,.gallery{ max-width:100%; }

  .gimg img{
    max-height:calc(100vh - var(--vh-offset));
  }

  .backtop{
    bottom:14px;
  }
}

/* ===== BACK TO TOP (same bubble size as X) ===== */
.backtop{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);

  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: rgba(255,255,255,.92);
  color: var(--muted);

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  opacity: 0;
  pointer-events: none;

  transition: opacity 180ms ease, color .18s ease, border-color .18s ease;
  z-index: 50;

  -webkit-transform: translateX(-50%) translateZ(0);
  transform: translateX(-50%) translateZ(0);
  backface-visibility: hidden;
}

.backtop svg{ display:block; }

.backtop.is-visible{
  opacity: 1;
  pointer-events: auto;
}

.backtop:hover{
  color: var(--text);
}

.backtop:active{
  color: var(--text);
}

/* ===== HOMEPAGE CURATED FEEL ===== */
.ptitle,
.psub{
  transition:opacity .2s ease;
}

.ptitle{ opacity:.96; }
.psub{ opacity:.85; }

@media (hover:hover){
  .project:hover .ptitle{ opacity:1; }
}

/* ===== HOVER ON HERO (zoom inside frame) ===== */
@media (hover:hover){
  .hero a img{ cursor: pointer; }

  .hero a img{
    transform: scale(1);
    transform-origin: 50% 50%;
    opacity: 1;
    will-change: transform, opacity;

    transition:
      transform 1100ms cubic-bezier(.16,1,.3,1),
      opacity 420ms cubic-bezier(.16,1,.3,1);
  }

  .hero a:hover img{
    transform: scale(1.045);
    opacity: 0.88;
  }
}

@media (prefers-reduced-motion: reduce){
  .hero a img{ transition:none !important; }
}

/* hide any legacy close button if present in old markup */
.project-close{ display:none !important; }